From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753715AbcARGxJ (ORCPT ); Mon, 18 Jan 2016 01:53:09 -0500 Received: from mail.kmu-office.ch ([178.209.48.109]:54874 "EHLO mail.kmu-office.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750925AbcARGxH (ORCPT ); Mon, 18 Jan 2016 01:53:07 -0500 From: Stefan Agner To: broonie@kernel.org Cc: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, Stefan Agner Subject: [RFC] regmap: clairify max_register meaning Date: Sun, 17 Jan 2016 22:52:56 -0800 Message-Id: <1453099976-9016-1-git-send-email-stefan@agner.ch> X-Mailer: git-send-email 2.7.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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