Skip to content

Commit

Permalink
hwmon: (ltc2947) Properly handle errors when looking for the external…
Browse files Browse the repository at this point in the history
… 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]>
  • Loading branch information
Uwe Kleine-König authored and groeck committed Sep 24, 2021
1 parent 724e8af commit 6f7d704
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/hwmon/ltc2947-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 6f7d704

Please sign in to comment.