linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] ACPI: Simplify namespace scanning for devices
@ 2012-12-16 13:47 Rafael J. Wysocki
  2012-12-16 13:49 ` [PATCH 1/6] ACPI / PCI: Fold acpi_pci_root_start() into acpi_pci_root_add() Rafael J. Wysocki
                   ` (7 more replies)
  0 siblings, 8 replies; 13+ messages in thread
From: Rafael J. Wysocki @ 2012-12-16 13:47 UTC (permalink / raw)
  To: ACPI Devel Maling List
  Cc: LKML, Bjorn Helgaas, Yinghai Lu, Toshi Kani, Yijing Wang,
	Jiang Liu, Wen Congyang

Hi All,

This series is on top of the one I sent on Thursday:

https://lkml.org/lkml/2012/12/13/632

It goes one step farther and makes some simplifications that become possible
after applying that patchset.

[1/6] Fold acpi_pci_root_start() into acpi_pci_root_add()
[2/6] Remove acpi_start_single_object() and acpi_bus_start()
[3/6] Remove the arguments of acpi_bus_add() that are not used
[4/6] Drop the second argument of acpi_bus_scan()
[5/6] Replace ACPI device add_type field with a match_driver flag
[6/6] Make acpi_bus_scan() and acpi_bus_add() take only one argument

It survives booting on Toshiba Portege R500 without any visible issues.

Thanks,
Rafael


-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 1/6] ACPI / PCI: Fold acpi_pci_root_start() into acpi_pci_root_add()
  2012-12-16 13:47 [PATCH 0/6] ACPI: Simplify namespace scanning for devices Rafael J. Wysocki
@ 2012-12-16 13:49 ` Rafael J. Wysocki
  2012-12-16 13:51 ` [PATCH 2/6] ACPI: Remove acpi_start_single_object() and acpi_bus_start() Rafael J. Wysocki
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Rafael J. Wysocki @ 2012-12-16 13:49 UTC (permalink / raw)
  To: ACPI Devel Maling List
  Cc: LKML, Bjorn Helgaas, Yinghai Lu, Toshi Kani, Yijing Wang,
	Jiang Liu, Wen Congyang

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Move the code from the ACPI PCI root bridge's .start() callback
routine, acpi_pci_root_start(), directly into acpi_pci_root_add()
and drop acpi_pci_root_start().

It is safe to do that, because it is now always guaranteed that
when struct pci_dev objects are created, their companion struct
acpi_device objects are already present, so it is not necessary to
wait for them to be created before calling pci_bus_add_devices().

This change was previously proposed in a different form by
Yinghai Lu.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/acpi/pci_root.c |   26 ++++++++------------------
 1 file changed, 8 insertions(+), 18 deletions(-)

Index: linux/drivers/acpi/pci_root.c
===================================================================
--- linux.orig/drivers/acpi/pci_root.c
+++ linux/drivers/acpi/pci_root.c
@@ -47,7 +47,6 @@ ACPI_MODULE_NAME("pci_root");
 #define ACPI_PCI_ROOT_DEVICE_NAME	"PCI Root Bridge"
 static int acpi_pci_root_add(struct acpi_device *device);
 static int acpi_pci_root_remove(struct acpi_device *device, int type);
-static int acpi_pci_root_start(struct acpi_device *device);
 
 #define ACPI_PCIE_REQ_SUPPORT (OSC_EXT_PCI_CONFIG_SUPPORT \
 				| OSC_ACTIVE_STATE_PWR_SUPPORT \
@@ -67,7 +66,6 @@ static struct acpi_driver acpi_pci_root_
 	.ops = {
 		.add = acpi_pci_root_add,
 		.remove = acpi_pci_root_remove,
-		.start = acpi_pci_root_start,
 		},
 };
 
@@ -453,6 +451,7 @@ static int __devinit acpi_pci_root_add(s
 	struct acpi_pci_root *root;
 	acpi_handle handle;
 	struct acpi_device *child;
+	struct acpi_pci_driver *driver;
 	u32 flags, base_flags;
 
 	root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL);
@@ -628,6 +627,13 @@ static int __devinit acpi_pci_root_add(s
 	if (device->wakeup.flags.run_wake)
 		device_set_run_wake(root->bus->bridge, true);
 
+	mutex_lock(&acpi_pci_root_lock);
+	list_for_each_entry(driver, &acpi_pci_drivers, node)
+		if (driver->add)
+			driver->add(root);
+	mutex_unlock(&acpi_pci_root_lock);
+
+	pci_bus_add_devices(root->bus);
 	return 0;
 
 out_del_root:
@@ -639,22 +645,6 @@ end:
 	return result;
 }
 
