Skip to content

Commit 3d68c7b

Browse files
Uwe Kleine-Königgregkh
authored andcommitted
hwmon: (ltc2947) Properly handle errors when looking for the external clock
[ Upstream commit 6f7d704 ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 194e8a4 commit 3d68c7b

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

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)