All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] PM: Use LIST_HEAD() to initialize on stack list head
@ 2026-05-19  5:59 Jisheng Zhang
  2026-05-26 11:14 ` Rafael J. Wysocki
  0 siblings, 1 reply; 2+ messages in thread
From: Jisheng Zhang @ 2026-05-19  5:59 UTC (permalink / raw)
  To: Rafael J . Wysocki, Pavel Machek, Len Brown, Greg Kroah-Hartman,
	Danilo Krummrich
  Cc: linux-pm, driver-core, linux-kernel

Use LIST_HEAD to initialize on stack list head. No intentional
functional impact.

Change generated with below coccinelle script:

@@
identifier name;
@@
- struct list_head name;
+ LIST_HEAD(name);
... when != name
- INIT_LIST_HEAD(&name);

Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
---
 drivers/base/power/clock_ops.c | 4 +---
 drivers/base/power/main.c      | 3 +--
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/base/power/clock_ops.c b/drivers/base/power/clock_ops.c
index 59bb37e8244c..1f708e10e711 100644
--- a/drivers/base/power/clock_ops.c
+++ b/drivers/base/power/clock_ops.c
@@ -422,13 +422,11 @@ void pm_clk_destroy(struct device *dev)
 {
 	struct pm_subsys_data *psd = dev_to_psd(dev);
 	struct pm_clock_entry *ce, *c;
-	struct list_head list;
+	LIST_HEAD(list);
 
 	if (!psd)
 		return;
 
-	INIT_LIST_HEAD(&list);
-
 	pm_clk_list_lock(psd);
 
 	list_for_each_entry_safe_reverse(ce, c, &psd->clock_list, node)
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index e1b550664bab..d0c7b1d4101e 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -1257,11 +1257,10 @@ static void device_complete(struct device *dev, pm_message_t state)
  */
 void dpm_complete(pm_message_t state)
 {
-	struct list_head list;
+	LIST_HEAD(list);
 
 	trace_suspend_resume(TPS("dpm_complete"), state.event, true);
 
-	INIT_LIST_HEAD(&list);
 	mutex_lock(&dpm_list_mtx);
 	while (!list_empty(&dpm_prepared_list)) {
 		struct device *dev = to_device(dpm_prepared_list.prev);
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] PM: Use LIST_HEAD() to initialize on stack list head
  2026-05-19  5:59 [PATCH] PM: Use LIST_HEAD() to initialize on stack list head Jisheng Zhang
@ 2026-05-26 11:14 ` Rafael J. Wysocki
  0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2026-05-26 11:14 UTC (permalink / raw)
  To: Jisheng Zhang
  Cc: Rafael J . Wysocki, Pavel Machek, Len Brown, Greg Kroah-Hartman,
	Danilo Krummrich, linux-pm, driver-core, linux-kernel

On Tue, May 19, 2026 at 8:18 AM Jisheng Zhang <jszhang@kernel.org> wrote:
>
> Use LIST_HEAD to initialize on stack list head. No intentional
> functional impact.
>
> Change generated with below coccinelle script:
>
> @@
> identifier name;
> @@
> - struct list_head name;
> + LIST_HEAD(name);
> ... when != name
> - INIT_LIST_HEAD(&name);
>
> Signed-off-by: Jisheng Zhang <jszhang@kernel.org>

I'd rather see two separate patches for these changes as they affect
unrelated code.

Thanks!

> ---
>  drivers/base/power/clock_ops.c | 4 +---
>  drivers/base/power/main.c      | 3 +--
>  2 files changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/base/power/clock_ops.c b/drivers/base/power/clock_ops.c
> index 59bb37e8244c..1f708e10e711 100644
> --- a/drivers/base/power/clock_ops.c
> +++ b/drivers/base/power/clock_ops.c
> @@ -422,13 +422,11 @@ void pm_clk_destroy(struct device *dev)
>  {
>         struct pm_subsys_data *psd = dev_to_psd(dev);
>         struct pm_clock_entry *ce, *c;
> -       struct list_head list;
> +       LIST_HEAD(list);
>
>         if (!psd)
>                 return;
>
> -       INIT_LIST_HEAD(&list);
> -
>         pm_clk_list_lock(psd);
>
>         list_for_each_entry_safe_reverse(ce, c, &psd->clock_list, node)
> diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
> index e1b550664bab..d0c7b1d4101e 100644
> --- a/drivers/base/power/main.c
> +++ b/drivers/base/power/main.c
> @@ -1257,11 +1257,10 @@ static void device_complete(struct device *dev, pm_message_t state)
>   */
>  void dpm_complete(pm_message_t state)
>  {
> -       struct list_head list;
> +       LIST_HEAD(list);
>
>         trace_suspend_resume(TPS("dpm_complete"), state.event, true);
>
> -       INIT_LIST_HEAD(&list);
>         mutex_lock(&dpm_list_mtx);
>         while (!list_empty(&dpm_prepared_list)) {
>                 struct device *dev = to_device(dpm_prepared_list.prev);
> --

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-05-26 11:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-19  5:59 [PATCH] PM: Use LIST_HEAD() to initialize on stack list head Jisheng Zhang
2026-05-26 11:14 ` Rafael J. Wysocki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.