-static int acpi_pci_root_start(struct acpi_device *device)
-{
-	struct acpi_pci_root *root = acpi_driver_data(device);
-	struct acpi_pci_driver *driver;
-
-	mutex_lock(&acpi_pci_root_lock);
-	list_for_each_entry(driver, &acpi_pci_drivers, node)
-		if (driver->add)
-			driver->add(root);
-	mutex_unlock(&acpi_pci_root_lock);
-
-	pci_bus_add_devices(root->bus);
-
-	return 0;
-}
-
 static int acpi_pci_root_remove(struct acpi_device *device, int type)
 {
 	struct acpi_pci_root *root = acpi_driver_data(device);


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 2/6] ACPI: Remove acpi_start_single_object() and acpi_bus_start()
  2012-12-16 13:47 [PATCH 0/6] ACPI: Simplify namespace scanning for devices Rafael J. Wysocki
  2012-12-16 13:49 ` [PATCH 1/6] ACPI / PCI: Fold acpi_pci_root_start() into acpi_pci_root_add() Rafael J. Wysocki
@ 2012-12-16 13:51 ` Rafael J. Wysocki
  2012-12-16 13:51 ` [PATCH 3/6] ACPI: Remove the arguments of acpi_bus_add() that are not used Rafael J. Wysocki
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Rafael J. Wysocki @ 2012-12-16 13:51 UTC (permalink / raw)
  To: ACPI Devel Maling List
  Cc: LKML, Bjorn Helgaas, Yinghai Lu, Toshi Kani, Yijing Wang,
	Jiang Liu, Wen Congyang

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

The ACPI PCI root bridge driver was the only ACPI driver implementing
the .start() callback, which isn't used by any ACPI drivers any more
now.

For this reason, acpi_start_single_object() has no purpose any more,
so remove it and all references to it.  Also remove
acpi_bus_start_device(), whose only purpose was to call
acpi_start_single_object().

Moreover, since after the removal of acpi_bus_start_device() the
only purpose of acpi_bus_start() remains to call
acpi_update_all_gpes(), move that into acpi_bus_add() and drop
acpi_bus_start() too, remove its header from acpi_bus.h and
update all of its former users accordingly.

This change was previously proposed in a different from by
Yinghai Lu.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/acpi/container.c           |   16 +-------
 drivers/acpi/scan.c                |   66 ++++---------------------------------
 drivers/pci/hotplug/acpiphp_glue.c |    4 --
 drivers/pci/hotplug/sgi_hotplug.c  |    2 -
 include/acpi/acpi_bus.h            |    1 
 5 files changed, 12 insertions(+), 77 deletions(-)

Index: linux/drivers/acpi/scan.c
===================================================================
--- linux.orig/drivers/acpi/scan.c
+++ linux/drivers/acpi/scan.c
@@ -612,7 +612,6 @@ static void acpi_device_remove_notify_ha
 }
 
 static int acpi_bus_driver_init(struct acpi_device *, struct acpi_driver *);
-static int acpi_start_single_object(struct acpi_device *);
 static int acpi_device_probe(struct device * dev)
 {
 	struct acpi_device *acpi_dev = to_acpi_device(dev);
@@ -621,9 +620,6 @@ static int acpi_device_probe(struct devi
 
 	ret = acpi_bus_driver_init(acpi_dev, acpi_drv);
 	if (!ret) {
-		if (acpi_dev->add_type == ACPI_BUS_ADD_START)
-			acpi_start_single_object(acpi_dev);
-
 		if (acpi_drv->ops.notify) {
 			ret = acpi_device_install_notify_handler(acpi_dev);
 			if (ret) {
@@ -802,24 +798,6 @@ acpi_bus_driver_init(struct acpi_device
 	return 0;
 }
 
-static int acpi_start_single_object(struct acpi_device *device)
-{
-	int result = 0;
-	struct acpi_driver *driver;
-
-
-	if (!(driver = device->driver))
-		return 0;
-
-	if (driver->ops.start) {
-		result = driver->ops.start(device);
-		if (result && driver->ops.remove)
-			driver->ops.remove(device, ACPI_BUS_REMOVAL_NORMAL);
-	}
-
-	return result;
-}
-
 /**
  * acpi_bus_register_driver - register a driver with the ACPI bus
  * @driver: driver being registered
@@ -1716,59 +1694,31 @@ static int acpi_bus_scan(acpi_handle han
 }
 
 /*
- * acpi_bus_add and acpi_bus_start
+ * acpi_bus_add
  *
  * scan a given ACPI tree and (probably recently hot-plugged)
- * create and add or starts found devices.
+ * create and add found devices.
  *
  * If no devices were found -ENODEV is returned which does not
  * mean that this is a real error, there just have been no suitable
  * ACPI objects in the table trunk from which the kernel could create
- * a device and add/start an appropriate driver.
+ * a device and add an appropriate driver.
  */
 
 int
 acpi_bus_add(struct acpi_device **child,
 	     struct acpi_device *parent, acpi_handle handle, int type)
 {
-	return acpi_bus_scan(handle, false, child);
-}
-EXPORT_SYMBOL(acpi_bus_add);
-
-static acpi_status acpi_bus_start_device(acpi_handle handle, u32 lvl,
-					 void *not_used, void **ret_not_used)
-{
-	struct acpi_device *device;
-	unsigned long long sta_not_used;
-	int type_not_used;
-
-	/*
-	 * Ignore errors ignored by acpi_bus_check_add() to avoid terminating
-	 * namespace walks prematurely.
-	 */
-	if (acpi_bus_type_and_status(handle, &type_not_used, &sta_not_used))
-		return AE_OK;
-
-	if (acpi_bus_get_device(handle, &device))
-		return AE_CTRL_DEPTH;
-
-	return acpi_start_single_object(device);
-}
-
-int acpi_bus_start(struct acpi_device *device)
-{
-	if (!device)
-		return -EINVAL;
+	int err;
 
-	if (ACPI_SUCCESS(acpi_start_single_object(device)))
-		acpi_walk_namespace(ACPI_TYPE_ANY, device->handle,
-				    ACPI_UINT32_MAX, acpi_bus_start_device,
-				    NULL, NULL, NULL);
+	err = acpi_bus_scan(handle, false, child);
+	if (err)
+		return err;
 
 	acpi_update_all_gpes();
 	return 0;
 }
-EXPORT_SYMBOL(acpi_bus_start);
+EXPORT_SYMBOL(acpi_bus_add);
 
 int acpi_bus_trim(struct acpi_device *start, int rmdevice)
 {
Index: linux/include/acpi/acpi_bus.h
===================================================================
--- linux.orig/include/acpi/acpi_bus.h
+++ linux/include/acpi/acpi_bus.h
@@ -402,7 +402,6 @@ int acpi_bus_add(struct acpi_device **ch
 		 acpi_handle handle, int type);
 void acpi_bus_hot_remove_device(void *context);
 int acpi_bus_trim(struct acpi_device *start, int rmdevice);
-int acpi_bus_start(struct acpi_device *device);
 acpi_status acpi_bus_get_ejd(acpi_handle handle, acpi_handle * ejd);
 int acpi_match_device_ids(struct acpi_device *device,
 			  const struct acpi_device_id *ids);
Index: linux/drivers/pci/hotplug/sgi_hotplug.c
===================================================================
--- linux.orig/drivers/pci/hotplug/sgi_hotplug.c
+++ linux/drivers/pci/hotplug/sgi_hotplug.c
@@ -457,8 +457,6 @@ static int enable_slot(struct hotplug_sl
 					       ret, (int)(adr>>16),
 					       (int)(adr&0xffff));
 					/* try to continue on */
-				} else {
-					acpi_bus_start(device);
 				}
 			}
 		}
Index: linux/drivers/pci/hotplug/acpiphp_glue.c
===================================================================
--- linux.orig/drivers/pci/hotplug/acpiphp_glue.c
+++ linux/drivers/pci/hotplug/acpiphp_glue.c
@@ -759,7 +759,6 @@ static int acpiphp_bus_add(struct acpiph
 			-ret_val);
 		goto acpiphp_bus_add_out;
 	}
-	ret_val = acpi_bus_start(device);
 
 acpiphp_bus_add_out:
 	return ret_val;
@@ -1148,8 +1147,7 @@ static void handle_bridge_insertion(acpi
 		err("cannot add bridge to acpi list\n");
 		return;
 	}
-	if (!acpiphp_configure_bridge(handle) &&
-		!acpi_bus_start(device))
+	if (!acpiphp_configure_bridge(handle))
 		add_bridge(handle);
 	else
 		err("cannot configure and start bridge\n");
Index: linux/drivers/acpi/container.c
===================================================================
--- linux.orig/drivers/acpi/container.c
+++ linux/drivers/acpi/container.c
@@ -139,24 +139,14 @@ static int container_device_add(struct a
 {
 	acpi_handle phandle;
 	struct acpi_device *pdev;
-	int result;
 
-
-	if (acpi_get_parent(handle, &phandle)) {
-		return -ENODEV;
-	}
-
-	if (acpi_bus_get_device(phandle, &pdev)) {
+	if (acpi_get_parent(handle, &phandle))
 		return -ENODEV;
-	}
 
-	if (acpi_bus_add(device, pdev, handle, ACPI_BUS_TYPE_DEVICE)) {
+	if (acpi_bus_get_device(phandle, &pdev))
 		return -ENODEV;
-	}
-
-	result = acpi_bus_start(*device);
 
-	return result;
+	return acpi_bus_add(device, pdev, handle, ACPI_BUS_TYPE_DEVICE);
 }
 
 static void container_notify_cb(acpi_handle handle, u32 type, void *context)


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 3/6] ACPI: Remove the arguments of acpi_bus_add() that are not used
  2012-12-16 13:47 [PATCH 0/6] ACPI: Simplify namespace scanning for devices Rafael J. Wysocki
  2012-12-16 13:49 ` [PATCH 1/6] ACPI / PCI: Fold acpi_pci_root_start() into acpi_pci_root_add() Rafael J. Wysocki
  2012-12-16 13:51 ` [PATCH 2/6] ACPI: Remove acpi_start_single_object() and acpi_bus_start() Rafael J. Wysocki
@ 2012-12-16 13:51 ` Rafael J. Wysocki
  2012-12-16 13:52 ` [PATCH 4/6] ACPI: Drop the second argument of acpi_bus_scan() Rafael J. Wysocki
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Rafael J. Wysocki @ 2012-12-16 13:51 UTC (permalink / raw)
  To: ACPI Devel Maling List
  Cc: LKML, Bjorn Helgaas, Yinghai Lu, Toshi Kani, Yijing Wang,
	Jiang Liu, Wen Congyang

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Notice that acpi_bus_add() uses only 2 of its 4 arguments and
redefine its header to match the body.  Update all of its callers as
necessary and observe that this leads to quite a number of removed
lines of code (Linus will like that).

Add a kerneldoc comment documenting acpi_bus_add() and wonder how
its callers make wrong assumptions about the second argument (make
note to self to take care of that later).

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/acpi/acpi_memhotplug.c     |   18 +-----------------
 drivers/acpi/container.c           |   16 +---------------
 drivers/acpi/dock.c                |   13 ++-----------
 drivers/acpi/processor_driver.c    |   24 +-----------------------
 drivers/acpi/scan.c                |   34 +++++++++++++++++++++-------------
 drivers/pci/hotplug/acpiphp_glue.c |   21 ++++-----------------
 drivers/pci/hotplug/sgi_hotplug.c  |    3 +--
 include/acpi/acpi_bus.h            |    3 +--
 8 files changed, 32 insertions(+), 100 deletions(-)

Index: linux/drivers/acpi/scan.c
===================================================================
--- linux.orig/drivers/acpi/scan.c
+++ linux/drivers/acpi/scan.c
@@ -1693,25 +1693,33 @@ static int acpi_bus_scan(acpi_handle han
 	return ret;
 }
 
-/*
- * acpi_bus_add
+/**
+ * acpi_bus_add - Add ACPI device node objects in a given namespace scope.
+ * @handle: Root of the namespace scope to scan.
+ * @ret: Location to store a return struct acpi_device pointer.
  *
- * scan a given ACPI tree and (probably recently hot-plugged)
- * create and add found devices.
+ * Scan a given ACPI tree (probably recently hot-plugged) and create and add
+ * found devices.
  *
- * If no devices were found -ENODEV is returned which does not
- * mean that this is a real error, there just have been no suitable
- * ACPI objects in the table trunk from which the kernel could create
- * a device and add an appropriate driver.
+ * If no devices were found, -ENODEV is returned, but it does not mean that
+ * there has been a real error.  There just have been no suitable ACPI objects
+ * in the table trunk from which the kernel could create a device and add an
+ * appropriate driver.
+ *
+ * If 0 is returned, the memory location pointed to by @ret will be populated
+ * with a pointer to a struct acpi_device created while scanning the namespace.
+ * If @handle corresponds to a device node, that will be a pointer to the struct
+ * acpi_device object corresponding to @handle.  Otherwise, it will be a pointer
+ * to a struct acpi_device corresponding to one of its descendants.
+ *
+ * If an error code is returned, NULL will be stored in the memory location
+ * pointed to by @ret.
  */
-
-int
-acpi_bus_add(struct acpi_device **child,
-	     struct acpi_device *parent, acpi_handle handle, int type)
+int acpi_bus_add(acpi_handle handle, struct acpi_device **ret)
 {
 	int err;
 
-	err = acpi_bus_scan(handle, false, child);
+	err = acpi_bus_scan(handle, false, ret);
 	if (err)
 		return err;
 
Index: linux/include/acpi/acpi_bus.h
===================================================================
--- linux.orig/include/acpi/acpi_bus.h
+++ linux/include/acpi/acpi_bus.h
@@ -398,8 +398,7 @@ static inline int acpi_bus_generate_proc
 #endif
 int acpi_bus_register_driver(struct acpi_driver *driver);
 void acpi_bus_unregister_driver(struct acpi_driver *driver);
-int acpi_bus_add(struct acpi_device **child, struct acpi_device *parent,
-		 acpi_handle handle, int type);
+int acpi_bus_add(acpi_handle handle, struct acpi_device **ret);
 void acpi_bus_hot_remove_device(void *context);
 int acpi_bus_trim(struct acpi_device *start, int rmdevice);
 acpi_status acpi_bus_get_ejd(acpi_handle handle, acpi_handle * ejd);
Index: linux/drivers/pci/hotplug/sgi_hotplug.c
===================================================================
--- linux.orig/drivers/pci/hotplug/sgi_hotplug.c
+++ linux/drivers/pci/hotplug/sgi_hotplug.c
@@ -448,8 +448,7 @@ static int enable_slot(struct hotplug_sl
 			if (ACPI_SUCCESS(ret) &&
 			    (adr>>16) == (slot->device_num + 1)) {
 
-				ret = acpi_bus_add(&device, pdevice, chandle,
-						   ACPI_BUS_TYPE_DEVICE);
+				ret = acpi_bus_add(chandle, &device);
 				if (ACPI_FAILURE(ret)) {
 					printk(KERN_ERR "%s: acpi_bus_add "
 					       "failed (0x%x) for slot %d "
Index: linux/drivers/pci/hotplug/acpiphp_glue.c
===================================================================
--- linux.orig/drivers/pci/hotplug/acpiphp_glue.c
+++ linux/drivers/pci/hotplug/acpiphp_glue.c
@@ -734,15 +734,9 @@ static unsigned char acpiphp_max_busnr(s
  */
 static int acpiphp_bus_add(struct acpiphp_func *func)
 {
-	acpi_handle phandle;
-	struct acpi_device *device, *pdevice;
+	struct acpi_device *device;
 	int ret_val;
 
-	acpi_get_parent(func->handle, &phandle);
-	if (acpi_bus_get_device(phandle, &pdevice)) {
-		dbg("no parent device, assuming NULL\n");
-		pdevice = NULL;
-	}
 	if (!acpi_bus_get_device(func->handle, &device)) {
 		dbg("bus exists... trim\n");
 		/* this shouldn't be in here, so remove
@@ -752,8 +746,7 @@ static int acpiphp_bus_add(struct acpiph
 		dbg("acpi_bus_trim return %x\n", ret_val);
 	}
 
-	ret_val = acpi_bus_add(&device, pdevice, func->handle,
-		ACPI_BUS_TYPE_DEVICE);
+	ret_val = acpi_bus_add(func->handle, &device);
 	if (ret_val) {
 		dbg("error adding bus, %x\n",
 			-ret_val);
@@ -1129,8 +1122,7 @@ static int acpiphp_configure_bridge (acp
 
 static void handle_bridge_insertion(acpi_handle handle, u32 type)
 {
-	struct acpi_device *device, *pdevice;
-	acpi_handle phandle;
+	struct acpi_device *device;
 
 	if ((type != ACPI_NOTIFY_BUS_CHECK) &&
 			(type != ACPI_NOTIFY_DEVICE_CHECK)) {
@@ -1138,12 +1130,7 @@ static void handle_bridge_insertion(acpi
 		return;
 	}
 
-	acpi_get_parent(handle, &phandle);
-	if (acpi_bus_get_device(phandle, &pdevice)) {
-		dbg("no parent device, assuming NULL\n");
-		pdevice = NULL;
-	}
-	if (acpi_bus_add(&device, pdevice, handle, ACPI_BUS_TYPE_DEVICE)) {
+	if (acpi_bus_add(handle, &device)) {
 		err("cannot add bridge to acpi list\n");
 		return;
 	}
Index: linux/drivers/acpi/processor_driver.c
===================================================================
--- linux.orig/drivers/acpi/processor_driver.c
+++ linux/drivers/acpi/processor_driver.c
@@ -677,28 +677,6 @@ static int is_processor_present(acpi_han
 	return 0;
 }
 
-static
-int acpi_processor_device_add(acpi_handle handle, struct acpi_device **device)
-{
-	acpi_handle phandle;
-	struct acpi_device *pdev;
-
-
-	if (acpi_get_parent(handle, &phandle)) {
-		return -ENODEV;
-	}
-
-	if (acpi_bus_get_device(phandle, &pdev)) {
-		return -ENODEV;
-	}
-
-	if (acpi_bus_add(device, pdev, handle, ACPI_BUS_TYPE_PROCESSOR)) {
-		return -ENODEV;
-	}
-
-	return 0;
-}
-
 static void acpi_processor_hotplug_notify(acpi_handle handle,
 					  u32 event, void *data)
 {
@@ -721,7 +699,7 @@ static void acpi_processor_hotplug_notif
 		if (!acpi_bus_get_device(handle, &device))
 			break;
 
-		result = acpi_processor_device_add(handle, &device);
+		result = acpi_bus_add(handle, &device);
 		if (result) {
 			acpi_handle_err(handle, "Unable to add the device\n");
 			break;
Index: linux/drivers/acpi/dock.c
===================================================================
--- linux.orig/drivers/acpi/dock.c
+++ linux/drivers/acpi/dock.c
@@ -310,8 +310,6 @@ static int dock_present(struct dock_stat
 static struct acpi_device * dock_create_acpi_device(acpi_handle handle)
 {
 	struct acpi_device *device;
-	struct acpi_device *parent_device;
-	acpi_handle parent;
 	int ret;
 
 	if (acpi_bus_get_device(handle, &device)) {
@@ -319,16 +317,9 @@ static struct acpi_device * dock_create_
 		 * no device created for this object,
 		 * so we should create one.
 		 */
-		acpi_get_parent(handle, &parent);
-		if (acpi_bus_get_device(parent, &parent_device))
-			parent_device = NULL;
-
-		ret = acpi_bus_add(&device, parent_device, handle,
-			ACPI_BUS_TYPE_DEVICE);
-		if (ret) {
+		ret = acpi_bus_add(handle, &device);
+		if (ret)
 			pr_debug("error adding bus, %x\n", -ret);
-			return NULL;
-		}
 	}
 	return device;
 }
Index: linux/drivers/acpi/container.c
===================================================================
--- linux.orig/drivers/acpi/container.c
+++ linux/drivers/acpi/container.c
@@ -135,20 +135,6 @@ static int acpi_container_remove(struct
 	return status;
 }
 
-static int container_device_add(struct acpi_device **device, acpi_handle handle)
-{
-	acpi_handle phandle;
-	struct acpi_device *pdev;
-
-	if (acpi_get_parent(handle, &phandle))
-		return -ENODEV;
-
-	if (acpi_bus_get_device(phandle, &pdev))
-		return -ENODEV;
-
-	return acpi_bus_add(device, pdev, handle, ACPI_BUS_TYPE_DEVICE);
-}
-
 static void container_notify_cb(acpi_handle handle, u32 type, void *context)
 {
 	struct acpi_device *device = NULL;
@@ -180,7 +166,7 @@ static void container_notify_cb(acpi_han
 		if (!ACPI_FAILURE(status) || device)
 			break;
 
-		result = container_device_add(&device, handle);
+		result = acpi_bus_add(handle, &device);
 		if (result) {
 			acpi_handle_warn(handle, "Failed to add container\n");
 			break;
Index: linux/drivers/acpi/acpi_memhotplug.c
===================================================================
--- linux.orig/drivers/acpi/acpi_memhotplug.c
+++ linux/drivers/acpi/acpi_memhotplug.c
@@ -158,33 +158,17 @@ acpi_memory_get_device(acpi_handle handl
 		       struct acpi_memory_device **mem_device)
 {
 	acpi_status status;
-	acpi_handle phandle;
 	struct acpi_device *device = NULL;
-	struct acpi_device *pdevice = NULL;
 	int result;
 
-
 	if (!acpi_bus_get_device(handle, &device) && device)
 		goto end;
 
-	status = acpi_get_parent(handle, &phandle);
-	if (ACPI_FAILURE(status)) {
-		ACPI_EXCEPTION((AE_INFO, status, "Cannot find acpi parent"));
-		return -EINVAL;
-	}
-
-	/* Get the parent device */
-	result = acpi_bus_get_device(phandle, &pdevice);
-	if (result) {
-		acpi_handle_warn(phandle, "Cannot get acpi bus device\n");
-		return -EINVAL;
-	}
-
 	/*
 	 * Now add the notified device.  This creates the acpi_device
 	 * and invokes .add function
 	 */
-	result = acpi_bus_add(&device, pdevice, handle, ACPI_BUS_TYPE_DEVICE);
+	result = acpi_bus_add(handle, &device);
 	if (result) {
 		acpi_handle_warn(handle, "Cannot add acpi bus\n");
 		return -EINVAL;


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 4/6] ACPI: Drop the second argument of acpi_bus_scan()
  2012-12-16 13:47 [PATCH 0/6] ACPI: Simplify namespace scanning for devices Rafael J. Wysocki
                   ` (2 preceding siblings ...)
  2012-12-16 13:51 ` [PATCH 3/6] ACPI: Remove the arguments of acpi_bus_add() that are not used Rafael J. Wysocki
@ 2012-12-16 13:52 ` Rafael J. Wysocki
  2012-12-16 13:53 ` [PATCH 5/6] ACPI: Replace ACPI device add_type field with a match_driver flag Rafael J. Wysocki
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Rafael J. Wysocki @ 2012-12-16 13:52 UTC (permalink / raw)
  To: ACPI Devel Maling List
  Cc: LKML, Bjorn Helgaas, Yinghai Lu, Toshi Kani, Yijing Wang,
	Jiang Liu, Wen Congyang

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

After the removal of acpi_start_single_object() and acpi_bus_start()
the second argument of acpi_bus_scan() is not necessary any more,
so drop it and update acpi_bus_check_add() accordingly.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/acpi/scan.c |   18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

Index: linux/drivers/acpi/scan.c
===================================================================
--- linux.orig/drivers/acpi/scan.c
+++ linux/drivers/acpi/scan.c
@@ -1592,8 +1592,8 @@ static int acpi_bus_type_and_status(acpi
 	return 0;
 }
 
-static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl,
-				      void *context, void **return_value)
+static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used,
+				      void *not_used, void **return_value)
 {
 	struct acpi_device *device = NULL;
 	int type;
@@ -1625,7 +1625,7 @@ static acpi_status acpi_bus_check_add(ac
 	if (!device)
 		return AE_CTRL_DEPTH;
 
-	device->add_type = context ? ACPI_BUS_ADD_START : ACPI_BUS_ADD_MATCH;
+	device->add_type = ACPI_BUS_ADD_START;
 
  out:
 	if (!*return_value)
@@ -1664,18 +1664,16 @@ static acpi_status acpi_bus_device_attac
 	return status;
 }
 
-static int acpi_bus_scan(acpi_handle handle, bool start,
-			 struct acpi_device **child)
+static int acpi_bus_scan(acpi_handle handle, struct acpi_device **child)
 {
 	void *device = NULL;
 	acpi_status status;
 	int ret = -ENODEV;
 
-	status = acpi_bus_check_add(handle, 0, (void *)start, &device);
+	status = acpi_bus_check_add(handle, 0, NULL, &device);
 	if (ACPI_SUCCESS(status))
 		acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX,
-				    acpi_bus_check_add, NULL, (void *)start,
-				    &device);
+				    acpi_bus_check_add, NULL, NULL, &device);
 
 	if (!device)
 		goto out;
@@ -1719,7 +1717,7 @@ int acpi_bus_add(acpi_handle handle, str
 {
 	int err;
 
-	err = acpi_bus_scan(handle, false, ret);
+	err = acpi_bus_scan(handle, ret);
 	if (err)
 		return err;
 
@@ -1825,7 +1823,7 @@ int __init acpi_scan_init(void)
 	/*
 	 * Enumerate devices in the ACPI namespace.
 	 */
-	result = acpi_bus_scan(ACPI_ROOT_OBJECT, true, &acpi_root);
+	result = acpi_bus_scan(ACPI_ROOT_OBJECT, &acpi_root);
 
 	if (!result)
 		result = acpi_bus_scan_fixed();


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 5/6] ACPI: Replace ACPI device add_type field with a match_driver flag
  2012-12-16 13:47 [PATCH 0/6] ACPI: Simplify namespace scanning for devices Rafael J. Wysocki
                   ` (3 preceding siblings ...)
  2012-12-16 13:52 ` [PATCH 4/6] ACPI: Drop the second argument of acpi_bus_scan() Rafael J. Wysocki
@ 2012-12-16 13:53 ` Rafael J. Wysocki
  2012-12-16 13:55 ` [PATCH 6/6] ACPI: Make acpi_bus_scan() and acpi_bus_add() take only one argument Rafael J. Wysocki
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Rafael J. Wysocki @ 2012-12-16 13:53 UTC (permalink / raw)
  To: ACPI Devel Maling List
  Cc: LKML, Bjorn Helgaas, Yinghai Lu, Toshi Kani, Yijing Wang,
	Jiang Liu, Wen Congyang

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

After the removal of the second argument of acpi_bus_scan() there is
no difference between the ACPI_BUS_ADD_MATCH and ACPI_BUS_ADD_START
add types, so the add_type field in struct acpi_device may be
replaced with a single flag.  Do that calling the flag match_driver.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/acpi/scan.c     |   21 +++++++++------------
 include/acpi/acpi_bus.h |   11 ++---------
 2 files changed, 11 insertions(+), 21 deletions(-)

Index: linux/drivers/acpi/scan.c
===================================================================
--- linux.orig/drivers/acpi/scan.c
+++ linux/drivers/acpi/scan.c
@@ -535,7 +535,7 @@ static int acpi_bus_match(struct device
 	struct acpi_device *acpi_dev = to_acpi_device(dev);
 	struct acpi_driver *acpi_drv = to_acpi_driver(drv);
 
-	return acpi_dev->add_type >= ACPI_BUS_ADD_MATCH
+	return acpi_dev->flags.match_driver
 		&& !acpi_match_device_ids(acpi_dev, acpi_drv->ids);
 }
 
@@ -1451,8 +1451,7 @@ static void acpi_hot_add_bind(struct acp
 
 static int acpi_add_single_object(struct acpi_device **child,
 				  acpi_handle handle, int type,
-				  unsigned long long sta,
-				  enum acpi_bus_add_type add_type)
+				  unsigned long long sta, bool match_driver)
 {
 	int result;
 	struct acpi_device *device;
@@ -1468,7 +1467,6 @@ static int acpi_add_single_object(struct
 	device->device_type = type;
 	device->handle = handle;
 	device->parent = acpi_bus_get_parent(handle);
-	device->add_type = add_type;
 	STRUCT_TO_INT(device->status) = sta;
 
 	acpi_device_get_busid(device);
@@ -1519,9 +1517,10 @@ static int acpi_add_single_object(struct
 	if ((result = acpi_device_set_context(device)))
 		goto end;
 
+	device->flags.match_driver = match_driver;
 	result = acpi_device_register(device);
 
-	if (device->add_type >= ACPI_BUS_ADD_MATCH)
+	if (device->flags.match_driver)
 		acpi_hot_add_bind(device);
 
 end:
@@ -1550,7 +1549,7 @@ static void acpi_bus_add_power_resource(
 	acpi_bus_get_device(handle, &device);
 	if (!device)
 		acpi_add_single_object(&device, handle, ACPI_BUS_TYPE_POWER,
-					ACPI_STA_DEFAULT, ACPI_BUS_ADD_START);
+					ACPI_STA_DEFAULT, true);
 }
 
 static int acpi_bus_type_and_status(acpi_handle handle, int *type,
@@ -1621,11 +1620,11 @@ static acpi_status acpi_bus_check_add(ac
 		return AE_CTRL_DEPTH;
 	}
 
-	acpi_add_single_object(&device, handle, type, sta, ACPI_BUS_ADD_BASIC);
+	acpi_add_single_object(&device, handle, type, sta, false);
 	if (!device)
 		return AE_CTRL_DEPTH;
 
-	device->add_type = ACPI_BUS_ADD_START;
+	device->flags.match_driver = true;
 
  out:
 	if (!*return_value)
@@ -1792,16 +1791,14 @@ static int acpi_bus_scan_fixed(void)
 	if ((acpi_gbl_FADT.flags & ACPI_FADT_POWER_BUTTON) == 0) {
 		result = acpi_add_single_object(&device, NULL,
 						ACPI_BUS_TYPE_POWER_BUTTON,
-						ACPI_STA_DEFAULT,
-						ACPI_BUS_ADD_START);
+						ACPI_STA_DEFAULT, true);
 		device_init_wakeup(&device->dev, true);
 	}
 
 	if ((acpi_gbl_FADT.flags & ACPI_FADT_SLEEP_BUTTON) == 0) {
 		result = acpi_add_single_object(&device, NULL,
 						ACPI_BUS_TYPE_SLEEP_BUTTON,
-						ACPI_STA_DEFAULT,
-						ACPI_BUS_ADD_START);
+						ACPI_STA_DEFAULT, true);
 	}
 
 	return result;
Index: linux/include/acpi/acpi_bus.h
===================================================================
--- linux.orig/include/acpi/acpi_bus.h
+++ linux/include/acpi/acpi_bus.h
@@ -63,13 +63,6 @@ acpi_get_physical_device_location(acpi_h
 #define ACPI_BUS_FILE_ROOT	"acpi"
 extern struct proc_dir_entry *acpi_root_dir;
 
-enum acpi_bus_add_type {
-	ACPI_BUS_ADD_BASIC = 0,
-	ACPI_BUS_ADD_MATCH,
-	ACPI_BUS_ADD_START,
-	ACPI_BUS_ADD_TYPE_COUNT
-};
-
 enum acpi_bus_removal_type {
 	ACPI_BUS_REMOVAL_NORMAL = 0,
 	ACPI_BUS_REMOVAL_EJECT,
@@ -150,7 +143,8 @@ struct acpi_device_flags {
 	u32 power_manageable:1;
 	u32 performance_manageable:1;
 	u32 eject_pending:1;
-	u32 reserved:24;
+	u32 match_driver:1;
+	u32 reserved:23;
 };
 
 /* File System */
@@ -285,7 +279,6 @@ struct acpi_device {
 	struct acpi_driver *driver;
 	void *driver_data;
 	struct device dev;
-	enum acpi_bus_add_type add_type;	/* how to handle adding */
 	enum acpi_bus_removal_type removal_type;	/* indicate for different removal type */
 	u8 physical_node_count;
 	struct list_head physical_node_list;


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 6/6] ACPI: Make acpi_bus_scan() and acpi_bus_add() take only one argument
  2012-12-16 13:47 [PATCH 0/6] ACPI: Simplify namespace scanning for devices Rafael J. Wysocki
                   ` (4 preceding siblings ...)
  2012-12-16 13:53 ` [PATCH 5/6] ACPI: Replace ACPI device add_type field with a match_driver flag Rafael J. Wysocki
@ 2012-12-16 13:55 ` Rafael J. Wysocki
  2012-12-16 15:59 ` [PATCH 0/6] ACPI: Simplify namespace scanning for devices Jiang Liu
  2012-12-16 17:36 ` Yinghai Lu
  7 siblings, 0 replies; 13+ messages in thread
