From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: ACPI Devel Maling List <linux-acpi@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>, Toshi Kani <toshi.kani@hp.com>
Subject: [PATCH 4/5] ACPI: Use list_for_each_entry() in acpi_unbind_one()
Date: Tue, 06 Aug 2013 02:28:01 +0200 [thread overview]
Message-ID: <4033872.Q1QjeRMsmt@vostro.rjw.lan> (raw)
In-Reply-To: <3015032.qfOqgEVZKP@vostro.rjw.lan>
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
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>
---
drivers/acpi/glue.c | 36 +++++++++++++++++-------------------
1 file changed, 17 insertions(+), 19 deletions(-)
Index: linux-pm/drivers/acpi/glue.c
===================================================================
--- linux-pm.orig/drivers/acpi/glue.c
+++ linux-pm/drivers/acpi/glue.c
@@ -214,7 +214,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;
@@ -224,25 +223,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_bind_physnode_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_bind_physnode_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;
next prev parent reply other threads:[~2013-08-06 0:21 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-06 0:22 [PATCH 0/5] ACPI: acpi_bind_one()/acpi_unbind_one() cleanups Rafael J. Wysocki
2013-08-06 0:26 ` [PATCH 1/5] ACPI: Reduce acpi_bind_one()/acpi_unbind_one() code duplication Rafael J. Wysocki
2013-08-06 0:26 ` [PATCH 2/5] ACPI: Create symlinks in acpi_bind_one() under physical_node_lock Rafael J. Wysocki
2013-08-06 0:27 ` [PATCH 3/5] ACPI: acpi_bind_one()/acpi_unbind_one() whitespace cleanups Rafael J. Wysocki
2013-08-06 0:28 ` Rafael J. Wysocki [this message]
2013-08-06 0:28 ` [PATCH 5/5] ACPI: Clean up error code path in acpi_unbind_one() Rafael J. Wysocki
2013-08-06 21:15 ` [PATCH 0/5] ACPI: acpi_bind_one()/acpi_unbind_one() cleanups Toshi Kani
2013-08-06 22:29 ` Rafael J. Wysocki
2013-08-06 22:51 ` Toshi Kani
2013-08-07 5:09 ` Yasuaki Ishimatsu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4033872.Q1QjeRMsmt@vostro.rjw.lan \
--to=rjw@sisk.pl \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=toshi.kani@hp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®