[PATCH v2 14/32] mfd: sec: s2dos05/s2mpu05: use explicit regmap config and drop default

From: André Draszik
Date: Fri Mar 28 2025 - 09:44:39 EST


When support for PMICs without compatibles was removed in
commit f736d2c0caa8 ("mfd: sec: Remove PMICs without compatibles"),
sec_regmap_config effectively became an orphan, because S5M8763X was
the only user left of it before removal, using the default: case of the
switch statement.

When s2dos05 and s2mpu05 support was added in commit bf231e5febcf
("mfd: sec-core: Add support for the Samsung s2dos05") and commit
ed33479b7beb ("mfd: sec: Add support for S2MPU05 PMIC"), they ended up
using that orphaned regmap_config in a non-obvious way due to the
default: case of the device type switch matching statement taking
effect again.

To make things more obvious, and to help the reader of this code while
reasoning about what the intention might be here, and to ensure future
additions to support new devices in this driver don't forget to add a
regmap config, add an explicit regmap config for these two devices, and
completely remove the generic regmap config as it becomes an orphan
again that shouldn't be used by any device.

Note that this commit doesn't fix the issue that s2dos05_regmap_config
ands2mpu05_regmap_config really are incomplete, but I have no
documentation on them.

Signed-off-by: André Draszik <andre.draszik@xxxxxxxxxx>

---
v2:
* squash two previously separate patches into this one (Krzysztof)
---
drivers/mfd/sec-i2c.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/drivers/mfd/sec-i2c.c b/drivers/mfd/sec-i2c.c
index a107a9c1e760f90fcb59a9944b74e9a39a0d946c..81f90003eea2a40f2caaebb49fc9494b89370e7f 100644
--- a/drivers/mfd/sec-i2c.c
+++ b/drivers/mfd/sec-i2c.c
@@ -61,7 +61,7 @@ static bool s2mpu02_volatile(struct device *dev, unsigned int reg)
}
}

-static const struct regmap_config sec_regmap_config = {
+static const struct regmap_config s2dos05_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
};
@@ -120,6 +120,11 @@ static const struct regmap_config s2mpu02_regmap_config = {
.cache_type = REGCACHE_FLAT,
};

+static const struct regmap_config s2mpu05_regmap_config = {
+ .reg_bits = 8,
+ .val_bits = 8,
+};
+
static const struct regmap_config s5m8767_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
@@ -138,6 +143,9 @@ static int sec_pmic_i2c_probe(struct i2c_client *client)
device_type = (unsigned long)of_device_get_match_data(&client->dev);

switch (device_type) {
+ case S2DOS05:
+ regmap = &s2dos05_regmap_config;
+ break;
case S2MPA01:
regmap = &s2mpa01_regmap_config;
break;
@@ -156,12 +164,16 @@ static int sec_pmic_i2c_probe(struct i2c_client *client)
case S2MPU02:
regmap = &s2mpu02_regmap_config;
break;
+ case S2MPU05:
+ regmap = &s2mpu05_regmap_config;
+ break;
case S5M8767X:
regmap = &s5m8767_regmap_config;
break;
default:
- regmap = &sec_regmap_config;
- break;
+ return dev_err_probe(&client->dev, -ENODEV,
+ "Unsupported device type %lu\n",
+ device_type);
}

regmap_pmic = devm_regmap_init_i2c(client, regmap);

--
2.49.0.472.ge94155a9ec-goog