Regmap: Converts group operation into single read write operations
Subsystems (2)
PATCH 1/1 Regmap: Converts group operation into single read write operations
Some devices does not support bulk read and write operations, for them we have series of single write and read operations.
--- drivers/base/regmap/internal.h | 3 +++ drivers/base/regmap/regmap.c | 40 ++++++++++++++++++++++++++++++++++++---- include/linux/regmap.h | 5 +++++ 3 files changed, 44 insertions(+), 4 deletions(-)
drivers/base/regmap/internal.h +3 -0
@@ -91,6 +91,9 @@ struct regmap {struct reg_default *patch;int patch_regs; + +/* if set, converts bulk rw to single rw */ +bool use_single_rw; };struct regcache_ops {
drivers/base/regmap/regmap.c +36 -4
@@ -247,6 +247,8 @@ struct regmap *regmap_init(struct device *dev, map->reg_stride = config->reg_stride; else map->reg_stride = 1; +if (config->use_single_rw) + map->use_single_rw = config->use_single_rw; map->dev = dev; map->bus = bus; map->bus_context = bus_context;
@@ -686,7 +688,21 @@ int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val,for (i =0 ; i < val_count * val_bytes; i += val_bytes) map->format.parse_val (wval + i); } - ret =_regmap_raw_write (map, reg, wval, val_bytes * val_count); +/* +* Some devices does not support bulk write, for +* them we have a series of single write operations. +*/ +if (map->use_single_rw) { +for (i =0 ; i < val_count; i++) { + ret =regmap_raw_write (map, + reg + (i * map->reg_stride), + val + (i * val_bytes), + val_bytes); +if (ret !=0 ) +return ret; + } + }else + ret =_regmap_raw_write (map, reg, wval, val_bytes * val_count);if (val_bytes !=1 )kfree (wval);
@@ -855,9 +871,25 @@ int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val,return -EINVAL ;if (vol || map->cache_type ==REGCACHE_NONE ) { - ret =regmap_raw_read (map, reg, val, val_bytes * val_count); -if (ret !=0 ) -return ret; +/* +* Some devices does not support bulk read, for +* them we have a series of single read operations. +*/ +if (map->use_single_rw) { +for (i =0 ; i < val_count; i++) { + ret =regmap_raw_read (map, + reg + (i * map->reg_stride), + val + (i * val_bytes), + val_bytes); +if (ret !=0 ) +return ret; + } + }else { + ret =regmap_raw_read (map, reg, val, + val_bytes * val_count); +if (ret !=0 ) +return ret; + }for (i =0 ; i < val_count * val_bytes; i += val_bytes) map->format.parse_val (val + i);
include/linux/regmap.h +5 -0
@@ -76,6 +76,9 @@ struct reg_default {* @write_flag_mask: Mask to be set in the top byte of the register when doing * a write. If both read_flag_mask and write_flag_mask are * empty the regmap_bus default masks are used. +* @use_single_rw: If set, converts the bulk read and write operations into +* a series of single read and write operations. This is useful +* for device that does not support bulk read and write. * * @cache_type: The actual cache type. * @reg_defaults_raw: Power on reset values for registers (for use with
@@ -104,6 +107,8 @@ struct regmap_config {u8 read_flag_mask;u8 write_flag_mask; + +bool use_single_rw; }; typedef int (*regmap_hw_write)(void *context, const void *data,
Mark Brown
AppliedQuoted 2 lines · Ashish Jangam
Some devices does not support bulk read and write operations, for them we have series of single write and read operations.
Applied, though please in future
- Use a changelog that matches the subsystem
- Follow the kernel coding style, you should use
I fixed both these things up, and also...
drivers/base/regmap/regmap.c struct regmap *regmap_init(struct device *dev, · line 251
Quoted 2 lines
drivers/base/regmap/regmap.c +2
-0+if (config->use_single_rw) + map->use_single_rw = config->use_single_rw;
There's no need to check if the flag is set here, you can just assign directly.
Quoted 5 lines · Ashish Jangam
Some devices does not support bulk read and write operations, for them we have series of single write and read operations.
Signed-off-by Anthony Olech <[email protected]>Signed-off-by Ashish Jangam <[email protected]>
Also, I'm assuming that there's joint authorship on this one? The order your signoffs are listed in I'd expect Anthony was the author...