Message ID | 1439374365-20623-11-git-send-email-mpa@pengutronix.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Wed, Aug 12, 2015 at 12:12:35PM +0200, Markus Pargmann wrote: > Define a fallback for busses which do not define a write() function. > Instead we write one register at a time using reg_write(). > > Without this patch, _regmap_raw_multi_reg_write would break as it tries > to call bus->write() without checking if it exists before. Why are we trying to use multi write APIs in the first place if we can't do raw I/O?
On Wed, Aug 12, 2015 at 01:39:23PM +0100, Mark Brown wrote: > On Wed, Aug 12, 2015 at 12:12:35PM +0200, Markus Pargmann wrote: > > Define a fallback for busses which do not define a write() function. > > Instead we write one register at a time using reg_write(). > > > > Without this patch, _regmap_raw_multi_reg_write would break as it tries > > to call bus->write() without checking if it exists before. > > Why are we trying to use multi write APIs in the first place if we can't > do raw I/O? Because we may not know if the bus supports raw IO and I would prefer if it is not necessary to know in the driver that just uses the regmap API if the underlying bus supports it. Sorry this patch is wrong, instead it should set can_multi_write properly depending on the availability of map->bus->write(). The code would already handle multi writes then. Thanks, Markus
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 78eb96288a68..87f15fb60bc5 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -1778,6 +1778,20 @@ static int _regmap_raw_multi_reg_write(struct regmap *map, if (!len) return -EINVAL; + /* + * If bus->write is not supported we have to use reg_write for each + * register value. + */ + if (!map->bus->write) { + for (i = 0; i < num_regs; i++) { + ret = map->reg_write(map, regs[i].reg, regs[i].def); + if (ret) + return ret; + } + + return 0; + } + buf = kzalloc(len, GFP_KERNEL); if (!buf) return -ENOMEM;
Define a fallback for busses which do not define a write() function. Instead we write one register at a time using reg_write(). Without this patch, _regmap_raw_multi_reg_write would break as it tries to call bus->write() without checking if it exists before. Signed-off-by: Markus Pargmann <mpa@pengutronix.de> --- drivers/base/regmap/regmap.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)