lkml.org 
[lkml]   [2016]   [Jan]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC] regmap: clairify max_register meaning
Date
The exact meaning of max_register is not entirely clear. Define
it to be the maximum address offset a register in a regmap can
actually have. This seems to be the interpretation most commonly
used.

Fix regcache-flat to follow this definition.

Signed-off-by: Stefan Agner <stefan@agner.ch>
---
Hi Mark,

I stumbled upon this while switching to regmap cache FLAT for the
FSL DCU and PWM FTM drivers.

Maybe I see something completely wrong here, but to me it seems
that the regcache-flat.c is the only code interpreting max_register
as register indexes rather then the maximum relative address...
At least regmap.c compares with range_max, which seems to use
addresses.

If this is right, we should probably check the max_register values
of the drivers using REGCACHE_FLAT before fixing this... Some
drivers I checked seem to pass the maximum register address already.

--
Stefan

drivers/base/regmap/regcache-flat.c | 3 +--
include/linux/regmap.h | 2 +-
2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/base/regmap/regcache-flat.c b/drivers/base/regmap/regcache-flat.c
index 686c9e0..fe997c1 100644
--- a/drivers/base/regmap/regcache-flat.c
+++ b/drivers/base/regmap/regcache-flat.c
@@ -21,8 +21,7 @@ static int regcache_flat_init(struct regmap *map)
int i;
unsigned int *cache;

- map->cache = kcalloc(map->max_register + 1, sizeof(unsigned int),
- GFP_KERNEL);
+ map->cache = kzalloc(map->max_register + map->reg_stride, GFP_KERNEL);
if (!map->cache)
return -ENOMEM;

diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index 1839434..27aaac9 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -162,7 +162,7 @@ typedef void (*regmap_unlock)(void *);
* This field is a duplicate of a similar file in
* 'struct regmap_bus' and serves exact same purpose.
* Use it only for "no-bus" cases.
- * @max_register: Optional, specifies the maximum valid register index.
+ * @max_register: Optional, specifies the maximum valid register address.
* @wr_table: Optional, points to a struct regmap_access_table specifying
* valid ranges for write access.
* @rd_table: As above, for read access.
--
2.7.0

\
 
 \ /
  Last update: 2016-01-18 08:01    [W:0.054 / U:0.264 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site