Skip to contentSkip to conversation

ACPI: More acpi_bind_one() cleanups

PATCH In review Rafael J. Wysocki 2 participants 4 messages Aug 7, 2013 – Aug 8, 2013 ACPI

lore
Share & tools
lore
#0 lore raw

cover ACPI: More acpi_bind_one() cleanups

Hi All,

Two more cleanups for acpi_bind_one() on top of linux-pm.git/linux-next follow:

[1/2] Drop unnecessary label from acpi_bind_one(). [2/2] Print diagnostic messages if device links cannot be created.

Thanks,
Rafael

Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
#1 lore raw

PATCH 1/2 ACPI: Drop unnecessary label from acpi_bind_one()

From: Rafael J. Wysocki <[email protected]>

The out_free label in acpi_bind_one() is only jumped to from one place, so in fact it is not necessary, because the code below it can be moved to that place directly. Move that code and drop the label.

---
 drivers/acpi/glue.c |   19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)
drivers/acpi/glue.c +7 -12
Index: linux-pm/drivers/acpi/glue.c
===================================================================
@@ -225,11 +225,15 @@ int acpi_bind_one(struct device *dev, ac
 	list_for_each_entry(pn, &acpi_dev->physical_node_list, node) {
 		/* Sanity check. */
 		if (pn->dev == dev) {
+			mutex_unlock(&acpi_dev->physical_node_lock);
+
 			dev_warn(dev, "Already associated with ACPI node\n");
-			if (ACPI_HANDLE(dev) == handle)
-				retval = 0;
+			kfree(physical_node);
+			if (ACPI_HANDLE(dev) != handle)
+				goto err;
 
-			goto out_free;
+			put_device(dev);
+			return 0;
 		}
 		if (pn->node_id == node_id) {
 			physnode_list = &pn->node;
@@ -262,15 +266,6 @@ int acpi_bind_one(struct device *dev, ac
 	ACPI_HANDLE_SET(dev, NULL);
 	put_device(dev);
 	return retval;
-
- out_free:
-	mutex_unlock(&acpi_dev->physical_node_lock);
-	kfree(physical_node);
-	if (retval)
-		goto err;
-
-	put_device(dev);
-	return 0;
 }
 EXPORT_SYMBOL_GPL(acpi_bind_one);
 
#2 lore raw

PATCH 2/2 ACPI: Print diagnostic messages if device links cannot be created

In reply to Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

Although the device links created by acpi_bind_one() are not essential from the kernel functionality point of view, user space may be confused when they are missing, so print diagnostic messages to the kernel log if they can't be created.

---
 drivers/acpi/glue.c |    7 +++++++
 1 file changed, 7 insertions(+)
drivers/acpi/glue.c +7 -0
Index: linux-pm/drivers/acpi/glue.c
===================================================================
@@ -252,8 +252,15 @@ int acpi_bind_one(struct device *dev, ac
 	acpi_physnode_link_name(physical_node_name, node_id);
 	retval = sysfs_create_link(&acpi_dev->dev.kobj, &dev->kobj,
 				   physical_node_name);
+	if (retval)
+		dev_err(&acpi_dev->dev, "Failed to create link %s (%d)\n",
+			physical_node_name, retval);
+
 	retval = sysfs_create_link(&dev->kobj, &acpi_dev->dev.kobj,
 				   "firmware_node");
+	if (retval)
+		dev_err(dev, "Failed to create link firmware_node (%d)\n",
+			retval);
 
 	mutex_unlock(&acpi_dev->physical_node_lock);
 
Acked-by on the v1 series
#3 lore raw
In reply to Rafael J. Wysocki
Quoted 7 lines · Rafael J. Wysocki

Hi All,

Two more cleanups for acpi_bind_one() on top of linux-pm.git/linux-next follow:

[1/2] Drop unnecessary label from acpi_bind_one(). [2/2] Print diagnostic messages if device links cannot be created.

Looks good.

Thanks,
-Toshi