* [PATCH] rtc: pic32: Add error handling in pic32_rtc_probe()
@ 2022-11-22 12:17 Gaosheng Cui
2022-11-22 13:47 ` Alexandre Belloni
0 siblings, 1 reply; 2+ messages in thread
From: Gaosheng Cui @ 2022-11-22 12:17 UTC (permalink / raw)
To: a.zummo, alexandre.belloni, cuigaosheng1; +Cc: linux-rtc
The pic32_rtc_enable(pdata, 0) and clk_disable_unprepare(pdata->clk)
should be called in the error handling of devm_rtc_allocate_device(),
fix it.
Fixes: 6515e23b9fde ("rtc: pic32: convert to devm_rtc_allocate_device")
Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
---
drivers/rtc/rtc-pic32.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/rtc/rtc-pic32.c b/drivers/rtc/rtc-pic32.c
index 7fb9145c43bd..258136e3fe96 100644
--- a/drivers/rtc/rtc-pic32.c
+++ b/drivers/rtc/rtc-pic32.c
@@ -331,8 +331,10 @@ static int pic32_rtc_probe(struct platform_device *pdev)
device_init_wakeup(&pdev->dev, 1);
pdata->rtc = devm_rtc_allocate_device(&pdev->dev);
- if (IS_ERR(pdata->rtc))
- return PTR_ERR(pdata->rtc);
+ if (IS_ERR(pdata->rtc)) {
+ ret = PTR_ERR(pdata->rtc);
+ goto err_nortc;
+ }
pdata->rtc->ops = &pic32_rtcops;
pdata->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] rtc: pic32: Add error handling in pic32_rtc_probe()
2022-11-22 12:17 [PATCH] rtc: pic32: Add error handling in pic32_rtc_probe() Gaosheng Cui
@ 2022-11-22 13:47 ` Alexandre Belloni
0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Belloni @ 2022-11-22 13:47 UTC (permalink / raw)
To: Gaosheng Cui; +Cc: a.zummo, linux-rtc
On 22/11/2022 20:17:21+0800, Gaosheng Cui wrote:
> The pic32_rtc_enable(pdata, 0) and clk_disable_unprepare(pdata->clk)
> should be called in the error handling of devm_rtc_allocate_device(),
> fix it.
>
> Fixes: 6515e23b9fde ("rtc: pic32: convert to devm_rtc_allocate_device")
> Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
> ---
> drivers/rtc/rtc-pic32.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/rtc/rtc-pic32.c b/drivers/rtc/rtc-pic32.c
> index 7fb9145c43bd..258136e3fe96 100644
> --- a/drivers/rtc/rtc-pic32.c
> +++ b/drivers/rtc/rtc-pic32.c
> @@ -331,8 +331,10 @@ static int pic32_rtc_probe(struct platform_device *pdev)
> device_init_wakeup(&pdev->dev, 1);
>
> pdata->rtc = devm_rtc_allocate_device(&pdev->dev);
A better solution is to move this call earlier in .probe
> - if (IS_ERR(pdata->rtc))
> - return PTR_ERR(pdata->rtc);
> + if (IS_ERR(pdata->rtc)) {
> + ret = PTR_ERR(pdata->rtc);
> + goto err_nortc;
> + }
>
> pdata->rtc->ops = &pic32_rtcops;
> pdata->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
> --
> 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-11-22 13:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-22 12:17 [PATCH] rtc: pic32: Add error handling in pic32_rtc_probe() Gaosheng Cui
2022-11-22 13:47 ` 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).