diff mbox

regmap: Allow regmap_bulk_read() to work for "no-bus" regmaps

Message ID 20131213171407.GN21983@codeaurora.org (mailing list archive)
State New, archived
Headers show

Commit Message

Stephen Boyd Dec. 13, 2013, 5:14 p.m. UTC
regmap_bulk_read() should decay to performing individual reads if
we're using a "no-bus" regmap. Unfortunately, it returns an
error because there is no map->bus pointer. Fix it.

Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
---

On 12/13/13 02:41, Mark Brown wrote:
> On Thu, Dec 12, 2013 at 03:13:01PM -0800, Stephen Boyd wrote:
>
>>> bulk_read() should decay to individual reads if there isn't a block
>>> operaton and it's not like the hardware actually supports bulk reads
>>> anyway.
>
>> So regmap_bulk_read() should work if I don't have a map->bus? To make it
>> work with reg_read/write I had to do this. I'm not sure how to make
>> bulk_write work.
>
> Yes, I'd expect the operation to work.  Your changes below are mostly
> fine (we should add an additional check for values that aren't integer
> numbers of bytes, I can add that) - can you send as a signed off patch
> please and I'll apply?

Here you go. Do you have any suggestions on how to make regmap_bulk_write()
work?

 drivers/base/regmap/regmap.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

Comments

Mark Brown Dec. 16, 2013, 8:57 p.m. UTC | #1
On Fri, Dec 13, 2013 at 09:14:07AM -0800, Stephen Boyd wrote:

> regmap_bulk_read() should decay to performing individual reads if
> we're using a "no-bus" regmap. Unfortunately, it returns an
> error because there is no map->bus pointer. Fix it.

Applied, thanks.

> > Yes, I'd expect the operation to work.  Your changes below are mostly
> > fine (we should add an additional check for values that aren't integer
> > numbers of bytes, I can add that) - can you send as a signed off patch
> > please and I'll apply?

> Here you go. Do you have any suggestions on how to make regmap_bulk_write()
> work?

Off the top of my head I'd expect it to just fall back onto
regmap_write() if it can't do raw I/O.  Or perhaps just change that loop
to do regmap_write() all the time since it's hardly the fast path.
diff mbox

Patch

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 9c021d9..1ccd61b 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -1897,14 +1897,10 @@  int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val,
 	size_t val_bytes = map->format.val_bytes;
 	bool vol = regmap_volatile_range(map, reg, val_count);
 
-	if (!map->bus)
-		return -EINVAL;
-	if (!map->format.parse_inplace)
-		return -EINVAL;
 	if (reg % map->reg_stride)
 		return -EINVAL;
 
-	if (vol || map->cache_type == REGCACHE_NONE) {
+	if (map->bus && map->format.parse_inplace && (vol || map->cache_type == REGCACHE_NONE)) {
 		/*
 		 * Some devices does not support bulk read, for
 		 * them we have a series of single read operations.