From: Mark Brown Date: Tue, 8 Oct 2013 17:37:36 +0000 (+0100) Subject: regmap: Don't generate gather writes for single register raw writes X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=651e013e3ce6c0646c39a07e22bebad75a207209;p=linux-beck.git regmap: Don't generate gather writes for single register raw writes Since it is quite common for single register raw or async writes to be generated by rbtree cache syncs or firmware downloads and essentially all hardware will be faster with only a single transfer optimise this case by copying single values into the internal scratch buffer before sending. Signed-off-by: Mark Brown --- diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 742f300ca48a..d27758c337af 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -1116,6 +1116,16 @@ int _regmap_raw_write(struct regmap *map, unsigned int reg, u8[0] |= map->write_flag_mask; + /* + * Essentially all I/O mechanisms will be faster with a single + * buffer to write. Since register syncs often generate raw + * writes of single registers optimise that case. + */ + if (val != work_val && val_len == map->format.val_bytes) { + memcpy(work_val, val, map->format.val_bytes); + val = work_val; + } + if (async && map->bus->async_write) { struct regmap_async *async;