aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/regmap/regmap-debugfs.c
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2012-12-09 03:20:10 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-12-10 11:29:47 -0500
commitafab2f7b21b042bcbffb1e82f78243382a122d70 (patch)
tree9e068db9a9be5a3d99b1bb03202537397c2af2a1 /drivers/base/regmap/regmap-debugfs.c
parentdb04328c167ff8e7c57f4a3532214aeada3a82fd (diff)
regmap: debugfs: Factor out initial seek
In preparation for doing things a bit more quickly than a linear scan factor out the initial seek from the debugfs register dump. 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.c39
1 files changed, 36 insertions, 3 deletions
diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c
index 3df274e06062..749a1dc5bbfb 100644
--- a/drivers/base/regmap/regmap-debugfs.c
+++ b/drivers/base/regmap/regmap-debugfs.c
@@ -56,16 +56,46 @@ static const struct file_operations regmap_name_fops = {
56 .llseek = default_llseek, 56 .llseek = default_llseek,
57}; 57};
58 58
59/*
60 * Work out where the start offset maps into register numbers, bearing
61 * in mind that we suppress hidden registers.
62 */
63static unsigned int regmap_debugfs_get_dump_start(struct regmap *map,
64 unsigned int base,
65 loff_t from,
66 loff_t *pos)
67{
68 loff_t p = *pos;
69 unsigned int i;
70
71 for (i = base; i <= map->max_register; i += map->reg_stride) {
72 if (!regmap_readable(map, i))
73 continue;
74
75 if (regmap_precious(map, i))
76 continue;
77
78 if (i >= from) {
79 *pos = p;
80 return i;
81 }
82
83 p += map->debugfs_tot_len;
84 }
85
86 return base;
87}
88
59static ssize_t regmap_read_debugfs(struct regmap *map, unsigned int from, 89static ssize_t regmap_read_debugfs(struct regmap *map, unsigned int from,
60 unsigned int to, char __user *user_buf, 90 unsigned int to, char __user *user_buf,
61 size_t count, loff_t *ppos) 91 size_t count, loff_t *ppos)
62{ 92{
63 size_t buf_pos = 0; 93 size_t buf_pos = 0;
64 loff_t p = 0; 94 loff_t p = *ppos;
65 ssize_t ret; 95 ssize_t ret;
66 int i; 96 int i;
67 char *buf; 97 char *buf;
68 unsigned int val; 98 unsigned int val, start_reg;
69 99
70 if (*ppos < 0 || !count) 100 if (*ppos < 0 || !count)
71 return -EINVAL; 101 return -EINVAL;
@@ -83,7 +113,10 @@ static ssize_t regmap_read_debugfs(struct regmap *map, unsigned int from,
83 map->debugfs_val_len + 3; /* : \n */ 113 map->debugfs_val_len + 3; /* : \n */
84 } 114 }
85 115
86 for (i = from; i <= to; i += map->reg_stride) { 116 /* Work out which register we're starting at */
117 start_reg = regmap_debugfs_get_dump_start(map, from, *ppos, &p);
118
119 for (i = start_reg; i <= to; i += map->reg_stride) {
87 if (!regmap_readable(map, i)) 120 if (!regmap_readable(map, i))
88 continue; 121 continue;
89 122