commit: http://blackfin.uclinux.org/git/?p=linux-kernel;a=commitdiff;h=96526db5486b1672a7a8476c2a2a2078e097a3c5
branch: http://blackfin.uclinux.org/git/?p=linux-kernel;a=shortlog;h=refs/heads/2011R1

Signed-off-by: Mark Brown <[email protected]>
---
 drivers/base/regmap/regmap-debugfs.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c
index fff8e83..e541d7f 100644
--- a/drivers/base/regmap/regmap-debugfs.c
+++ b/drivers/base/regmap/regmap-debugfs.c
@@ -20,7 +20,14 @@
 
 static struct dentry *regmap_debugfs_root;
 
-static int regmap_map_open_file(struct inode *inode, struct file *file)
+/* Calculate the length of a fixed format  */
+static size_t regmap_calc_reg_len(int max_val, char *buf, size_t buf_size)
+{
+	snprintf(buf, buf_size, "%x", max_val);
+	return strlen(buf);
+}
+
+static int regmap_open_file(struct inode *inode, struct file *file)
 {
 	file->private_data = inode->i_private;
 	return 0;
@@ -46,8 +53,7 @@ static ssize_t regmap_map_read_file(struct file *file, char __user *user_buf,
 		return -ENOMEM;
 
 	/* Calculate the length of a fixed format  */
-	snprintf(buf, count, "%x", map->max_register);
-	reg_len = strlen(buf);
+	reg_len = regmap_calc_reg_len(map->max_register, buf, count);
 	val_len = 2 * map->format.val_bytes;
 	tot_len = reg_len + val_len + 3;      /* : \n */
 
@@ -98,7 +104,7 @@ out:
 }
 
 static const struct file_operations regmap_map_fops = {
-	.open = regmap_map_open_file,
+	.open = regmap_open_file,
 	.read = regmap_map_read_file,
 	.llseek = default_llseek,
 };
_______________________________________________
Linux-kernel-commits mailing list
[email protected]
https://blackfin.uclinux.org/mailman/listinfo/linux-kernel-commits

Reply via email to