regmap: Only send a single buffer for async I/O if writing one register
authorMark Brown <broonie@linaro.org>
Thu, 10 Oct 2013 21:38:29 +0000 (22:38 +0100)
committerMark Brown <broonie@linaro.org>
Mon, 14 Oct 2013 21:09:26 +0000 (22:09 +0100)
Extend the interface for async I/O by allowing the value buffer to be
omitted and sending the value as part of the register buffer, minimising
the number of separate hardware operations required.

Signed-off-by: Mark Brown <broonie@linaro.org>
drivers/base/regmap/regmap.c

index a975a601f718a2fa5412f79da1e434a156d4e9aa..d0ce2fef43a3547c5d45108de67883f0aade05d4 100644 (file)
@@ -1157,18 +1157,23 @@ int _regmap_raw_write(struct regmap *map, unsigned int reg,
                /* If the caller supplied the value we can use it safely. */
                memcpy(async->work_buf, map->work_buf, map->format.pad_bytes +
                       map->format.reg_bytes + map->format.val_bytes);
-               if (val == work_val)
-                       val = async->work_buf + map->format.pad_bytes +
-                               map->format.reg_bytes;
 
                spin_lock_irqsave(&map->async_lock, flags);
                list_add_tail(&async->list, &map->async_list);
                spin_unlock_irqrestore(&map->async_lock, flags);
 
-               ret = map->bus->async_write(map->bus_context, async->work_buf,
-                                           map->format.reg_bytes +
-                                           map->format.pad_bytes,
-                                           val, val_len, async);
+               if (val != work_val)
+                       ret = map->bus->async_write(map->bus_context,
+                                                   async->work_buf,
+                                                   map->format.reg_bytes +
+                                                   map->format.pad_bytes,
+                                                   val, val_len, async);
+               else
+                       ret = map->bus->async_write(map->bus_context,
+                                                   async->work_buf,
+                                                   map->format.reg_bytes +
+                                                   map->format.pad_bytes +
+                                                   val_len, NULL, 0, async);
 
                if (ret != 0) {
                        dev_err(map->dev, "Failed to schedule write: %d\n",