[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1453099976-9016-1-git-send-email-stefan@agner.ch>
Date: Sun, 17 Jan 2016 22:52:56 -0800
From: Stefan Agner <stefan@...er.ch>
To: broonie@...nel.org
Cc: gregkh@...uxfoundation.org, linux-kernel@...r.kernel.org,
Stefan Agner <stefan@...er.ch>
Subject: [RFC] regmap: clairify max_register meaning
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@...er.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
Powered by blists - more mailing lists