diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-08-06 19:22:08 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-08-07 17:41:47 -0400 |
commit | 3e3327837c180781960188563b4e4d5c004c2b29 (patch) | |
tree | 04649fa00e68597285ee43fccbfe9af996944e01 | |
parent | f501b6ec290f59b9c444bc061acf0e422347fb55 (diff) |
ACPI: Use list_for_each_entry() in acpi_unbind_one()
Since acpi_unbind_one() walks physical_node_list under the ACPI
device object's physical_node_lock mutex and the walk may be
terminated as soon as the matching entry has been found, it is
not necessary to use list_for_each_safe() for that walk, so use
list_for_each_entry() instead and make the code slightly more
straightforward.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Toshi Kani <toshi.kani@hp.com>
Acked-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
-rw-r--r-- | drivers/acpi/glue.c | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c index 69641c061619..570628e1def3 100644 --- a/drivers/acpi/glue.c +++ b/drivers/acpi/glue.c | |||
@@ -279,7 +279,6 @@ int acpi_unbind_one(struct device *dev) | |||
279 | struct acpi_device_physical_node *entry; | 279 | struct acpi_device_physical_node *entry; |
280 | struct acpi_device *acpi_dev; | 280 | struct acpi_device *acpi_dev; |
281 | acpi_status status; | 281 | acpi_status status; |
282 | struct list_head *node, *next; | ||
283 | 282 | ||
284 | if (!ACPI_HANDLE(dev)) | 283 | if (!ACPI_HANDLE(dev)) |
285 | return 0; | 284 | return 0; |
@@ -289,25 +288,24 @@ int acpi_unbind_one(struct device *dev) | |||
289 | goto err; | 288 | goto err; |
290 | 289 | ||
291 | mutex_lock(&acpi_dev->physical_node_lock); | 290 | mutex_lock(&acpi_dev->physical_node_lock); |
292 | list_for_each_safe(node, next, &acpi_dev->physical_node_list) { | 291 | |
293 | char physical_node_name[PHYSICAL_NODE_NAME_SIZE]; | 292 | list_for_each_entry(entry, &acpi_dev->physical_node_list, node) |
294 | 293 | if (entry->dev == dev) { | |
295 | entry = list_entry(node, struct acpi_device_physical_node, | 294 | char physnode_name[PHYSICAL_NODE_NAME_SIZE]; |
296 | node); | 295 | |
297 | if (entry->dev != dev) | 296 | list_del(&entry->node); |
298 | continue; | 297 | acpi_dev->physical_node_count--; |
299 | 298 | ||
300 | list_del(node); | 299 | acpi_physnode_link_name(physnode_name, entry->node_id); |
301 | acpi_dev->physical_node_count--; | 300 | sysfs_remove_link(&acpi_dev->dev.kobj, physnode_name); |
302 | 301 | sysfs_remove_link(&dev->kobj, "firmware_node"); | |
303 | acpi_physnode_link_name(physical_node_name, entry->node_id); | 302 | ACPI_HANDLE_SET(dev, NULL); |
304 | sysfs_remove_link(&acpi_dev->dev.kobj, physical_node_name); | 303 | /* acpi_bind_one() increase refcnt by one. */ |
305 | sysfs_remove_link(&dev->kobj, "firmware_node"); | 304 | put_device(dev); |
306 | ACPI_HANDLE_SET(dev, NULL); | 305 | kfree(entry); |
307 | /* acpi_bind_one increase refcnt by one */ | 306 | break; |
308 | put_device(dev); | 307 | } |
309 | kfree(entry); | 308 | |
310 | } | ||
311 | mutex_unlock(&acpi_dev->physical_node_lock); | 309 | mutex_unlock(&acpi_dev->physical_node_lock); |
312 | 310 | ||
313 | return 0; | 311 | return 0; |