regmap: implement register striding
regmap_config.reg_stride is introduced. All extant register addresses are a multiple of this value. Users of serial-oriented regmap busses will typically set this to 1. Users of the MMIO regmap bus will typically set this based on the value size of their registers, in bytes, so 4 for a 32-bit register. Throughout the regmap code, actual register addresses are used. Wherever the register address is used to index some array of values, the address is divided by the stride to determine the index, or vice-versa. Error- checking is added to all entry-points for register address data to ensure that register addresses actually satisfy the specified stride. The MMIO bus ensures that the specified stride is large enough for the register size. Signed-off-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
This commit is contained in:

committed by
Mark Brown

parent
c0cc6fe1d0
commit
f01ee60fff
@@ -80,7 +80,7 @@ static ssize_t regmap_map_read_file(struct file *file, char __user *user_buf,
|
||||
val_len = 2 * map->format.val_bytes;
|
||||
tot_len = reg_len + val_len + 3; /* : \n */
|
||||
|
||||
for (i = 0; i < map->max_register + 1; i++) {
|
||||
for (i = 0; i <= map->max_register; i += map->reg_stride) {
|
||||
if (!regmap_readable(map, i))
|
||||
continue;
|
||||
|
||||
@@ -197,7 +197,7 @@ static ssize_t regmap_access_read_file(struct file *file,
|
||||
reg_len = regmap_calc_reg_len(map->max_register, buf, count);
|
||||
tot_len = reg_len + 10; /* ': R W V P\n' */
|
||||
|
||||
for (i = 0; i < map->max_register + 1; i++) {
|
||||
for (i = 0; i <= map->max_register; i += map->reg_stride) {
|
||||
/* Ignore registers which are neither readable nor writable */
|
||||
if (!regmap_readable(map, i) && !regmap_writeable(map, i))
|
||||
continue;
|
||||
|
Reference in New Issue
Block a user