From: Rafael J. Wysocki @ 2012-12-16 13:55 UTC (permalink / raw)
  To: ACPI Devel Maling List
  Cc: LKML, Bjorn Helgaas, Yinghai Lu, Toshi Kani, Yijing Wang,
	Jiang Liu, Wen Congyang

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

The callers of acpi_bus_add() usually assume that if it has
succeeded, then a struct acpi_device object has been attached to
the handle passed as the first argument.  Unfortunately, however,
this assumption is wrong, because acpi_bus_scan(), and acpi_bus_add()
too as a result, may return a pointer to a different struct
acpi_device object on success (it may be an object corresponding to
one of the descendant ACPI nodes in the namespace scope below that
handle).

For this reason, the callers of acpi_bus_add() who care about
whether or not a struct acpi_device object has been created for
its first argument need to check that using acpi_bus_get_device()
anyway, so the second argument of acpi_bus_add() is not really
useful for them.  The same observation applies to acpi_bus_scan()
executed directly from acpi_scan_init().

Therefore modify the relevant callers of acpi_bus_add() to check the
existence of the struct acpi_device in question with the help of
acpi_bus_get_device() and drop the no longer necessary second
argument of acpi_bus_add().  Accordingly, modify acpi_scan_init() to
use acpi_bus_get_device() to get acpi_root and drop the no longer
needed second argument of acpi_bus_scan().

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/acpi/acpi_memhotplug.c     |    7 +++++-
 drivers/acpi/container.c           |    7 +++++-
 drivers/acpi/dock.c                |    4 ++-
 drivers/acpi/processor_driver.c    |    8 +++++--
 drivers/acpi/scan.c                |   38 ++++++++++---------------------------
 drivers/pci/hotplug/acpiphp_glue.c |   19 ++++++++++--------
 drivers/pci/hotplug/sgi_hotplug.c  |    3 --
 include/acpi/acpi_bus.h            |    2 -
 8 files changed, 45 insertions(+), 43 deletions(-)

