* [PATCH v2 01/12] PM: sleep: wakeirq: Introduce device-managed variant of dev_pm_set_wake_irq
2025-01-03 8:41 [PATCH v2 00/12] pm: Introduce devm_pm_set_wake_irq Peng Fan (OSS)
@ 2025-01-03 8:41 ` Peng Fan (OSS)
2025-01-14 20:20 ` Rafael J. Wysocki
2025-01-03 8:41 ` [PATCH v2 02/12] input: keyboard: ep93xx_keypad: Use devm_pm_set_wake_irq Peng Fan (OSS)
` (12 subsequent siblings)
13 siblings, 1 reply; 20+ messages in thread
From: Peng Fan (OSS) @ 2025-01-03 8:41 UTC (permalink / raw)
To: Rafael J. Wysocki, Len Brown, Pavel Machek, Greg Kroah-Hartman,
Dmitry Torokhov, Alexandre Belloni, Maxime Coquelin,
Alexandre Torgue, Linus Walleij, Conor Dooley, Daire McNamara
Cc: linux-pm, linux-kernel, linux-input, linux-rtc, linux-stm32,
linux-arm-kernel, linux-arm-msm, linux-riscv, Peng Fan
From: Peng Fan <peng.fan@nxp.com>
Add device-managed variant of dev_pm_set_wake_irq which automatically
clear the wake irq on device destruction to simplify error handling
and resource management in drivers.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/base/power/wakeirq.c | 26 ++++++++++++++++++++++++++
include/linux/pm_wakeirq.h | 6 ++++++
2 files changed, 32 insertions(+)
diff --git a/drivers/base/power/wakeirq.c b/drivers/base/power/wakeirq.c
index 5a5a9e978e85f3fc9d89cb7d43527dc1dd42a9b1..8aa28c08b2891f3af490175362cc1a759069bd50 100644
--- a/drivers/base/power/wakeirq.c
+++ b/drivers/base/power/wakeirq.c
@@ -103,6 +103,32 @@ void dev_pm_clear_wake_irq(struct device *dev)
}
EXPORT_SYMBOL_GPL(dev_pm_clear_wake_irq);
+static void devm_pm_clear_wake_irq(void *dev)
+{
+ dev_pm_clear_wake_irq(dev);
+}
+
+/**
+ * devm_pm_set_wake_irq - device-managed variant of dev_pm_set_wake_irq
+ * @dev: Device entry
+ * @irq: Device IO interrupt
+ *
+ *
+ * Attach a device IO interrupt as a wake IRQ, same with dev_pm_set_wake_irq,
+ * but the device will be auto clear wake capability on driver detach.
+ */
+int devm_pm_set_wake_irq(struct device *dev, int irq)
+{
+ int ret;
+
+ ret = dev_pm_set_wake_irq(dev, irq);
+ if (ret)
+ return ret;
+
+ return devm_add_action_or_reset(dev, devm_pm_clear_wake_irq, dev);
+}
+EXPORT_SYMBOL_GPL(devm_pm_set_wake_irq);
+
/**
* handle_threaded_wake_irq - Handler for dedicated wake-up interrupts
* @irq: Device specific dedicated wake-up interrupt
diff --git a/include/linux/pm_wakeirq.h b/include/linux/pm_wakeirq.h
index d9642c6cf85211af603ce39e280a5b4de6617ee5..25b63ed51b765c2c6919f259668a12675330835e 100644
--- a/include/linux/pm_wakeirq.h
+++ b/include/linux/pm_wakeirq.h
@@ -10,6 +10,7 @@ extern int dev_pm_set_wake_irq(struct device *dev, int irq);
extern int dev_pm_set_dedicated_wake_irq(struct device *dev, int irq);
extern int dev_pm_set_dedicated_wake_irq_reverse(struct device *dev, int irq);
extern void dev_pm_clear_wake_irq(struct device *dev);
+extern int devm_pm_set_wake_irq(struct device *dev, int irq);
#else /* !CONFIG_PM */
@@ -32,5 +33,10 @@ static inline void dev_pm_clear_wake_irq(struct device *dev)
{
}
+static inline int devm_pm_set_wake_irq(struct device *dev, int irq)
+{
+ return 0;
+}
+
#endif /* CONFIG_PM */
#endif /* _LINUX_PM_WAKEIRQ_H */
--
2.37.1
^ permalink raw reply related [flat|nested] 20+ messages in thread* Re: [PATCH v2 01/12] PM: sleep: wakeirq: Introduce device-managed variant of dev_pm_set_wake_irq
2025-01-03 8:41 ` [PATCH v2 01/12] PM: sleep: wakeirq: Introduce device-managed variant of dev_pm_set_wake_irq Peng Fan (OSS)
@ 2025-01-14 20:20 ` Rafael J. Wysocki
2025-01-15 1:28 ` Peng Fan
0 siblings, 1 reply; 20+ messages in thread
From: Rafael J. Wysocki @ 2025-01-14 20:20 UTC (permalink / raw)
To: Peng Fan (OSS)
Cc: Rafael J. Wysocki, Len Brown, Pavel Machek, Greg Kroah-Hartman,
Dmitry Torokhov, Alexandre Belloni, Maxime Coquelin,
Alexandre Torgue, Linus Walleij, Conor Dooley, Daire McNamara,
linux-pm, linux-kernel, linux-input, linux-rtc, linux-stm32,
linux-arm-kernel, linux-arm-msm, linux-riscv, Peng Fan
On Fri, Jan 3, 2025 at 9:42 AM Peng Fan (OSS) <peng.fan@oss.nxp.com> wrote:
>
> From: Peng Fan <peng.fan@nxp.com>
>
> Add device-managed variant of dev_pm_set_wake_irq which automatically
> clear the wake irq on device destruction to simplify error handling
> and resource management in drivers.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
> drivers/base/power/wakeirq.c | 26 ++++++++++++++++++++++++++
> include/linux/pm_wakeirq.h | 6 ++++++
> 2 files changed, 32 insertions(+)
>
> diff --git a/drivers/base/power/wakeirq.c b/drivers/base/power/wakeirq.c
> index 5a5a9e978e85f3fc9d89cb7d43527dc1dd42a9b1..8aa28c08b2891f3af490175362cc1a759069bd50 100644
> --- a/drivers/base/power/wakeirq.c
> +++ b/drivers/base/power/wakeirq.c
> @@ -103,6 +103,32 @@ void dev_pm_clear_wake_irq(struct device *dev)
> }
> EXPORT_SYMBOL_GPL(dev_pm_clear_wake_irq);
>
> +static void devm_pm_clear_wake_irq(void *dev)
> +{
> + dev_pm_clear_wake_irq(dev);
> +}
> +
> +/**
> + * devm_pm_set_wake_irq - device-managed variant of dev_pm_set_wake_irq
> + * @dev: Device entry
> + * @irq: Device IO interrupt
> + *
> + *
> + * Attach a device IO interrupt as a wake IRQ, same with dev_pm_set_wake_irq,
> + * but the device will be auto clear wake capability on driver detach.
> + */
> +int devm_pm_set_wake_irq(struct device *dev, int irq)
> +{
> + int ret;
> +
> + ret = dev_pm_set_wake_irq(dev, irq);
> + if (ret)
> + return ret;
> +
> + return devm_add_action_or_reset(dev, devm_pm_clear_wake_irq, dev);
> +}
> +EXPORT_SYMBOL_GPL(devm_pm_set_wake_irq);
> +
> /**
> * handle_threaded_wake_irq - Handler for dedicated wake-up interrupts
> * @irq: Device specific dedicated wake-up interrupt
> diff --git a/include/linux/pm_wakeirq.h b/include/linux/pm_wakeirq.h
> index d9642c6cf85211af603ce39e280a5b4de6617ee5..25b63ed51b765c2c6919f259668a12675330835e 100644
> --- a/include/linux/pm_wakeirq.h
> +++ b/include/linux/pm_wakeirq.h
> @@ -10,6 +10,7 @@ extern int dev_pm_set_wake_irq(struct device *dev, int irq);
> extern int dev_pm_set_dedicated_wake_irq(struct device *dev, int irq);
> extern int dev_pm_set_dedicated_wake_irq_reverse(struct device *dev, int irq);
> extern void dev_pm_clear_wake_irq(struct device *dev);
> +extern int devm_pm_set_wake_irq(struct device *dev, int irq);
>
> #else /* !CONFIG_PM */
>
> @@ -32,5 +33,10 @@ static inline void dev_pm_clear_wake_irq(struct device *dev)
> {
> }
>
> +static inline int devm_pm_set_wake_irq(struct device *dev, int irq)
> +{
> + return 0;
> +}
> +
> #endif /* CONFIG_PM */
> #endif /* _LINUX_PM_WAKEIRQ_H */
>
> --
I can apply this patch for 6.14, but the rest of the series will need
to be picked up by the respective driver maintainers.
I hope this works for you?
^ permalink raw reply [flat|nested] 20+ messages in thread* RE: [PATCH v2 01/12] PM: sleep: wakeirq: Introduce device-managed variant of dev_pm_set_wake_irq
2025-01-14 20:20 ` Rafael J. Wysocki
@ 2025-01-15 1:28 ` Peng Fan
2025-01-17 19:30 ` Rafael J. Wysocki
0 siblings, 1 reply; 20+ messages in thread
From: Peng Fan @ 2025-01-15 1:28 UTC (permalink / raw)
To: Rafael J. Wysocki, Peng Fan (OSS)
Cc: Len Brown, Pavel Machek, Greg Kroah-Hartman, Dmitry Torokhov,
Alexandre Belloni, Maxime Coquelin, Alexandre Torgue,
Linus Walleij, Conor Dooley, Daire McNamara,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-input@vger.kernel.org, linux-rtc@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org,
linux-arm-msm@vger.kernel.org, linux-riscv@lists.infradead.org
> Subject: Re: [PATCH v2 01/12] PM: sleep: wakeirq: Introduce device-
> managed variant of dev_pm_set_wake_irq
>
> On Fri, Jan 3, 2025 at 9:42 AM Peng Fan (OSS) <peng.fan@oss.nxp.com>
> wrote:
> >
> > From: Peng Fan <peng.fan@nxp.com>
> >
> > Add device-managed variant of dev_pm_set_wake_irq which
> automatically
> > clear the wake irq on device destruction to simplify error handling
> > and resource management in drivers.
> >
> > Signed-off-by: Peng Fan <peng.fan@nxp.com>
> > ---
> > drivers/base/power/wakeirq.c | 26 ++++++++++++++++++++++++++
> > include/linux/pm_wakeirq.h | 6 ++++++
> > 2 files changed, 32 insertions(+)
> >
> > diff --git a/drivers/base/power/wakeirq.c
> > b/drivers/base/power/wakeirq.c index
> >
> 5a5a9e978e85f3fc9d89cb7d43527dc1dd42a9b1..8aa28c08b2891f3af
> 490175362cc
> > 1a759069bd50 100644
> > --- a/drivers/base/power/wakeirq.c
> > +++ b/drivers/base/power/wakeirq.c
> > @@ -103,6 +103,32 @@ void dev_pm_clear_wake_irq(struct device
> *dev) }
> > EXPORT_SYMBOL_GPL(dev_pm_clear_wake_irq);
> >
> > +static void devm_pm_clear_wake_irq(void *dev) {
> > + dev_pm_clear_wake_irq(dev);
> > +}
> > +
> > +/**
> > + * devm_pm_set_wake_irq - device-managed variant of
> > +dev_pm_set_wake_irq
> > + * @dev: Device entry
> > + * @irq: Device IO interrupt
> > + *
> > + *
> > + * Attach a device IO interrupt as a wake IRQ, same with
> > +dev_pm_set_wake_irq,
> > + * but the device will be auto clear wake capability on driver detach.
> > + */
> > +int devm_pm_set_wake_irq(struct device *dev, int irq) {
> > + int ret;
> > +
> > + ret = dev_pm_set_wake_irq(dev, irq);
> > + if (ret)
> > + return ret;
> > +
> > + return devm_add_action_or_reset(dev,
> devm_pm_clear_wake_irq,
> > +dev); } EXPORT_SYMBOL_GPL(devm_pm_set_wake_irq);
> > +
> > /**
> > * handle_threaded_wake_irq - Handler for dedicated wake-up
> interrupts
> > * @irq: Device specific dedicated wake-up interrupt diff --git
> > a/include/linux/pm_wakeirq.h b/include/linux/pm_wakeirq.h index
> >
> d9642c6cf85211af603ce39e280a5b4de6617ee5..25b63ed51b765c2c6
> 919f259668a
> > 12675330835e 100644
> > --- a/include/linux/pm_wakeirq.h
> > +++ b/include/linux/pm_wakeirq.h
> > @@ -10,6 +10,7 @@ extern int dev_pm_set_wake_irq(struct device
> *dev,
> > int irq); extern int dev_pm_set_dedicated_wake_irq(struct device
> > *dev, int irq); extern int
> > dev_pm_set_dedicated_wake_irq_reverse(struct device *dev, int irq);
> > extern void dev_pm_clear_wake_irq(struct device *dev);
> > +extern int devm_pm_set_wake_irq(struct device *dev, int irq);
> >
> > #else /* !CONFIG_PM */
> >
> > @@ -32,5 +33,10 @@ static inline void
> dev_pm_clear_wake_irq(struct
> > device *dev) { }
> >
> > +static inline int devm_pm_set_wake_irq(struct device *dev, int irq) {
> > + return 0;
> > +}
> > +
> > #endif /* CONFIG_PM */
> > #endif /* _LINUX_PM_WAKEIRQ_H */
> >
> > --
>
> I can apply this patch for 6.14, but the rest of the series will need to be
> picked up by the respective driver maintainers.
>
> I hope this works for you?
Yes. please just pick up patch 1.
Patch [2-12]/12 should go through RTC and INPUT maintainer's tree
Thanks,
Peng.
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [PATCH v2 01/12] PM: sleep: wakeirq: Introduce device-managed variant of dev_pm_set_wake_irq
2025-01-15 1:28 ` Peng Fan
@ 2025-01-17 19:30 ` Rafael J. Wysocki
0 siblings, 0 replies; 20+ messages in thread
From: Rafael J. Wysocki @ 2025-01-17 19:30 UTC (permalink / raw)
To: Peng Fan
Cc: Rafael J. Wysocki, Peng Fan (OSS), Len Brown, Pavel Machek,
Greg Kroah-Hartman, Dmitry Torokhov, Alexandre Belloni,
Maxime Coquelin, Alexandre Torgue, Linus Walleij, Conor Dooley,
Daire McNamara, linux-pm@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-input@vger.kernel.org,
linux-rtc@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org,
linux-arm-msm@vger.kernel.org, linux-riscv@lists.infradead.org
On Wed, Jan 15, 2025 at 2:28 AM Peng Fan <peng.fan@nxp.com> wrote:
>
> > Subject: Re: [PATCH v2 01/12] PM: sleep: wakeirq: Introduce device-
> > managed variant of dev_pm_set_wake_irq
> >
> > On Fri, Jan 3, 2025 at 9:42 AM Peng Fan (OSS) <peng.fan@oss.nxp.com>
> > wrote:
> > >
> > > From: Peng Fan <peng.fan@nxp.com>
> > >
> > > Add device-managed variant of dev_pm_set_wake_irq which
> > automatically
> > > clear the wake irq on device destruction to simplify error handling
> > > and resource management in drivers.
> > >
> > > Signed-off-by: Peng Fan <peng.fan@nxp.com>
> > > ---
> > > drivers/base/power/wakeirq.c | 26 ++++++++++++++++++++++++++
> > > include/linux/pm_wakeirq.h | 6 ++++++
> > > 2 files changed, 32 insertions(+)
> > >
> > > diff --git a/drivers/base/power/wakeirq.c
> > > b/drivers/base/power/wakeirq.c index
> > >
> > 5a5a9e978e85f3fc9d89cb7d43527dc1dd42a9b1..8aa28c08b2891f3af
> > 490175362cc
> > > 1a759069bd50 100644
> > > --- a/drivers/base/power/wakeirq.c
> > > +++ b/drivers/base/power/wakeirq.c
> > > @@ -103,6 +103,32 @@ void dev_pm_clear_wake_irq(struct device
> > *dev) }
> > > EXPORT_SYMBOL_GPL(dev_pm_clear_wake_irq);
> > >
> > > +static void devm_pm_clear_wake_irq(void *dev) {
> > > + dev_pm_clear_wake_irq(dev);
> > > +}
> > > +
> > > +/**
> > > + * devm_pm_set_wake_irq - device-managed variant of
> > > +dev_pm_set_wake_irq
> > > + * @dev: Device entry
> > > + * @irq: Device IO interrupt
> > > + *
> > > + *
> > > + * Attach a device IO interrupt as a wake IRQ, same with
> > > +dev_pm_set_wake_irq,
> > > + * but the device will be auto clear wake capability on driver detach.
> > > + */
> > > +int devm_pm_set_wake_irq(struct device *dev, int irq) {
> > > + int ret;
> > > +
> > > + ret = dev_pm_set_wake_irq(dev, irq);
> > > + if (ret)
> > > + return ret;
> > > +
> > > + return devm_add_action_or_reset(dev,
> > devm_pm_clear_wake_irq,
> > > +dev); } EXPORT_SYMBOL_GPL(devm_pm_set_wake_irq);
> > > +
> > > /**
> > > * handle_threaded_wake_irq - Handler for dedicated wake-up
> > interrupts
> > > * @irq: Device specific dedicated wake-up interrupt diff --git
> > > a/include/linux/pm_wakeirq.h b/include/linux/pm_wakeirq.h index
> > >
> > d9642c6cf85211af603ce39e280a5b4de6617ee5..25b63ed51b765c2c6
> > 919f259668a
> > > 12675330835e 100644
> > > --- a/include/linux/pm_wakeirq.h
> > > +++ b/include/linux/pm_wakeirq.h
> > > @@ -10,6 +10,7 @@ extern int dev_pm_set_wake_irq(struct device
> > *dev,
> > > int irq); extern int dev_pm_set_dedicated_wake_irq(struct device
> > > *dev, int irq); extern int
> > > dev_pm_set_dedicated_wake_irq_reverse(struct device *dev, int irq);
> > > extern void dev_pm_clear_wake_irq(struct device *dev);
> > > +extern int devm_pm_set_wake_irq(struct device *dev, int irq);
> > >
> > > #else /* !CONFIG_PM */
> > >
> > > @@ -32,5 +33,10 @@ static inline void
> > dev_pm_clear_wake_irq(struct
> > > device *dev) { }
> > >
> > > +static inline int devm_pm_set_wake_irq(struct device *dev, int irq) {
> > > + return 0;
> > > +}
> > > +
> > > #endif /* CONFIG_PM */
> > > #endif /* _LINUX_PM_WAKEIRQ_H */
> > >
> > > --
> >
> > I can apply this patch for 6.14, but the rest of the series will need to be
> > picked up by the respective driver maintainers.
> >
> > I hope this works for you?
>
> Yes. please just pick up patch 1.
OK, applied.
Thanks!
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH v2 02/12] input: keyboard: ep93xx_keypad: Use devm_pm_set_wake_irq
2025-01-03 8:41 [PATCH v2 00/12] pm: Introduce devm_pm_set_wake_irq Peng Fan (OSS)
2025-01-03 8:41 ` [PATCH v2 01/12] PM: sleep: wakeirq: Introduce device-managed variant of dev_pm_set_wake_irq Peng Fan (OSS)
@ 2025-01-03 8:41 ` Peng Fan (OSS)
2025-01-03 8:41 ` [PATCH v2 03/12] input: keyboard: omap4_keypad: " Peng Fan (OSS)
` (11 subsequent siblings)
13 siblings, 0 replies; 20+ messages in thread
From: Peng Fan (OSS) @ 2025-01-03 8:41 UTC (permalink / raw)
To: Rafael J. Wysocki, Len Brown, Pavel Machek, Greg Kroah-Hartman,
Dmitry Torokhov, Alexandre Belloni, Maxime Coquelin,
Alexandre Torgue, Linus Walleij, Conor Dooley, Daire McNamara
Cc: linux-pm, linux-kernel, linux-input, linux-rtc, linux-stm32,
linux-arm-kernel, linux-arm-msm, linux-riscv, Peng Fan
From: Peng Fan <peng.fan@nxp.com>
Use devm_pm_set_wake_irq, then the 'driver.remove()' could be cleaned up.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/input/keyboard/ep93xx_keypad.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/drivers/input/keyboard/ep93xx_keypad.c b/drivers/input/keyboard/ep93xx_keypad.c
index 817c23438f6e5176431e1f736bb511f9919b67de..6e3cbe3ca72dbd43485c23f6042b4fba007ff5e6 100644
--- a/drivers/input/keyboard/ep93xx_keypad.c
+++ b/drivers/input/keyboard/ep93xx_keypad.c
@@ -260,18 +260,13 @@ static int ep93xx_keypad_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, keypad);
device_init_wakeup(&pdev->dev, 1);
- err = dev_pm_set_wake_irq(&pdev->dev, keypad->irq);
+ err = devm_pm_set_wake_irq(&pdev->dev, keypad->irq);
if (err)
dev_warn(&pdev->dev, "failed to set up wakeup irq: %d\n", err);
return 0;
}
-static void ep93xx_keypad_remove(struct platform_device *pdev)
-{
- dev_pm_clear_wake_irq(&pdev->dev);
-}
-
static const struct of_device_id ep93xx_keypad_of_ids[] = {
{ .compatible = "cirrus,ep9307-keypad" },
{ /* sentinel */ }
@@ -285,7 +280,6 @@ static struct platform_driver ep93xx_keypad_driver = {
.of_match_table = ep93xx_keypad_of_ids,
},
.probe = ep93xx_keypad_probe,
- .remove = ep93xx_keypad_remove,
};
module_platform_driver(ep93xx_keypad_driver);
--
2.37.1
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH v2 03/12] input: keyboard: omap4_keypad: Use devm_pm_set_wake_irq
2025-01-03 8:41 [PATCH v2 00/12] pm: Introduce devm_pm_set_wake_irq Peng Fan (OSS)
2025-01-03 8:41 ` [PATCH v2 01/12] PM: sleep: wakeirq: Introduce device-managed variant of dev_pm_set_wake_irq Peng Fan (OSS)
2025-01-03 8:41 ` [PATCH v2 02/12] input: keyboard: ep93xx_keypad: Use devm_pm_set_wake_irq Peng Fan (OSS)
@ 2025-01-03 8:41 ` Peng Fan (OSS)
2025-01-03 8:41 ` [PATCH v2 04/12] input: misc: nxp-bbnsm-pwrkey: Use resource managed API to simplify code Peng Fan (OSS)
` (10 subsequent siblings)
13 siblings, 0 replies; 20+ messages in thread
From: Peng Fan (OSS) @ 2025-01-03 8:41 UTC (permalink / raw)
To: Rafael J. Wysocki, Len Brown, Pavel Machek, Greg Kroah-Hartman,
Dmitry Torokhov, Alexandre Belloni, Maxime Coquelin,
Alexandre Torgue, Linus Walleij, Conor Dooley, Daire McNamara
Cc: linux-pm, linux-kernel, linux-input, linux-rtc, linux-stm32,
linux-arm-kernel, linux-arm-msm, linux-riscv, Peng Fan
From: Peng Fan <peng.fan@nxp.com>
Use devm_pm_set_wake_irq, then the 'driver.remove()' could be cleaned up.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/input/keyboard/omap4-keypad.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c
index bffe89c0717adf9ebe5b33892efa4dc30b158f83..b7bd649d1628a6bf10db4135f73778f62db92647 100644
--- a/drivers/input/keyboard/omap4-keypad.c
+++ b/drivers/input/keyboard/omap4-keypad.c
@@ -465,18 +465,13 @@ static int omap4_keypad_probe(struct platform_device *pdev)
}
device_init_wakeup(dev, true);
- error = dev_pm_set_wake_irq(dev, keypad_data->irq);
+ error = devm_pm_set_wake_irq(dev, keypad_data->irq);
if (error)
dev_warn(dev, "failed to set up wakeup irq: %d\n", error);
return 0;
}
-static void omap4_keypad_remove(struct platform_device *pdev)
-{
- dev_pm_clear_wake_irq(&pdev->dev);
-}
-
static const struct of_device_id omap_keypad_dt_match[] = {
{ .compatible = "ti,omap4-keypad" },
{},
@@ -485,7 +480,6 @@ MODULE_DEVICE_TABLE(of, omap_keypad_dt_match);
static struct platform_driver omap4_keypad_driver = {
.probe = omap4_keypad_probe,
- .remove = omap4_keypad_remove,
.driver = {
.name = "omap4-keypad",
.of_match_table = omap_keypad_dt_match,
--
2.37.1
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH v2 04/12] input: misc: nxp-bbnsm-pwrkey: Use resource managed API to simplify code
2025-01-03 8:41 [PATCH v2 00/12] pm: Introduce devm_pm_set_wake_irq Peng Fan (OSS)
` (2 preceding siblings ...)
2025-01-03 8:41 ` [PATCH v2 03/12] input: keyboard: omap4_keypad: " Peng Fan (OSS)
@ 2025-01-03 8:41 ` Peng Fan (OSS)
2025-01-03 8:41 ` [PATCH v2 05/12] input: touchscreen: ti_am335x_tsc: " Peng Fan (OSS)
` (9 subsequent siblings)
13 siblings, 0 replies; 20+ messages in thread
From: Peng Fan (OSS) @ 2025-01-03 8:41 UTC (permalink / raw)
To: Rafael J. Wysocki, Len Brown, Pavel Machek, Greg Kroah-Hartman,
Dmitry Torokhov, Alexandre Belloni, Maxime Coquelin,
Alexandre Torgue, Linus Walleij, Conor Dooley, Daire McNamara
Cc: linux-pm, linux-kernel, linux-input, linux-rtc, linux-stm32,
linux-arm-kernel, linux-arm-msm, linux-riscv, Peng Fan
From: Peng Fan <peng.fan@nxp.com>
Use devm_pm_set_wake_irq and devm_device_init_wakeup to cleanup the
'driver.remove()' hook.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/input/misc/nxp-bbnsm-pwrkey.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/drivers/input/misc/nxp-bbnsm-pwrkey.c b/drivers/input/misc/nxp-bbnsm-pwrkey.c
index 7ba8d166d68c18b396e616f6f9074ae98c4629b7..5faad2c98af35c52dcacbf25728dbaf2cbb3c625 100644
--- a/drivers/input/misc/nxp-bbnsm-pwrkey.c
+++ b/drivers/input/misc/nxp-bbnsm-pwrkey.c
@@ -179,20 +179,17 @@ static int bbnsm_pwrkey_probe(struct platform_device *pdev)
return error;
}
- device_init_wakeup(&pdev->dev, true);
- error = dev_pm_set_wake_irq(&pdev->dev, bbnsm->irq);
+ error = devm_device_init_wakeup(&pdev->dev);
+ if (error)
+ return error;
+
+ error = devm_pm_set_wake_irq(&pdev->dev, bbnsm->irq);
if (error)
dev_warn(&pdev->dev, "irq wake enable failed.\n");
return 0;
}
-static void bbnsm_pwrkey_remove(struct platform_device *pdev)
-{
- dev_pm_clear_wake_irq(&pdev->dev);
- device_init_wakeup(&pdev->dev, false);
-}
-
static int __maybe_unused bbnsm_pwrkey_suspend(struct device *dev)
{
struct platform_device *pdev = to_platform_device(dev);
@@ -229,8 +226,6 @@ static struct platform_driver bbnsm_pwrkey_driver = {
.of_match_table = bbnsm_pwrkey_ids,
},
.probe = bbnsm_pwrkey_probe,
- .remove = bbnsm_pwrkey_remove,
-
};
module_platform_driver(bbnsm_pwrkey_driver);
--
2.37.1
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH v2 05/12] input: touchscreen: ti_am335x_tsc: Use resource managed API to simplify code
2025-01-03 8:41 [PATCH v2 00/12] pm: Introduce devm_pm_set_wake_irq Peng Fan (OSS)
` (3 preceding siblings ...)
2025-01-03 8:41 ` [PATCH v2 04/12] input: misc: nxp-bbnsm-pwrkey: Use resource managed API to simplify code Peng Fan (OSS)
@ 2025-01-03 8:41 ` Peng Fan (OSS)
2025-01-03 8:41 ` [PATCH v2 06/12] rtc: stm32: " Peng Fan (OSS)
` (8 subsequent siblings)
13 siblings, 0 replies; 20+ messages in thread
From: Peng Fan (OSS) @ 2025-01-03 8:41 UTC (permalink / raw)
To: Rafael J. Wysocki, Len Brown, Pavel Machek, Greg Kroah-Hartman,
Dmitry Torokhov, Alexandre Belloni, Maxime Coquelin,
Alexandre Torgue, Linus Walleij, Conor Dooley, Daire McNamara
Cc: linux-pm, linux-kernel, linux-input, linux-rtc, linux-stm32,
linux-arm-kernel, linux-arm-msm, linux-riscv, Peng Fan
From: Peng Fan <peng.fan@nxp.com>
Use devm_input_allocate_device/devm_kzalloc/devm_request_irq to simplify
code
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/input/touchscreen/ti_am335x_tsc.c | 43 ++++++++++---------------------
1 file changed, 14 insertions(+), 29 deletions(-)
diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c b/drivers/input/touchscreen/ti_am335x_tsc.c
index 93d659ff90aa94ecbd7000fe05e0eef8ab3546ba..aef38b2e4e464e3b76395de5991a0f41b4f852f4 100644
--- a/drivers/input/touchscreen/ti_am335x_tsc.c
+++ b/drivers/input/touchscreen/ti_am335x_tsc.c
@@ -418,12 +418,11 @@ static int titsc_probe(struct platform_device *pdev)
int err;
/* Allocate memory for device */
- ts_dev = kzalloc(sizeof(*ts_dev), GFP_KERNEL);
- input_dev = input_allocate_device();
+ ts_dev = devm_kzalloc(&pdev->dev, sizeof(*ts_dev), GFP_KERNEL);
+ input_dev = devm_input_allocate_device(&pdev->dev);
if (!ts_dev || !input_dev) {
dev_err(&pdev->dev, "failed to allocate memory.\n");
- err = -ENOMEM;
- goto err_free_mem;
+ return -ENOMEM;
}
tscadc_dev->tsc = ts_dev;
@@ -435,18 +434,21 @@ static int titsc_probe(struct platform_device *pdev)
err = titsc_parse_dt(pdev, ts_dev);
if (err) {
dev_err(&pdev->dev, "Could not find valid DT data.\n");
- goto err_free_mem;
+ return err;
}
- err = request_irq(ts_dev->irq, titsc_irq,
- IRQF_SHARED, pdev->dev.driver->name, ts_dev);
+ err = devm_request_irq(&pdev->dev, ts_dev->irq, titsc_irq, IRQF_SHARED,
+ pdev->dev.driver->name, ts_dev);
if (err) {
dev_err(&pdev->dev, "failed to allocate irq.\n");
- goto err_free_mem;
+ return err;
}
- device_init_wakeup(&pdev->dev, true);
- err = dev_pm_set_wake_irq(&pdev->dev, ts_dev->irq);
+ err = devm_device_init_wakeup(&pdev->dev);
+ if (err)
+ dev_err(&pdev->dev, "device init wakeup failed.\n");
+
+ err = devm_pm_set_wake_irq(&pdev->dev, ts_dev->irq);
if (err)
dev_err(&pdev->dev, "irq wake enable failed.\n");
@@ -456,7 +458,7 @@ static int titsc_probe(struct platform_device *pdev)
err = titsc_config_wires(ts_dev);
if (err) {
dev_err(&pdev->dev, "wrong i/p wire configuration\n");
- goto err_free_irq;
+ return err;
}
titsc_step_config(ts_dev);
titsc_writel(ts_dev, REG_FIFO0THR,
@@ -475,19 +477,10 @@ static int titsc_probe(struct platform_device *pdev)
/* register to the input system */
err = input_register_device(input_dev);
if (err)
- goto err_free_irq;
+ return err;
platform_set_drvdata(pdev, ts_dev);
return 0;
-
-err_free_irq:
- dev_pm_clear_wake_irq(&pdev->dev);
- device_init_wakeup(&pdev->dev, false);
- free_irq(ts_dev->irq, ts_dev);
-err_free_mem:
- input_free_device(input_dev);
- kfree(ts_dev);
- return err;
}
static void titsc_remove(struct platform_device *pdev)
@@ -495,18 +488,10 @@ static void titsc_remove(struct platform_device *pdev)
struct titsc *ts_dev = platform_get_drvdata(pdev);
u32 steps;
- dev_pm_clear_wake_irq(&pdev->dev);
- device_init_wakeup(&pdev->dev, false);
- free_irq(ts_dev->irq, ts_dev);
-
/* total steps followed by the enable mask */
steps = 2 * ts_dev->coordinate_readouts + 2;
steps = (1 << steps) - 1;
am335x_tsc_se_clr(ts_dev->mfd_tscadc, steps);
-
- input_unregister_device(ts_dev->input);
-
- kfree(ts_dev);
}
static int titsc_suspend(struct device *dev)
--
2.37.1
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH v2 06/12] rtc: stm32: Use resource managed API to simplify code
2025-01-03 8:41 [PATCH v2 00/12] pm: Introduce devm_pm_set_wake_irq Peng Fan (OSS)
` (4 preceding siblings ...)
2025-01-03 8:41 ` [PATCH v2 05/12] input: touchscreen: ti_am335x_tsc: " Peng Fan (OSS)
@ 2025-01-03 8:41 ` Peng Fan (OSS)
2025-01-20 8:32 ` [Linux-stm32] " Antonio Borneo
2025-01-03 8:41 ` [PATCH v2 07/12] rtc: nxp-bbnsm: " Peng Fan (OSS)
` (7 subsequent siblings)
13 siblings, 1 reply; 20+ messages in thread
From: Peng Fan (OSS) @ 2025-01-03 8:41 UTC (permalink / raw)
To: Rafael J. Wysocki, Len Brown, Pavel Machek, Greg Kroah-Hartman,
Dmitry Torokhov, Alexandre Belloni, Maxime Coquelin,
Alexandre Torgue, Linus Walleij, Conor Dooley, Daire McNamara
Cc: linux-pm, linux-kernel, linux-input, linux-rtc, linux-stm32,
linux-arm-kernel, linux-arm-msm, linux-riscv, Peng Fan
From: Peng Fan <peng.fan@nxp.com>
Use devm_pm_set_wake_irq and devm_device_init_wakeup to cleanup the
error handling code and 'driver.remove()' hook.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/rtc/rtc-stm32.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/drivers/rtc/rtc-stm32.c b/drivers/rtc/rtc-stm32.c
index 9f1a019ec8afa57245c6d40d378ec50fdcd64deb..183017b0d33d10481f94891de24cf2eee95893f5 100644
--- a/drivers/rtc/rtc-stm32.c
+++ b/drivers/rtc/rtc-stm32.c
@@ -1151,11 +1151,11 @@ static int stm32_rtc_probe(struct platform_device *pdev)
goto err;
}
- ret = device_init_wakeup(&pdev->dev, true);
+ ret = devm_device_init_wakeup(&pdev->dev);
if (ret)
goto err;
- ret = dev_pm_set_wake_irq(&pdev->dev, rtc->irq_alarm);
+ ret = devm_pm_set_wake_irq(&pdev->dev, rtc->irq_alarm);
if (ret)
goto err;
@@ -1216,9 +1216,6 @@ static int stm32_rtc_probe(struct platform_device *pdev)
if (rtc->data->need_dbp)
regmap_update_bits(rtc->dbp, rtc->dbp_reg, rtc->dbp_mask, 0);
- dev_pm_clear_wake_irq(&pdev->dev);
- device_init_wakeup(&pdev->dev, false);
-
return ret;
}
@@ -1245,9 +1242,6 @@ static void stm32_rtc_remove(struct platform_device *pdev)
/* Enable backup domain write protection if needed */
if (rtc->data->need_dbp)
regmap_update_bits(rtc->dbp, rtc->dbp_reg, rtc->dbp_mask, 0);
-
- dev_pm_clear_wake_irq(&pdev->dev);
- device_init_wakeup(&pdev->dev, false);
}
static int stm32_rtc_suspend(struct device *dev)
--
2.37.1
^ permalink raw reply related [flat|nested] 20+ messages in thread* Re: [Linux-stm32] [PATCH v2 06/12] rtc: stm32: Use resource managed API to simplify code
2025-01-03 8:41 ` [PATCH v2 06/12] rtc: stm32: " Peng Fan (OSS)
@ 2025-01-20 8:32 ` Antonio Borneo
0 siblings, 0 replies; 20+ messages in thread
From: Antonio Borneo @ 2025-01-20 8:32 UTC (permalink / raw)
To: Peng Fan (OSS), Rafael J. Wysocki, Len Brown, Pavel Machek,
Greg Kroah-Hartman, Dmitry Torokhov, Alexandre Belloni,
Maxime Coquelin, Alexandre Torgue, Linus Walleij, Conor Dooley,
Daire McNamara
Cc: linux-rtc, Peng Fan, linux-pm, linux-arm-msm, linux-kernel,
linux-input, linux-riscv, linux-stm32, linux-arm-kernel
On Fri, 2025-01-03 at 16:41 +0800, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@nxp.com>
>
> Use devm_pm_set_wake_irq and devm_device_init_wakeup to cleanup the
> error handling code and 'driver.remove()' hook.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
Reviewed-by: Antonio Borneo <antonio.borneo@foss.st.com>
Thanks,
Antonio
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH v2 07/12] rtc: nxp-bbnsm: Use resource managed API to simplify code
2025-01-03 8:41 [PATCH v2 00/12] pm: Introduce devm_pm_set_wake_irq Peng Fan (OSS)
` (5 preceding siblings ...)
2025-01-03 8:41 ` [PATCH v2 06/12] rtc: stm32: " Peng Fan (OSS)
@ 2025-01-03 8:41 ` Peng Fan (OSS)
2025-01-03 8:41 ` [PATCH v2 08/12] rtc: ds1343: Use devm_pm_set_wake_irq Peng Fan (OSS)
` (6 subsequent siblings)
13 siblings, 0 replies; 20+ messages in thread
From: Peng Fan (OSS) @ 2025-01-03 8:41 UTC (permalink / raw)
To: Rafael J. Wysocki, Len Brown, Pavel Machek, Greg Kroah-Hartman,
Dmitry Torokhov, Alexandre Belloni, Maxime Coquelin,
Alexandre Torgue, Linus Walleij, Conor Dooley, Daire McNamara
Cc: linux-pm, linux-kernel, linux-input, linux-rtc, linux-stm32,
linux-arm-kernel, linux-arm-msm, linux-riscv, Peng Fan
From: Peng Fan <peng.fan@nxp.com>
Use devm_pm_set_wake_irq and devm_device_init_wakeup to cleanup the
error handling code and 'driver.remove()' hook.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/rtc/rtc-nxp-bbnsm.c | 29 +++++++++--------------------
1 file changed, 9 insertions(+), 20 deletions(-)
diff --git a/drivers/rtc/rtc-nxp-bbnsm.c b/drivers/rtc/rtc-nxp-bbnsm.c
index fa3b0328c7a255ff8a902a58d61a4b0e59eac493..d4fc9dc583d317d4852b7d897a6c45cfff6961a2 100644
--- a/drivers/rtc/rtc-nxp-bbnsm.c
+++ b/drivers/rtc/rtc-nxp-bbnsm.c
@@ -189,36 +189,26 @@ static int bbnsm_rtc_probe(struct platform_device *pdev)
/* clear all the pending events */
regmap_write(bbnsm->regmap, BBNSM_EVENTS, 0x7A);
- device_init_wakeup(&pdev->dev, true);
- dev_pm_set_wake_irq(&pdev->dev, bbnsm->irq);
+ ret = devm_device_init_wakeup(&pdev->dev);
+ if (ret)
+ dev_err(&pdev->dev, "failed to init wakeup, %d\n", ret);
+
+ ret = devm_pm_set_wake_irq(&pdev->dev, bbnsm->irq);
+ if (ret)
+ dev_err(&pdev->dev, "failed to set wake irq, %d\n", ret);
ret = devm_request_irq(&pdev->dev, bbnsm->irq, bbnsm_rtc_irq_handler,
IRQF_SHARED, "rtc alarm", &pdev->dev);
if (ret) {
dev_err(&pdev->dev, "failed to request irq %d: %d\n",
bbnsm->irq, ret);
- goto err;
+ return ret;
}
bbnsm->rtc->ops = &bbnsm_rtc_ops;
bbnsm->rtc->range_max = U32_MAX;
- ret = devm_rtc_register_device(bbnsm->rtc);
- if (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);
+ return devm_rtc_register_device(bbnsm->rtc);
}
static const struct of_device_id bbnsm_dt_ids[] = {
@@ -233,7 +223,6 @@ 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] 20+ messages in thread* [PATCH v2 08/12] rtc: ds1343: Use devm_pm_set_wake_irq
2025-01-03 8:41 [PATCH v2 00/12] pm: Introduce devm_pm_set_wake_irq Peng Fan (OSS)
` (6 preceding siblings ...)
2025-01-03 8:41 ` [PATCH v2 07/12] rtc: nxp-bbnsm: " Peng Fan (OSS)
@ 2025-01-03 8:41 ` Peng Fan (OSS)
2025-01-03 8:41 ` [PATCH v2 09/12] rtc: pm8xxx: " Peng Fan (OSS)
` (5 subsequent siblings)
13 siblings, 0 replies; 20+ messages in thread
From: Peng Fan (OSS) @ 2025-01-03 8:41 UTC (permalink / raw)
To: Rafael J. Wysocki, Len Brown, Pavel Machek, Greg Kroah-Hartman,
Dmitry Torokhov, Alexandre Belloni, Maxime Coquelin,
Alexandre Torgue, Linus Walleij, Conor Dooley, Daire McNamara
Cc: linux-pm, linux-kernel, linux-input, linux-rtc, linux-stm32,
linux-arm-kernel, linux-arm-msm, linux-riscv, Peng Fan
From: Peng Fan <peng.fan@nxp.com>
Use devm_pm_set_wake_irq, then the 'driver.remove()' could be cleaned up.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/rtc/rtc-ds1343.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/drivers/rtc/rtc-ds1343.c b/drivers/rtc/rtc-ds1343.c
index ed5a6ba89a3eeb2a0b9d6dea3c8b3d40aa2cf317..aa9500791b7e0300b150bd654b69c74f3e5e6e6b 100644
--- a/drivers/rtc/rtc-ds1343.c
+++ b/drivers/rtc/rtc-ds1343.c
@@ -427,18 +427,13 @@ static int ds1343_probe(struct spi_device *spi)
"unable to request irq for rtc ds1343\n");
} else {
device_init_wakeup(&spi->dev, true);
- dev_pm_set_wake_irq(&spi->dev, spi->irq);
+ devm_pm_set_wake_irq(&spi->dev, spi->irq);
}
}
return 0;
}
-static void ds1343_remove(struct spi_device *spi)
-{
- dev_pm_clear_wake_irq(&spi->dev);
-}
-
#ifdef CONFIG_PM_SLEEP
static int ds1343_suspend(struct device *dev)
@@ -471,7 +466,6 @@ static struct spi_driver ds1343_driver = {
.pm = &ds1343_pm,
},
.probe = ds1343_probe,
- .remove = ds1343_remove,
.id_table = ds1343_id,
};
--
2.37.1
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH v2 09/12] rtc: pm8xxx: Use devm_pm_set_wake_irq
2025-01-03 8:41 [PATCH v2 00/12] pm: Introduce devm_pm_set_wake_irq Peng Fan (OSS)
` (7 preceding siblings ...)
2025-01-03 8:41 ` [PATCH v2 08/12] rtc: ds1343: Use devm_pm_set_wake_irq Peng Fan (OSS)
@ 2025-01-03 8:41 ` Peng Fan (OSS)
2025-01-14 12:17 ` Linus Walleij
2025-01-03 8:41 ` [PATCH v2 10/12] rtc: ab8500: Use resource managed API to simplify code Peng Fan (OSS)
` (4 subsequent siblings)
13 siblings, 1 reply; 20+ messages in thread
From: Peng Fan (OSS) @ 2025-01-03 8:41 UTC (permalink / raw)
To: Rafael J. Wysocki, Len Brown, Pavel Machek, Greg Kroah-Hartman,
Dmitry Torokhov, Alexandre Belloni, Maxime Coquelin,
Alexandre Torgue, Linus Walleij, Conor Dooley, Daire McNamara
Cc: linux-pm, linux-kernel, linux-input, linux-rtc, linux-stm32,
linux-arm-kernel, linux-arm-msm, linux-riscv, Peng Fan
From: Peng Fan <peng.fan@nxp.com>
Use devm_pm_set_wake_irq, then the 'driver.remove()' could be cleaned up.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/rtc/rtc-pm8xxx.c | 12 +-----------
1 file changed, 1 insertion(+), 11 deletions(-)
diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c
index 2f32187ecc8d3276a451a317ab83446b7b04ecc8..f1b620b168fcca8c640e4beaaf7e8c17776c5ed9 100644
--- a/drivers/rtc/rtc-pm8xxx.c
+++ b/drivers/rtc/rtc-pm8xxx.c
@@ -523,21 +523,11 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev)
if (rc)
return rc;
- rc = dev_pm_set_wake_irq(&pdev->dev, rtc_dd->alarm_irq);
- if (rc)
- return rc;
-
- return 0;
-}
-
-static void pm8xxx_remove(struct platform_device *pdev)
-{
- dev_pm_clear_wake_irq(&pdev->dev);
+ return devm_pm_set_wake_irq(&pdev->dev, rtc_dd->alarm_irq);
}
static struct platform_driver pm8xxx_rtc_driver = {
.probe = pm8xxx_rtc_probe,
- .remove = pm8xxx_remove,
.driver = {
.name = "rtc-pm8xxx",
.of_match_table = pm8xxx_id_table,
--
2.37.1
^ permalink raw reply related [flat|nested] 20+ messages in thread* Re: [PATCH v2 09/12] rtc: pm8xxx: Use devm_pm_set_wake_irq
2025-01-03 8:41 ` [PATCH v2 09/12] rtc: pm8xxx: " Peng Fan (OSS)
@ 2025-01-14 12:17 ` Linus Walleij
0 siblings, 0 replies; 20+ messages in thread
From: Linus Walleij @ 2025-01-14 12:17 UTC (permalink / raw)
To: Peng Fan (OSS)
Cc: Rafael J. Wysocki, Len Brown, Pavel Machek, Greg Kroah-Hartman,
Dmitry Torokhov, Alexandre Belloni, Maxime Coquelin,
Alexandre Torgue, Conor Dooley, Daire McNamara, linux-pm,
linux-kernel, linux-input, linux-rtc, linux-stm32,
linux-arm-kernel, linux-arm-msm, linux-riscv, Peng Fan
On Fri, Jan 3, 2025 at 9:42 AM Peng Fan (OSS) <peng.fan@oss.nxp.com> wrote:
> From: Peng Fan <peng.fan@nxp.com>
>
> Use devm_pm_set_wake_irq, then the 'driver.remove()' could be cleaned up.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH v2 10/12] rtc: ab8500: Use resource managed API to simplify code
2025-01-03 8:41 [PATCH v2 00/12] pm: Introduce devm_pm_set_wake_irq Peng Fan (OSS)
` (8 preceding siblings ...)
2025-01-03 8:41 ` [PATCH v2 09/12] rtc: pm8xxx: " Peng Fan (OSS)
@ 2025-01-03 8:41 ` Peng Fan (OSS)
2025-01-03 8:41 ` [PATCH v2 11/12] rtc: mpfs: Use devm_pm_set_wake_irq Peng Fan (OSS)
` (3 subsequent siblings)
13 siblings, 0 replies; 20+ messages in thread
From: Peng Fan (OSS) @ 2025-01-03 8:41 UTC (permalink / raw)
To: Rafael J. Wysocki, Len Brown, Pavel Machek, Greg Kroah-Hartman,
Dmitry Torokhov, Alexandre Belloni, Maxime Coquelin,
Alexandre Torgue, Linus Walleij, Conor Dooley, Daire McNamara
Cc: linux-pm, linux-kernel, linux-input, linux-rtc, linux-stm32,
linux-arm-kernel, linux-arm-msm, linux-riscv, Peng Fan
From: Peng Fan <peng.fan@nxp.com>
Use devm_pm_set_wake_irq and devm_device_init_wakeup to cleanup the
error handling code and 'driver.remove()' hook.
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/rtc/rtc-ab8500.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/drivers/rtc/rtc-ab8500.c b/drivers/rtc/rtc-ab8500.c
index 2dcda96f4a8ef727514c751322b84d8d2b382b75..ed2b6b8bb3bf8f99fef9f8bee9676f71f8a86d2a 100644
--- a/drivers/rtc/rtc-ab8500.c
+++ b/drivers/rtc/rtc-ab8500.c
@@ -361,7 +361,7 @@ static int ab8500_rtc_probe(struct platform_device *pdev)
return -ENODEV;
}
- device_init_wakeup(&pdev->dev, true);
+ devm_device_init_wakeup(&pdev->dev);
rtc = devm_rtc_allocate_device(&pdev->dev);
if (IS_ERR(rtc))
@@ -375,7 +375,7 @@ static int ab8500_rtc_probe(struct platform_device *pdev)
if (err < 0)
return err;
- dev_pm_set_wake_irq(&pdev->dev, irq);
+ devm_pm_set_wake_irq(&pdev->dev, irq);
platform_set_drvdata(pdev, rtc);
set_bit(RTC_FEATURE_ALARM_RES_MINUTE, rtc->features);
@@ -392,18 +392,11 @@ static int ab8500_rtc_probe(struct platform_device *pdev)
return devm_rtc_register_device(rtc);
}
-static void ab8500_rtc_remove(struct platform_device *pdev)
-{
- dev_pm_clear_wake_irq(&pdev->dev);
- device_init_wakeup(&pdev->dev, false);
-}
-
static struct platform_driver ab8500_rtc_driver = {
.driver = {
.name = "ab8500-rtc",
},
.probe = ab8500_rtc_probe,
- .remove = ab8500_rtc_remove,
.id_table = ab85xx_rtc_ids,
};
--
2.37.1
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH v2 11/12] rtc: mpfs: Use devm_pm_set_wake_irq
2025-01-03 8:41 [PATCH v2 00/12] pm: Introduce devm_pm_set_wake_irq Peng Fan (OSS)
` (9 preceding siblings ...)
2025-01-03 8:41 ` [PATCH v2 10/12] rtc: ab8500: Use resource managed API to simplify code Peng Fan (OSS)
@ 2025-01-03 8:41 ` Peng Fan (OSS)
2025-01-03 8:41 ` [PATCH v2 12/12] rtc: pl031: Use resource managed API to simplify code Peng Fan (OSS)
` (2 subsequent siblings)
13 siblings, 0 replies; 20+ messages in thread
From: Peng Fan (OSS) @ 2025-01-03 8:41 UTC (permalink / raw)
To: Rafael J. Wysocki, Len Brown, Pavel Machek, Greg Kroah-Hartman,
Dmitry Torokhov, Alexandre Belloni, Maxime Coquelin,
Alexandre Torgue, Linus Walleij, Conor Dooley, Daire McNamara
Cc: linux-pm, linux-kernel, linux-input, linux-rtc, linux-stm32,
linux-arm-kernel, linux-arm-msm, linux-riscv, Peng Fan
From: Peng Fan <peng.fan@nxp.com>
Use devm_pm_set_wake_irq, then the 'driver.remove()' could be cleaned up.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/rtc/rtc-mpfs.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/drivers/rtc/rtc-mpfs.c b/drivers/rtc/rtc-mpfs.c
index 3892b0f9917fa7bc4f732cfe2c2b2f548ba7429f..5a38649cbd43b3c6f2fec5db95c4f0013deb2a08 100644
--- a/drivers/rtc/rtc-mpfs.c
+++ b/drivers/rtc/rtc-mpfs.c
@@ -267,18 +267,13 @@ static int mpfs_rtc_probe(struct platform_device *pdev)
dev_info(&pdev->dev, "prescaler set to: %lu\n", prescaler);
device_init_wakeup(&pdev->dev, true);
- ret = dev_pm_set_wake_irq(&pdev->dev, wakeup_irq);
+ ret = devm_pm_set_wake_irq(&pdev->dev, wakeup_irq);
if (ret)
dev_err(&pdev->dev, "failed to enable irq wake\n");
return devm_rtc_register_device(rtcdev->rtc);
}
-static void mpfs_rtc_remove(struct platform_device *pdev)
-{
- dev_pm_clear_wake_irq(&pdev->dev);
-}
-
static const struct of_device_id mpfs_rtc_of_match[] = {
{ .compatible = "microchip,mpfs-rtc" },
{ }
@@ -288,7 +283,6 @@ MODULE_DEVICE_TABLE(of, mpfs_rtc_of_match);
static struct platform_driver mpfs_rtc_driver = {
.probe = mpfs_rtc_probe,
- .remove = mpfs_rtc_remove,
.driver = {
.name = "mpfs_rtc",
.of_match_table = mpfs_rtc_of_match,
--
2.37.1
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH v2 12/12] rtc: pl031: Use resource managed API to simplify code
2025-01-03 8:41 [PATCH v2 00/12] pm: Introduce devm_pm_set_wake_irq Peng Fan (OSS)
` (10 preceding siblings ...)
2025-01-03 8:41 ` [PATCH v2 11/12] rtc: mpfs: Use devm_pm_set_wake_irq Peng Fan (OSS)
@ 2025-01-03 8:41 ` Peng Fan (OSS)
2025-01-20 8:57 ` [PATCH v2 00/12] pm: Introduce devm_pm_set_wake_irq Peng Fan
2025-02-03 19:15 ` patchwork-bot+linux-riscv
13 siblings, 0 replies; 20+ messages in thread
From: Peng Fan (OSS) @ 2025-01-03 8:41 UTC (permalink / raw)
To: Rafael J. Wysocki, Len Brown, Pavel Machek, Greg Kroah-Hartman,
Dmitry Torokhov, Alexandre Belloni, Maxime Coquelin,
Alexandre Torgue, Linus Walleij, Conor Dooley, Daire McNamara
Cc: linux-pm, linux-kernel, linux-input, linux-rtc, linux-stm32,
linux-arm-kernel, linux-arm-msm, linux-riscv, Peng Fan
From: Peng Fan <peng.fan@nxp.com>
Use devm_pm_set_wake_irq and devm_device_init_wakeup to cleanup the
error handling code and 'driver.remove()' hook.
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/rtc/rtc-pl031.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/rtc/rtc-pl031.c b/drivers/rtc/rtc-pl031.c
index bad6a5d9c6839ca70905e3d46286b9729c1fd435..47bfc5395e5908b7722b98276399120f1ba65af0 100644
--- a/drivers/rtc/rtc-pl031.c
+++ b/drivers/rtc/rtc-pl031.c
@@ -284,8 +284,6 @@ static void pl031_remove(struct amba_device *adev)
{
struct pl031_local *ldata = dev_get_drvdata(&adev->dev);
- dev_pm_clear_wake_irq(&adev->dev);
- device_init_wakeup(&adev->dev, false);
if (adev->irq[0])
free_irq(adev->irq[0], ldata);
amba_release_regions(adev);
@@ -350,7 +348,7 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id)
}
}
- device_init_wakeup(&adev->dev, true);
+ devm_device_init_wakeup(&adev->dev);
ldata->rtc = devm_rtc_allocate_device(&adev->dev);
if (IS_ERR(ldata->rtc)) {
ret = PTR_ERR(ldata->rtc);
@@ -373,7 +371,7 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id)
vendor->irqflags, "rtc-pl031", ldata);
if (ret)
goto out;
- dev_pm_set_wake_irq(&adev->dev, adev->irq[0]);
+ devm_pm_set_wake_irq(&adev->dev, adev->irq[0]);
}
return 0;
--
2.37.1
^ permalink raw reply related [flat|nested] 20+ messages in thread* Re: [PATCH v2 00/12] pm: Introduce devm_pm_set_wake_irq
2025-01-03 8:41 [PATCH v2 00/12] pm: Introduce devm_pm_set_wake_irq Peng Fan (OSS)
` (11 preceding siblings ...)
2025-01-03 8:41 ` [PATCH v2 12/12] rtc: pl031: Use resource managed API to simplify code Peng Fan (OSS)
@ 2025-01-20 8:57 ` Peng Fan
2025-02-03 19:15 ` patchwork-bot+linux-riscv
13 siblings, 0 replies; 20+ messages in thread
From: Peng Fan @ 2025-01-20 8:57 UTC (permalink / raw)
To: Rafael J. Wysocki, Len Brown, Pavel Machek, Greg Kroah-Hartman,
Dmitry Torokhov, Alexandre Belloni, Maxime Coquelin,
Alexandre Torgue, Linus Walleij, Conor Dooley, Daire McNamara
Cc: linux-pm, linux-kernel, linux-input, linux-rtc, linux-stm32,
linux-arm-kernel, linux-arm-msm, linux-riscv, Peng Fan
Hi Alexandre, Dmitry
On Fri, Jan 03, 2025 at 04:41:12PM +0800, Peng Fan (OSS) wrote:
>This was a retry to address [1][2], to let common code handle
>dev_pm_clear_wake_irq. Then no need to call dev_pm_clear_wake_irq
>in each driver.remove() hook and error handling path.
Patch 1 has been accepted into pm tree.
For the rtc and input patches, are you ok with them?
Thanks,
Peng
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [PATCH v2 00/12] pm: Introduce devm_pm_set_wake_irq
2025-01-03 8:41 [PATCH v2 00/12] pm: Introduce devm_pm_set_wake_irq Peng Fan (OSS)
` (12 preceding siblings ...)
2025-01-20 8:57 ` [PATCH v2 00/12] pm: Introduce devm_pm_set_wake_irq Peng Fan
@ 2025-02-03 19:15 ` patchwork-bot+linux-riscv
13 siblings, 0 replies; 20+ messages in thread
From: patchwork-bot+linux-riscv @ 2025-02-03 19:15 UTC (permalink / raw)
To: Peng Fan
Cc: linux-riscv, rafael, len.brown, pavel, gregkh, dmitry.torokhov,
alexandre.belloni, mcoquelin.stm32, alexandre.torgue,
linus.walleij, conor.dooley, daire.mcnamara, linux-pm,
linux-kernel, linux-input, linux-rtc, linux-stm32,
linux-arm-kernel, linux-arm-msm, peng.fan
Hello:
This series was applied to riscv/linux.git (fixes)
by Rafael J. Wysocki <rafael.j.wysocki@intel.com>:
On Fri, 03 Jan 2025 16:41:12 +0800 you wrote:
> This was a retry to address [1][2], to let common code handle
> dev_pm_clear_wake_irq. Then no need to call dev_pm_clear_wake_irq
> in each driver.remove() hook and error handling path.
>
> In this patchset, I include input and rtc patches to show the usage
> to avoid introducing an API without users. There are still
> other places using dev_pm_clear_wake_irq. If this patchset is
> good for you, I could start to clean up other drivers such as mmc and
> etc.
>
> [...]
Here is the summary with links:
- [v2,01/12] PM: sleep: wakeirq: Introduce device-managed variant of dev_pm_set_wake_irq
https://git.kernel.org/riscv/c/fd8318a32573
- [v2,02/12] input: keyboard: ep93xx_keypad: Use devm_pm_set_wake_irq
(no matching commit)
- [v2,03/12] input: keyboard: omap4_keypad: Use devm_pm_set_wake_irq
(no matching commit)
- [v2,04/12] input: misc: nxp-bbnsm-pwrkey: Use resource managed API to simplify code
(no matching commit)
- [v2,05/12] input: touchscreen: ti_am335x_tsc: Use resource managed API to simplify code
(no matching commit)
- [v2,06/12] rtc: stm32: Use resource managed API to simplify code
(no matching commit)
- [v2,07/12] rtc: nxp-bbnsm: Use resource managed API to simplify code
(no matching commit)
- [v2,08/12] rtc: ds1343: Use devm_pm_set_wake_irq
(no matching commit)
- [v2,09/12] rtc: pm8xxx: Use devm_pm_set_wake_irq
(no matching commit)
- [v2,10/12] rtc: ab8500: Use resource managed API to simplify code
(no matching commit)
- [v2,11/12] rtc: mpfs: Use devm_pm_set_wake_irq
(no matching commit)
- [v2,12/12] rtc: pl031: Use resource managed API to simplify code
(no matching commit)
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 20+ messages in thread