Re: [PATCH] PM: Use LIST_HEAD() to initialize on stack list head
From: Rafael J. Wysocki
Date: Tue May 26 2026 - 07:15:36 EST
On Tue, May 19, 2026 at 8:18 AM Jisheng Zhang <jszhang@xxxxxxxxxx> 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@xxxxxxxxxx>
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);
> --