Index: linux/drivers/acpi/scan.c
===================================================================
--- linux.orig/drivers/acpi/scan.c
+++ linux/drivers/acpi/scan.c
@@ -1663,37 +1663,27 @@ static acpi_status acpi_bus_device_attac
 	return status;
 }
 
-static int acpi_bus_scan(acpi_handle handle, struct acpi_device **child)
+static int acpi_bus_scan(acpi_handle handle)
 {
 	void *device = NULL;
-	acpi_status status;
-	int ret = -ENODEV;
 
-	status = acpi_bus_check_add(handle, 0, NULL, &device);
-	if (ACPI_SUCCESS(status))
+	if (ACPI_SUCCESS(acpi_bus_check_add(handle, 0, NULL, &device)))
 		acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX,
 				    acpi_bus_check_add, NULL, NULL, &device);
 
 	if (!device)
-		goto out;
+		return -ENODEV;
 
-	ret = 0;
-	status = acpi_bus_device_attach(handle, 0, NULL, NULL);
-	if (ACPI_SUCCESS(status))
+	if (ACPI_SUCCESS(acpi_bus_device_attach(handle, 0, NULL, NULL)))
 		acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX,
 				    acpi_bus_device_attach, NULL, NULL, NULL);
 
- out:
-	if (child)
-		*child = device;
-
-	return ret;
+	return 0;
 }
 
 /**
  * acpi_bus_add - Add ACPI device node objects in a given namespace scope.
  * @handle: Root of the namespace scope to scan.
- * @ret: Location to store a return struct acpi_device pointer.
  *
  * Scan a given ACPI tree (probably recently hot-plugged) and create and add
  * found devices.
@@ -1702,21 +1692,12 @@ static int acpi_bus_scan(acpi_handle han
  * there has been a real error.  There just have been no suitable ACPI objects
  * in the table trunk from which the kernel could create a device and add an
  * appropriate driver.
- *
- * If 0 is returned, the memory location pointed to by @ret will be populated
- * with a pointer to a struct acpi_device created while scanning the namespace.
- * If @handle corresponds to a device node, that will be a pointer to the struct
- * acpi_device object corresponding to @handle.  Otherwise, it will be a pointer
- * to a struct acpi_device corresponding to one of its descendants.
- *
- * If an error code is returned, NULL will be stored in the memory location
- * pointed to by @ret.
  */
