Skip to content

Commit 1cea1b6

Browse files
andredlag-linaro
authored andcommitted
mfd: sec-i2c: s2dos05/s2mpu05: Use explicit regmap config and drop default
When support for PMICs without compatibles was removed in commit f736d2c ("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 bf231e5 ("mfd: sec-core: Add support for the Samsung s2dos05") and commit ed33479 ("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. Reviewed-by: Krzysztof Kozlowski <[email protected]> Signed-off-by: André Draszik <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lee Jones <[email protected]>
1 parent 176a306 commit 1cea1b6

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

drivers/mfd/sec-i2c.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static bool s2mpu02_volatile(struct device *dev, unsigned int reg)
6161
}
6262
}
6363

64-
static const struct regmap_config sec_regmap_config = {
64+
static const struct regmap_config s2dos05_regmap_config = {
6565
.reg_bits = 8,
6666
.val_bits = 8,
6767
};
@@ -120,6 +120,11 @@ static const struct regmap_config s2mpu02_regmap_config = {
120120
.cache_type = REGCACHE_FLAT,
121121
};
122122

123+
static const struct regmap_config s2mpu05_regmap_config = {
124+
.reg_bits = 8,
125+
.val_bits = 8,
126+
};
127+
123128
static const struct regmap_config s5m8767_regmap_config = {
124129
.reg_bits = 8,
125130
.val_bits = 8,
@@ -138,6 +143,9 @@ static int sec_pmic_i2c_probe(struct i2c_client *client)
138143
device_type = (unsigned long)of_device_get_match_data(&client->dev);
139144

140145
switch (device_type) {
146+
case S2DOS05:
147+
regmap = &s2dos05_regmap_config;
148+
break;
141149
case S2MPA01:
142150
regmap = &s2mpa01_regmap_config;
143151
break;
@@ -156,12 +164,16 @@ static int sec_pmic_i2c_probe(struct i2c_client *client)
156164
case S2MPU02:
157165
regmap = &s2mpu02_regmap_config;
158166
break;
167+
case S2MPU05:
168+
regmap = &s2mpu05_regmap_config;
169+
break;
159170
case S5M8767X:
160171
regmap = &s5m8767_regmap_config;
161172
break;
162173
default:
163-
regmap = &sec_regmap_config;
164-
break;
174+
return dev_err_probe(&client->dev, -ENODEV,
175+
"Unsupported device type %lu\n",
176+
device_type);
165177
}
166178

167179
regmap_pmic = devm_regmap_init_i2c(client, regmap);

0 commit comments

Comments
 (0)