[PATCH 1/5] ACPI / scan: Do not bind ACPI drivers to objects with scan handlers

From: Rafael J. Wysocki
Date: Wed Jun 12 2013 - 19:19:25 EST


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

ACPI drivers generally should not be bound to device objects having
scan handlers attatched to them.

However, there is one exception which is the container scan handler.
Namely, it turns out that some BIOSes (on ia64 HP rx2600 in
particular) put container device IDs into the same objects along with
some other more specific ones which makes those device objects match
the container scan handler as well as some other scan handlers or
ACPI drivers. Fortunately, though, the container scan handler is
only needed for hotplug to work and it doesn't actually do anything
to the device objects in question, so it is really OK to have both
the container scan handler and something else attached to the same
device object at the same time.

Following that, make acpi_device_probe() fail with -EINVAL if the
device object being probed has an ACPI scan handler that is not the
container scan handler attached to it.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
---
drivers/acpi/container.c | 5 +++--
drivers/acpi/internal.h | 10 ++++++++++
drivers/acpi/scan.c | 4 ++++
drivers/acpi/video.c | 3 ---
4 files changed, 17 insertions(+), 5 deletions(-)

Index: linux-pm/drivers/acpi/container.c
===================================================================
--- linux-pm.orig/drivers/acpi/container.c
+++ linux-pm/drivers/acpi/container.c
@@ -51,7 +51,7 @@ static int container_device_attach(struc
return 1;
}

-static struct acpi_scan_handler container_handler = {
+struct acpi_scan_handler container_scan_handler = {
.ids = container_device_ids,
.attach = container_device_attach,
.hotplug = {
@@ -62,5 +62,6 @@ static struct acpi_scan_handler containe

void __init acpi_container_init(void)
{
- acpi_scan_add_handler_with_hotplug(&container_handler, "container");
+ acpi_scan_add_handler_with_hotplug(&container_scan_handler,
+ "container");
}
Index: linux-pm/drivers/acpi/internal.h
===================================================================
--- linux-pm.orig/drivers/acpi/internal.h
+++ linux-pm/drivers/acpi/internal.h
@@ -37,8 +37,18 @@ void acpi_processor_init(void);
void acpi_platform_init(void);
int acpi_sysfs_init(void);
#ifdef CONFIG_ACPI_CONTAINER
+extern struct acpi_scan_handler container_scan_handler;
+
+static inline struct acpi_scan_handler *acpi_container_scan_handler(void)
+{
+ return &container_scan_handler;
+}
void acpi_container_init(void);
#else
+static inline struct acpi_scan_handler *acpi_container_scan_handler(void)
+{
+ return NULL;
+}
static inline void acpi_container_init(void) {}
#endif
#ifdef CONFIG_ACPI_HOTPLUG_MEMORY
Index: linux-pm/drivers/acpi/scan.c
===================================================================
--- linux-pm.orig/drivers/acpi/scan.c
+++ linux-pm/drivers/acpi/scan.c
@@ -939,6 +939,10 @@ static int acpi_device_probe(struct devi
struct acpi_driver *acpi_drv = to_acpi_driver(dev->driver);
int ret;

+ if (acpi_dev->handler
+ && acpi_dev->handler != acpi_container_scan_handler())
+ return -EINVAL;
+
if (!acpi_drv->ops.add)
return -ENOSYS;

Index: linux-pm/drivers/acpi/video.c
===================================================================
--- linux-pm.orig/drivers/acpi/video.c
+++ linux-pm/drivers/acpi/video.c
@@ -1722,9 +1722,6 @@ static int acpi_video_bus_add(struct acp
int error;
acpi_status status;

- if (device->handler)
- return -EINVAL;
-
status = acpi_walk_namespace(ACPI_TYPE_DEVICE,
device->parent->handle, 1,
acpi_video_bus_match, NULL,

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/