]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
regmap: core: Provide regmap_can_raw_write() operation
authorMark Brown <broonie@opensource.wolfsonmicro.com>
Tue, 26 Mar 2013 21:24:20 +0000 (21:24 +0000)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Wed, 27 Mar 2013 13:03:39 +0000 (13:03 +0000)
Mainly useful internally but exported since this is a public API that's
being checked for.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
drivers/base/regmap/regmap.c
include/linux/regmap.h

index 9174c9d45a161e403201e51cd324a61658da01b5..9ab1e1fedbc9e34aed486dc5b2de5a753dabd763 100644 (file)
@@ -1097,6 +1097,17 @@ int _regmap_raw_write(struct regmap *map, unsigned int reg,
        return ret;
 }
 
+/**
+ * regmap_can_raw_write - Test if regmap_raw_write() is supported
+ *
+ * @map: Map to check.
+ */
+bool regmap_can_raw_write(struct regmap *map)
+{
+       return map->bus && map->format.format_val && map->format.format_reg;
+}
+EXPORT_SYMBOL_GPL(regmap_can_raw_write);
+
 static int _regmap_bus_formatted_write(void *context, unsigned int reg,
                                       unsigned int val)
 {
@@ -1220,12 +1231,10 @@ int regmap_raw_write(struct regmap *map, unsigned int reg,
 {
        int ret;
 
-       if (!map->bus)
+       if (!regmap_can_raw_write(map))
                return -EINVAL;
        if (val_len % map->format.val_bytes)
                return -EINVAL;
-       if (reg % map->reg_stride)
-               return -EINVAL;
 
        map->lock(map->lock_arg);
 
index bf77dfdabef9559b021503b9163fd548ac8553de..02d84e24b7c2083ff1a4ddf13a1b2ac7ad663261 100644 (file)
@@ -389,6 +389,7 @@ int regmap_update_bits_check(struct regmap *map, unsigned int reg,
                             bool *change);
 int regmap_get_val_bytes(struct regmap *map);
 int regmap_async_complete(struct regmap *map);
+bool regmap_can_raw_write(struct regmap *map);
 
 int regcache_sync(struct regmap *map);
 int regcache_sync_region(struct regmap *map, unsigned int min,