Commit 221ad7f2 authored by Mark Brown's avatar Mark Brown

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: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 8817796b
...@@ -1097,6 +1097,17 @@ int _regmap_raw_write(struct regmap *map, unsigned int reg, ...@@ -1097,6 +1097,17 @@ int _regmap_raw_write(struct regmap *map, unsigned int reg,
return ret; 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, static int _regmap_bus_formatted_write(void *context, unsigned int reg,
unsigned int val) unsigned int val)
{ {
...@@ -1220,12 +1231,10 @@ int regmap_raw_write(struct regmap *map, unsigned int reg, ...@@ -1220,12 +1231,10 @@ int regmap_raw_write(struct regmap *map, unsigned int reg,
{ {
int ret; int ret;
if (!map->bus) if (!regmap_can_raw_write(map))
return -EINVAL; return -EINVAL;
if (val_len % map->format.val_bytes) if (val_len % map->format.val_bytes)
return -EINVAL; return -EINVAL;
if (reg % map->reg_stride)
return -EINVAL;
map->lock(map->lock_arg); map->lock(map->lock_arg);
......
...@@ -389,6 +389,7 @@ int regmap_update_bits_check(struct regmap *map, unsigned int reg, ...@@ -389,6 +389,7 @@ int regmap_update_bits_check(struct regmap *map, unsigned int reg,
bool *change); bool *change);
int regmap_get_val_bytes(struct regmap *map); int regmap_get_val_bytes(struct regmap *map);
int regmap_async_complete(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(struct regmap *map);
int regcache_sync_region(struct regmap *map, unsigned int min, int regcache_sync_region(struct regmap *map, unsigned int min,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment