hwmon: (ltc2947) Properly handle errors when looking for the external clock
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Thu, 23 Sep 2021 20:11:13 +0000 (22:11 +0200)
committerGuenter Roeck <linux@roeck-us.net>
Fri, 24 Sep 2021 12:02:24 +0000 (05:02 -0700)
The return value of devm_clk_get should in general be propagated to
upper layer. In this case the clk is optional, use the appropriate
wrapper instead of interpreting all errors as "The optional clk is not
available".

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20210923201113.398932-1-u.kleine-koenig@pengutronix.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/ltc2947-core.c

index bb3f7749a0b001cb21a668f62de984363671575b..5423466de697af5bf704217f26eaccea058f404d 100644 (file)
@@ -989,8 +989,12 @@ static int ltc2947_setup(struct ltc2947_data *st)
                return ret;
 
        /* check external clock presence */
-       extclk = devm_clk_get(st->dev, NULL);
-       if (!IS_ERR(extclk)) {
+       extclk = devm_clk_get_optional(st->dev, NULL);
+       if (IS_ERR(extclk))
+               return dev_err_probe(st->dev, PTR_ERR(extclk),
+                                    "Failed to get external clock\n");
+
+       if (extclk) {
                unsigned long rate_hz;
                u8 pre = 0, div, tbctl;
                u64 aux;