linux-hwmon.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hwmon: ltc2947: Properly handle errors when looking for the external clock
@ 2021-09-23 20:11 Uwe Kleine-König
  2021-09-24  2:03 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: Uwe Kleine-König @ 2021-09-23 20:11 UTC (permalink / raw)
  To: Nuno Sá, Jean Delvare, Guenter Roeck; +Cc: linux-hwmon, kernel

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>
---
 drivers/hwmon/ltc2947-core.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/hwmon/ltc2947-core.c b/drivers/hwmon/ltc2947-core.c
index bb3f7749a0b0..5423466de697 100644
--- a/drivers/hwmon/ltc2947-core.c
+++ b/drivers/hwmon/ltc2947-core.c
@@ -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;

base-commit: 7d2a07b769330c34b4deabeed939325c77a7ec2f
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] hwmon: ltc2947: Properly handle errors when looking for the external clock
  2021-09-23 20:11 [PATCH] hwmon: ltc2947: Properly handle errors when looking for the external clock Uwe Kleine-König
@ 2021-09-24  2:03 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2021-09-24  2:03 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: Nuno Sá, Jean Delvare, linux-hwmon, kernel

On Thu, Sep 23, 2021 at 10:11:13PM +0200, Uwe Kleine-König wrote:
> 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>

Applied.

Thanks,
Guenter

> ---
>  drivers/hwmon/ltc2947-core.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> 
> base-commit: 7d2a07b769330c34b4deabeed939325c77a7ec2f
> 
> diff --git a/drivers/hwmon/ltc2947-core.c b/drivers/hwmon/ltc2947-core.c
> index bb3f7749a0b0..5423466de697 100644
> --- a/drivers/hwmon/ltc2947-core.c
> +++ b/drivers/hwmon/ltc2947-core.c
> @@ -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;

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-24  2:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-23 20:11 [PATCH] hwmon: ltc2947: Properly handle errors when looking for the external clock Uwe Kleine-König
2021-09-24  2:03 ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).