From d43ec68e9837dfa6618ab473622683fdbf6e68a9 Mon Sep 17 00:00:00 2001 From: Patrick Mochel Date: Thu, 7 Dec 2006 20:56:23 +0800 Subject: ACPI: add device_driver and hepler functions Add device_driver into acpi_driver for driver model. Add helper functions 'to_acpi_device' and 'to_acpi_driver' to get structure acpi_device/acpi_driver by device/device_driver. Signed-off-by: Zhang Rui Signed-off-by: Len Brown --- include/acpi/acpi_bus.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include/acpi/acpi_bus.h') diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index fdd10953b2b..a09538eb61e 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -136,6 +136,7 @@ struct acpi_driver { atomic_t references; char *ids; /* Supported Hardware IDs */ struct acpi_device_ops ops; + struct device_driver drv; }; /* @@ -301,6 +302,8 @@ struct acpi_device { }; #define acpi_driver_data(d) ((d)->driver_data) +#define to_acpi_device(d) container_of(d, struct acpi_device, dev) +#define to_acpi_driver(d) container_of(d, struct acpi_driver, drv) /* * Events -- cgit v1.2.3 From 5d9464a46918ced087c351a10f38cee95725f85b Mon Sep 17 00:00:00 2001 From: Patrick Mochel Date: Thu, 7 Dec 2006 20:56:27 +0800 Subject: ACPI: add ACPI bus_type for driver model Add ACPI bus_type for Linux driver model. 1. .shutdown method is added into acpi_driver.ops needed by bus_type operations. 2. remove useless parameter 'int state' in .resume method. 3. change parameter 'int state' to 'pm_message_t state' in .suspend method. Note: The new .uevent method mark ACPI drivers by PNPID instead of by name. Udev script needs to look for "HWID=" or "COMPTID=" to load ACPI drivers as a result. Signed-off-by: Li Shaohua Signed-off-by: Zhang Rui Signed-off-by: Len Brown --- include/acpi/acpi_bus.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'include/acpi/acpi_bus.h') diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index a09538eb61e..d7dd5261545 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -92,13 +92,14 @@ typedef int (*acpi_op_remove) (struct acpi_device * device, int type); typedef int (*acpi_op_lock) (struct acpi_device * device, int type); typedef int (*acpi_op_start) (struct acpi_device * device); typedef int (*acpi_op_stop) (struct acpi_device * device, int type); -typedef int (*acpi_op_suspend) (struct acpi_device * device, int state); -typedef int (*acpi_op_resume) (struct acpi_device * device, int state); +typedef int (*acpi_op_suspend) (struct acpi_device * device, pm_message_t state); +typedef int (*acpi_op_resume) (struct acpi_device * device); typedef int (*acpi_op_scan) (struct acpi_device * device); typedef int (*acpi_op_bind) (struct acpi_device * device); typedef int (*acpi_op_unbind) (struct acpi_device * device); typedef int (*acpi_op_match) (struct acpi_device * device, struct acpi_driver * driver); +typedef int (*acpi_op_shutdown) (struct acpi_device * device); struct acpi_bus_ops { u32 acpi_op_add:1; @@ -112,7 +113,8 @@ struct acpi_bus_ops { u32 acpi_op_bind:1; u32 acpi_op_unbind:1; u32 acpi_op_match:1; - u32 reserved:21; + u32 acpi_op_shutdown:1; + u32 reserved:20; }; struct acpi_device_ops { @@ -127,6 +129,7 @@ struct acpi_device_ops { acpi_op_bind bind; acpi_op_unbind unbind; acpi_op_match match; + acpi_op_shutdown shutdown; }; struct acpi_driver { -- cgit v1.2.3 From 1890a97ab3f66d1e99768439f8067608b9b97fe3 Mon Sep 17 00:00:00 2001 From: Patrick Mochel Date: Thu, 7 Dec 2006 20:56:31 +0800 Subject: ACPI: change registration interface to follow driver model ACPI device/driver registration Interfaces are modified to follow Linux driver model. Signed-off-by: Li Shaohua Signed-off-by: Zhang Rui Signed-off-by: Len Brown --- include/acpi/acpi_bus.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'include/acpi/acpi_bus.h') diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index d7dd5261545..807acf69a70 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -133,13 +133,12 @@ struct acpi_device_ops { }; struct acpi_driver { - struct list_head node; char name[80]; char class[80]; - atomic_t references; char *ids; /* Supported Hardware IDs */ struct acpi_device_ops ops; struct device_driver drv; + struct module *owner; }; /* -- cgit v1.2.3 From f883d9db008deb20d4969c26475100cec2b7f6f8 Mon Sep 17 00:00:00 2001 From: Patrick Mochel Date: Thu, 7 Dec 2006 20:56:38 +0800 Subject: ACPI: convert to sysfs framework Setup new sysfs framework 1. Remove /sys/firmware/acpi 2. Add ACPI device in device tree. File "eject" for every device that has _EJ0 method is moved from /sys/firmware to /sys/devices. Operation on this file is exactly the same as before. i.e. echo 1 to "eject" will cause hot removal of this device. Corresponding changes should be made in userspace for hot removal. Signed-off-by: Li Shaohua Signed-off-by: Zhang Rui Signed-off-by: Len Brown --- include/acpi/acpi_bus.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include/acpi/acpi_bus.h') diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index 807acf69a70..598fab35281 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -299,7 +299,6 @@ struct acpi_device { struct acpi_device_ops ops; struct acpi_driver *driver; void *driver_data; - struct kobject kobj; struct device dev; }; -- cgit v1.2.3 From c4168bff32e218b8400cb48b48adb9b7f7bb31b8 Mon Sep 17 00:00:00 2001 From: Li Shaohua Date: Thu, 7 Dec 2006 20:56:41 +0800 Subject: ACPI: add acpi_bus_ops in acpi_device 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 Signed-off-by: Len Brown --- include/acpi/acpi_bus.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/acpi/acpi_bus.h') diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index 598fab35281..8976dbea63c 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) -- cgit v1.2.3 From 96333578b023957537c3e98b50af7f3b7e08e411 Mon Sep 17 00:00:00 2001 From: Li Shaohua Date: Thu, 7 Dec 2006 20:56:46 +0800 Subject: ACPI: add acpi_bus_removal_type in acpi_device Add removal_type in structure acpi_device for hot removal. ACPI_BUS_REMOVAL_EJECT is used for ACPI device hot removal. Only one parameter is allowed in .remove method due to driver model. So removal_type is added to indicate different removal type. Signed-off-by: Zhang Rui Signed-off-by: Len Brown --- include/acpi/acpi_bus.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/acpi/acpi_bus.h') diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index 8976dbea63c..58dc8f65186 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -301,6 +301,7 @@ struct acpi_device { void *driver_data; struct device dev; struct acpi_bus_ops bus_ops; /* workaround for different code path for hotplug */ + enum acpi_bus_removal_type removal_type; /* indicate for different removal type */ }; #define acpi_driver_data(d) ((d)->driver_data) -- cgit v1.2.3 From ae8433324be16673c75951986dcf85f29c090557 Mon Sep 17 00:00:00 2001 From: Zhang Rui Date: Thu, 7 Dec 2006 20:57:10 +0800 Subject: ACPI: Set fake hid for non-PNPID ACPI devices We do this mainly because: 1. hid is used to match ACPI devices and drivers. .match method which is incompatible to driver model can be deleted from acpi_driver.ops then. 2. As the .uevent method mark ACPI drivers by PNPID, fake hid is set to non-PNPID devices so that udev script can load the right ACPI driver by looking for "HWID = " or "COMPTID = ". Signed-off-by: Zhang Rui Signed-off-by: Len Brown --- include/acpi/acpi_bus.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'include/acpi/acpi_bus.h') diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index 58dc8f65186..a6b4037beea 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -97,8 +97,6 @@ typedef int (*acpi_op_resume) (struct acpi_device * device); typedef int (*acpi_op_scan) (struct acpi_device * device); typedef int (*acpi_op_bind) (struct acpi_device * device); typedef int (*acpi_op_unbind) (struct acpi_device * device); -typedef int (*acpi_op_match) (struct acpi_device * device, - struct acpi_driver * driver); typedef int (*acpi_op_shutdown) (struct acpi_device * device); struct acpi_bus_ops { @@ -112,9 +110,8 @@ struct acpi_bus_ops { u32 acpi_op_scan:1; u32 acpi_op_bind:1; u32 acpi_op_unbind:1; - u32 acpi_op_match:1; u32 acpi_op_shutdown:1; - u32 reserved:20; + u32 reserved:21; }; struct acpi_device_ops { @@ -128,7 +125,6 @@ struct acpi_device_ops { acpi_op_scan scan; acpi_op_bind bind; acpi_op_unbind unbind; - acpi_op_match match; acpi_op_shutdown shutdown; }; -- cgit v1.2.3 From bb0958544f3c7c016b2a3025ab3694363e403aa1 Mon Sep 17 00:00:00 2001 From: Zhang Rui Date: Thu, 4 Jan 2007 15:03:18 +0800 Subject: ACPI: use more understandable bus_id for ACPI devices Some of the ACPI devices use the internal fake hids which are exposed to userspace as devces' bus_id after sysfs conversion. To make it more friendly, we convert them to more understandable strings. For those devices w/o PNPids, we use "device:instance_no" as the bus_id instead of "PNPIDNON:instance_no". Signed-off-by: Zhang Rui Signed-off-by: Len Brown --- include/acpi/acpi_bus.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/acpi/acpi_bus.h') diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index a6b4037beea..e7df8423d15 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -184,7 +184,7 @@ struct acpi_device_dir { typedef char acpi_bus_id[5]; typedef unsigned long acpi_bus_address; -typedef char acpi_hardware_id[9]; +typedef char acpi_hardware_id[15]; typedef char acpi_unique_id[9]; typedef char acpi_device_name[40]; typedef char acpi_device_class[20]; -- cgit v1.2.3