Skip to contentSkip to conversation

PM: Use LIST_HEAD() to initialize on stack list head

PATCH In review Jisheng Zhang 2 participants 2 messages May 19 – May 26

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PM: Use LIST_HEAD() to initialize on stack list head

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);

---
 drivers/base/power/clock_ops.c | 4 +---
 drivers/base/power/main.c      | 3 +--
 2 files changed, 2 insertions(+), 5 deletions(-)
drivers/base/power/clock_ops.c +1 -3
index 59bb37e8244c..1f708e10e711 100644
@@ -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)
drivers/base/power/main.c +1 -2
index e1b550664bab..d0c7b1d4101e 100644
@@ -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);
Signature · 1 line
2.53.0
#1 lore raw
Quoted 14 lines · Jisheng Zhang

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);

Quoted 1 line

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

Thanks!

Quoted 42 lines
---
 drivers/base/power/clock_ops.c | 4 +---
 drivers/base/power/main.c      | 3 +--
 2 files changed, 2 insertions(+), 5 deletions(-)
drivers/base/power/clock_ops.c +1 -3
index 59bb37e8244c..1f708e10e711 100644
@@ -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)
drivers/base/power/main.c +1 -3
index e1b550664bab..d0c7b1d4101e 100644
@@ -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);
--