diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2011-08-10 04:15:31 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2011-08-14 06:51:14 -0400 |
commit | 21f555445676e5c7d30bb9b3487cb183d02e45e3 (patch) | |
tree | a8f18e1cb71364af81722652c19b8584fb856757 /drivers/base/regmap/regmap-debugfs.c | |
parent | 8de2f081ef8ee716663f916df9f2a7d015fa0dad (diff) |
regmap: Share some of the debugfs infrastructure ready for more files
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/base/regmap/regmap-debugfs.c')
-rw-r--r-- | 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 fff8e832a985..e541d7f4b4e0 100644 --- a/drivers/base/regmap/regmap-debugfs.c +++ b/drivers/base/regmap/regmap-debugfs.c | |||
@@ -20,7 +20,14 @@ | |||
20 | 20 | ||
21 | static struct dentry *regmap_debugfs_root; | 21 | static struct dentry *regmap_debugfs_root; |
22 | 22 | ||
23 | static int regmap_map_open_file(struct inode *inode, struct file *file) | 23 | /* Calculate the length of a fixed format */ |
24 | static size_t regmap_calc_reg_len(int max_val, char *buf, size_t buf_size) | ||
25 | { | ||
26 | snprintf(buf, buf_size, "%x", max_val); | ||
27 | return strlen(buf); | ||
28 | } | ||
29 | |||
30 | static int regmap_open_file(struct inode *inode, struct file *file) | ||
24 | { | 31 | { |
25 | file->private_data = inode->i_private; | 32 | file->private_data = inode->i_private; |
26 | return 0; | 33 | return 0; |
@@ -46,8 +53,7 @@ static ssize_t regmap_map_read_file(struct file *file, char __user *user_buf, | |||
46 | return -ENOMEM; | 53 | return -ENOMEM; |
47 | 54 | ||
48 | /* Calculate the length of a fixed format */ | 55 | /* Calculate the length of a fixed format */ |
49 | snprintf(buf, count, "%x", map->max_register); | 56 | reg_len = regmap_calc_reg_len(map->max_register, buf, count); |
50 | reg_len = strlen(buf); | ||
51 | val_len = 2 * map->format.val_bytes; | 57 | val_len = 2 * map->format.val_bytes; |
52 | tot_len = reg_len + val_len + 3; /* : \n */ | 58 | tot_len = reg_len + val_len + 3; /* : \n */ |
53 | 59 | ||
@@ -98,7 +104,7 @@ out: | |||
98 | } | 104 | } |
99 | 105 | ||
100 | static const struct file_operations regmap_map_fops = { | 106 | static const struct file_operations regmap_map_fops = { |
101 | .open = regmap_map_open_file, | 107 | .open = regmap_open_file, |
102 | .read = regmap_map_read_file, | 108 | .read = regmap_map_read_file, |
103 | .llseek = default_llseek, | 109 | .llseek = default_llseek, |
104 | }; | 110 | }; |