Skip to content

Commit b389cea

Browse files
AxelLinbroonie
authored andcommitted
regulator: bd718x7: Simplify the code by removing struct bd718xx_pmic_inits
Nowdays ROHM_CHIP_TYPE_AMOUNT includes not only BD71837/BD71847 but also BD70528/BD71828 which are not supported by this driver. So it seems not necessay to have pmic_regulators[ROHM_CHIP_TYPE_AMOUNT] as mapping table. Simplify the code by removing struct bd718xx_pmic_inits and pmic_regulators[ROHM_CHIP_TYPE_AMOUNT]. Signed-off-by: Axel Lin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent ebf652b commit b389cea

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

drivers/regulator/bd718x7-regulator.c

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,28 +1142,14 @@ static const struct bd718xx_regulator_data bd71837_regulators[] = {
11421142
},
11431143
};
11441144

1145-
struct bd718xx_pmic_inits {
1146-
const struct bd718xx_regulator_data *r_datas;
1147-
unsigned int r_amount;
1148-
};
1149-
11501145
static int bd718xx_probe(struct platform_device *pdev)
11511146
{
11521147
struct bd718xx *mfd;
11531148
struct regulator_config config = { 0 };
1154-
struct bd718xx_pmic_inits pmic_regulators[ROHM_CHIP_TYPE_AMOUNT] = {
1155-
[ROHM_CHIP_TYPE_BD71837] = {
1156-
.r_datas = bd71837_regulators,
1157-
.r_amount = ARRAY_SIZE(bd71837_regulators),
1158-
},
1159-
[ROHM_CHIP_TYPE_BD71847] = {
1160-
.r_datas = bd71847_regulators,
1161-
.r_amount = ARRAY_SIZE(bd71847_regulators),
1162-
},
1163-
};
1164-
11651149
int i, j, err;
11661150
bool use_snvs;
1151+
const struct bd718xx_regulator_data *reg_data;
1152+
unsigned int num_reg_data;
11671153

11681154
mfd = dev_get_drvdata(pdev->dev.parent);
11691155
if (!mfd) {
@@ -1172,8 +1158,16 @@ static int bd718xx_probe(struct platform_device *pdev)
11721158
goto err;
11731159
}
11741160

1175-
if (mfd->chip.chip_type >= ROHM_CHIP_TYPE_AMOUNT ||
1176-
!pmic_regulators[mfd->chip.chip_type].r_datas) {
1161+
switch (mfd->chip.chip_type) {
1162+
case ROHM_CHIP_TYPE_BD71837:
1163+
reg_data = bd71837_regulators;
1164+
num_reg_data = ARRAY_SIZE(bd71837_regulators);
1165+
break;
1166+
case ROHM_CHIP_TYPE_BD71847:
1167+
reg_data = bd71847_regulators;
1168+
num_reg_data = ARRAY_SIZE(bd71847_regulators);
1169+
break;
1170+
default:
11771171
dev_err(&pdev->dev, "Unsupported chip type\n");
11781172
err = -EINVAL;
11791173
goto err;
@@ -1215,13 +1209,13 @@ static int bd718xx_probe(struct platform_device *pdev)
12151209
}
12161210
}
12171211

1218-
for (i = 0; i < pmic_regulators[mfd->chip.chip_type].r_amount; i++) {
1212+
for (i = 0; i < num_reg_data; i++) {
12191213

12201214
const struct regulator_desc *desc;
12211215
struct regulator_dev *rdev;
12221216
const struct bd718xx_regulator_data *r;
12231217

1224-
r = &pmic_regulators[mfd->chip.chip_type].r_datas[i];
1218+
r = &reg_data[i];
12251219
desc = &r->desc;
12261220

12271221
config.dev = pdev->dev.parent;

0 commit comments

Comments
 (0)