* [PATCH] rtc: twl: Check return value of platform_get_irq()
@ 2025-07-24 2:06 Salah Triki
2025-07-24 7:33 ` Alexandre Belloni
0 siblings, 1 reply; 3+ messages in thread
From: Salah Triki @ 2025-07-24 2:06 UTC (permalink / raw)
To: Alexandre Belloni, linux-rtc, linux-kernel; +Cc: salah.triki
platform_get_irq() may fail, so check its return value and propagate
the error in case of failure.
Signed-off-by: Salah Triki <salah.triki@gmail.com>
---
drivers/rtc/rtc-twl.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/rtc/rtc-twl.c b/drivers/rtc/rtc-twl.c
index e6106e67e1f4..992b3e1347f2 100644
--- a/drivers/rtc/rtc-twl.c
+++ b/drivers/rtc/rtc-twl.c
@@ -224,8 +224,11 @@ static int twl_rtc_alarm_irq_enable(struct device *dev, unsigned enabled)
{
struct platform_device *pdev = to_platform_device(dev);
struct twl_rtc *twl_rtc = dev_get_drvdata(dev);
- int irq = platform_get_irq(pdev, 0);
- int ret;
+ int irq, ret;
+
+ irq = platform_get_irq(pdev, 0);
+ if (irq < 0)
+ return irq;
if (enabled) {
ret = set_rtc_irq_bit(twl_rtc,
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] rtc: twl: Check return value of platform_get_irq()
2025-07-24 2:06 [PATCH] rtc: twl: Check return value of platform_get_irq() Salah Triki
@ 2025-07-24 7:33 ` Alexandre Belloni
2025-07-27 16:42 ` Markus Elfring
0 siblings, 1 reply; 3+ messages in thread
From: Alexandre Belloni @ 2025-07-24 7:33 UTC (permalink / raw)
To: Salah Triki; +Cc: linux-rtc, linux-kernel
On 24/07/2025 03:06:31+0100, Salah Triki wrote:
> platform_get_irq() may fail, so check its return value and propagate
> the error in case of failure.
>
> Signed-off-by: Salah Triki <salah.triki@gmail.com>
> ---
> drivers/rtc/rtc-twl.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/rtc/rtc-twl.c b/drivers/rtc/rtc-twl.c
> index e6106e67e1f4..992b3e1347f2 100644
> --- a/drivers/rtc/rtc-twl.c
> +++ b/drivers/rtc/rtc-twl.c
> @@ -224,8 +224,11 @@ static int twl_rtc_alarm_irq_enable(struct device *dev, unsigned enabled)
> {
> struct platform_device *pdev = to_platform_device(dev);
> struct twl_rtc *twl_rtc = dev_get_drvdata(dev);
> - int irq = platform_get_irq(pdev, 0);
> - int ret;
> + int irq, ret;
> +
> + irq = platform_get_irq(pdev, 0);
> + if (irq < 0)
> + return irq;
It won't ever fail because we know it already succeeded earlier.
>
> if (enabled) {
> ret = set_rtc_irq_bit(twl_rtc,
> --
> 2.43.0
>
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] rtc: twl: Check return value of platform_get_irq()
2025-07-24 7:33 ` Alexandre Belloni
@ 2025-07-27 16:42 ` Markus Elfring
0 siblings, 0 replies; 3+ messages in thread
From: Markus Elfring @ 2025-07-27 16:42 UTC (permalink / raw)
To: Alexandre Belloni, linux-rtc, Salah Triki; +Cc: LKML
…
> > +++ b/drivers/rtc/rtc-twl.c
> > @@ -224,8 +224,11 @@ static int twl_rtc_alarm_irq_enable(struct device *dev, unsigned enabled)
> > {
> > struct platform_device *pdev = to_platform_device(dev);
> > struct twl_rtc *twl_rtc = dev_get_drvdata(dev);
> > - int irq = platform_get_irq(pdev, 0);
> > - int ret;
> > + int irq, ret;
> > +
> > + irq = platform_get_irq(pdev, 0);
> > + if (irq < 0)
> > + return irq;
>
> It won't ever fail because we know it already succeeded earlier.
An execution failure would be strange at this place after a successful function call
within twl_rtc_probe(), wouldn't it?
https://elixir.bootlin.com/linux/v6.16-rc7/source/drivers/rtc/rtc-twl.c#L504-L519
Regards,
Markus
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-07-27 16:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-24 2:06 [PATCH] rtc: twl: Check return value of platform_get_irq() Salah Triki
2025-07-24 7:33 ` Alexandre Belloni
2025-07-27 16:42 ` Markus Elfring
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).