diff options
author | Dimitris Papastamos <dp@opensource.wolfsonmicro.com> | 2012-02-22 09:20:09 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-02-22 09:24:45 -0500 |
commit | f0c2319f9f196726ebe4d7508fd8fbd804988db3 (patch) | |
tree | 7fd39dbf7cbadc9f175f7dface4641b16189fdf6 /drivers/base/regmap | |
parent | 09c6ecd394105c4864a0e409e181c9b1578c2a63 (diff) |
regmap: Expose the driver name in debugfs
Add a file called 'name' containing the name of the driver.
Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/base/regmap')
-rw-r--r-- | drivers/base/regmap/regmap-debugfs.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c index 7accb81dd94e..c32b60a93ceb 100644 --- a/drivers/base/regmap/regmap-debugfs.c +++ b/drivers/base/regmap/regmap-debugfs.c | |||
@@ -33,6 +33,35 @@ static int regmap_open_file(struct inode *inode, struct file *file) | |||
33 | return 0; | 33 | return 0; |
34 | } | 34 | } |
35 | 35 | ||
36 | static ssize_t regmap_name_read_file(struct file *file, | ||
37 | char __user *user_buf, size_t count, | ||
38 | loff_t *ppos) | ||
39 | { | ||
40 | struct regmap *map = file->private_data; | ||
41 | int ret; | ||
42 | char *buf; | ||
43 | |||
44 | buf = kmalloc(PAGE_SIZE, GFP_KERNEL); | ||
45 | if (!buf) | ||
46 | return -ENOMEM; | ||
47 | |||
48 | ret = snprintf(buf, PAGE_SIZE, "%s\n", map->dev->driver->name); | ||
49 | if (ret < 0) { | ||
50 | kfree(buf); | ||
51 | return ret; | ||
52 | } | ||
53 | |||
54 | ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret); | ||
55 | kfree(buf); | ||
56 | return ret; | ||
57 | } | ||
58 | |||
59 | static const struct file_operations regmap_name_fops = { | ||
60 | .open = regmap_open_file, | ||
61 | .read = regmap_name_read_file, | ||
62 | .llseek = default_llseek, | ||
63 | }; | ||
64 | |||
36 | static ssize_t regmap_map_read_file(struct file *file, char __user *user_buf, | 65 | static ssize_t regmap_map_read_file(struct file *file, char __user *user_buf, |
37 | size_t count, loff_t *ppos) | 66 | size_t count, loff_t *ppos) |
38 | { | 67 | { |
@@ -228,6 +257,9 @@ void regmap_debugfs_init(struct regmap *map) | |||
228 | return; | 257 | return; |
229 | } | 258 | } |
230 | 259 | ||
260 | debugfs_create_file("name", 0400, map->debugfs, | ||
261 | map, ®map_name_fops); | ||
262 | |||
231 | if (map->max_register) { | 263 | if (map->max_register) { |
232 | debugfs_create_file("registers", 0400, map->debugfs, | 264 | debugfs_create_file("registers", 0400, map->debugfs, |
233 | map, ®map_map_fops); | 265 | map, ®map_map_fops); |