leds: lm3692x: Handle failure to probe the regulator
authorGuido Günther <agx@sigxcpu.org>
Sat, 21 Sep 2019 21:12:10 +0000 (14:12 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 4 Jan 2020 18:17:02 +0000 (19:17 +0100)
[ Upstream commit 396128d2ffcba6e1954cfdc9a89293ff79cbfd7c ]

Instead use devm_regulator_get_optional since the regulator
is optional and check for errors.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
Acked-by: Pavel Machek <pavel@ucw.cz>
Reviewed-by: Dan Murphy <dmurphy@ti.com>
Signed-off-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/leds/leds-lm3692x.c

index 3d381f2f73d04014e93e9c7738df85e57168cfe0..1ac9a44570eedd01d7722d711054ccfedb4e5301 100644 (file)
@@ -334,9 +334,18 @@ static int lm3692x_probe_dt(struct lm3692x_led *led)
                return ret;
        }
 
-       led->regulator = devm_regulator_get(&led->client->dev, "vled");
-       if (IS_ERR(led->regulator))
+       led->regulator = devm_regulator_get_optional(&led->client->dev, "vled");
+       if (IS_ERR(led->regulator)) {
+               ret = PTR_ERR(led->regulator);
+               if (ret != -ENODEV) {
+                       if (ret != -EPROBE_DEFER)
+                               dev_err(&led->client->dev,
+                                       "Failed to get vled regulator: %d\n",
+                                       ret);
+                       return ret;
+               }
                led->regulator = NULL;
+       }
 
        child = device_get_next_child_node(&led->client->dev, child);
        if (!child) {