-int acpi_bus_add(acpi_handle handle, struct acpi_device **ret)
+int acpi_bus_add(acpi_handle handle)
 {
 	int err;
 
-	err = acpi_bus_scan(handle, ret);
+	err = acpi_bus_scan(handle);
 	if (err)
 		return err;
 
@@ -1820,8 +1801,11 @@ int __init acpi_scan_init(void)
 	/*
 	 * Enumerate devices in the ACPI namespace.
 	 */
-	result = acpi_bus_scan(ACPI_ROOT_OBJECT, &acpi_root);
+	result = acpi_bus_scan(ACPI_ROOT_OBJECT);
+	if (result)
+		return result;
 
+	result = acpi_bus_get_device(ACPI_ROOT_OBJECT, &acpi_root);
 	if (!result)
 		result = acpi_bus_scan_fixed();
 
Index: linux/include/acpi/acpi_bus.h
===================================================================
--- linux.orig/include/acpi/acpi_bus.h
+++ linux/include/acpi/acpi_bus.h
@@ -391,7 +391,7 @@ static inline int acpi_bus_generate_proc
 #endif
 int acpi_bus_register_driver(struct acpi_driver *driver);
 void acpi_bus_unregister_driver(struct acpi_driver *driver);
-int acpi_bus_add(acpi_handle handle, struct acpi_device **ret);
+int acpi_bus_add(acpi_handle handle);
 void acpi_bus_hot_remove_device(void *context);
 int acpi_bus_trim(struct acpi_device *start, int rmdevice);
 acpi_status acpi_bus_get_ejd(acpi_handle handle, acpi_handle * ejd);
Index: linux/drivers/pci/hotplug/sgi_hotplug.c
===================================================================
--- linux.orig/drivers/pci/hotplug/sgi_hotplug.c
+++ linux/drivers/pci/hotplug/sgi_hotplug.c
@@ -412,7 +412,6 @@ static int enable_slot(struct hotplug_sl
 	if (SN_ACPI_BASE_SUPPORT() && ssdt) {
 		unsigned long long adr;
 		struct acpi_device *pdevice;
-		struct acpi_device *device;
 		acpi_handle phandle;
 		acpi_handle chandle = NULL;
 		acpi_handle rethandle;
@@ -448,7 +447,7 @@ static int enable_slot(struct hotplug_sl
 			if (ACPI_SUCCESS(ret) &&
 			    (adr>>16) == (slot->device_num + 1)) {
 
-				ret = acpi_bus_add(chandle, &device);
+				ret = acpi_bus_add(chandle);
 				if (ACPI_FAILURE(ret)) {
 					printk(KERN_ERR "%s: acpi_bus_add "
 					       "failed (0x%x) for slot %d "
Index: linux/drivers/pci/hotplug/acpiphp_glue.c
===================================================================
--- linux.orig/drivers/pci/hotplug/acpiphp_glue.c
+++ linux/drivers/pci/hotplug/acpiphp_glue.c
@@ -746,14 +746,13 @@ static int acpiphp_bus_add(struct acpiph
 		dbg("acpi_bus_trim return %x\n", ret_val);
 	}
 
-	ret_val = acpi_bus_add(func->handle, &device);
-	if (ret_val) {
-		dbg("error adding bus, %x\n",
-			-ret_val);
-		goto acpiphp_bus_add_out;
-	}
+	ret_val = acpi_bus_add(func->handle);
+	if (!ret_val)
+		ret_val = acpi_bus_get_device(func->handle, &device);
+
+	if (ret_val)
+		dbg("error adding bus, %x\n", -ret_val);
 
-acpiphp_bus_add_out:
 	return ret_val;
 }
 
@@ -1130,10 +1129,14 @@ static void handle_bridge_insertion(acpi
 		return;
 	}
 
-	if (acpi_bus_add(handle, &device)) {
+	if (acpi_bus_add(handle)) {
 		err("cannot add bridge to acpi list\n");
 		return;
 	}
+	if (acpi_bus_get_device(handle, &device)) {
+		err("ACPI device object missing\n");
+		return;
+	}
 	if (!acpiphp_configure_bridge(handle))
 		add_bridge(handle);
 	else
Index: linux/drivers/acpi/processor_driver.c
===================================================================
--- linux.orig/drivers/acpi/processor_driver.c
+++ linux/drivers/acpi/processor_driver.c
@@ -699,12 +699,16 @@ static void acpi_processor_hotplug_notif
 		if (!acpi_bus_get_device(handle, &device))
 			break;
 
-		result = acpi_bus_add(handle, &device);
+		result = acpi_bus_add(handle);
 		if (result) {
 			acpi_handle_err(handle, "Unable to add the device\n");
 			break;
 		}
-
+		result = acpi_bus_get_device(handle, &device);
+		if (result) {
+			acpi_handle_err(handle, "Missing device object\n");
+			break;
+		}
 		ost_code = ACPI_OST_SC_SUCCESS;
 		break;
 
Index: linux/drivers/acpi/dock.c
===================================================================
--- linux.orig/drivers/acpi/dock.c
+++ linux/drivers/acpi/dock.c
@@ -317,9 +317,11 @@ static struct acpi_device * dock_create_
 		 * no device created for this object,
 		 * so we should create one.
 		 */
-		ret = acpi_bus_add(handle, &device);
+		ret = acpi_bus_add(handle);
 		if (ret)
 			pr_debug("error adding bus, %x\n", -ret);
+
+		acpi_bus_get_device(handle, &device);
 	}
 	return device;
 }
Index: linux/drivers/acpi/container.c
===================================================================
--- linux.orig/drivers/acpi/container.c
+++ linux/drivers/acpi/container.c
@@ -166,11 +166,16 @@ static void container_notify_cb(acpi_han
 		if (!ACPI_FAILURE(status) || device)
 			break;
 
-		result = acpi_bus_add(handle, &device);
+		result = acpi_bus_add(handle);
 		if (result) {
 			acpi_handle_warn(handle, "Failed to add container\n");
 			break;
 		}
+		result = acpi_bus_get_device(handle, &device);
+		if (result) {
+			acpi_handle_warn(handle, "Missing device object\n");
+			break;
+		}
 
 		kobject_uevent(&device->dev.kobj, KOBJ_ONLINE);
 		ost_code = ACPI_OST_SC_SUCCESS;
Index: linux/drivers/acpi/acpi_memhotplug.c
===================================================================
--- linux.orig/drivers/acpi/acpi_memhotplug.c
+++ linux/drivers/acpi/acpi_memhotplug.c
@@ -168,11 +168,16 @@ acpi_memory_get_device(acpi_handle handl
 	 * Now add the notified device.  This creates the acpi_device
 	 * and invokes .add function
 	 */
-	result = acpi_bus_add(handle, &device);
+	result = acpi_bus_add(handle);
 	if (result) {
 		acpi_handle_warn(handle, "Cannot add acpi bus\n");
 		return -EINVAL;
 	}
+	result = acpi_bus_get_device(handle, &device);
+	if (result) {
+		acpi_handle_warn(handle, "Missing device object\n");
+		return -EINVAL;
+	}
 
       end:
 	*mem_device = acpi_driver_data(device);


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/6] ACPI: Simplify namespace scanning for devices
  2012-12-16 13:47 [PATCH 0/6] ACPI: Simplify namespace scanning for devices Rafael J. Wysocki
                   ` (5 preceding siblings ...)
  2012-12-16 13:55 ` [PATCH 6/6] ACPI: Make acpi_bus_scan() and acpi_bus_add() take only one argument Rafael J. Wysocki
@ 2012-12-16 15:59 ` Jiang Liu
  2012-12-16 22:29   ` Rafael J. Wysocki
  2012-12-16 17:36 ` Yinghai Lu
  7 siblings, 1 reply; 13+ messages in thread
From: Jiang Liu @ 2012-12-16 15:59 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: ACPI Devel Maling List, LKML, Bjorn Helgaas, Yinghai Lu,
	Toshi Kani, Yijing Wang, Wen Congyang

Hi Rafael,
	Great idea to get rid of the .start() staff, it could also
simplify our hotplug framework too.
	Thanks!
	Gerry

On 12/16/2012 09:47 PM, Rafael J. Wysocki wrote:
> Hi All,
> 
> This series is on top of the one I sent on Thursday:
> 
> https://lkml.org/lkml/2012/12/13/632
> 
> It goes one step farther and makes some simplifications that become possible
> after applying that patchset.
> 
> [1/6] Fold acpi_pci_root_start() into acpi_pci_root_add()
> [2/6] Remove acpi_start_single_object() and acpi_bus_start()
> [3/6] Remove the arguments of acpi_bus_add() that are not used
> [4/6] Drop the second argument of acpi_bus_scan()
> [5/6] Replace ACPI device add_type field with a match_driver flag
> [6/6] Make acpi_bus_scan() and acpi_bus_add() take only one argument
> 
> It survives booting on Toshiba Portege R500 without any visible issues.
> 
> Thanks,
> Rafael
> 
> 


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/6] ACPI: Simplify namespace scanning for devices
  2012-12-16 13:47 [PATCH 0/6] ACPI: Simplify namespace scanning for devices Rafael J. Wysocki
                   ` (6 preceding siblings ...)
  2012-12-16 15:59 ` [PATCH 0/6] ACPI: Simplify namespace scanning for devices Jiang Liu
@ 2012-12-16 17:36 ` Yinghai Lu
  2012-12-16 22:31   ` Rafael J. Wysocki
  7 siblings, 1 reply; 13+ messages in thread
From: Yinghai Lu @ 2012-12-16 17:36 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: ACPI Devel Maling List, LKML, Bjorn Helgaas, Toshi Kani,
	Yijing Wang, Jiang Liu, Wen Congyang

On Sun, Dec 16, 2012 at 5:47 AM, Rafael J. Wysocki <rjw@sisk.pl> wrote:
> Hi All,
>
> This series is on top of the one I sent on Thursday:
>
> https://lkml.org/lkml/2012/12/13/632
>
> It goes one step farther and makes some simplifications that become possible
> after applying that patchset.
>
> [1/6] Fold acpi_pci_root_start() into acpi_pci_root_add()
> [2/6] Remove acpi_start_single_object() and acpi_bus_start()
> [3/6] Remove the arguments of acpi_bus_add() that are not used
> [4/6] Drop the second argument of acpi_bus_scan()
> [5/6] Replace ACPI device add_type field with a match_driver flag
> [6/6] Make acpi_bus_scan() and acpi_bus_add() take only one argument
>
> It survives booting on Toshiba Portege R500 without any visible issues.

Do you have git branch that i could test?

I'd like to rebase for-pci-root-bus-hotplug patches, so what should be base?

It would be hard for me to base on your acpi tree and Bjorn's pci tree.

Thanks

Yinghai

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/6] ACPI: Simplify namespace scanning for devices
  2012-12-16 15:59 ` [PATCH 0/6] ACPI: Simplify namespace scanning for devices Jiang Liu
@ 2012-12-16 22:29   ` Rafael J. Wysocki
  0 siblings, 0 replies; 13+ messages in thread
From: Rafael J. Wysocki @ 2012-12-16 22:29 UTC (permalink / raw)
  To: Jiang Liu
  Cc: ACPI Devel Maling List, LKML, Bjorn Helgaas, Yinghai Lu,
	Toshi Kani, Yijing Wang, Wen Congyang

Hi,

On Sunday, December 16, 2012 11:59:58 PM Jiang Liu wrote:
> Hi Rafael,
> 	Great idea to get rid of the .start() staff, it could also
> simplify our hotplug framework too.

Well, this has been a Yinghai's idea, but thanks anyway. :-)

I see some more room for improvements like this, for example in the
acpi_pci_bind()/acpi_pci_unbind() area.

Thanks,
Rafael


-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/6] ACPI: Simplify namespace scanning for devices
  2012-12-16 17:36 ` Yinghai Lu
@ 2012-12-16 22:31   ` Rafael J. Wysocki
  2012-12-17  7:00     ` Yinghai Lu
  0 siblings, 1 reply; 13+ messages in thread
From: Rafael J. Wysocki @ 2012-12-16 22:31 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: ACPI Devel Maling List, LKML, Bjorn Helgaas, Toshi Kani,
	Yijing Wang, Jiang Liu, Wen Congyang

On Sunday, December 16, 2012 09:36:49 AM Yinghai Lu wrote:
> On Sun, Dec 16, 2012 at 5:47 AM, Rafael J. Wysocki <rjw@sisk.pl> wrote:
> > Hi All,
> >
> > This series is on top of the one I sent on Thursday:
> >
> > https://lkml.org/lkml/2012/12/13/632
> >
> > It goes one step farther and makes some simplifications that become possible
> > after applying that patchset.
> >
> > [1/6] Fold acpi_pci_root_start() into acpi_pci_root_add()
> > [2/6] Remove acpi_start_single_object() and acpi_bus_start()
> > [3/6] Remove the arguments of acpi_bus_add() that are not used
> > [4/6] Drop the second argument of acpi_bus_scan()
> > [5/6] Replace ACPI device add_type field with a match_driver flag
> > [6/6] Make acpi_bus_scan() and acpi_bus_add() take only one argument
> >
> > It survives booting on Toshiba Portege R500 without any visible issues.
> 
> Do you have git branch that i could test?

There you go:

git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git acpi-scan-temp

> I'd like to rebase for-pci-root-bus-hotplug patches, so what should be base?

I'll need to talk about that with Bjorn.  Hopefully he'll be reachable tomorrow.

> It would be hard for me to base on your acpi tree and Bjorn's pci tree.

We'll work out something.

Thanks,
Rafael


-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/6] ACPI: Simplify namespace scanning for devices
  2012-12-16 22:31   ` Rafael J. Wysocki
@ 2012-12-17  7:00     ` Yinghai Lu
  2012-12-17  7:51       ` Rafael J. Wysocki
  0 siblings, 1 reply; 13+ messages in thread
From: Yinghai Lu @ 2012-12-17  7:00 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: ACPI Devel Maling List, LKML, Bjorn Helgaas, Toshi Kani,
	Yijing Wang, Jiang Liu, Wen Congyang

On Sun, Dec 16, 2012 at 2:31 PM, Rafael J. Wysocki <rjw@sisk.pl> wrote:
> On Sunday, December 16, 2012 09:36:49 AM Yinghai Lu wrote:
> There you go:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git acpi-scan-temp
>
>> I'd like to rebase for-pci-root-bus-hotplug patches, so what should be base?
>
rebase all pci patches (without four patches about drivers_autoprobe
and remove acpi_pci_root_start)
on top your branch.

root bus hotplug seems work well without problem.

Thanks a lot.

Yinghai

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/6] ACPI: Simplify namespace scanning for devices
  2012-12-17  7:00     ` Yinghai Lu
@ 2012-12-17  7:51       ` Rafael J. Wysocki
  0 siblings, 0 replies; 13+ messages in thread
From: Rafael J. Wysocki @ 2012-12-17  7:51 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: ACPI Devel Maling List, LKML, Bjorn Helgaas, Toshi Kani,
	Yijing Wang, Jiang Liu, Wen Congyang

On Sunday, December 16, 2012 11:00:04 PM Yinghai Lu wrote:
> On Sun, Dec 16, 2012 at 2:31 PM, Rafael J. Wysocki <rjw@sisk.pl> wrote:
> > On Sunday, December 16, 2012 09:36:49 AM Yinghai Lu wrote:
> > There you go:
> >
> > git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git acpi-scan-temp
> >
> >> I'd like to rebase for-pci-root-bus-hotplug patches, so what should be base?
> >
> rebase all pci patches (without four patches about drivers_autoprobe
> and remove acpi_pci_root_start)
> on top your branch.
> 
> root bus hotplug seems work well without problem.
> 
> Thanks a lot.

Great, thanks for testing. :-)

Rafael


-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2012-12-17  7:46 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-16 13:47 [PATCH 0/6] ACPI: Simplify namespace scanning for devices Rafael J. Wysocki
2012-12-16 13:49 ` [PATCH 1/6] ACPI / PCI: Fold acpi_pci_root_start() into acpi_pci_root_add() Rafael J. Wysocki
2012-12-16 13:51 ` [PATCH 2/6] ACPI: Remove acpi_start_single_object() and acpi_bus_start() Rafael J. Wysocki
2012-12-16 13:51 ` [PATCH 3/6] ACPI: Remove the arguments of acpi_bus_add() that are not used Rafael J. Wysocki
2012-12-16 13:52 ` [PATCH 4/6] ACPI: Drop the second argument of acpi_bus_scan() Rafael J. Wysocki
2012-12-16 13:53 ` [PATCH 5/6] ACPI: Replace ACPI device add_type field with a match_driver flag Rafael J. Wysocki
2012-12-16 13:55 ` [PATCH 6/6] ACPI: Make acpi_bus_scan() and acpi_bus_add() take only one argument Rafael J. Wysocki
2012-12-16 15:59 ` [PATCH 0/6] ACPI: Simplify namespace scanning for devices Jiang Liu
2012-12-16 22:29   ` Rafael J. Wysocki
2012-12-16 17:36 ` Yinghai Lu
2012-12-16 22:31   ` Rafael J. Wysocki
2012-12-17  7:00     ` Yinghai Lu
2012-12-17  7:51       ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).