From: AndrĂ© Draszik Date: Thu, 22 Jan 2026 15:43:39 +0000 (+0000) Subject: regulator: s2mps11: use dev_err_probe() where appropriate X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6430d65d7b74712e9ff60e270687d66265dad6f2;p=thirdparty%2Fkernel%2Flinux.git 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 Signed-off-by: AndrĂ© Draszik Link: https://patch.msgid.link/20260122-s2mpg1x-regulators-v7-12-3b1f9831fffd@linaro.org Signed-off-by: Mark Brown --- diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c index 1f51fbc6c7b6..30586e9884bf 100644 --- a/drivers/regulator/s2mps11.c +++ b/drivers/regulator/s2mps11.c @@ -1249,9 +1249,9 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) BUILD_BUG_ON(S2MPS_REGULATOR_MAX < ARRAY_SIZE(s2mpu05_regulators)); break; default: - dev_err(&pdev->dev, "Invalid device type: %u\n", - s2mps11->dev_type); - return -EINVAL; + return dev_err_probe(&pdev->dev, -ENODEV, + "Unsupported device type %d\n", + s2mps11->dev_type); } s2mps11->ext_control_gpiod = devm_kcalloc(&pdev->dev, rdev_num, @@ -1290,21 +1290,20 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) devm_gpiod_unhinge(&pdev->dev, config.ena_gpiod); regulator = devm_regulator_register(&pdev->dev, ®ulators[i], &config); - if (IS_ERR(regulator)) { - dev_err(&pdev->dev, "regulator init failed for %d\n", - i); - return PTR_ERR(regulator); - } + if (IS_ERR(regulator)) + return dev_err_probe(&pdev->dev, PTR_ERR(regulator), + "regulator init failed for %d/%s\n", + regulators[i].id, + regulators[i].name); if (config.ena_gpiod) { ret = s2mps14_pmic_enable_ext_control(s2mps11, - regulator); - if (ret < 0) { - dev_err(&pdev->dev, - "failed to enable GPIO control over %s: %d\n", - regulator->desc->name, ret); - return ret; - } + regulator); + if (ret < 0) + return dev_err_probe(&pdev->dev, ret, + "failed to enable GPIO control over %d/%s\n", + regulator->desc->id, + regulator->desc->name); } }