All of lore.kernel.org
 help / color / mirror / Atom feed
From: Len Brown <len.brown@intel.com>
To: linux-acpi@vger.kernel.org
Cc: Li Shaohua <shaohua.li@intel.com>,
	Zhang Rui <rui.zhang@intel.com>, Len Brown <len.brown@intel.com>
Subject: [PATCH 8/13] ACPI: add acpi_bus_ops in acpi_device
Date: Fri, 24 Nov 2006 00:17:36 -0500	[thread overview]
Message-ID: <11643454711040-git-send-email-len.brown@intel.com> (raw)
Message-ID: <b23b4763ca902ef393e87c81177a0b6d6f8388ae.1164343921.git.len.brown@intel.com> (raw)
In-Reply-To: <11643454703489-git-send-email-len.brown@intel.com>
In-Reply-To: <bd119392c453771fdb994728a2568c2e3f17705d.1164343921.git.len.brown@intel.com>

From: Li Shaohua <shaohua.li@intel.com>

Add acpi_bus_ops in acpi_device to support acpi hot plug.

NOTE:	Two methods .add and .start in acpi_driver.ops are
	called separately to probe ACPI devices, while only
	.probe method is called in driver model.
	As executing .add and .start separately is critical
	for ACPI device hot plug, we use acpi_bus_ops to
	distinguish different code path.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
---
 drivers/acpi/scan.c     |   55 ++++++++++++++++++++++++-----------------------
 include/acpi/acpi_bus.h |    1 +
 2 files changed, 29 insertions(+), 27 deletions(-)

diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 97f6bbd..2a82645 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -212,7 +212,8 @@ static int acpi_device_probe(struct devi
 
 	ret = acpi_bus_driver_init(acpi_dev, acpi_drv);
 	if (!ret) {
-		acpi_start_single_object(acpi_dev);
+		if (acpi_dev->bus_ops.acpi_op_start)
+			acpi_start_single_object(acpi_dev);
 		ACPI_DEBUG_PRINT((ACPI_DB_INFO,
 			"Found driver [%s] for device [%s]\n",
 			acpi_drv->name, acpi_dev->pnp.bus_id));
@@ -305,7 +306,6 @@ static void acpi_device_unregister(struc
 		list_del(&device->g_list);
 
 	list_del(&device->wakeup_list);
-
 	spin_unlock(&acpi_device_lock);
 
 	acpi_detach_data(device->handle, acpi_bus_data_handler);
@@ -876,7 +876,8 @@ static int acpi_bus_remove(struct acpi_d
 
 static int
 acpi_add_single_object(struct acpi_device **child,
-		       struct acpi_device *parent, acpi_handle handle, int type)
+		       struct acpi_device *parent, acpi_handle handle, int type,
+			struct acpi_bus_ops *ops)
 {
 	int result = 0;
 	struct acpi_device *device = NULL;
@@ -894,6 +895,8 @@ acpi_add_single_object(struct acpi_devic
 
 	device->handle = handle;
 	device->parent = parent;
+	device->bus_ops = *ops; /* workround for not call .start */
+
 
 	acpi_device_get_busid(device, handle, type);
 
@@ -1079,14 +1082,14 @@ static int acpi_bus_scan(struct acpi_dev
 
 		if (ops->acpi_op_add)
 			status = acpi_add_single_object(&child, parent,
-							chandle, type);
+				chandle, type, ops);
 		else
 			status = acpi_bus_get_device(chandle, &child);
 
 		if (ACPI_FAILURE(status))
 			continue;
 
-		if (ops->acpi_op_start) {
+		if (ops->acpi_op_start && !(ops->acpi_op_add)) {
 			status = acpi_start_single_object(child);
 			if (ACPI_FAILURE(status))
 				continue;
@@ -1124,13 +1127,13 @@ acpi_bus_add(struct acpi_device **child,
 	int result;
 	struct acpi_bus_ops ops;
 
+	memset(&ops, 0, sizeof(ops));
+	ops.acpi_op_add = 1;
 
-	result = acpi_add_single_object(child, parent, handle, type);
-	if (!result) {
-		memset(&ops, 0, sizeof(ops));
-		ops.acpi_op_add = 1;
+	result = acpi_add_single_object(child, parent, handle, type, &ops);
+	if (!result)
 		result = acpi_bus_scan(*child, &ops);
-	}
+
 	return result;
 }
 
@@ -1216,28 +1219,30 @@ static int acpi_bus_scan_fixed(struct ac
 {
 	int result = 0;
 	struct acpi_device *device = NULL;
-
+	struct acpi_bus_ops ops;
 
 	if (!root)
 		return -ENODEV;
 
+	memset(&ops, 0, sizeof(ops));
+	ops.acpi_op_add = 1;
+	ops.acpi_op_start = 1;
+
 	/*
 	 * Enumerate all fixed-feature devices.
 	 */
 	if (acpi_fadt.pwr_button == 0) {
 		result = acpi_add_single_object(&device, acpi_root,
 						NULL,
-						ACPI_BUS_TYPE_POWER_BUTTON);
-		if (!result)
-			result = acpi_start_single_object(device);
+						ACPI_BUS_TYPE_POWER_BUTTON,
+						&ops);
 	}
 
 	if (acpi_fadt.sleep_button == 0) {
 		result = acpi_add_single_object(&device, acpi_root,
 						NULL,
-						ACPI_BUS_TYPE_SLEEP_BUTTON);
-		if (!result)
-			result = acpi_start_single_object(device);
+						ACPI_BUS_TYPE_SLEEP_BUTTON,
+						&ops);
 	}
 
 	return result;
@@ -1252,6 +1257,10 @@ static int __init acpi_scan_init(void)
 	if (acpi_disabled)
 		return 0;
 
+	memset(&ops, 0, sizeof(ops));
+	ops.acpi_op_add = 1;
+	ops.acpi_op_start = 1;
+
 	result = bus_register(&acpi_bus_type);
 	if (result) {
 		/* We don't want to quit even if we failed to add suspend/resume */
@@ -1262,11 +1271,7 @@ static int __init acpi_scan_init(void)
 	 * Create the root device in the bus's device tree
 	 */
 	result = acpi_add_single_object(&acpi_root, NULL, ACPI_ROOT_OBJECT,
-					ACPI_BUS_TYPE_SYSTEM);
-	if (result)
-		goto Done;
-
-	result = acpi_start_single_object(acpi_root);
+					ACPI_BUS_TYPE_SYSTEM, &ops);
 	if (result)
 		goto Done;
 
@@ -1274,12 +1279,8 @@ static int __init acpi_scan_init(void)
 	 * Enumerate devices in the ACPI namespace.
 	 */
 	result = acpi_bus_scan_fixed(acpi_root);
-	if (!result) {
-		memset(&ops, 0, sizeof(ops));
-		ops.acpi_op_add = 1;
-		ops.acpi_op_start = 1;
+	if (!result)
 		result = acpi_bus_scan(acpi_root, &ops);
-	}
 
 	if (result)
 		acpi_device_unregister(acpi_root, ACPI_BUS_REMOVAL_NORMAL);
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index d409d9a..b7baac7 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -300,6 +300,7 @@ struct acpi_device {
 	struct acpi_driver *driver;
 	void *driver_data;
 	struct device dev;
+	struct acpi_bus_ops bus_ops;	/* workaround for different code path for hotplug */
 };
 
 #define acpi_driver_data(d)	((d)->driver_data)
-- 
1.4.4.g59427

  parent reply	other threads:[~2006-11-24  5:14 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-24  5:17 contents of sysfs branch Len Brown
2006-11-24  5:17 ` [PATCH 1/13] ACPI: clean up scan.c Len Brown
2006-11-24  5:17   ` Len Brown
2006-11-24  5:17   ` [PATCH 2/13] ACPI: rename some functions Len Brown
2006-11-24  5:17     ` Len Brown
2006-11-24  5:17   ` [PATCH 3/13] ACPI: add device_driver and helper functions Len Brown
2006-11-24  5:17     ` Len Brown
2006-11-24  5:17   ` [PATCH 4/13] ACPI: add ACPI bus_type for driver model Len Brown
2006-11-24  5:17     ` Len Brown
2006-11-24  5:17   ` [PATCH 5/13] ACPI: change registration interface to follow " Len Brown
2006-11-24  5:17     ` Len Brown
2006-11-24  5:17   ` [PATCH 6/13] ACPI: adjust init order Len Brown
2006-11-24  5:17     ` Len Brown
2006-11-24  5:17   ` [PATCH 7/13] ACPI: convert to sysfs framework Len Brown
2006-11-24  5:17     ` Len Brown
2006-11-24  5:17   ` Len Brown [this message]
2006-11-24  5:17     ` [PATCH 8/13] ACPI: add acpi_bus_ops in acpi_device Len Brown
2006-11-24  5:17   ` [PATCH 9/13] ACPI: add acpi_bus_removal_type " Len Brown
2006-11-24  5:17     ` Len Brown
2006-11-24  5:17   ` [PATCH 10/13] ACPI: consolidate two motherboard drivers into one Len Brown
2006-11-24  5:17     ` Len Brown
2006-11-24  5:17   ` [PATCH 11/13] ACPI: Convert ACPI PCI .bind/.unbind to use PCI bridge driver Len Brown
2006-11-24  5:17     ` Len Brown
2006-11-24  5:17   ` [PATCH 12/13] ACPI: Set fake hid for non-PNPID ACPI devices Len Brown
2006-11-24  5:17     ` Len Brown
2006-11-24  5:17   ` [PATCH 13/13] ACPI: use unique number as bus_id of ACPI device in sysfs Len Brown
2006-11-24  5:17     ` Len Brown
2006-11-24  6:36       ` Len Brown
2006-11-24  9:40         ` Zhang Rui
2006-11-26  5:10           ` Zhang Rui
2006-11-27  6:10             ` Len Brown
2006-11-27  6:35               ` Zhang Rui
2006-11-27  6:06           ` Len Brown
2006-12-01  8:55 ` updated patches of sysfs branch Zhang Rui

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=11643454711040-git-send-email-len.brown@intel.com \
    --to=len.brown@intel.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=rui.zhang@intel.com \
    --cc=shaohua.li@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.