aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2013-03-26 17:24:20 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2013-03-27 09:03:39 -0400
commit221ad7f2df7c54b3f05471a3599ea7368366aaeb (patch)
tree2ca3853d0441538ebd3634c0bac564775b5ca97b /drivers/base
parent8817796b75c8847d63d6d4523c79c24b47748a05 (diff)
regmap: core: Provide regmap_can_raw_write() operation
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>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/regmap/regmap.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 9174c9d45a16..9ab1e1fedbc9 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -1097,6 +1097,17 @@ int _regmap_raw_write(struct regmap *map, unsigned int reg,
1097 return ret; 1097 return ret;
1098} 1098}
1099 1099
1100/**
1101 * regmap_can_raw_write - Test if regmap_raw_write() is supported
1102 *
1103 * @map: Map to check.
1104 */
1105bool regmap_can_raw_write(struct regmap *map)
1106{
1107 return map->bus && map->format.format_val && map->format.format_reg;
1108}
1109EXPORT_SYMBOL_GPL(regmap_can_raw_write);
1110
1100static int _regmap_bus_formatted_write(void *context, unsigned int reg, 1111static int _regmap_bus_formatted_write(void *context, unsigned int reg,
1101 unsigned int val) 1112 unsigned int val)
1102{ 1113{
@@ -1220,12 +1231,10 @@ int regmap_raw_write(struct regmap *map, unsigned int reg,
1220{ 1231{
1221 int ret; 1232 int ret;
1222 1233
1223 if (!map->bus) 1234 if (!regmap_can_raw_write(map))
1224 return -EINVAL; 1235 return -EINVAL;
1225 if (val_len % map->format.val_bytes) 1236 if (val_len % map->format.val_bytes)
1226 return -EINVAL; 1237 return -EINVAL;
1227 if (reg % map->reg_stride)
1228 return -EINVAL;
1229 1238
1230 map->lock(map->lock_arg); 1239 map->lock(map->lock_arg);
1231 1240