]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
regulator: gpio: Use dev_err_probe
authorNishanth Menon <nm@ti.com>
Mon, 12 May 2025 18:57:27 +0000 (13:57 -0500)
committerMark Brown <broonie@kernel.org>
Tue, 13 May 2025 05:48:57 +0000 (07:48 +0200)
During probe the gpio driver may not yet be available. Use
dev_err_probe to provide just the pertinent log.

Since dev_err_probe takes care of reporting the error value,
drop the redundant ret variable while at it.

Signed-off-by: Nishanth Menon <nm@ti.com>
Link: https://patch.msgid.link/20250512185727.2907411-1-nm@ti.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/regulator/gpio-regulator.c

index 65927fa2ef161cdafef3f0334c6be6894b35fa4d..75bd53445ba786698ef6763334ef7e6b21560ce5 100644 (file)
@@ -240,7 +240,7 @@ static int gpio_regulator_probe(struct platform_device *pdev)
        struct regulator_config cfg = { };
        struct regulator_dev *rdev;
        enum gpiod_flags gflags;
-       int ptr, ret, state, i;
+       int ptr, state, i;
 
        drvdata = devm_kzalloc(dev, sizeof(struct gpio_regulator_data),
                               GFP_KERNEL);
@@ -345,11 +345,9 @@ static int gpio_regulator_probe(struct platform_device *pdev)
                return PTR_ERR(cfg.ena_gpiod);
 
        rdev = devm_regulator_register(dev, &drvdata->desc, &cfg);
-       if (IS_ERR(rdev)) {
-               ret = PTR_ERR(rdev);
-               dev_err(dev, "Failed to register regulator: %d\n", ret);
-               return ret;
-       }
+       if (IS_ERR(rdev))
+               return dev_err_probe(dev, PTR_ERR(rdev),
+                                    "Failed to register regulator\n");
 
        platform_set_drvdata(pdev, drvdata);