Skip to content

Commit 6430d65

Browse files
andredbroonie
authored andcommitted
regulator: s2mps11: use dev_err_probe() where appropriate
dev_err_probe() exists to simplify code and harmonise error messages, there's no reason not to use it here. While at it, harmonise some error messages to add regulator name and ID like in other messages in this driver, and update messages to be more similar to other child-drivers of this PMIC (e.g. RTC). Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Signed-off-by: André Draszik <andre.draszik@linaro.org> Link: https://patch.msgid.link/20260122-s2mpg1x-regulators-v7-12-3b1f9831fffd@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 0809d3d commit 6430d65

1 file changed

Lines changed: 14 additions & 15 deletions

File tree

drivers/regulator/s2mps11.c

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,9 +1249,9 @@ static int s2mps11_pmic_probe(struct platform_device *pdev)
12491249
BUILD_BUG_ON(S2MPS_REGULATOR_MAX < ARRAY_SIZE(s2mpu05_regulators));
12501250
break;
12511251
default:
1252-
dev_err(&pdev->dev, "Invalid device type: %u\n",
1253-
s2mps11->dev_type);
1254-
return -EINVAL;
1252+
return dev_err_probe(&pdev->dev, -ENODEV,
1253+
"Unsupported device type %d\n",
1254+
s2mps11->dev_type);
12551255
}
12561256

12571257
s2mps11->ext_control_gpiod = devm_kcalloc(&pdev->dev, rdev_num,
@@ -1290,21 +1290,20 @@ static int s2mps11_pmic_probe(struct platform_device *pdev)
12901290
devm_gpiod_unhinge(&pdev->dev, config.ena_gpiod);
12911291
regulator = devm_regulator_register(&pdev->dev,
12921292
&regulators[i], &config);
1293-
if (IS_ERR(regulator)) {
1294-
dev_err(&pdev->dev, "regulator init failed for %d\n",
1295-
i);
1296-
return PTR_ERR(regulator);
1297-
}
1293+
if (IS_ERR(regulator))
1294+
return dev_err_probe(&pdev->dev, PTR_ERR(regulator),
1295+
"regulator init failed for %d/%s\n",
1296+
regulators[i].id,
1297+
regulators[i].name);
12981298

12991299
if (config.ena_gpiod) {
13001300
ret = s2mps14_pmic_enable_ext_control(s2mps11,
1301-
regulator);
1302-
if (ret < 0) {
1303-
dev_err(&pdev->dev,
1304-
"failed to enable GPIO control over %s: %d\n",
1305-
regulator->desc->name, ret);
1306-
return ret;
1307-
}
1301+
regulator);
1302+
if (ret < 0)
1303+
return dev_err_probe(&pdev->dev, ret,
1304+
"failed to enable GPIO control over %d/%s\n",
1305+
regulator->desc->id,
1306+
regulator->desc->name);
13081307
}
13091308
}
13101309

0 commit comments

Comments
 (0)