* [PATCH V2] rtc: bbnsm: add remove hook
@ 2024-11-04 3:15 Peng Fan (OSS)
2024-11-10 22:32 ` Alexandre Belloni
0 siblings, 1 reply; 2+ messages in thread
From: Peng Fan (OSS) @ 2024-11-04 3:15 UTC (permalink / raw)
To: Alexandre Belloni, Jacky Bai, Peng Fan,
open list:REAL TIME CLOCK (RTC) SUBSYSTEM, open list
Cc: Christophe JAILLET
From: Peng Fan <peng.fan@nxp.com>
Without remove hook to clear wake irq, there will be kernel dump when
doing module test.
"bbnsm_rtc 44440000.bbnsm:rtc: wake irq already initialized"
Add remove hook to clear wake irq and set wakeup to false.
Fixes: eb7b85853c38 ("rtc: bbnsm: Add the bbnsm rtc support")
Cc: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
V2:
Per Christophe JAILLET
Use remove, not remove_new
Fix error handling in probe
drivers/rtc/rtc-nxp-bbnsm.c | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/drivers/rtc/rtc-nxp-bbnsm.c b/drivers/rtc/rtc-nxp-bbnsm.c
index acbfbeb8b070..31225baddadf 100644
--- a/drivers/rtc/rtc-nxp-bbnsm.c
+++ b/drivers/rtc/rtc-nxp-bbnsm.c
@@ -197,13 +197,30 @@ static int bbnsm_rtc_probe(struct platform_device *pdev)
if (ret) {
dev_err(&pdev->dev, "failed to request irq %d: %d\n",
bbnsm->irq, ret);
- return ret;
+ goto err;
}
bbnsm->rtc->ops = &bbnsm_rtc_ops;
bbnsm->rtc->range_max = U32_MAX;
- return devm_rtc_register_device(bbnsm->rtc);
+ ret = devm_rtc_register_device(bbnsm->rtc);
+ if (ret) {
+ dev_err(&pdev->dev, "failed to register rtc :%d\n", ret);
+ goto err;
+ }
+
+ return 0;
+
+err:
+ dev_pm_clear_wake_irq(&pdev->dev);
+ device_init_wakeup(&pdev->dev, false);
+ return ret;
+}
+
+static void bbnsm_rtc_remove(struct platform_device *pdev)
+{
+ dev_pm_clear_wake_irq(&pdev->dev);
+ device_init_wakeup(&pdev->dev, false);
}
static const struct of_device_id bbnsm_dt_ids[] = {
@@ -218,6 +235,7 @@ static struct platform_driver bbnsm_rtc_driver = {
.of_match_table = bbnsm_dt_ids,
},
.probe = bbnsm_rtc_probe,
+ .remove = bbnsm_rtc_remove,
};
module_platform_driver(bbnsm_rtc_driver);
--
2.37.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH V2] rtc: bbnsm: add remove hook
2024-11-04 3:15 [PATCH V2] rtc: bbnsm: add remove hook Peng Fan (OSS)
@ 2024-11-10 22:32 ` Alexandre Belloni
0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Belloni @ 2024-11-10 22:32 UTC (permalink / raw)
To: Peng Fan (OSS)
Cc: Jacky Bai, Peng Fan, open list:REAL TIME CLOCK (RTC) SUBSYSTEM,
open list, Christophe JAILLET
On 04/11/2024 11:15:12+0800, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@nxp.com>
>
> Without remove hook to clear wake irq, there will be kernel dump when
> doing module test.
> "bbnsm_rtc 44440000.bbnsm:rtc: wake irq already initialized"
>
> Add remove hook to clear wake irq and set wakeup to false.
>
> Fixes: eb7b85853c38 ("rtc: bbnsm: Add the bbnsm rtc support")
> Cc: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>
> V2:
> Per Christophe JAILLET
> Use remove, not remove_new
> Fix error handling in probe
>
> drivers/rtc/rtc-nxp-bbnsm.c | 22 ++++++++++++++++++++--
> 1 file changed, 20 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/rtc/rtc-nxp-bbnsm.c b/drivers/rtc/rtc-nxp-bbnsm.c
> index acbfbeb8b070..31225baddadf 100644
> --- a/drivers/rtc/rtc-nxp-bbnsm.c
> +++ b/drivers/rtc/rtc-nxp-bbnsm.c
> @@ -197,13 +197,30 @@ static int bbnsm_rtc_probe(struct platform_device *pdev)
> if (ret) {
> dev_err(&pdev->dev, "failed to request irq %d: %d\n",
> bbnsm->irq, ret);
> - return ret;
> + goto err;
> }
>
> bbnsm->rtc->ops = &bbnsm_rtc_ops;
> bbnsm->rtc->range_max = U32_MAX;
>
> - return devm_rtc_register_device(bbnsm->rtc);
> + ret = devm_rtc_register_device(bbnsm->rtc);
> + if (ret) {
> + dev_err(&pdev->dev, "failed to register rtc :%d\n", ret);
No extra error message, all the failing paths of
devm_rtc_register_device already have one.
> + goto err;
> + }
> +
> + return 0;
> +
> +err:
> + dev_pm_clear_wake_irq(&pdev->dev);
> + device_init_wakeup(&pdev->dev, false);
> + return ret;
> +}
> +
> +static void bbnsm_rtc_remove(struct platform_device *pdev)
> +{
> + dev_pm_clear_wake_irq(&pdev->dev);
> + device_init_wakeup(&pdev->dev, false);
> }
>
> static const struct of_device_id bbnsm_dt_ids[] = {
> @@ -218,6 +235,7 @@ static struct platform_driver bbnsm_rtc_driver = {
> .of_match_table = bbnsm_dt_ids,
> },
> .probe = bbnsm_rtc_probe,
> + .remove = bbnsm_rtc_remove,
> };
> module_platform_driver(bbnsm_rtc_driver);
>
> --
> 2.37.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:[~2024-11-10 22:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-04 3:15 [PATCH V2] rtc: bbnsm: add remove hook Peng Fan (OSS)
2024-11-10 22:32 ` 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).