[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250627142309.1444135-3-elder@riscstar.com>
Date: Fri, 27 Jun 2025 09:23:01 -0500
From: Alex Elder <elder@...cstar.com>
To: lee@...nel.org,
lgirdwood@...il.com,
broonie@...nel.org,
alexandre.belloni@...tlin.com,
robh@...nel.org,
krzk+dt@...nel.org,
conor+dt@...nel.org
Cc: mat.jonczyk@...pl,
dlan@...too.org,
paul.walmsley@...ive.com,
palmer@...belt.com,
aou@...s.berkeley.edu,
alex@...ti.fr,
troymitchell988@...il.com,
guodong@...cstar.com,
linux-rtc@...r.kernel.org,
devicetree@...r.kernel.org,
linux-riscv@...ts.infradead.org,
spacemit@...ts.linux.dev,
linux-kernel@...r.kernel.org
Subject: [PATCH v6 2/8] mfd: simple-mfd-i2c: specify max_register
All devices supported by simple MFD use the same 8-bit register
8-bit value regmap configuration. There is an option available
for a device to specify a custome configuration, but no existing
device uses it.
Lee Jones suggested modifying the simple MFD implementation to
remove the generality of the full regmap configuration and add a
max_register value to the simple_mfd_data structure. This can
be used in the regmap configuration to limit the valid register
addresses if desired. It's simpler, and covers all existing and
anticipated device types.
Signed-off-by: Alex Elder <elder@...cstar.com>
Suggested-by: Lee Jones <lee@...nel.org>
---
v6: - New patch, changing the simple MFD functionality
drivers/mfd/simple-mfd-i2c.c | 18 ++++++------------
drivers/mfd/simple-mfd-i2c.h | 2 +-
2 files changed, 7 insertions(+), 13 deletions(-)
diff --git a/drivers/mfd/simple-mfd-i2c.c b/drivers/mfd/simple-mfd-i2c.c
index 22159913bea03..c1dc315d44dcf 100644
--- a/drivers/mfd/simple-mfd-i2c.c
+++ b/drivers/mfd/simple-mfd-i2c.c
@@ -24,27 +24,21 @@
#include "simple-mfd-i2c.h"
-static const struct regmap_config regmap_config_8r_8v = {
- .reg_bits = 8,
- .val_bits = 8,
-};
-
static int simple_mfd_i2c_probe(struct i2c_client *i2c)
{
const struct simple_mfd_data *simple_mfd_data;
- const struct regmap_config *regmap_config;
+ struct regmap_config regmap_config = { };
struct regmap *regmap;
int ret;
simple_mfd_data = device_get_match_data(&i2c->dev);
- /* If no regmap_config is specified, use the default 8reg and 8val bits */
- if (!simple_mfd_data || !simple_mfd_data->regmap_config)
- regmap_config = ®map_config_8r_8v;
- else
- regmap_config = simple_mfd_data->regmap_config;
+ regmap_config.reg_bits = 8;
+ regmap_config.val_bits = 8;
+ if (simple_mfd_data)
+ regmap_config.max_register = simple_mfd_data->max_register;
- regmap = devm_regmap_init_i2c(i2c, regmap_config);
+ regmap = devm_regmap_init_i2c(i2c, ®map_config);
if (IS_ERR(regmap))
return PTR_ERR(regmap);
diff --git a/drivers/mfd/simple-mfd-i2c.h b/drivers/mfd/simple-mfd-i2c.h
index 7cb2bdd347d97..4121fe1bc1d70 100644
--- a/drivers/mfd/simple-mfd-i2c.h
+++ b/drivers/mfd/simple-mfd-i2c.h
@@ -24,9 +24,9 @@
#include <linux/regmap.h>
struct simple_mfd_data {
- const struct regmap_config *regmap_config;
const struct mfd_cell *mfd_cell;
size_t mfd_cell_size;
+ unsigned int max_register;
};
#endif /* __MFD_SIMPLE_MFD_I2C_H */
--
2.45.2
Powered by blists - more mailing lists