Commit 07761a4cd43c1d32918e20254236eb96007b1d6c
Committed by
Rafael J. Wysocki
1 parent
98d54f81e3
ACPI: list_for_each_safe() -> list_for_each_entry_safe()
Replace list_for_each_safe() and open-coded list entry address computations with list_for_each_entry_safe() in several places to simplify code. Signed-off-by: chenqiwu <chenqiwu@xiaomi.com> [ rjw: Subject & changelog ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Showing 2 changed files with 15 additions and 23 deletions Side-by-side Diff
drivers/acpi/proc.c
... | ... | @@ -22,14 +22,13 @@ |
22 | 22 | static int |
23 | 23 | acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset) |
24 | 24 | { |
25 | - struct list_head *node, *next; | |
25 | + struct acpi_device *dev, *tmp; | |
26 | 26 | |
27 | 27 | seq_printf(seq, "Device\tS-state\t Status Sysfs node\n"); |
28 | 28 | |
29 | 29 | mutex_lock(&acpi_device_lock); |
30 | - list_for_each_safe(node, next, &acpi_wakeup_device_list) { | |
31 | - struct acpi_device *dev = | |
32 | - container_of(node, struct acpi_device, wakeup_list); | |
30 | + list_for_each_entry_safe(dev, tmp, &acpi_wakeup_device_list, | |
31 | + wakeup_list) { | |
33 | 32 | struct acpi_device_physical_node *entry; |
34 | 33 | |
35 | 34 | if (!dev->wakeup.flags.valid) |
... | ... | @@ -96,7 +95,7 @@ |
96 | 95 | const char __user * buffer, |
97 | 96 | size_t count, loff_t * ppos) |
98 | 97 | { |
99 | - struct list_head *node, *next; | |
98 | + struct acpi_device *dev, *tmp; | |
100 | 99 | char strbuf[5]; |
101 | 100 | char str[5] = ""; |
102 | 101 | |
... | ... | @@ -109,9 +108,8 @@ |
109 | 108 | sscanf(strbuf, "%s", str); |
110 | 109 | |
111 | 110 | mutex_lock(&acpi_device_lock); |
112 | - list_for_each_safe(node, next, &acpi_wakeup_device_list) { | |
113 | - struct acpi_device *dev = | |
114 | - container_of(node, struct acpi_device, wakeup_list); | |
111 | + list_for_each_entry_safe(dev, tmp, &acpi_wakeup_device_list, | |
112 | + wakeup_list) { | |
115 | 113 | if (!dev->wakeup.flags.valid) |
116 | 114 | continue; |
117 | 115 |
drivers/acpi/wakeup.c
... | ... | @@ -30,12 +30,10 @@ |
30 | 30 | */ |
31 | 31 | void acpi_enable_wakeup_devices(u8 sleep_state) |
32 | 32 | { |
33 | - struct list_head *node, *next; | |
33 | + struct acpi_device *dev, *tmp; | |
34 | 34 | |
35 | - list_for_each_safe(node, next, &acpi_wakeup_device_list) { | |
36 | - struct acpi_device *dev = | |
37 | - container_of(node, struct acpi_device, wakeup_list); | |
38 | - | |
35 | + list_for_each_entry_safe(dev, tmp, &acpi_wakeup_device_list, | |
36 | + wakeup_list) { | |
39 | 37 | if (!dev->wakeup.flags.valid |
40 | 38 | || sleep_state > (u32) dev->wakeup.sleep_state |
41 | 39 | || !(device_may_wakeup(&dev->dev) |
42 | 40 | |
... | ... | @@ -57,12 +55,10 @@ |
57 | 55 | */ |
58 | 56 | void acpi_disable_wakeup_devices(u8 sleep_state) |
59 | 57 | { |
60 | - struct list_head *node, *next; | |
58 | + struct acpi_device *dev, *tmp; | |
61 | 59 | |
62 | - list_for_each_safe(node, next, &acpi_wakeup_device_list) { | |
63 | - struct acpi_device *dev = | |
64 | - container_of(node, struct acpi_device, wakeup_list); | |
65 | - | |
60 | + list_for_each_entry_safe(dev, tmp, &acpi_wakeup_device_list, | |
61 | + wakeup_list) { | |
66 | 62 | if (!dev->wakeup.flags.valid |
67 | 63 | || sleep_state > (u32) dev->wakeup.sleep_state |
68 | 64 | || !(device_may_wakeup(&dev->dev) |
69 | 65 | |
... | ... | @@ -79,13 +75,11 @@ |
79 | 75 | |
80 | 76 | int __init acpi_wakeup_device_init(void) |
81 | 77 | { |
82 | - struct list_head *node, *next; | |
78 | + struct acpi_device *dev, *tmp; | |
83 | 79 | |
84 | 80 | mutex_lock(&acpi_device_lock); |
85 | - list_for_each_safe(node, next, &acpi_wakeup_device_list) { | |
86 | - struct acpi_device *dev = container_of(node, | |
87 | - struct acpi_device, | |
88 | - wakeup_list); | |
81 | + list_for_each_entry_safe(dev, tmp, &acpi_wakeup_device_list, | |
82 | + wakeup_list) { | |
89 | 83 | if (device_can_wakeup(&dev->dev)) { |
90 | 84 | /* Button GPEs are supposed to be always enabled. */ |
91 | 85 | acpi_enable_gpe(dev->wakeup.gpe_device, |