* [PATCH] rtc: snvs: Handle error for clk_enable
@ 2022-03-04 7:20 Jiasheng Jiang
2022-03-08 16:34 ` Alexandre Belloni
0 siblings, 1 reply; 2+ messages in thread
From: Jiasheng Jiang @ 2022-03-04 7:20 UTC (permalink / raw)
To: a.zummo, alexandre.belloni; +Cc: linux-rtc, linux-kernel, Jiasheng Jiang
As the potential failure of the clk_enable(),
it should be better to check it and return error
if fails.
Fixes: edb190cb1734 ("rtc: snvs: make sure clock is enabled for interrupt handle")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
drivers/rtc/rtc-snvs.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/rtc/rtc-snvs.c b/drivers/rtc/rtc-snvs.c
index bd929b0e7d7d..f273f7d873f8 100644
--- a/drivers/rtc/rtc-snvs.c
+++ b/drivers/rtc/rtc-snvs.c
@@ -269,8 +269,11 @@ static irqreturn_t snvs_rtc_irq_handler(int irq, void *dev_id)
struct snvs_rtc_data *data = dev_get_drvdata(dev);
u32 lpsr;
u32 events = 0;
+ int ret;
- clk_enable(data->clk);
+ ret = clk_enable(data->clk);
+ if (ret)
+ return IRQ_NONE;
regmap_read(data->regmap, data->offset + SNVS_LPSR, &lpsr);
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] rtc: snvs: Handle error for clk_enable
2022-03-04 7:20 [PATCH] rtc: snvs: Handle error for clk_enable Jiasheng Jiang
@ 2022-03-08 16:34 ` Alexandre Belloni
0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Belloni @ 2022-03-08 16:34 UTC (permalink / raw)
To: Jiasheng Jiang; +Cc: a.zummo, linux-rtc, linux-kernel
On 04/03/2022 15:20:18+0800, Jiasheng Jiang wrote:
> As the potential failure of the clk_enable(),
> it should be better to check it and return error
> if fails.
>
> Fixes: edb190cb1734 ("rtc: snvs: make sure clock is enabled for interrupt handle")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> ---
> drivers/rtc/rtc-snvs.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/rtc/rtc-snvs.c b/drivers/rtc/rtc-snvs.c
> index bd929b0e7d7d..f273f7d873f8 100644
> --- a/drivers/rtc/rtc-snvs.c
> +++ b/drivers/rtc/rtc-snvs.c
> @@ -269,8 +269,11 @@ static irqreturn_t snvs_rtc_irq_handler(int irq, void *dev_id)
> struct snvs_rtc_data *data = dev_get_drvdata(dev);
> u32 lpsr;
> u32 events = 0;
> + int ret;
>
> - clk_enable(data->clk);
> + ret = clk_enable(data->clk);
> + if (ret)
> + return IRQ_NONE;
I don't think you thought about the implication here, if this happens,
then the interrupt will be considered spurious which is definitively not
something we want.
>
> regmap_read(data->regmap, data->offset + SNVS_LPSR, &lpsr);
>
> --
> 2.25.1
>
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-03-08 16:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-04 7:20 [PATCH] rtc: snvs: Handle error for clk_enable Jiasheng Jiang
2022-03-08 16:34 ` Alexandre Belloni
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).