summaryrefslogtreecommitdiffstats
path: root/drivers/acpi/glue.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-08-07 01:22:08 +0200
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-08-07 23:41:47 +0200
commit3e3327837c180781960188563b4e4d5c004c2b29 (patch)
tree04649fa00e68597285ee43fccbfe9af996944e01 /drivers/acpi/glue.c
parentf501b6ec290f59b9c444bc061acf0e422347fb55 (diff)
downloadop-kernel-dev-3e3327837c180781960188563b4e4d5c004c2b29.zip
op-kernel-dev-3e3327837c180781960188563b4e4d5c004c2b29.tar.gz
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>
Diffstat (limited to 'drivers/acpi/glue.c')
-rw-r--r--drivers/acpi/glue.c38
1 files changed, 18 insertions, 20 deletions
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index 69641c0..570628e 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -279,7 +279,6 @@ int acpi_unbind_one(struct device *dev)
struct acpi_device_physical_node *entry;
struct acpi_device *acpi_dev;
acpi_status status;
- struct list_head *node, *next;
if (!ACPI_HANDLE(dev))
return 0;
@@ -289,25 +288,24 @@ int acpi_unbind_one(struct device *dev)
goto err;
mutex_lock(&acpi_dev->physical_node_lock);
- list_for_each_safe(node, next, &acpi_dev->physical_node_list) {
- char physical_node_name[PHYSICAL_NODE_NAME_SIZE];
-
- entry = list_entry(node, struct acpi_device_physical_node,
- node);
- if (entry->dev != dev)
- continue;
-
- list_del(node);
- acpi_dev->physical_node_count--;
-
- acpi_physnode_link_name(physical_node_name, entry->node_id);
- sysfs_remove_link(&acpi_dev->dev.kobj, physical_node_name);
- sysfs_remove_link(&dev->kobj, "firmware_node");
- ACPI_HANDLE_SET(dev, NULL);
- /* acpi_bind_one increase refcnt by one */
- put_device(dev);
- kfree(entry);
- }
+
+ list_for_each_entry(entry, &acpi_dev->physical_node_list, node)
+ if (entry->dev == dev) {
+ char physnode_name[PHYSICAL_NODE_NAME_SIZE];
+
+ list_del(&entry->node);
+ acpi_dev->physical_node_count--;
+
+ acpi_physnode_link_name(physnode_name, entry->node_id);
+ sysfs_remove_link(&acpi_dev->dev.kobj, physnode_name);
+ sysfs_remove_link(&dev->kobj, "firmware_node");
+ ACPI_HANDLE_SET(dev, NULL);
+ /* acpi_bind_one() increase refcnt by one. */
+ put_device(dev);
+ kfree(entry);
+ break;
+ }
+
mutex_unlock(&acpi_dev->physical_node_lock);
return 0;
OpenPOWER on IntegriCloud