mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [RFC] regmap: clairify max_register meaning
@ 2016-01-18  6:52 Stefan Agner
  2016-01-18 16:05 ` Mark Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Agner @ 2016-01-18  6:52 UTC (permalink / raw)
  To: broonie; +Cc: gregkh, linux-kernel, Stefan Agner

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-01-19 17:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-18  6:52 [RFC] regmap: clairify max_register meaning Stefan Agner
2016-01-18 16:05 ` Mark Brown
2016-01-18 17:19   ` Stefan Agner
2016-01-19 17:41     ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®