Skip to content

Commit 6f7d704

Browse files
Uwe Kleine-Königgroeck
authored andcommitted
hwmon: (ltc2947) Properly handle errors when looking for the external clock
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]>
1 parent 724e8af commit 6f7d704

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/hwmon/ltc2947-core.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -989,8 +989,12 @@ static int ltc2947_setup(struct ltc2947_data *st)
989989
return ret;
990990

991991
/* check external clock presence */
992-
extclk = devm_clk_get(st->dev, NULL);
993-
if (!IS_ERR(extclk)) {
992+
extclk = devm_clk_get_optional(st->dev, NULL);
993+
if (IS_ERR(extclk))
994+
return dev_err_probe(st->dev, PTR_ERR(extclk),
995+
"Failed to get external clock\n");
996+
997+
if (extclk) {
994998
unsigned long rate_hz;
995999
u8 pre = 0, div, tbctl;
9961000
u64 aux;

0 commit comments

Comments
 (0)