]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
When doing a single register write we use work_buf for both the register
authorMark Brown <broonie@opensource.wolfsonmicro.com>
Wed, 3 Aug 2011 00:52:39 +0000 (10:52 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Fri, 5 Aug 2011 02:52:15 +0000 (12:52 +1000)
and the value with the buffer formatted for sending directly to the device
so we can just do a write() directly.  This saves allocating a temporary
buffer if we can't do gather writes and is likely to be faster than doing
a gather write.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Greg KH <greg@kroah.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
drivers/base/regmap/regmap.c

index 0eef4da1ac61f1deb274e56fb5601cfc6275c193..60d94fe682139bb13ab0b72e4a37407ea6187a35 100644 (file)
@@ -202,13 +202,20 @@ static int _regmap_raw_write(struct regmap *map, unsigned int reg,
 
        map->format.format_reg(map->work_buf, reg);
 
-       /* Try to do a gather write if we can */
-       if (map->bus->gather_write)
+       /* If we're doing a single register write we can probably just
+        * send the work_buf directly, otherwise try to do a gather
+        * write.
+        */
+       if (val == map->work_buf + map->format.reg_bytes)
+               ret = map->bus->write(map->dev, map->work_buf,
+                                     map->format.reg_bytes +
+                                     map->format.val_bytes);
+       else if (map->bus->gather_write)
                ret = map->bus->gather_write(map->dev, map->work_buf,
                                             map->format.reg_bytes,
                                             val, val_len);
 
-       /* Otherwise fall back on linearising by hand. */
+       /* If that didn't work fall back on linearising by hand. */
        if (ret == -ENOTSUPP) {
                len = map->format.reg_bytes + val_len;
                buf = kmalloc(len, GFP_KERNEL);