Merge branch 'topic/smbus-block' of git://git.kernel.org/pub/scm/linux/kernel/git...
authorMark Brown <broonie@kernel.org>
Fri, 4 Sep 2015 16:16:39 +0000 (17:16 +0100)
committerMark Brown <broonie@kernel.org>
Fri, 4 Sep 2015 16:16:39 +0000 (17:16 +0100)
drivers/base/regmap/regmap.c

index 2ffdb62f75f7306ce1fca9468b7f51566cc6ed67..e48cb8562e684c99a7008406062174e100496fb1 100644 (file)
@@ -2429,7 +2429,34 @@ int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val,
                                          &ival);
                        if (ret != 0)
                                return ret;
-                       map->format.format_val(val + (i * val_bytes), ival, 0);
+
+                       if (map->format.format_val) {
+                               map->format.format_val(val + (i * val_bytes), ival, 0);
+                       } else {
+                               /* Devices providing read and write
+                                * operations can use the bulk I/O
+                                * functions if they define a val_bytes,
+                                * we assume that the values are native
+                                * endian.
+                                */
+                               u32 *u32 = val;
+                               u16 *u16 = val;
+                               u8 *u8 = val;
+
+                               switch (map->format.val_bytes) {
+                               case 4:
+                                       u32[i] = ival;
+                                       break;
+                               case 2:
+                                       u16[i] = ival;
+                                       break;
+                               case 1:
+                                       u8[i] = ival;
+                                       break;
+                               default:
+                                       return -EINVAL;
+                               }
+                       }
                }
        }