[PATCH v2] regmap: debugfs: Fix start_reg calculation (v2)
From: Srinivas KANDAGATLA
Date: Wed May 08 2013 - 06:24:56 EST
From: Srinivas Kandagatla <srinivas.kandagatla@xxxxxx>
If we dump syscon regmap registers via debugfs you will notice that the
dump contains lot of XXXXXXXX values.
An example configuration is:
syscon@fdde0000{
compatible = "syscon";
reg = <0xfdde0000 0x15c>;
};
example dump:
cat /sys/kernel/debug/regmap/myregmap/registers
...
154: 001c1dff
158: 00000003
05a: XXXXXXXX
05e: XXXXXXXX
...
regmap_debugfs_get_dump_start should return the offset of the register
it should start reading from, However in the current code it does not
consider stride while calculating this. If we use the return value to
dump the registers we can endup with wrong start address, in the example
case for the second loop the code ends up with start_reg = 0x56. Which
is incorrect. Also this keeps incremeting by stride, which can than
result in unaligned address
This patch fixes this issue by considering the stride value at all
required places in regmap_debugfs_get_dump_start function.
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@xxxxxx>
---
drivers/base/regmap/regmap-debugfs.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c
index 81d6f60..6cd1b78a 100644
--- a/drivers/base/regmap/regmap-debugfs.c
+++ b/drivers/base/regmap/regmap-debugfs.c
@@ -97,7 +97,8 @@ static unsigned int regmap_debugfs_get_dump_start(struct regmap *map,
c->max = p - 1;
fpos_offset = c->max - c->min;
reg_offset = fpos_offset / map->debugfs_tot_len;
- c->max_reg = c->base_reg + reg_offset;
+ c->max_reg = c->base_reg +
+ (reg_offset * map->reg_stride);
list_add_tail(&c->list,
&map->debugfs_off_cache);
c = NULL;
@@ -126,7 +127,7 @@ static unsigned int regmap_debugfs_get_dump_start(struct regmap *map,
c->max = p - 1;
fpos_offset = c->max - c->min;
reg_offset = fpos_offset / map->debugfs_tot_len;
- c->max_reg = c->base_reg + reg_offset;
+ c->max_reg = c->base_reg + (reg_offset * map->reg_stride);
list_add_tail(&c->list,
&map->debugfs_off_cache);
}
@@ -145,7 +146,7 @@ static unsigned int regmap_debugfs_get_dump_start(struct regmap *map,
fpos_offset = from - c->min;
reg_offset = fpos_offset / map->debugfs_tot_len;
*pos = c->min + (reg_offset * map->debugfs_tot_len);
- return c->base_reg + reg_offset;
+ return c->base_reg + (reg_offset * map->reg_stride);
}
*pos = c->max;
--
1.7.6.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/