diff options
author | Laxman Dewangan <ldewangan@nvidia.com> | 2012-02-10 11:00:27 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-02-11 18:03:45 -0500 |
commit | c9157198417076c0c2664ba997e7b0217f61fcce (patch) | |
tree | 354dcd5c829676cc7702b490dd18853176cdbac5 | |
parent | d65b4e98d7ea3038b767b70fe8be959b2913f16d (diff) |
regmap: Support for caching in reg_raw_write()
Adding support for caching of data into the
non-volatile register from the call of reg_raw_write().
This will allow the larger block of data write into multiple
register without worrying whether register is cached or not
through reg_raw_write().
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r-- | drivers/base/regmap/regmap.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 65558034318f..74a6d4f8e3b8 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c | |||
@@ -321,6 +321,26 @@ static int _regmap_raw_write(struct regmap *map, unsigned int reg, | |||
321 | if (!map->writeable_reg(map->dev, reg + i)) | 321 | if (!map->writeable_reg(map->dev, reg + i)) |
322 | return -EINVAL; | 322 | return -EINVAL; |
323 | 323 | ||
324 | if (!map->cache_bypass && map->format.parse_val) { | ||
325 | unsigned int ival; | ||
326 | int val_bytes = map->format.val_bytes; | ||
327 | for (i = 0; i < val_len / val_bytes; i++) { | ||
328 | memcpy(map->work_buf, val + (i * val_bytes), val_bytes); | ||
329 | ival = map->format.parse_val(map->work_buf); | ||
330 | ret = regcache_write(map, reg + i, ival); | ||
331 | if (ret) { | ||
332 | dev_err(map->dev, | ||
333 | "Error in caching of register: %u ret: %d\n", | ||
334 | reg + i, ret); | ||
335 | return ret; | ||
336 | } | ||
337 | } | ||
338 | if (map->cache_only) { | ||
339 | map->cache_dirty = true; | ||
340 | return 0; | ||
341 | } | ||
342 | } | ||
343 | |||
324 | map->format.format_reg(map->work_buf, reg); | 344 | map->format.format_reg(map->work_buf, reg); |
325 | 345 | ||
326 | u8[0] |= map->write_flag_mask; | 346 | u8[0] |= map->write_flag_mask; |
@@ -366,7 +386,7 @@ int _regmap_write(struct regmap *map, unsigned int reg, | |||
366 | int ret; | 386 | int ret; |
367 | BUG_ON(!map->format.format_write && !map->format.format_val); | 387 | BUG_ON(!map->format.format_write && !map->format.format_val); |
368 | 388 | ||
369 | if (!map->cache_bypass) { | 389 | if (!map->cache_bypass && map->format.format_write) { |
370 | ret = regcache_write(map, reg, val); | 390 | ret = regcache_write(map, reg, val); |
371 | if (ret != 0) | 391 | if (ret != 0) |
372 | return ret; | 392 | return ret; |
@@ -441,12 +461,8 @@ EXPORT_SYMBOL_GPL(regmap_write); | |||
441 | int regmap_raw_write(struct regmap *map, unsigned int reg, | 461 | int regmap_raw_write(struct regmap *map, unsigned int reg, |
442 | const void *val, size_t val_len) | 462 | const void *val, size_t val_len) |
443 | { | 463 | { |
444 | size_t val_count = val_len / map->format.val_bytes; | ||
445 | int ret; | 464 | int ret; |
446 | 465 | ||
447 | WARN_ON(!regmap_volatile_range(map, reg, val_count) && | ||
448 | map->cache_type != REGCACHE_NONE); | ||
449 | |||
450 | mutex_lock(&map->lock); | 466 | mutex_lock(&map->lock); |
451 | 467 | ||
452 | ret = _regmap_raw_write(map, reg, val, val_len); | 468 | ret = _regmap_raw_write(map, reg, val, val_len); |