linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] ACPI autoloading - ACPICA adjustance
@ 2007-06-17 20:24 Thomas Renninger
  2007-06-17 20:27 ` [PATCH 2/3] ACPI autoloading - Create acpi alias interface Thomas Renninger
  2007-07-03  7:58 ` [PATCH 1/3] ACPI autoloading - ACPICA adjustance Len Brown
  0 siblings, 2 replies; 19+ messages in thread
From: Thomas Renninger @ 2007-06-17 20:24 UTC (permalink / raw)
  To: Len Brown; +Cc: linux-kernel, linux-acpi

[-- Attachment #1: Type: text/plain, Size: 6844 bytes --]

Define standardized HIDs - Rename current acpi_device_id to __acpi_device_id

Signed-off-by: Thomas Renninger <trenn@suse.de>

---
 drivers/acpi/events/evrgnini.c    |    2 +-
 drivers/acpi/namespace/nsxfeval.c |    2 +-
 drivers/acpi/utilities/uteval.c   |    4 ++--
 include/acpi/acpi_bus.h           |    5 +++--
 include/acpi/acpi_drivers.h       |   33 +++++++++++++++++++++++++--------
 include/acpi/actypes.h            |    6 +++---
 include/acpi/acutils.h            |    4 ++--
 7 files changed, 37 insertions(+), 19 deletions(-)

Index: linux-2.6.22-rc4/drivers/acpi/events/evrgnini.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/acpi/events/evrgnini.c
+++ linux-2.6.22-rc4/drivers/acpi/events/evrgnini.c
@@ -377,7 +377,7 @@ static u8 acpi_ev_match_pci_root_bridge(
 static u8 acpi_ev_is_pci_root_bridge(struct acpi_namespace_node *node)
 {
 	acpi_status status;
-	struct acpi_device_id hid;
+	struct __acpi_device_id hid;
 	struct acpi_compatible_id_list *cid;
 	acpi_native_uint i;
 
Index: linux-2.6.22-rc4/drivers/acpi/utilities/uteval.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/acpi/utilities/uteval.c
+++ linux-2.6.22-rc4/drivers/acpi/utilities/uteval.c
@@ -410,7 +410,7 @@ acpi_ut_copy_id_string(char *destination
 
 acpi_status
 acpi_ut_execute_HID(struct acpi_namespace_node *device_node,
-		    struct acpi_device_id *hid)
+		    struct __acpi_device_id *hid)
 {
 	union acpi_operand_object *obj_desc;
 	acpi_status status;
@@ -612,7 +612,7 @@ acpi_ut_execute_CID(struct acpi_namespac
 
 acpi_status
 acpi_ut_execute_UID(struct acpi_namespace_node *device_node,
-		    struct acpi_device_id *uid)
+		    struct __acpi_device_id *uid)
 {
 	union acpi_operand_object *obj_desc;
 	acpi_status status;
Index: linux-2.6.22-rc4/include/acpi/actypes.h
===================================================================
--- linux-2.6.22-rc4.orig/include/acpi/actypes.h
+++ linux-2.6.22-rc4/include/acpi/actypes.h
@@ -809,7 +809,7 @@ acpi_status(*acpi_walk_callback) (acpi_h
 
 /* Common string version of device HIDs and UIDs */
 
-struct acpi_device_id {
+struct __acpi_device_id {
 	char value[ACPI_DEVICE_ID_LENGTH];
 };
 
@@ -859,8 +859,8 @@ struct acpi_device_info {
 	u32 valid;		/* Indicates which fields below are valid */
 	u32 current_status;	/* _STA value */
 	acpi_integer address;	/* _ADR value if any */
-	struct acpi_device_id hardware_id;	/* _HID value if any */
-	struct acpi_device_id unique_id;	/* _UID value if any */
+	struct __acpi_device_id hardware_id;	/* _HID value if any */
+	struct __acpi_device_id unique_id;	/* _UID value if any */
 	u8 highest_dstates[4];	/* _sx_d values: 0xFF indicates not valid */
 	struct acpi_compatible_id_list compatibility_id;	/* List of _CIDs if any */
 };
Index: linux-2.6.22-rc4/include/acpi/acutils.h
===================================================================
--- linux-2.6.22-rc4.orig/include/acpi/acutils.h
+++ linux-2.6.22-rc4/include/acpi/acutils.h
@@ -354,7 +354,7 @@ acpi_ut_evaluate_numeric_object(char *ob
 
 acpi_status
 acpi_ut_execute_HID(struct acpi_namespace_node *device_node,
-		    struct acpi_device_id *hid);
+		    struct __acpi_device_id *hid);
 
 acpi_status
 acpi_ut_execute_CID(struct acpi_namespace_node *device_node,
@@ -366,7 +366,7 @@ acpi_ut_execute_STA(struct acpi_namespac
 
 acpi_status
 acpi_ut_execute_UID(struct acpi_namespace_node *device_node,
-		    struct acpi_device_id *uid);
+		    struct __acpi_device_id *uid);
 
 acpi_status
 acpi_ut_execute_sxds(struct acpi_namespace_node *device_node, u8 * highest);
Index: linux-2.6.22-rc4/include/acpi/acpi_bus.h
===================================================================
--- linux-2.6.22-rc4.orig/include/acpi/acpi_bus.h
+++ linux-2.6.22-rc4/include/acpi/acpi_bus.h
@@ -131,7 +131,7 @@ struct acpi_device_ops {
 struct acpi_driver {
 	char name[80];
 	char class[80];
-	char *ids;		/* Supported Hardware IDs */
+	const struct acpi_device_id *ids; /* Supported Hardware IDs */
 	struct acpi_device_ops ops;
 	struct device_driver drv;
 	struct module *owner;
@@ -340,7 +340,8 @@ int acpi_bus_add(struct acpi_device **ch
 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_ids(struct acpi_device *device, char *ids);
+int acpi_match_device_ids(struct acpi_device *device,
+			  const struct acpi_device_id *ids);
 int acpi_create_dir(struct acpi_device *);
 void acpi_remove_dir(struct acpi_device *);
 
Index: linux-2.6.22-rc4/include/acpi/acpi_drivers.h
===================================================================
--- linux-2.6.22-rc4.orig/include/acpi/acpi_drivers.h
+++ linux-2.6.22-rc4/include/acpi/acpi_drivers.h
@@ -34,16 +34,33 @@
 #define ACPI_BUS_COMPONENT		0x00010000
 #define ACPI_SYSTEM_COMPONENT		0x02000000
 
-/* _HID definitions */
+/*
+  _HID definitions
+  HIDs starting with 'X' are self defined here and are used for devices where
+  a HID does not exist in spec.
+  HIDs must conform to (ACPI spec - 6.1.4):
 
-#define ACPI_POWER_HID			"power_resource"
+  Numeric 32-bit compressed EISA type ID are not supported (never seen one as
+  an ACPI HID?)
+
+  A valid PNP ID must be of the form AAA#### where A is an uppercase letter
+  and # is a hex digit.
+  A valid ACPI ID must be of the form ACPI#### where # is a hex digit.
+
+  and our self-defined: XAAA#### where A is an uppercase letter and # is a hex
+  digit.
+
+*/
+
+#define ACPI_POWER_HID			"XPWR0001"
 #define ACPI_PROCESSOR_HID		"ACPI0007"
-#define ACPI_SYSTEM_HID			"acpi_system"
-#define ACPI_THERMAL_HID		"thermal"
-#define ACPI_BUTTON_HID_POWERF		"button_power"
-#define ACPI_BUTTON_HID_SLEEPF		"button_sleep"
-#define ACPI_VIDEO_HID			"video"
-#define ACPI_BAY_HID			"bay"
+#define ACPI_SYSTEM_HID			"XSYS0001"
+#define ACPI_THERMAL_HID		"XTHM0001"
+#define ACPI_BUTTON_HID_POWERF		"XPBT0001"
+#define ACPI_BUTTON_HID_SLEEPF		"XSBT0001"
+#define ACPI_VIDEO_HID			"XVID0001"
+#define ACPI_BAY_HID			"XBAY0001"
+
 /* --------------------------------------------------------------------------
                                        PCI
    -------------------------------------------------------------------------- */
Index: linux-2.6.22-rc4/drivers/acpi/namespace/nsxfeval.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/acpi/namespace/nsxfeval.c
+++ linux-2.6.22-rc4/drivers/acpi/namespace/nsxfeval.c
@@ -440,7 +440,7 @@ acpi_ns_get_device_callback(acpi_handle 
 	acpi_status status;
 	struct acpi_namespace_node *node;
 	u32 flags;
-	struct acpi_device_id hid;
+	struct __acpi_device_id hid;
 	struct acpi_compatible_id_list *cid;
 	acpi_native_uint i;
 


[-- Attachment #2: acpica_rename_device_id.patch --]
[-- Type: text/x-patch, Size: 6843 bytes --]

Define standardized HIDs - Rename current acpi_device_id to __acpi_device_id

Signed-off-by: Thomas Renninger <trenn@suse.de>

---
 drivers/acpi/events/evrgnini.c    |    2 +-
 drivers/acpi/namespace/nsxfeval.c |    2 +-
 drivers/acpi/utilities/uteval.c   |    4 ++--
 include/acpi/acpi_bus.h           |    5 +++--
 include/acpi/acpi_drivers.h       |   33 +++++++++++++++++++++++++--------
 include/acpi/actypes.h            |    6 +++---
 include/acpi/acutils.h            |    4 ++--
 7 files changed, 37 insertions(+), 19 deletions(-)

Index: linux-2.6.22-rc4/drivers/acpi/events/evrgnini.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/acpi/events/evrgnini.c
+++ linux-2.6.22-rc4/drivers/acpi/events/evrgnini.c
@@ -377,7 +377,7 @@ static u8 acpi_ev_match_pci_root_bridge(
 static u8 acpi_ev_is_pci_root_bridge(struct acpi_namespace_node *node)
 {
 	acpi_status status;
-	struct acpi_device_id hid;
+	struct __acpi_device_id hid;
 	struct acpi_compatible_id_list *cid;
 	acpi_native_uint i;
 
Index: linux-2.6.22-rc4/drivers/acpi/utilities/uteval.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/acpi/utilities/uteval.c
+++ linux-2.6.22-rc4/drivers/acpi/utilities/uteval.c
@@ -410,7 +410,7 @@ acpi_ut_copy_id_string(char *destination
 
 acpi_status
 acpi_ut_execute_HID(struct acpi_namespace_node *device_node,
-		    struct acpi_device_id *hid)
+		    struct __acpi_device_id *hid)
 {
 	union acpi_operand_object *obj_desc;
 	acpi_status status;
@@ -612,7 +612,7 @@ acpi_ut_execute_CID(struct acpi_namespac
 
 acpi_status
 acpi_ut_execute_UID(struct acpi_namespace_node *device_node,
-		    struct acpi_device_id *uid)
+		    struct __acpi_device_id *uid)
 {
 	union acpi_operand_object *obj_desc;
 	acpi_status status;
Index: linux-2.6.22-rc4/include/acpi/actypes.h
===================================================================
--- linux-2.6.22-rc4.orig/include/acpi/actypes.h
+++ linux-2.6.22-rc4/include/acpi/actypes.h
@@ -809,7 +809,7 @@ acpi_status(*acpi_walk_callback) (acpi_h
 
 /* Common string version of device HIDs and UIDs */
 
-struct acpi_device_id {
+struct __acpi_device_id {
 	char value[ACPI_DEVICE_ID_LENGTH];
 };
 
@@ -859,8 +859,8 @@ struct acpi_device_info {
 	u32 valid;		/* Indicates which fields below are valid */
 	u32 current_status;	/* _STA value */
 	acpi_integer address;	/* _ADR value if any */
-	struct acpi_device_id hardware_id;	/* _HID value if any */
-	struct acpi_device_id unique_id;	/* _UID value if any */
+	struct __acpi_device_id hardware_id;	/* _HID value if any */
+	struct __acpi_device_id unique_id;	/* _UID value if any */
 	u8 highest_dstates[4];	/* _sx_d values: 0xFF indicates not valid */
 	struct acpi_compatible_id_list compatibility_id;	/* List of _CIDs if any */
 };
Index: linux-2.6.22-rc4/include/acpi/acutils.h
===================================================================
--- linux-2.6.22-rc4.orig/include/acpi/acutils.h
+++ linux-2.6.22-rc4/include/acpi/acutils.h
@@ -354,7 +354,7 @@ acpi_ut_evaluate_numeric_object(char *ob
 
 acpi_status
 acpi_ut_execute_HID(struct acpi_namespace_node *device_node,
-		    struct acpi_device_id *hid);
+		    struct __acpi_device_id *hid);
 
 acpi_status
 acpi_ut_execute_CID(struct acpi_namespace_node *device_node,
@@ -366,7 +366,7 @@ acpi_ut_execute_STA(struct acpi_namespac
 
 acpi_status
 acpi_ut_execute_UID(struct acpi_namespace_node *device_node,
-		    struct acpi_device_id *uid);
+		    struct __acpi_device_id *uid);
 
 acpi_status
 acpi_ut_execute_sxds(struct acpi_namespace_node *device_node, u8 * highest);
Index: linux-2.6.22-rc4/include/acpi/acpi_bus.h
===================================================================
--- linux-2.6.22-rc4.orig/include/acpi/acpi_bus.h
+++ linux-2.6.22-rc4/include/acpi/acpi_bus.h
@@ -131,7 +131,7 @@ struct acpi_device_ops {
 struct acpi_driver {
 	char name[80];
 	char class[80];
-	char *ids;		/* Supported Hardware IDs */
+	const struct acpi_device_id *ids; /* Supported Hardware IDs */
 	struct acpi_device_ops ops;
 	struct device_driver drv;
 	struct module *owner;
@@ -340,7 +340,8 @@ int acpi_bus_add(struct acpi_device **ch
 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_ids(struct acpi_device *device, char *ids);
+int acpi_match_device_ids(struct acpi_device *device,
+			  const struct acpi_device_id *ids);
 int acpi_create_dir(struct acpi_device *);
 void acpi_remove_dir(struct acpi_device *);
 
Index: linux-2.6.22-rc4/include/acpi/acpi_drivers.h
===================================================================
--- linux-2.6.22-rc4.orig/include/acpi/acpi_drivers.h
+++ linux-2.6.22-rc4/include/acpi/acpi_drivers.h
@@ -34,16 +34,33 @@
 #define ACPI_BUS_COMPONENT		0x00010000
 #define ACPI_SYSTEM_COMPONENT		0x02000000
 
-/* _HID definitions */
+/*
+  _HID definitions
+  HIDs starting with 'X' are self defined here and are used for devices where
+  a HID does not exist in spec.
+  HIDs must conform to (ACPI spec - 6.1.4):
 
-#define ACPI_POWER_HID			"power_resource"
+  Numeric 32-bit compressed EISA type ID are not supported (never seen one as
+  an ACPI HID?)
+
+  A valid PNP ID must be of the form AAA#### where A is an uppercase letter
+  and # is a hex digit.
+  A valid ACPI ID must be of the form ACPI#### where # is a hex digit.
+
+  and our self-defined: XAAA#### where A is an uppercase letter and # is a hex
+  digit.
+
+*/
+
+#define ACPI_POWER_HID			"XPWR0001"
 #define ACPI_PROCESSOR_HID		"ACPI0007"
-#define ACPI_SYSTEM_HID			"acpi_system"
-#define ACPI_THERMAL_HID		"thermal"
-#define ACPI_BUTTON_HID_POWERF		"button_power"
-#define ACPI_BUTTON_HID_SLEEPF		"button_sleep"
-#define ACPI_VIDEO_HID			"video"
-#define ACPI_BAY_HID			"bay"
+#define ACPI_SYSTEM_HID			"XSYS0001"
+#define ACPI_THERMAL_HID		"XTHM0001"
+#define ACPI_BUTTON_HID_POWERF		"XPBT0001"
+#define ACPI_BUTTON_HID_SLEEPF		"XSBT0001"
+#define ACPI_VIDEO_HID			"XVID0001"
+#define ACPI_BAY_HID			"XBAY0001"
+
 /* --------------------------------------------------------------------------
                                        PCI
    -------------------------------------------------------------------------- */
Index: linux-2.6.22-rc4/drivers/acpi/namespace/nsxfeval.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/acpi/namespace/nsxfeval.c
+++ linux-2.6.22-rc4/drivers/acpi/namespace/nsxfeval.c
@@ -440,7 +440,7 @@ acpi_ns_get_device_callback(acpi_handle 
 	acpi_status status;
 	struct acpi_namespace_node *node;
 	u32 flags;
-	struct acpi_device_id hid;
+	struct __acpi_device_id hid;
 	struct acpi_compatible_id_list *cid;
 	acpi_native_uint i;
 

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

* [PATCH 3/3] ACPI autoloading - Create __mod_acpi_device_table symbol for all acpi drivers.
@ 2007-06-17 20:24   ` Thomas Renninger
  2007-06-17 22:49     ` Henrique de Moraes Holschuh
  2007-06-20 17:06     ` Mattia Dongili
  0 siblings, 2 replies; 19+ messages in thread
From: Thomas Renninger @ 2007-06-17 20:24 UTC (permalink / raw)
  To: Len Brown; +Cc: linux-kernel, linux-acpi, Henrique de Moraes Holschuh

[-- Attachment #1: Type: text/plain, Size: 22011 bytes --]

Create __mod_acpi_device_table symbol for all acpi drivers.

modpost is going to use this one to create modules.alias

Hopefully thinkpad module still works.
IMO this one should get restructured and make use of acpi_bus_register_driver
and try to avoid to test for HIDs/CIDs for its own.

Signed-off-by: Thomas Renninger <trenn@suse.de>

---
 drivers/acpi/ac.c               |    9 +++++++--
 drivers/acpi/acpi_memhotplug.c  |    8 +++++++-
 drivers/acpi/asus_acpi.c        |   11 ++++++++---
 drivers/acpi/battery.c          |   10 ++++++++--
 drivers/acpi/button.c           |   10 +++++++++-
 drivers/acpi/container.c        |   10 +++++++++-
 drivers/acpi/ec.c               |   15 +++++++++++++--
 drivers/acpi/fan.c              |    8 +++++++-
 drivers/acpi/pci_link.c         |    9 +++++++--
 drivers/acpi/pci_root.c         |    9 +++++++--
 drivers/acpi/power.c            |    8 +++++++-
 drivers/acpi/processor_core.c   |    8 +++++++-
 drivers/acpi/sbs.c              |    9 +++++++--
 drivers/acpi/thermal.c          |    8 +++++++-
 drivers/acpi/video.c            |    8 +++++++-
 drivers/char/hpet.c             |    8 +++++++-
 drivers/input/misc/atlas_btns.c |    9 +++++++--
 drivers/misc/asus-laptop.c      |    9 +++++++--
 drivers/misc/sony-laptop.c      |   21 +++++++++++++++++++--
 drivers/misc/thinkpad_acpi.c    |   31 +++++++++++++++++++++++++++----
 drivers/misc/thinkpad_acpi.h    |    2 +-
 21 files changed, 185 insertions(+), 35 deletions(-)

Index: linux-2.6.22-rc4/drivers/acpi/button.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/acpi/button.c
+++ linux-2.6.22-rc4/drivers/acpi/button.c
@@ -66,6 +66,14 @@ MODULE_AUTHOR("Paul Diefenbaugh");
 MODULE_DESCRIPTION("ACPI Button Driver");
 MODULE_LICENSE("GPL");
 
+static const struct acpi_device_id button_device_ids[] = {
+	{ACPI_BUTTON_HID_LID, 0},
+	{ACPI_BUTTON_HID_SLEEP, 0},
+	{ACPI_BUTTON_HID_POWER, 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, button_device_ids);
+
 static int acpi_button_add(struct acpi_device *device);
 static int acpi_button_remove(struct acpi_device *device, int type);
 static int acpi_button_info_open_fs(struct inode *inode, struct file *file);
@@ -74,7 +82,7 @@ static int acpi_button_state_open_fs(str
 static struct acpi_driver acpi_button_driver = {
 	.name = "button",
 	.class = ACPI_BUTTON_CLASS,
-	.ids = "button_power,button_sleep,PNP0C0D,PNP0C0C,PNP0C0E",
+	.ids = button_device_ids,
 	.ops = {
 		.add = acpi_button_add,
 		.remove = acpi_button_remove,
Index: linux-2.6.22-rc4/drivers/acpi/asus_acpi.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/acpi/asus_acpi.c
+++ linux-2.6.22-rc4/drivers/acpi/asus_acpi.c
@@ -56,7 +56,6 @@
 #define ACPI_HOTK_NAME          "Asus Laptop ACPI Extras Driver"
 #define ACPI_HOTK_CLASS         "hotkey"
 #define ACPI_HOTK_DEVICE_NAME   "Hotkey"
-#define ACPI_HOTK_HID           "ATK0100"
 
 /*
  * Some events we use, same for all Asus
@@ -426,14 +425,20 @@ static struct acpi_table_header *asus_in
 static struct asus_hotk *hotk;
 
 /*
- * The hotkey driver declaration
+ * The hotkey driver and autoloading declaration
  */
 static int asus_hotk_add(struct acpi_device *device);
 static int asus_hotk_remove(struct acpi_device *device, int type);
+static const struct acpi_device_id asus_device_ids[] = {
+	{"ATK0100", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, asus_device_ids);
+
 static struct acpi_driver asus_hotk_driver = {
 	.name = "asus_acpi",
 	.class = ACPI_HOTK_CLASS,
-	.ids = ACPI_HOTK_HID,
+	.ids = asus_device_ids,
 	.ops = {
 		.add = asus_hotk_add,
 		.remove = asus_hotk_remove,
Index: linux-2.6.22-rc4/drivers/acpi/fan.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/acpi/fan.c
+++ linux-2.6.22-rc4/drivers/acpi/fan.c
@@ -50,10 +50,16 @@ static int acpi_fan_remove(struct acpi_d
 static int acpi_fan_suspend(struct acpi_device *device, pm_message_t state);
 static int acpi_fan_resume(struct acpi_device *device);
 
+static const struct acpi_device_id fan_device_ids[] = {
+	{"PNP0C0B", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, fan_device_ids);
+
 static struct acpi_driver acpi_fan_driver = {
 	.name = "fan",
 	.class = ACPI_FAN_CLASS,
-	.ids = "PNP0C0B",
+	.ids = fan_device_ids,
 	.ops = {
 		.add = acpi_fan_add,
 		.remove = acpi_fan_remove,
Index: linux-2.6.22-rc4/drivers/acpi/container.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/acpi/container.c
+++ linux-2.6.22-rc4/drivers/acpi/container.c
@@ -52,10 +52,18 @@ MODULE_LICENSE("GPL");
 static int acpi_container_add(struct acpi_device *device);
 static int acpi_container_remove(struct acpi_device *device, int type);
 
+static const struct acpi_device_id container_device_ids[] = {
+	{"ACPI0004", 0},
+	{"PNP0A05", 0},
+	{"PNP0A06", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, container_device_ids);
+
 static struct acpi_driver acpi_container_driver = {
 	.name = "container",
 	.class = ACPI_CONTAINER_CLASS,
-	.ids = "ACPI0004,PNP0A05,PNP0A06",
+	.ids = container_device_ids,
 	.ops = {
 		.add = acpi_container_add,
 		.remove = acpi_container_remove,
Index: linux-2.6.22-rc4/drivers/acpi/sbs.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/acpi/sbs.c
+++ linux-2.6.22-rc4/drivers/acpi/sbs.c
@@ -38,7 +38,6 @@
 #define ACPI_SBS_CLASS			"sbs"
 #define ACPI_AC_CLASS			"ac_adapter"
 #define ACPI_BATTERY_CLASS		"battery"
-#define ACPI_SBS_HID			"ACPI0002"
 #define ACPI_SBS_DEVICE_NAME		"Smart Battery System"
 #define ACPI_SBS_FILE_INFO		"info"
 #define ACPI_SBS_FILE_STATE		"state"
@@ -124,10 +123,16 @@ static int acpi_sbs_add(struct acpi_devi
 static int acpi_sbs_remove(struct acpi_device *device, int type);
 static int acpi_sbs_resume(struct acpi_device *device);
 
+static const struct acpi_device_id sbs_device_ids[] = {
+	{"ACPI0002", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, sbs_device_ids);
+
 static struct acpi_driver acpi_sbs_driver = {
 	.name = "sbs",
 	.class = ACPI_SBS_CLASS,
-	.ids = ACPI_SBS_HID,
+	.ids = sbs_device_ids,
 	.ops = {
 		.add = acpi_sbs_add,
 		.remove = acpi_sbs_remove,
Index: linux-2.6.22-rc4/drivers/acpi/battery.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/acpi/battery.c
+++ linux-2.6.22-rc4/drivers/acpi/battery.c
@@ -41,7 +41,6 @@
 
 #define ACPI_BATTERY_COMPONENT		0x00040000
 #define ACPI_BATTERY_CLASS		"battery"
-#define ACPI_BATTERY_HID		"PNP0C0A"
 #define ACPI_BATTERY_DEVICE_NAME	"Battery"
 #define ACPI_BATTERY_FILE_INFO		"info"
 #define ACPI_BATTERY_FILE_STATUS	"state"
@@ -65,10 +64,16 @@ static int acpi_battery_add(struct acpi_
 static int acpi_battery_remove(struct acpi_device *device, int type);
 static int acpi_battery_resume(struct acpi_device *device);
 
+static const struct acpi_device_id battery_device_ids[] = {
+	{"PNP0C0A", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, battery_device_ids);
+
 static struct acpi_driver acpi_battery_driver = {
 	.name = "battery",
 	.class = ACPI_BATTERY_CLASS,
-	.ids = ACPI_BATTERY_HID,
+	.ids = battery_device_ids,
 	.ops = {
 		.add = acpi_battery_add,
 		.resume = acpi_battery_resume,
Index: linux-2.6.22-rc4/drivers/acpi/thermal.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/acpi/thermal.c
+++ linux-2.6.22-rc4/drivers/acpi/thermal.c
@@ -92,10 +92,16 @@ static int acpi_thermal_polling_open_fs(
 static ssize_t acpi_thermal_write_polling(struct file *, const char __user *,
 					  size_t, loff_t *);
 
+static const struct acpi_device_id  thermal_device_ids[] = {
+	{ACPI_THERMAL_HID, 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, thermal_device_ids);
+
 static struct acpi_driver acpi_thermal_driver = {
 	.name = "thermal",
 	.class = ACPI_THERMAL_CLASS,
-	.ids = ACPI_THERMAL_HID,
+	.ids = thermal_device_ids,
 	.ops = {
 		.add = acpi_thermal_add,
 		.remove = acpi_thermal_remove,
Index: linux-2.6.22-rc4/drivers/acpi/ac.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/acpi/ac.c
+++ linux-2.6.22-rc4/drivers/acpi/ac.c
@@ -34,7 +34,6 @@
 
 #define ACPI_AC_COMPONENT		0x00020000
 #define ACPI_AC_CLASS			"ac_adapter"
-#define ACPI_AC_HID 			"ACPI0003"
 #define ACPI_AC_DEVICE_NAME		"AC Adapter"
 #define ACPI_AC_FILE_STATE		"state"
 #define ACPI_AC_NOTIFY_STATUS		0x80
@@ -56,10 +55,16 @@ static int acpi_ac_add(struct acpi_devic
 static int acpi_ac_remove(struct acpi_device *device, int type);
 static int acpi_ac_open_fs(struct inode *inode, struct file *file);
 
+const static struct acpi_device_id ac_device_ids[] = {
+	{"ACPI0003", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, ac_device_ids);
+
 static struct acpi_driver acpi_ac_driver = {
 	.name = "ac",
 	.class = ACPI_AC_CLASS,
-	.ids = ACPI_AC_HID,
+	.ids = ac_device_ids,
 	.ops = {
 		.add = acpi_ac_add,
 		.remove = acpi_ac_remove,
Index: linux-2.6.22-rc4/drivers/acpi/pci_link.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/acpi/pci_link.c
+++ linux-2.6.22-rc4/drivers/acpi/pci_link.c
@@ -46,7 +46,6 @@
 #define _COMPONENT		ACPI_PCI_COMPONENT
 ACPI_MODULE_NAME("pci_link");
 #define ACPI_PCI_LINK_CLASS		"pci_irq_routing"
-#define ACPI_PCI_LINK_HID		"PNP0C0F"
 #define ACPI_PCI_LINK_DEVICE_NAME	"PCI Interrupt Link"
 #define ACPI_PCI_LINK_FILE_INFO		"info"
 #define ACPI_PCI_LINK_FILE_STATUS	"state"
@@ -54,10 +53,16 @@ ACPI_MODULE_NAME("pci_link");
 static int acpi_pci_link_add(struct acpi_device *device);
 static int acpi_pci_link_remove(struct acpi_device *device, int type);
 
+static struct acpi_device_id link_device_ids[] = {
+	{"PNP0C0F", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, link_device_ids);
+
 static struct acpi_driver acpi_pci_link_driver = {
 	.name = "pci_link",
 	.class = ACPI_PCI_LINK_CLASS,
-	.ids = ACPI_PCI_LINK_HID,
+	.ids = link_device_ids,
 	.ops = {
 		.add = acpi_pci_link_add,
 		.remove = acpi_pci_link_remove,
Index: linux-2.6.22-rc4/drivers/acpi/pci_root.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/acpi/pci_root.c
+++ linux-2.6.22-rc4/drivers/acpi/pci_root.c
@@ -38,16 +38,21 @@
 #define _COMPONENT		ACPI_PCI_COMPONENT
 ACPI_MODULE_NAME("pci_root");
 #define ACPI_PCI_ROOT_CLASS		"pci_bridge"
-#define ACPI_PCI_ROOT_HID		"PNP0A03"
 #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);
 
+static struct acpi_device_id root_device_ids[] = {
+	{"PNP0A03", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, root_device_ids);
+
 static struct acpi_driver acpi_pci_root_driver = {
 	.name = "pci_root",
 	.class = ACPI_PCI_ROOT_CLASS,
-	.ids = ACPI_PCI_ROOT_HID,
+	.ids = root_device_ids,
 	.ops = {
 		.add = acpi_pci_root_add,
 		.remove = acpi_pci_root_remove,
Index: linux-2.6.22-rc4/drivers/acpi/power.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/acpi/power.c
+++ linux-2.6.22-rc4/drivers/acpi/power.c
@@ -59,10 +59,16 @@ static int acpi_power_remove(struct acpi
 static int acpi_power_resume(struct acpi_device *device);
 static int acpi_power_open_fs(struct inode *inode, struct file *file);
 
+static struct acpi_device_id power_device_ids[] = {
+	{ACPI_POWER_HID, 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, power_device_ids);
+
 static struct acpi_driver acpi_power_driver = {
 	.name = "power",
 	.class = ACPI_POWER_CLASS,
-	.ids = ACPI_POWER_HID,
+	.ids = power_device_ids,
 	.ops = {
 		.add = acpi_power_add,
 		.remove = acpi_power_remove,
Index: linux-2.6.22-rc4/drivers/acpi/acpi_memhotplug.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/acpi/acpi_memhotplug.c
+++ linux-2.6.22-rc4/drivers/acpi/acpi_memhotplug.c
@@ -53,10 +53,16 @@ static int acpi_memory_device_add(struct
 static int acpi_memory_device_remove(struct acpi_device *device, int type);
 static int acpi_memory_device_start(struct acpi_device *device);
 
+static const struct acpi_device_id memory_device_ids[] = {
+	{ACPI_MEMORY_DEVICE_HID, 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, memory_device_ids);
+
 static struct acpi_driver acpi_memory_device_driver = {
 	.name = "acpi_memhotplug",
 	.class = ACPI_MEMORY_DEVICE_CLASS,
-	.ids = ACPI_MEMORY_DEVICE_HID,
+	.ids = memory_device_ids,
 	.ops = {
 		.add = acpi_memory_device_add,
 		.remove = acpi_memory_device_remove,
Index: linux-2.6.22-rc4/drivers/acpi/processor_core.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/acpi/processor_core.c
+++ linux-2.6.22-rc4/drivers/acpi/processor_core.c
@@ -85,10 +85,16 @@ static void acpi_processor_notify(acpi_h
 static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu);
 static int acpi_processor_handle_eject(struct acpi_processor *pr);
 
+static const struct acpi_device_id processor_device_ids[] = {
+	{ACPI_PROCESSOR_HID, 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, processor_device_ids);
+
 static struct acpi_driver acpi_processor_driver = {
 	.name = "processor",
 	.class = ACPI_PROCESSOR_CLASS,
-	.ids = ACPI_PROCESSOR_HID,
+	.ids = processor_device_ids,
 	.ops = {
 		.add = acpi_processor_add,
 		.remove = acpi_processor_remove,
Index: linux-2.6.22-rc4/drivers/acpi/video.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/acpi/video.c
+++ linux-2.6.22-rc4/drivers/acpi/video.c
@@ -73,10 +73,16 @@ MODULE_LICENSE("GPL");
 static int acpi_video_bus_add(struct acpi_device *device);
 static int acpi_video_bus_remove(struct acpi_device *device, int type);
 
+static const struct acpi_device_id video_device_ids[] = {
+	{ACPI_VIDEO_HID, 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, video_device_ids);
+
 static struct acpi_driver acpi_video_bus = {
 	.name = "video",
 	.class = ACPI_VIDEO_CLASS,
-	.ids = ACPI_VIDEO_HID,
+	.ids = video_device_ids,
 	.ops = {
 		.add = acpi_video_bus_add,
 		.remove = acpi_video_bus_remove,
Index: linux-2.6.22-rc4/drivers/char/hpet.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/char/hpet.c
+++ linux-2.6.22-rc4/drivers/char/hpet.c
@@ -999,9 +999,15 @@ static int hpet_acpi_remove(struct acpi_
 	return -EINVAL;
 }
 
+static const struct acpi_device_id hpet_device_ids[] = {
+	{"PNP0103", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, hpet_device_ids);
+
 static struct acpi_driver hpet_acpi_driver = {
 	.name = "hpet",
-	.ids = "PNP0103",
+	.ids = hpet_device_ids,
 	.ops = {
 		.add = hpet_acpi_add,
 		.remove = hpet_acpi_remove,
Index: linux-2.6.22-rc4/drivers/input/misc/atlas_btns.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/input/misc/atlas_btns.c
+++ linux-2.6.22-rc4/drivers/input/misc/atlas_btns.c
@@ -31,7 +31,6 @@
 
 #define ACPI_ATLAS_NAME			"Atlas ACPI"
 #define ACPI_ATLAS_CLASS		"Atlas"
-#define ACPI_ATLAS_BUTTON_HID		"ASIM0000"
 
 static struct input_dev *input_dev;
 
@@ -130,10 +129,16 @@ static int atlas_acpi_button_remove(stru
 	return status;
 }
 
+static const struct acpi_device_id atlas_device_ids[] = {
+	{"ASIM0000", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, atlas_device_ids);
+
 static struct acpi_driver atlas_acpi_driver = {
 	.name	= ACPI_ATLAS_NAME,
 	.class	= ACPI_ATLAS_CLASS,
-	.ids	= ACPI_ATLAS_BUTTON_HID,
+	.ids	= atlas_device_ids,
 	.ops	= {
 		.add	= atlas_acpi_button_add,
 		.remove	= atlas_acpi_button_remove,
Index: linux-2.6.22-rc4/drivers/misc/asus-laptop.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/misc/asus-laptop.c
+++ linux-2.6.22-rc4/drivers/misc/asus-laptop.c
@@ -53,7 +53,6 @@
 #define ASUS_HOTK_NAME          "Asus Laptop Support"
 #define ASUS_HOTK_CLASS         "hotkey"
 #define ASUS_HOTK_DEVICE_NAME   "Hotkey"
-#define ASUS_HOTK_HID           "ATK0100"
 #define ASUS_HOTK_FILE          "asus-laptop"
 #define ASUS_HOTK_PREFIX        "\\_SB.ATKD."
 
@@ -197,12 +196,18 @@ static struct asus_hotk *hotk;
 /*
  * The hotkey driver declaration
  */
+static const struct acpi_device_id asus_device_ids[] = {
+	{"ATK0100", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, asus_device_ids);
+
 static int asus_hotk_add(struct acpi_device *device);
 static int asus_hotk_remove(struct acpi_device *device, int type);
 static struct acpi_driver asus_hotk_driver = {
 	.name = ASUS_HOTK_NAME,
 	.class = ASUS_HOTK_CLASS,
-	.ids = ASUS_HOTK_HID,
+	.ids = asus_device_ids,
 	.ops = {
 		.add = asus_hotk_add,
 		.remove = asus_hotk_remove,
Index: linux-2.6.22-rc4/drivers/acpi/ec.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/acpi/ec.c
+++ linux-2.6.22-rc4/drivers/acpi/ec.c
@@ -43,7 +43,6 @@
 ACPI_MODULE_NAME("ec");
 #define ACPI_EC_COMPONENT		0x00100000
 #define ACPI_EC_CLASS			"embedded_controller"
-#define ACPI_EC_HID			"PNP0C09"
 #define ACPI_EC_DEVICE_NAME		"Embedded Controller"
 #define ACPI_EC_FILE_INFO		"info"
 #undef PREFIX
@@ -80,10 +79,22 @@ static int acpi_ec_start(struct acpi_dev
 static int acpi_ec_stop(struct acpi_device *device, int type);
 static int acpi_ec_add(struct acpi_device *device);
 
+/*
+   ec never can be a module..., anyway let's keep the autoloading
+   things here, this line does not hurt.
+*/
+
+static const struct acpi_device_id ec_device_ids[] = {
+	{"PNP0C09", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, ec_device_ids);
+
+
 static struct acpi_driver acpi_ec_driver = {
 	.name = "ec",
 	.class = ACPI_EC_CLASS,
-	.ids = ACPI_EC_HID,
+	.ids = ec_device_ids,
 	.ops = {
 		.add = acpi_ec_add,
 		.remove = acpi_ec_remove,
Index: linux-2.6.22-rc4/drivers/misc/thinkpad_acpi.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/misc/thinkpad_acpi.c
+++ linux-2.6.22-rc4/drivers/misc/thinkpad_acpi.c
@@ -388,12 +388,13 @@ static int __init register_tpacpi_subdri
 
 	sprintf(ibm->acpi->driver->name, "%s_%s", IBM_NAME, ibm->name);
 	ibm->acpi->driver->ids = ibm->acpi->hid;
+
 	ibm->acpi->driver->ops.add = &tpacpi_device_add;
 
 	rc = acpi_bus_register_driver(ibm->acpi->driver);
 	if (rc < 0) {
 		printk(IBM_ERR "acpi_bus_register_driver(%s) failed: %d\n",
-		       ibm->acpi->hid, rc);
+		       ibm->name, rc);
 		kfree(ibm->acpi->driver);
 		ibm->acpi->driver = NULL;
 	} else if (!rc)
@@ -1000,8 +1001,24 @@ errexit:
 	return res;
 }
 
+static const struct acpi_device_id ibm_device_ids[] = {
+	{IBM_HKEY_HID, 0},
+	{IBM_PCI_HID, 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, ibm_device_ids);
+
+static const struct acpi_device_id ibm_htk_device_ids[] = {
+	{IBM_HKEY_HID, 0},
+	{"", 0},
+};
+static const struct acpi_device_id ibm_pci_device_ids[] = {
+	{IBM_PCI_HID, 0},
+	{"", 0},
+};
+
 static struct tp_acpi_drv_struct ibm_hotkey_acpidriver = {
-	.hid = IBM_HKEY_HID,
+//	.hid = ibm_htk_device_ids,
 	.notify = hotkey_notify,
 	.handle = &hkey_handle,
 	.type = ACPI_DEVICE_NOTIFY,
@@ -1763,6 +1780,11 @@ IBM_HANDLE(dock, root, "\\_SB.GDCK",	/* 
 /* don't list other alternatives as we install a notify handler on the 570 */
 IBM_HANDLE(pci, root, "\\_SB.PCI");	/* 570 */
 
+static const struct acpi_device_id ibm_pci_device_ids[] = {
+	{IBM_PCI_HID, 0},
+	{"", 0},
+};
+
 static struct tp_acpi_drv_struct ibm_dock_acpidriver[2] = {
 	{
 	 .notify = dock_notify,
@@ -1770,7 +1792,7 @@ static struct tp_acpi_drv_struct ibm_doc
 	 .type = ACPI_SYSTEM_NOTIFY,
 	},
 	{
-	 .hid = IBM_PCI_HID,
+	 .hid = ibm_pci_device_ids,
 	 .notify = dock_notify,
 	 .handle = &pci_handle,
 	 .type = ACPI_SYSTEM_NOTIFY,
@@ -1829,7 +1851,8 @@ static int __init dock_init2(struct ibm_
 static void dock_notify(struct ibm_struct *ibm, u32 event)
 {
 	int docked = dock_docked();
-	int pci = ibm->acpi->hid && strstr(ibm->acpi->hid, IBM_PCI_HID);
+	int pci = ibm->acpi->hid && ibm->acpi->device &&
+		acpi_match_device_ids(ibm->acpi->device, ibm_pci_device_ids);
 
 	if (event == 1 && !pci)	/* 570 */
 		acpi_bus_generate_event(ibm->acpi->device, event, 1);	/* button */
Index: linux-2.6.22-rc4/drivers/misc/thinkpad_acpi.h
===================================================================
--- linux-2.6.22-rc4.orig/drivers/misc/thinkpad_acpi.h
+++ linux-2.6.22-rc4/drivers/misc/thinkpad_acpi.h
@@ -182,7 +182,7 @@ static void thinkpad_acpi_module_exit(vo
 struct ibm_struct;
 
 struct tp_acpi_drv_struct {
-	char *hid;
+	const struct acpi_device_id *hid;
 	struct acpi_driver *driver;
 
 	void (*notify) (struct ibm_struct *, u32);
Index: linux-2.6.22-rc4/drivers/misc/sony-laptop.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/misc/sony-laptop.c
+++ linux-2.6.22-rc4/drivers/misc/sony-laptop.c
@@ -890,10 +890,22 @@ static int sony_nc_remove(struct acpi_de
 	return 0;
 }
 
+static const struct acpi_device_id sony_device_ids[] = {
+	{SONY_NC_HID, 0},
+	{SONY_PIC_HID, 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, sony_device_ids);
+
+static const struct acpi_device_id sony_nc_device_ids[] = {
+	{SONY_NC_HID, 0},
+	{"", 0},
+};
+
 static struct acpi_driver sony_nc_driver = {
 	.name = SONY_NC_DRIVER_NAME,
 	.class = SONY_NC_CLASS,
-	.ids = SONY_NC_HID,
+	.ids = sony_nc_device_ids,
 	.owner = THIS_MODULE,
 	.ops = {
 		.add = sony_nc_add,
@@ -2221,10 +2233,15 @@ static int sony_pic_resume(struct acpi_d
 	return 0;
 }
 
+static const struct acpi_device_id sony_pic_device_ids[] = {
+	{SONY_PIC_HID, 0},
+	{"", 0},
+};
+
 static struct acpi_driver sony_pic_driver = {
 	.name = SONY_PIC_DRIVER_NAME,
 	.class = SONY_PIC_CLASS,
-	.ids = SONY_PIC_HID,
+	.ids = sony_pic_device_ids,
 	.owner = THIS_MODULE,
 	.ops = {
 		.add = sony_pic_add,


[-- Attachment #2: acpi_autoloading_implement_device_ids.patch --]
[-- Type: text/x-patch, Size: 22010 bytes --]

Create __mod_acpi_device_table symbol for all acpi drivers.

modpost is going to use this one to create modules.alias

Hopefully thinkpad module still works.
IMO this one should get restructured and make use of acpi_bus_register_driver
and try to avoid to test for HIDs/CIDs for its own.

Signed-off-by: Thomas Renninger <trenn@suse.de>

---
 drivers/acpi/ac.c               |    9 +++++++--
 drivers/acpi/acpi_memhotplug.c  |    8 +++++++-
 drivers/acpi/asus_acpi.c        |   11 ++++++++---
 drivers/acpi/battery.c          |   10 ++++++++--
 drivers/acpi/button.c           |   10 +++++++++-
 drivers/acpi/container.c        |   10 +++++++++-
 drivers/acpi/ec.c               |   15 +++++++++++++--
 drivers/acpi/fan.c              |    8 +++++++-
 drivers/acpi/pci_link.c         |    9 +++++++--
 drivers/acpi/pci_root.c         |    9 +++++++--
 drivers/acpi/power.c            |    8 +++++++-
 drivers/acpi/processor_core.c   |    8 +++++++-
 drivers/acpi/sbs.c              |    9 +++++++--
 drivers/acpi/thermal.c          |    8 +++++++-
 drivers/acpi/video.c            |    8 +++++++-
 drivers/char/hpet.c             |    8 +++++++-
 drivers/input/misc/atlas_btns.c |    9 +++++++--
 drivers/misc/asus-laptop.c      |    9 +++++++--
 drivers/misc/sony-laptop.c      |   21 +++++++++++++++++++--
 drivers/misc/thinkpad_acpi.c    |   31 +++++++++++++++++++++++++++----
 drivers/misc/thinkpad_acpi.h    |    2 +-
 21 files changed, 185 insertions(+), 35 deletions(-)

Index: linux-2.6.22-rc4/drivers/acpi/button.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/acpi/button.c
+++ linux-2.6.22-rc4/drivers/acpi/button.c
@@ -66,6 +66,14 @@ MODULE_AUTHOR("Paul Diefenbaugh");
 MODULE_DESCRIPTION("ACPI Button Driver");
 MODULE_LICENSE("GPL");
 
+static const struct acpi_device_id button_device_ids[] = {
+	{ACPI_BUTTON_HID_LID, 0},
+	{ACPI_BUTTON_HID_SLEEP, 0},
+	{ACPI_BUTTON_HID_POWER, 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, button_device_ids);
+
 static int acpi_button_add(struct acpi_device *device);
 static int acpi_button_remove(struct acpi_device *device, int type);
 static int acpi_button_info_open_fs(struct inode *inode, struct file *file);
@@ -74,7 +82,7 @@ static int acpi_button_state_open_fs(str
 static struct acpi_driver acpi_button_driver = {
 	.name = "button",
 	.class = ACPI_BUTTON_CLASS,
-	.ids = "button_power,button_sleep,PNP0C0D,PNP0C0C,PNP0C0E",
+	.ids = button_device_ids,
 	.ops = {
 		.add = acpi_button_add,
 		.remove = acpi_button_remove,
Index: linux-2.6.22-rc4/drivers/acpi/asus_acpi.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/acpi/asus_acpi.c
+++ linux-2.6.22-rc4/drivers/acpi/asus_acpi.c
@@ -56,7 +56,6 @@
 #define ACPI_HOTK_NAME          "Asus Laptop ACPI Extras Driver"
 #define ACPI_HOTK_CLASS         "hotkey"
 #define ACPI_HOTK_DEVICE_NAME   "Hotkey"
-#define ACPI_HOTK_HID           "ATK0100"
 
 /*
  * Some events we use, same for all Asus
@@ -426,14 +425,20 @@ static struct acpi_table_header *asus_in
 static struct asus_hotk *hotk;
 
 /*
- * The hotkey driver declaration
+ * The hotkey driver and autoloading declaration
  */
 static int asus_hotk_add(struct acpi_device *device);
 static int asus_hotk_remove(struct acpi_device *device, int type);
+static const struct acpi_device_id asus_device_ids[] = {
+	{"ATK0100", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, asus_device_ids);
+
 static struct acpi_driver asus_hotk_driver = {
 	.name = "asus_acpi",
 	.class = ACPI_HOTK_CLASS,
-	.ids = ACPI_HOTK_HID,
+	.ids = asus_device_ids,
 	.ops = {
 		.add = asus_hotk_add,
 		.remove = asus_hotk_remove,
Index: linux-2.6.22-rc4/drivers/acpi/fan.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/acpi/fan.c
+++ linux-2.6.22-rc4/drivers/acpi/fan.c
@@ -50,10 +50,16 @@ static int acpi_fan_remove(struct acpi_d
 static int acpi_fan_suspend(struct acpi_device *device, pm_message_t state);
 static int acpi_fan_resume(struct acpi_device *device);
 
+static const struct acpi_device_id fan_device_ids[] = {
+	{"PNP0C0B", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, fan_device_ids);
+
 static struct acpi_driver acpi_fan_driver = {
 	.name = "fan",
 	.class = ACPI_FAN_CLASS,
-	.ids = "PNP0C0B",
+	.ids = fan_device_ids,
 	.ops = {
 		.add = acpi_fan_add,
 		.remove = acpi_fan_remove,
Index: linux-2.6.22-rc4/drivers/acpi/container.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/acpi/container.c
+++ linux-2.6.22-rc4/drivers/acpi/container.c
@@ -52,10 +52,18 @@ MODULE_LICENSE("GPL");
 static int acpi_container_add(struct acpi_device *device);
 static int acpi_container_remove(struct acpi_device *device, int type);
 
+static const struct acpi_device_id container_device_ids[] = {
+	{"ACPI0004", 0},
+	{"PNP0A05", 0},
+	{"PNP0A06", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, container_device_ids);
+
 static struct acpi_driver acpi_container_driver = {
 	.name = "container",
 	.class = ACPI_CONTAINER_CLASS,
-	.ids = "ACPI0004,PNP0A05,PNP0A06",
+	.ids = container_device_ids,
 	.ops = {
 		.add = acpi_container_add,
 		.remove = acpi_container_remove,
Index: linux-2.6.22-rc4/drivers/acpi/sbs.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/acpi/sbs.c
+++ linux-2.6.22-rc4/drivers/acpi/sbs.c
@@ -38,7 +38,6 @@
 #define ACPI_SBS_CLASS			"sbs"
 #define ACPI_AC_CLASS			"ac_adapter"
 #define ACPI_BATTERY_CLASS		"battery"
-#define ACPI_SBS_HID			"ACPI0002"
 #define ACPI_SBS_DEVICE_NAME		"Smart Battery System"
 #define ACPI_SBS_FILE_INFO		"info"
 #define ACPI_SBS_FILE_STATE		"state"
@@ -124,10 +123,16 @@ static int acpi_sbs_add(struct acpi_devi
 static int acpi_sbs_remove(struct acpi_device *device, int type);
 static int acpi_sbs_resume(struct acpi_device *device);
 
+static const struct acpi_device_id sbs_device_ids[] = {
+	{"ACPI0002", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, sbs_device_ids);
+
 static struct acpi_driver acpi_sbs_driver = {
 	.name = "sbs",
 	.class = ACPI_SBS_CLASS,
-	.ids = ACPI_SBS_HID,
+	.ids = sbs_device_ids,
 	.ops = {
 		.add = acpi_sbs_add,
 		.remove = acpi_sbs_remove,
Index: linux-2.6.22-rc4/drivers/acpi/battery.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/acpi/battery.c
+++ linux-2.6.22-rc4/drivers/acpi/battery.c
@@ -41,7 +41,6 @@
 
 #define ACPI_BATTERY_COMPONENT		0x00040000
 #define ACPI_BATTERY_CLASS		"battery"
-#define ACPI_BATTERY_HID		"PNP0C0A"
 #define ACPI_BATTERY_DEVICE_NAME	"Battery"
 #define ACPI_BATTERY_FILE_INFO		"info"
 #define ACPI_BATTERY_FILE_STATUS	"state"
@@ -65,10 +64,16 @@ static int acpi_battery_add(struct acpi_
 static int acpi_battery_remove(struct acpi_device *device, int type);
 static int acpi_battery_resume(struct acpi_device *device);
 
+static const struct acpi_device_id battery_device_ids[] = {
+	{"PNP0C0A", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, battery_device_ids);
+
 static struct acpi_driver acpi_battery_driver = {
 	.name = "battery",
 	.class = ACPI_BATTERY_CLASS,
-	.ids = ACPI_BATTERY_HID,
+	.ids = battery_device_ids,
 	.ops = {
 		.add = acpi_battery_add,
 		.resume = acpi_battery_resume,
Index: linux-2.6.22-rc4/drivers/acpi/thermal.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/acpi/thermal.c
+++ linux-2.6.22-rc4/drivers/acpi/thermal.c
@@ -92,10 +92,16 @@ static int acpi_thermal_polling_open_fs(
 static ssize_t acpi_thermal_write_polling(struct file *, const char __user *,
 					  size_t, loff_t *);
 
+static const struct acpi_device_id  thermal_device_ids[] = {
+	{ACPI_THERMAL_HID, 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, thermal_device_ids);
+
 static struct acpi_driver acpi_thermal_driver = {
 	.name = "thermal",
 	.class = ACPI_THERMAL_CLASS,
-	.ids = ACPI_THERMAL_HID,
+	.ids = thermal_device_ids,
 	.ops = {
 		.add = acpi_thermal_add,
 		.remove = acpi_thermal_remove,
Index: linux-2.6.22-rc4/drivers/acpi/ac.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/acpi/ac.c
+++ linux-2.6.22-rc4/drivers/acpi/ac.c
@@ -34,7 +34,6 @@
 
 #define ACPI_AC_COMPONENT		0x00020000
 #define ACPI_AC_CLASS			"ac_adapter"
-#define ACPI_AC_HID 			"ACPI0003"
 #define ACPI_AC_DEVICE_NAME		"AC Adapter"
 #define ACPI_AC_FILE_STATE		"state"
 #define ACPI_AC_NOTIFY_STATUS		0x80
@@ -56,10 +55,16 @@ static int acpi_ac_add(struct acpi_devic
 static int acpi_ac_remove(struct acpi_device *device, int type);
 static int acpi_ac_open_fs(struct inode *inode, struct file *file);
 
+const static struct acpi_device_id ac_device_ids[] = {
+	{"ACPI0003", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, ac_device_ids);
+
 static struct acpi_driver acpi_ac_driver = {
 	.name = "ac",
 	.class = ACPI_AC_CLASS,
-	.ids = ACPI_AC_HID,
+	.ids = ac_device_ids,
 	.ops = {
 		.add = acpi_ac_add,
 		.remove = acpi_ac_remove,
Index: linux-2.6.22-rc4/drivers/acpi/pci_link.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/acpi/pci_link.c
+++ linux-2.6.22-rc4/drivers/acpi/pci_link.c
@@ -46,7 +46,6 @@
 #define _COMPONENT		ACPI_PCI_COMPONENT
 ACPI_MODULE_NAME("pci_link");
 #define ACPI_PCI_LINK_CLASS		"pci_irq_routing"
-#define ACPI_PCI_LINK_HID		"PNP0C0F"
 #define ACPI_PCI_LINK_DEVICE_NAME	"PCI Interrupt Link"
 #define ACPI_PCI_LINK_FILE_INFO		"info"
 #define ACPI_PCI_LINK_FILE_STATUS	"state"
@@ -54,10 +53,16 @@ ACPI_MODULE_NAME("pci_link");
 static int acpi_pci_link_add(struct acpi_device *device);
 static int acpi_pci_link_remove(struct acpi_device *device, int type);
 
+static struct acpi_device_id link_device_ids[] = {
+	{"PNP0C0F", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, link_device_ids);
+
 static struct acpi_driver acpi_pci_link_driver = {
 	.name = "pci_link",
 	.class = ACPI_PCI_LINK_CLASS,
-	.ids = ACPI_PCI_LINK_HID,
+	.ids = link_device_ids,
 	.ops = {
 		.add = acpi_pci_link_add,
 		.remove = acpi_pci_link_remove,
Index: linux-2.6.22-rc4/drivers/acpi/pci_root.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/acpi/pci_root.c
+++ linux-2.6.22-rc4/drivers/acpi/pci_root.c
@@ -38,16 +38,21 @@
 #define _COMPONENT		ACPI_PCI_COMPONENT
 ACPI_MODULE_NAME("pci_root");
 #define ACPI_PCI_ROOT_CLASS		"pci_bridge"
-#define ACPI_PCI_ROOT_HID		"PNP0A03"
 #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);
 
+static struct acpi_device_id root_device_ids[] = {
+	{"PNP0A03", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, root_device_ids);
+
 static struct acpi_driver acpi_pci_root_driver = {
 	.name = "pci_root",
 	.class = ACPI_PCI_ROOT_CLASS,
-	.ids = ACPI_PCI_ROOT_HID,
+	.ids = root_device_ids,
 	.ops = {
 		.add = acpi_pci_root_add,
 		.remove = acpi_pci_root_remove,
Index: linux-2.6.22-rc4/drivers/acpi/power.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/acpi/power.c
+++ linux-2.6.22-rc4/drivers/acpi/power.c
@@ -59,10 +59,16 @@ static int acpi_power_remove(struct acpi
 static int acpi_power_resume(struct acpi_device *device);
 static int acpi_power_open_fs(struct inode *inode, struct file *file);
 
+static struct acpi_device_id power_device_ids[] = {
+	{ACPI_POWER_HID, 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, power_device_ids);
+
 static struct acpi_driver acpi_power_driver = {
 	.name = "power",
 	.class = ACPI_POWER_CLASS,
-	.ids = ACPI_POWER_HID,
+	.ids = power_device_ids,
 	.ops = {
 		.add = acpi_power_add,
 		.remove = acpi_power_remove,
Index: linux-2.6.22-rc4/drivers/acpi/acpi_memhotplug.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/acpi/acpi_memhotplug.c
+++ linux-2.6.22-rc4/drivers/acpi/acpi_memhotplug.c
@@ -53,10 +53,16 @@ static int acpi_memory_device_add(struct
 static int acpi_memory_device_remove(struct acpi_device *device, int type);
 static int acpi_memory_device_start(struct acpi_device *device);
 
+static const struct acpi_device_id memory_device_ids[] = {
+	{ACPI_MEMORY_DEVICE_HID, 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, memory_device_ids);
+
 static struct acpi_driver acpi_memory_device_driver = {
 	.name = "acpi_memhotplug",
 	.class = ACPI_MEMORY_DEVICE_CLASS,
-	.ids = ACPI_MEMORY_DEVICE_HID,
+	.ids = memory_device_ids,
 	.ops = {
 		.add = acpi_memory_device_add,
 		.remove = acpi_memory_device_remove,
Index: linux-2.6.22-rc4/drivers/acpi/processor_core.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/acpi/processor_core.c
+++ linux-2.6.22-rc4/drivers/acpi/processor_core.c
@@ -85,10 +85,16 @@ static void acpi_processor_notify(acpi_h
 static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu);
 static int acpi_processor_handle_eject(struct acpi_processor *pr);
 
+static const struct acpi_device_id processor_device_ids[] = {
+	{ACPI_PROCESSOR_HID, 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, processor_device_ids);
+
 static struct acpi_driver acpi_processor_driver = {
 	.name = "processor",
 	.class = ACPI_PROCESSOR_CLASS,
-	.ids = ACPI_PROCESSOR_HID,
+	.ids = processor_device_ids,
 	.ops = {
 		.add = acpi_processor_add,
 		.remove = acpi_processor_remove,
Index: linux-2.6.22-rc4/drivers/acpi/video.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/acpi/video.c
+++ linux-2.6.22-rc4/drivers/acpi/video.c
@@ -73,10 +73,16 @@ MODULE_LICENSE("GPL");
 static int acpi_video_bus_add(struct acpi_device *device);
 static int acpi_video_bus_remove(struct acpi_device *device, int type);
 
+static const struct acpi_device_id video_device_ids[] = {
+	{ACPI_VIDEO_HID, 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, video_device_ids);
+
 static struct acpi_driver acpi_video_bus = {
 	.name = "video",
 	.class = ACPI_VIDEO_CLASS,
-	.ids = ACPI_VIDEO_HID,
+	.ids = video_device_ids,
 	.ops = {
 		.add = acpi_video_bus_add,
 		.remove = acpi_video_bus_remove,
Index: linux-2.6.22-rc4/drivers/char/hpet.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/char/hpet.c
+++ linux-2.6.22-rc4/drivers/char/hpet.c
@@ -999,9 +999,15 @@ static int hpet_acpi_remove(struct acpi_
 	return -EINVAL;
 }
 
+static const struct acpi_device_id hpet_device_ids[] = {
+	{"PNP0103", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, hpet_device_ids);
+
 static struct acpi_driver hpet_acpi_driver = {
 	.name = "hpet",
-	.ids = "PNP0103",
+	.ids = hpet_device_ids,
 	.ops = {
 		.add = hpet_acpi_add,
 		.remove = hpet_acpi_remove,
Index: linux-2.6.22-rc4/drivers/input/misc/atlas_btns.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/input/misc/atlas_btns.c
+++ linux-2.6.22-rc4/drivers/input/misc/atlas_btns.c
@@ -31,7 +31,6 @@
 
 #define ACPI_ATLAS_NAME			"Atlas ACPI"
 #define ACPI_ATLAS_CLASS		"Atlas"
-#define ACPI_ATLAS_BUTTON_HID		"ASIM0000"
 
 static struct input_dev *input_dev;
 
@@ -130,10 +129,16 @@ static int atlas_acpi_button_remove(stru
 	return status;
 }
 
+static const struct acpi_device_id atlas_device_ids[] = {
+	{"ASIM0000", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, atlas_device_ids);
+
 static struct acpi_driver atlas_acpi_driver = {
 	.name	= ACPI_ATLAS_NAME,
 	.class	= ACPI_ATLAS_CLASS,
-	.ids	= ACPI_ATLAS_BUTTON_HID,
+	.ids	= atlas_device_ids,
 	.ops	= {
 		.add	= atlas_acpi_button_add,
 		.remove	= atlas_acpi_button_remove,
Index: linux-2.6.22-rc4/drivers/misc/asus-laptop.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/misc/asus-laptop.c
+++ linux-2.6.22-rc4/drivers/misc/asus-laptop.c
@@ -53,7 +53,6 @@
 #define ASUS_HOTK_NAME          "Asus Laptop Support"
 #define ASUS_HOTK_CLASS         "hotkey"
 #define ASUS_HOTK_DEVICE_NAME   "Hotkey"
-#define ASUS_HOTK_HID           "ATK0100"
 #define ASUS_HOTK_FILE          "asus-laptop"
 #define ASUS_HOTK_PREFIX        "\\_SB.ATKD."
 
@@ -197,12 +196,18 @@ static struct asus_hotk *hotk;
 /*
  * The hotkey driver declaration
  */
+static const struct acpi_device_id asus_device_ids[] = {
+	{"ATK0100", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, asus_device_ids);
+
 static int asus_hotk_add(struct acpi_device *device);
 static int asus_hotk_remove(struct acpi_device *device, int type);
 static struct acpi_driver asus_hotk_driver = {
 	.name = ASUS_HOTK_NAME,
 	.class = ASUS_HOTK_CLASS,
-	.ids = ASUS_HOTK_HID,
+	.ids = asus_device_ids,
 	.ops = {
 		.add = asus_hotk_add,
 		.remove = asus_hotk_remove,
Index: linux-2.6.22-rc4/drivers/acpi/ec.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/acpi/ec.c
+++ linux-2.6.22-rc4/drivers/acpi/ec.c
@@ -43,7 +43,6 @@
 ACPI_MODULE_NAME("ec");
 #define ACPI_EC_COMPONENT		0x00100000
 #define ACPI_EC_CLASS			"embedded_controller"
-#define ACPI_EC_HID			"PNP0C09"
 #define ACPI_EC_DEVICE_NAME		"Embedded Controller"
 #define ACPI_EC_FILE_INFO		"info"
 #undef PREFIX
@@ -80,10 +79,22 @@ static int acpi_ec_start(struct acpi_dev
 static int acpi_ec_stop(struct acpi_device *device, int type);
 static int acpi_ec_add(struct acpi_device *device);
 
+/*
+   ec never can be a module..., anyway let's keep the autoloading
+   things here, this line does not hurt.
+*/
+
+static const struct acpi_device_id ec_device_ids[] = {
+	{"PNP0C09", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, ec_device_ids);
+
+
 static struct acpi_driver acpi_ec_driver = {
 	.name = "ec",
 	.class = ACPI_EC_CLASS,
-	.ids = ACPI_EC_HID,
+	.ids = ec_device_ids,
 	.ops = {
 		.add = acpi_ec_add,
 		.remove = acpi_ec_remove,
Index: linux-2.6.22-rc4/drivers/misc/thinkpad_acpi.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/misc/thinkpad_acpi.c
+++ linux-2.6.22-rc4/drivers/misc/thinkpad_acpi.c
@@ -388,12 +388,13 @@ static int __init register_tpacpi_subdri
 
 	sprintf(ibm->acpi->driver->name, "%s_%s", IBM_NAME, ibm->name);
 	ibm->acpi->driver->ids = ibm->acpi->hid;
+
 	ibm->acpi->driver->ops.add = &tpacpi_device_add;
 
 	rc = acpi_bus_register_driver(ibm->acpi->driver);
 	if (rc < 0) {
 		printk(IBM_ERR "acpi_bus_register_driver(%s) failed: %d\n",
-		       ibm->acpi->hid, rc);
+		       ibm->name, rc);
 		kfree(ibm->acpi->driver);
 		ibm->acpi->driver = NULL;
 	} else if (!rc)
@@ -1000,8 +1001,24 @@ errexit:
 	return res;
 }
 
+static const struct acpi_device_id ibm_device_ids[] = {
+	{IBM_HKEY_HID, 0},
+	{IBM_PCI_HID, 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, ibm_device_ids);
+
+static const struct acpi_device_id ibm_htk_device_ids[] = {
+	{IBM_HKEY_HID, 0},
+	{"", 0},
+};
+static const struct acpi_device_id ibm_pci_device_ids[] = {
+	{IBM_PCI_HID, 0},
+	{"", 0},
+};
+
 static struct tp_acpi_drv_struct ibm_hotkey_acpidriver = {
-	.hid = IBM_HKEY_HID,
+//	.hid = ibm_htk_device_ids,
 	.notify = hotkey_notify,
 	.handle = &hkey_handle,
 	.type = ACPI_DEVICE_NOTIFY,
@@ -1763,6 +1780,11 @@ IBM_HANDLE(dock, root, "\\_SB.GDCK",	/* 
 /* don't list other alternatives as we install a notify handler on the 570 */
 IBM_HANDLE(pci, root, "\\_SB.PCI");	/* 570 */
 
+static const struct acpi_device_id ibm_pci_device_ids[] = {
+	{IBM_PCI_HID, 0},
+	{"", 0},
+};
+
 static struct tp_acpi_drv_struct ibm_dock_acpidriver[2] = {
 	{
 	 .notify = dock_notify,
@@ -1770,7 +1792,7 @@ static struct tp_acpi_drv_struct ibm_doc
 	 .type = ACPI_SYSTEM_NOTIFY,
 	},
 	{
-	 .hid = IBM_PCI_HID,
+	 .hid = ibm_pci_device_ids,
 	 .notify = dock_notify,
 	 .handle = &pci_handle,
 	 .type = ACPI_SYSTEM_NOTIFY,
@@ -1829,7 +1851,8 @@ static int __init dock_init2(struct ibm_
 static void dock_notify(struct ibm_struct *ibm, u32 event)
 {
 	int docked = dock_docked();
-	int pci = ibm->acpi->hid && strstr(ibm->acpi->hid, IBM_PCI_HID);
+	int pci = ibm->acpi->hid && ibm->acpi->device &&
+		acpi_match_device_ids(ibm->acpi->device, ibm_pci_device_ids);
 
 	if (event == 1 && !pci)	/* 570 */
 		acpi_bus_generate_event(ibm->acpi->device, event, 1);	/* button */
Index: linux-2.6.22-rc4/drivers/misc/thinkpad_acpi.h
===================================================================
--- linux-2.6.22-rc4.orig/drivers/misc/thinkpad_acpi.h
+++ linux-2.6.22-rc4/drivers/misc/thinkpad_acpi.h
@@ -182,7 +182,7 @@ static void thinkpad_acpi_module_exit(vo
 struct ibm_struct;
 
 struct tp_acpi_drv_struct {
-	char *hid;
+	const struct acpi_device_id *hid;
 	struct acpi_driver *driver;
 
 	void (*notify) (struct ibm_struct *, u32);
Index: linux-2.6.22-rc4/drivers/misc/sony-laptop.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/misc/sony-laptop.c
+++ linux-2.6.22-rc4/drivers/misc/sony-laptop.c
@@ -890,10 +890,22 @@ static int sony_nc_remove(struct acpi_de
 	return 0;
 }
 
+static const struct acpi_device_id sony_device_ids[] = {
+	{SONY_NC_HID, 0},
+	{SONY_PIC_HID, 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, sony_device_ids);
+
+static const struct acpi_device_id sony_nc_device_ids[] = {
+	{SONY_NC_HID, 0},
+	{"", 0},
+};
+
 static struct acpi_driver sony_nc_driver = {
 	.name = SONY_NC_DRIVER_NAME,
 	.class = SONY_NC_CLASS,
-	.ids = SONY_NC_HID,
+	.ids = sony_nc_device_ids,
 	.owner = THIS_MODULE,
 	.ops = {
 		.add = sony_nc_add,
@@ -2221,10 +2233,15 @@ static int sony_pic_resume(struct acpi_d
 	return 0;
 }
 
+static const struct acpi_device_id sony_pic_device_ids[] = {
+	{SONY_PIC_HID, 0},
+	{"", 0},
+};
+
 static struct acpi_driver sony_pic_driver = {
 	.name = SONY_PIC_DRIVER_NAME,
 	.class = SONY_PIC_CLASS,
-	.ids = SONY_PIC_HID,
+	.ids = sony_pic_device_ids,
 	.owner = THIS_MODULE,
 	.ops = {
 		.add = sony_pic_add,

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

* [PATCH 2/3] ACPI autoloading - Create acpi alias interface
@ 2007-06-17 20:27 ` Thomas Renninger
  2007-06-17 20:24   ` [PATCH 3/3] ACPI autoloading - Create __mod_acpi_device_table symbol for all acpi drivers Thomas Renninger
  2007-06-20 15:52   ` [PATCH 2/3] ACPI autoloading - Create acpi alias interface Mattia Dongili
  0 siblings, 2 replies; 19+ messages in thread
From: Thomas Renninger @ 2007-06-17 20:27 UTC (permalink / raw)
  To: Len Brown; +Cc: linux-kernel, linux-acpi, Kay Sievers

[-- Attachment #1: Type: text/plain, Size: 10943 bytes --]

Create acpi alias interface

Modify modpost (file2alias.c) to add acpi*:XYZ0001: alias in modules.alias
like:
grep acpi /lib/modules/2.6.22-rc4-default/modules.alias 
alias acpi*:SNY5001:* sony_laptop
alias acpi*:SNY6001:* sony_laptop
for e.g. the sony_laptop module.
This module matches against all ACPI devices with a HID or CID of SNY5001
or SNY6001

Export an uevent and modalias sysfs file containing the string:
[MODALIAS=]acpi:PNP0C0C:
additional CIDs are concatenated at the end.

Signed-off-by: Thomas Renninger <trenn@suse.de>

---
 drivers/acpi/scan.c             |  185 +++++++++++++++++++++++++++++++---------
 drivers/pnp/pnpacpi/core.c      |   18 ++-
 include/linux/acpi.h            |    1 
 include/linux/mod_devicetable.h |   15 +++
 scripts/mod/file2alias.c        |   12 ++
 5 files changed, 183 insertions(+), 48 deletions(-)

Index: linux-2.6.22-rc4/include/linux/mod_devicetable.h
===================================================================
--- linux-2.6.22-rc4.orig/include/linux/mod_devicetable.h
+++ linux-2.6.22-rc4/include/linux/mod_devicetable.h
@@ -159,6 +159,21 @@ struct ap_device_id {
 
 #define AP_DEVICE_ID_MATCH_DEVICE_TYPE		0x01
 
+#define ACPI_ID_LEN	9
+
+/*
+  Similar exists in include/acpi/acmacros.h
+  use this one for acpi linux specific stuff e.g.
+  in ACPI modules and the other one inside the
+  interpreter
+*/
+
+/* Exists already in acpi includes (include/acpi/actypes.h) */
+
+struct acpi_device_id {
+	__u8 id[ACPI_ID_LEN];
+	kernel_ulong_t driver_data;
+};
 
 #define PNP_ID_LEN	8
 #define PNP_MAX_DEVICES	8
Index: linux-2.6.22-rc4/scripts/mod/file2alias.c
===================================================================
--- linux-2.6.22-rc4.orig/scripts/mod/file2alias.c
+++ linux-2.6.22-rc4/scripts/mod/file2alias.c
@@ -290,6 +290,14 @@ static int do_serio_entry(const char *fi
 	return 1;
 }
 
+/* looks like: "acpi:ACPI0003 or acpi:PNP0C0B" */
+static int do_acpi_entry(const char *filename,
+			struct acpi_device_id *id, char *alias)
+{
+	sprintf(alias, "acpi*:%s:", id->id);
+	return 1;
+}
+
 /* looks like: "pnp:dD" */
 static int do_pnp_entry(const char *filename,
 			struct pnp_device_id *id, char *alias)
@@ -551,6 +559,10 @@ void handle_moddevtable(struct module *m
 		do_table(symval, sym->st_size,
 			 sizeof(struct serio_device_id), "serio",
 			 do_serio_entry, mod);
+	else if (sym_is(symname, "__mod_acpi_device_table"))
+		do_table(symval, sym->st_size,
+			 sizeof(struct acpi_device_id), "acpi",
+			 do_acpi_entry, mod);
 	else if (sym_is(symname, "__mod_pnp_device_table"))
 		do_table(symval, sym->st_size,
 			 sizeof(struct pnp_device_id), "pnp",
Index: linux-2.6.22-rc4/drivers/acpi/scan.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/acpi/scan.c
+++ linux-2.6.22-rc4/drivers/acpi/scan.c
@@ -16,7 +16,7 @@ ACPI_MODULE_NAME("scan");
 extern struct acpi_device *acpi_root;
 
 #define ACPI_BUS_CLASS			"system_bus"
-#define ACPI_BUS_HID			"ACPI_BUS"
+#define ACPI_BUS_HID			"XBUS0001"
 #define ACPI_BUS_DEVICE_NAME		"System Bus"
 
 static LIST_HEAD(acpi_device_list);
@@ -29,6 +29,69 @@ struct acpi_device_bus_id{
 	unsigned int instance_no;
 	struct list_head node;
 };
+
+/*
+  Currently only handles ID strings, not compressed EISA, here the spec:
+
+  A _HID object evaluates to either a numeric 32-bit compressed EISA type ID
+  or a string. If a string, the format must be an alphanumeric PNP or ACPI ID
+  with no asterisk or other leading characters.
+
+  Why is hardware_id char[15] -> see include/acpi/acpi_bus.h ?!?
+
+  This function only handles devices correctly that have a HID.
+  If there are devices that have CID(s), but no HID work needs
+*/
+int create_modalias(struct acpi_device *acpi_dev, char *modalias, int size){
+
+	int len;
+
+	if (!acpi_dev->flags.hardware_id)
+		return -ENODEV;
+
+	len = snprintf(modalias, size, "acpi:%s:",
+		       acpi_dev->pnp.hardware_id);
+	if (len < 0 || len >= size)
+		return -EINVAL;
+	size -= len;
+
+	if (acpi_dev->flags.compatible_ids) {
+		struct acpi_compatible_id_list *cid_list;
+		int i;
+		int count;
+
+		cid_list = acpi_dev->pnp.cid_list;
+		for (i = 0; i < cid_list->count; i++) {
+			count = snprintf(&modalias[len], size, "%s:",
+					 cid_list->id[i].value);
+			if (count < 0 || count >= size) {
+				printk(KERN_ERR "acpi: %s cid[%i] exceeds event buffer size",
+				       acpi_dev->pnp.device_name, i);
+				break;
+			}
+			len += count;
+			size -= count;
+		}
+	}
+
+	modalias[len] = '\0';
+	return len;
+}
+
+static ssize_t
+acpi_device_modalias_show(struct device *dev, struct device_attribute *attr, char *buf) {
+	struct acpi_device *acpi_dev = to_acpi_device(dev);
+	int len;
+
+	/* Device has no HID and no CID or string is >1024 */
+	len = create_modalias(acpi_dev, buf, 1024);
+	if (len <= 0)
+		return 0;
+	buf[len++] = '\n';
+	return len;
+}
+static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL);
+
 static int acpi_eject_operation(acpi_handle handle, int lockable)
 {
 	struct acpi_object_list arg_list;
@@ -154,6 +217,12 @@ static int acpi_device_setup_files(struc
 			goto end;
 	}
 
+	if (dev->flags.hardware_id || dev->flags.compatible_ids){
+		result = device_create_file(&dev->dev, &dev_attr_modalias);
+		if(result)
+			goto end;
+	}
+
         /*
          * If device has _EJ0, 'eject' file is created that is used to trigger
          * hot-removal function from userland.
@@ -178,6 +247,9 @@ static void acpi_device_remove_files(str
 	if (ACPI_SUCCESS(status))
 		device_remove_file(&dev->dev, &dev_attr_eject);
 
+	if (dev->flags.hardware_id || dev->flags.compatible_ids)
+		device_remove_file(&dev->dev, &dev_attr_modalias);
+
 	if(dev->flags.hardware_id)
 		device_remove_file(&dev->dev, &dev_attr_hid);
 	if(dev->handle)
@@ -186,6 +258,37 @@ static void acpi_device_remove_files(str
 /* --------------------------------------------------------------------------
 			ACPI Bus operations
    -------------------------------------------------------------------------- */
+
+int acpi_match_device_ids(struct acpi_device *device,
+			  const struct acpi_device_id *ids)
+{
+	const struct acpi_device_id *id;
+
+	if (device->flags.hardware_id) {
+		for (id = ids; id->id[0]; id++) {
+			if (!strcmp((char*)id->id, device->pnp.hardware_id))
+				return 0;
+		}
+	}
+
+	if (device->flags.compatible_ids) {
+		struct acpi_compatible_id_list *cid_list = device->pnp.cid_list;
+		int i;
+
+		for (id = ids; id->id[0]; id++) {
+			/* compare multiple _CID entries against driver ids */
+			for (i = 0; i < cid_list->count; i++) {
+				if (!strcmp((char*)id->id,
+					    cid_list->id[i].value))
+					return 0;
+			}
+		}
+	}
+
+	return -ENOENT;
+}
+EXPORT_SYMBOL(acpi_match_device_ids);
+
 static void acpi_device_release(struct device *dev)
 {
 	struct acpi_device *acpi_dev = to_acpi_device(dev);
@@ -219,37 +322,19 @@ 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_match_ids(acpi_dev, acpi_drv->ids);
+	return !acpi_match_device_ids(acpi_dev, acpi_drv->ids);
 }
 
 static int acpi_device_uevent(struct device *dev, char **envp, int num_envp,
-	char *buffer, int buffer_size)
+			      char *buffer, int buffer_size)
 {
 	struct acpi_device *acpi_dev = to_acpi_device(dev);
-	int i = 0, length = 0, ret = 0;
-
-	if (acpi_dev->flags.hardware_id)
-		ret = add_uevent_var(envp, num_envp, &i,
-			buffer, buffer_size, &length,
-			"HWID=%s", acpi_dev->pnp.hardware_id);
-	if (ret)
-		return -ENOMEM;
-	if (acpi_dev->flags.compatible_ids) {
-		int j;
-		struct acpi_compatible_id_list *cid_list;
 
-		cid_list = acpi_dev->pnp.cid_list;
-
-		for (j = 0; j < cid_list->count; j++) {
-			ret = add_uevent_var(envp, num_envp, &i, buffer,
-				buffer_size, &length, "COMPTID=%s",
-				cid_list->id[j].value);
-			if (ret)
-				return -ENOMEM;
-		}
+	strcpy(buffer, "MODALIAS=");
+	if (create_modalias(acpi_dev, buffer + 9, buffer_size - 9) > 0) {
+		envp[0] = buffer;
+		envp[1] = NULL;
 	}
-
-	envp[i] = NULL;
 	return 0;
 }
 
@@ -543,25 +628,6 @@ void acpi_bus_data_handler(acpi_handle h
 	return;
 }
 
-int acpi_match_ids(struct acpi_device *device, char *ids)
-{
-	if (device->flags.hardware_id)
-		if (strstr(ids, device->pnp.hardware_id))
-			return 0;
-
-	if (device->flags.compatible_ids) {
-		struct acpi_compatible_id_list *cid_list = device->pnp.cid_list;
-		int i;
-
-		/* compare multiple _CID entries against driver ids */
-		for (i = 0; i < cid_list->count; i++) {
-			if (strstr(ids, cid_list->id[i].value))
-				return 0;
-		}
-	}
-	return -ENOENT;
-}
-
 static int acpi_bus_get_perf_flags(struct acpi_device *device)
 {
 	device->performance.state = ACPI_STATE_UNKNOWN;
@@ -624,6 +690,13 @@ static int acpi_bus_get_wakeup_device_fl
 	struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
 	union acpi_object *package = NULL;
 
+	struct acpi_device_id button_device_ids[] = {
+		{"PNP0C0D", 0},
+		{"PNP0C0C", 0},
+		{"PNP0C0E", 0},
+		{"", 0},
+	};
+
 
 	/* _PRW */
 	status = acpi_evaluate_object(device->handle, "_PRW", NULL, &buffer);
@@ -643,7 +716,7 @@ static int acpi_bus_get_wakeup_device_fl
 
 	device->wakeup.flags.valid = 1;
 	/* Power button, Lid switch always enable wakeup */
-	if (!acpi_match_ids(device, "PNP0C0D,PNP0C0C,PNP0C0E"))
+	if (!acpi_match_device_ids(device, button_device_ids))
 		device->wakeup.flags.run_wake = 1;
 
       end:
Index: linux-2.6.22-rc4/drivers/pnp/pnpacpi/core.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/pnp/pnpacpi/core.c
+++ linux-2.6.22-rc4/drivers/pnp/pnpacpi/core.c
@@ -21,7 +21,10 @@
 
 #include <linux/acpi.h>
 #include <linux/pnp.h>
+#include <linux/mod_devicetable.h>
 #include <acpi/acpi_bus.h>
+#include <acpi/actypes.h>
+
 #include "pnpacpi.h"
 
 static int num = 0;
@@ -33,15 +36,17 @@ static int num = 0;
  * have irqs (PIC, Timer) because we call acpi_register_gsi.
  * Finaly only devices that have a CRS method need to be in this list.
  */
-static char __initdata excluded_id_list[] =
-	"PNP0C09," /* EC */
-	"PNP0C0F," /* Link device */
-	"PNP0000," /* PIC */
-	"PNP0100," /* Timer */
-	;
+static __initdata struct acpi_device_id excluded_id_list[] ={
+	{"PNP0C09", 0}, /* EC */
+	{"PNP0C0F", 0}, /* Link device */
+	{"PNP0000", 0}, /* PIC */
+	{"PNP0100", 0}, /* Timer */
+	{"", 0};
+};
+
 static inline int is_exclusive_device(struct acpi_device *dev)
 {
-	return (!acpi_match_ids(dev, excluded_id_list));
+	return (!acpi_match_device_ids(dev, excluded_id_list));
 }
 
 /*
Index: linux-2.6.22-rc4/include/linux/acpi.h
===================================================================
--- linux-2.6.22-rc4.orig/include/linux/acpi.h
+++ linux-2.6.22-rc4/include/linux/acpi.h
@@ -33,6 +33,7 @@
 #endif
 
 #include <linux/list.h>
+#include <linux/mod_devicetable.h>
 
 #include <acpi/acpi.h>
 #include <acpi/acpi_bus.h>


[-- Attachment #2: acpi_autoloading_interface.patch --]
[-- Type: text/x-patch, Size: 10942 bytes --]

Create acpi alias interface

Modify modpost (file2alias.c) to add acpi*:XYZ0001: alias in modules.alias
like:
grep acpi /lib/modules/2.6.22-rc4-default/modules.alias 
alias acpi*:SNY5001:* sony_laptop
alias acpi*:SNY6001:* sony_laptop
for e.g. the sony_laptop module.
This module matches against all ACPI devices with a HID or CID of SNY5001
or SNY6001

Export an uevent and modalias sysfs file containing the string:
[MODALIAS=]acpi:PNP0C0C:
additional CIDs are concatenated at the end.

Signed-off-by: Thomas Renninger <trenn@suse.de>

---
 drivers/acpi/scan.c             |  185 +++++++++++++++++++++++++++++++---------
 drivers/pnp/pnpacpi/core.c      |   18 ++-
 include/linux/acpi.h            |    1 
 include/linux/mod_devicetable.h |   15 +++
 scripts/mod/file2alias.c        |   12 ++
 5 files changed, 183 insertions(+), 48 deletions(-)

Index: linux-2.6.22-rc4/include/linux/mod_devicetable.h
===================================================================
--- linux-2.6.22-rc4.orig/include/linux/mod_devicetable.h
+++ linux-2.6.22-rc4/include/linux/mod_devicetable.h
@@ -159,6 +159,21 @@ struct ap_device_id {
 
 #define AP_DEVICE_ID_MATCH_DEVICE_TYPE		0x01
 
+#define ACPI_ID_LEN	9
+
+/*
+  Similar exists in include/acpi/acmacros.h
+  use this one for acpi linux specific stuff e.g.
+  in ACPI modules and the other one inside the
+  interpreter
+*/
+
+/* Exists already in acpi includes (include/acpi/actypes.h) */
+
+struct acpi_device_id {
+	__u8 id[ACPI_ID_LEN];
+	kernel_ulong_t driver_data;
+};
 
 #define PNP_ID_LEN	8
 #define PNP_MAX_DEVICES	8
Index: linux-2.6.22-rc4/scripts/mod/file2alias.c
===================================================================
--- linux-2.6.22-rc4.orig/scripts/mod/file2alias.c
+++ linux-2.6.22-rc4/scripts/mod/file2alias.c
@@ -290,6 +290,14 @@ static int do_serio_entry(const char *fi
 	return 1;
 }
 
+/* looks like: "acpi:ACPI0003 or acpi:PNP0C0B" */
+static int do_acpi_entry(const char *filename,
+			struct acpi_device_id *id, char *alias)
+{
+	sprintf(alias, "acpi*:%s:", id->id);
+	return 1;
+}
+
 /* looks like: "pnp:dD" */
 static int do_pnp_entry(const char *filename,
 			struct pnp_device_id *id, char *alias)
@@ -551,6 +559,10 @@ void handle_moddevtable(struct module *m
 		do_table(symval, sym->st_size,
 			 sizeof(struct serio_device_id), "serio",
 			 do_serio_entry, mod);
+	else if (sym_is(symname, "__mod_acpi_device_table"))
+		do_table(symval, sym->st_size,
+			 sizeof(struct acpi_device_id), "acpi",
+			 do_acpi_entry, mod);
 	else if (sym_is(symname, "__mod_pnp_device_table"))
 		do_table(symval, sym->st_size,
 			 sizeof(struct pnp_device_id), "pnp",
Index: linux-2.6.22-rc4/drivers/acpi/scan.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/acpi/scan.c
+++ linux-2.6.22-rc4/drivers/acpi/scan.c
@@ -16,7 +16,7 @@ ACPI_MODULE_NAME("scan");
 extern struct acpi_device *acpi_root;
 
 #define ACPI_BUS_CLASS			"system_bus"
-#define ACPI_BUS_HID			"ACPI_BUS"
+#define ACPI_BUS_HID			"XBUS0001"
 #define ACPI_BUS_DEVICE_NAME		"System Bus"
 
 static LIST_HEAD(acpi_device_list);
@@ -29,6 +29,69 @@ struct acpi_device_bus_id{
 	unsigned int instance_no;
 	struct list_head node;
 };
+
+/*
+  Currently only handles ID strings, not compressed EISA, here the spec:
+
+  A _HID object evaluates to either a numeric 32-bit compressed EISA type ID
+  or a string. If a string, the format must be an alphanumeric PNP or ACPI ID
+  with no asterisk or other leading characters.
+
+  Why is hardware_id char[15] -> see include/acpi/acpi_bus.h ?!?
+
+  This function only handles devices correctly that have a HID.
+  If there are devices that have CID(s), but no HID work needs
+*/
+int create_modalias(struct acpi_device *acpi_dev, char *modalias, int size){
+
+	int len;
+
+	if (!acpi_dev->flags.hardware_id)
+		return -ENODEV;
+
+	len = snprintf(modalias, size, "acpi:%s:",
+		       acpi_dev->pnp.hardware_id);
+	if (len < 0 || len >= size)
+		return -EINVAL;
+	size -= len;
+
+	if (acpi_dev->flags.compatible_ids) {
+		struct acpi_compatible_id_list *cid_list;
+		int i;
+		int count;
+
+		cid_list = acpi_dev->pnp.cid_list;
+		for (i = 0; i < cid_list->count; i++) {
+			count = snprintf(&modalias[len], size, "%s:",
+					 cid_list->id[i].value);
+			if (count < 0 || count >= size) {
+				printk(KERN_ERR "acpi: %s cid[%i] exceeds event buffer size",
+				       acpi_dev->pnp.device_name, i);
+				break;
+			}
+			len += count;
+			size -= count;
+		}
+	}
+
+	modalias[len] = '\0';
+	return len;
+}
+
+static ssize_t
+acpi_device_modalias_show(struct device *dev, struct device_attribute *attr, char *buf) {
+	struct acpi_device *acpi_dev = to_acpi_device(dev);
+	int len;
+
+	/* Device has no HID and no CID or string is >1024 */
+	len = create_modalias(acpi_dev, buf, 1024);
+	if (len <= 0)
+		return 0;
+	buf[len++] = '\n';
+	return len;
+}
+static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL);
+
 static int acpi_eject_operation(acpi_handle handle, int lockable)
 {
 	struct acpi_object_list arg_list;
@@ -154,6 +217,12 @@ static int acpi_device_setup_files(struc
 			goto end;
 	}
 
+	if (dev->flags.hardware_id || dev->flags.compatible_ids){
+		result = device_create_file(&dev->dev, &dev_attr_modalias);
+		if(result)
+			goto end;
+	}
+
         /*
          * If device has _EJ0, 'eject' file is created that is used to trigger
          * hot-removal function from userland.
@@ -178,6 +247,9 @@ static void acpi_device_remove_files(str
 	if (ACPI_SUCCESS(status))
 		device_remove_file(&dev->dev, &dev_attr_eject);
 
+	if (dev->flags.hardware_id || dev->flags.compatible_ids)
+		device_remove_file(&dev->dev, &dev_attr_modalias);
+
 	if(dev->flags.hardware_id)
 		device_remove_file(&dev->dev, &dev_attr_hid);
 	if(dev->handle)
@@ -186,6 +258,37 @@ static void acpi_device_remove_files(str
 /* --------------------------------------------------------------------------
 			ACPI Bus operations
    -------------------------------------------------------------------------- */
+
+int acpi_match_device_ids(struct acpi_device *device,
+			  const struct acpi_device_id *ids)
+{
+	const struct acpi_device_id *id;
+
+	if (device->flags.hardware_id) {
+		for (id = ids; id->id[0]; id++) {
+			if (!strcmp((char*)id->id, device->pnp.hardware_id))
+				return 0;
+		}
+	}
+
+	if (device->flags.compatible_ids) {
+		struct acpi_compatible_id_list *cid_list = device->pnp.cid_list;
+		int i;
+
+		for (id = ids; id->id[0]; id++) {
+			/* compare multiple _CID entries against driver ids */
+			for (i = 0; i < cid_list->count; i++) {
+				if (!strcmp((char*)id->id,
+					    cid_list->id[i].value))
+					return 0;
+			}
+		}
+	}
+
+	return -ENOENT;
+}
+EXPORT_SYMBOL(acpi_match_device_ids);
+
 static void acpi_device_release(struct device *dev)
 {
 	struct acpi_device *acpi_dev = to_acpi_device(dev);
@@ -219,37 +322,19 @@ 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_match_ids(acpi_dev, acpi_drv->ids);
+	return !acpi_match_device_ids(acpi_dev, acpi_drv->ids);
 }
 
 static int acpi_device_uevent(struct device *dev, char **envp, int num_envp,
-	char *buffer, int buffer_size)
+			      char *buffer, int buffer_size)
 {
 	struct acpi_device *acpi_dev = to_acpi_device(dev);
-	int i = 0, length = 0, ret = 0;
-
-	if (acpi_dev->flags.hardware_id)
-		ret = add_uevent_var(envp, num_envp, &i,
-			buffer, buffer_size, &length,
-			"HWID=%s", acpi_dev->pnp.hardware_id);
-	if (ret)
-		return -ENOMEM;
-	if (acpi_dev->flags.compatible_ids) {
-		int j;
-		struct acpi_compatible_id_list *cid_list;
 
-		cid_list = acpi_dev->pnp.cid_list;
-
-		for (j = 0; j < cid_list->count; j++) {
-			ret = add_uevent_var(envp, num_envp, &i, buffer,
-				buffer_size, &length, "COMPTID=%s",
-				cid_list->id[j].value);
-			if (ret)
-				return -ENOMEM;
-		}
+	strcpy(buffer, "MODALIAS=");
+	if (create_modalias(acpi_dev, buffer + 9, buffer_size - 9) > 0) {
+		envp[0] = buffer;
+		envp[1] = NULL;
 	}
-
-	envp[i] = NULL;
 	return 0;
 }
 
@@ -543,25 +628,6 @@ void acpi_bus_data_handler(acpi_handle h
 	return;
 }
 
-int acpi_match_ids(struct acpi_device *device, char *ids)
-{
-	if (device->flags.hardware_id)
-		if (strstr(ids, device->pnp.hardware_id))
-			return 0;
-
-	if (device->flags.compatible_ids) {
-		struct acpi_compatible_id_list *cid_list = device->pnp.cid_list;
-		int i;
-
-		/* compare multiple _CID entries against driver ids */
-		for (i = 0; i < cid_list->count; i++) {
-			if (strstr(ids, cid_list->id[i].value))
-				return 0;
-		}
-	}
-	return -ENOENT;
-}
-
 static int acpi_bus_get_perf_flags(struct acpi_device *device)
 {
 	device->performance.state = ACPI_STATE_UNKNOWN;
@@ -624,6 +690,13 @@ static int acpi_bus_get_wakeup_device_fl
 	struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
 	union acpi_object *package = NULL;
 
+	struct acpi_device_id button_device_ids[] = {
+		{"PNP0C0D", 0},
+		{"PNP0C0C", 0},
+		{"PNP0C0E", 0},
+		{"", 0},
+	};
+
 
 	/* _PRW */
 	status = acpi_evaluate_object(device->handle, "_PRW", NULL, &buffer);
@@ -643,7 +716,7 @@ static int acpi_bus_get_wakeup_device_fl
 
 	device->wakeup.flags.valid = 1;
 	/* Power button, Lid switch always enable wakeup */
-	if (!acpi_match_ids(device, "PNP0C0D,PNP0C0C,PNP0C0E"))
+	if (!acpi_match_device_ids(device, button_device_ids))
 		device->wakeup.flags.run_wake = 1;
 
       end:
Index: linux-2.6.22-rc4/drivers/pnp/pnpacpi/core.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/pnp/pnpacpi/core.c
+++ linux-2.6.22-rc4/drivers/pnp/pnpacpi/core.c
@@ -21,7 +21,10 @@
 
 #include <linux/acpi.h>
 #include <linux/pnp.h>
+#include <linux/mod_devicetable.h>
 #include <acpi/acpi_bus.h>
+#include <acpi/actypes.h>
+
 #include "pnpacpi.h"
 
 static int num = 0;
@@ -33,15 +36,17 @@ static int num = 0;
  * have irqs (PIC, Timer) because we call acpi_register_gsi.
  * Finaly only devices that have a CRS method need to be in this list.
  */
-static char __initdata excluded_id_list[] =
-	"PNP0C09," /* EC */
-	"PNP0C0F," /* Link device */
-	"PNP0000," /* PIC */
-	"PNP0100," /* Timer */
-	;
+static __initdata struct acpi_device_id excluded_id_list[] ={
+	{"PNP0C09", 0}, /* EC */
+	{"PNP0C0F", 0}, /* Link device */
+	{"PNP0000", 0}, /* PIC */
+	{"PNP0100", 0}, /* Timer */
+	{"", 0};
+};
+
 static inline int is_exclusive_device(struct acpi_device *dev)
 {
-	return (!acpi_match_ids(dev, excluded_id_list));
+	return (!acpi_match_device_ids(dev, excluded_id_list));
 }
 
 /*
Index: linux-2.6.22-rc4/include/linux/acpi.h
===================================================================
--- linux-2.6.22-rc4.orig/include/linux/acpi.h
+++ linux-2.6.22-rc4/include/linux/acpi.h
@@ -33,6 +33,7 @@
 #endif
 
 #include <linux/list.h>
+#include <linux/mod_devicetable.h>
 
 #include <acpi/acpi.h>
 #include <acpi/acpi_bus.h>

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

* Re: [PATCH 3/3] ACPI autoloading - Create __mod_acpi_device_table symbol for all acpi drivers.
  2007-06-17 20:24   ` [PATCH 3/3] ACPI autoloading - Create __mod_acpi_device_table symbol for all acpi drivers Thomas Renninger
@ 2007-06-17 22:49     ` Henrique de Moraes Holschuh
  2007-06-19 12:53       ` Thomas Renninger
  2007-06-20 17:06     ` Mattia Dongili
  1 sibling, 1 reply; 19+ messages in thread
From: Henrique de Moraes Holschuh @ 2007-06-17 22:49 UTC (permalink / raw)
  To: Thomas Renninger; +Cc: Len Brown, linux-kernel, linux-acpi

On Sun, 17 Jun 2007, Thomas Renninger wrote:
> Create __mod_acpi_device_table symbol for all acpi drivers.

thinkpad-acpi will autoload by DMI ids in 2.6.23, which is a much better
solution for model-specific drivers like thinkpad-acpi than autoloading by
HID, IMHO.

Thus, I'd prefer if your patches did not make thinkpad-acpi autoload by HID.

I will send a first batch of thinkpad-acpi changes for 2.6.23 to the list
soon, which includes the dmi autoload aliases.

-- 
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique Holschuh

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

* Re: [PATCH 3/3] ACPI autoloading - Create __mod_acpi_device_table symbol for all acpi drivers.
  2007-06-17 22:49     ` Henrique de Moraes Holschuh
@ 2007-06-19 12:53       ` Thomas Renninger
  2007-06-19 16:23         ` Mattia Dongili
  2007-06-19 21:27         ` Henrique de Moraes Holschuh
  0 siblings, 2 replies; 19+ messages in thread
From: Thomas Renninger @ 2007-06-19 12:53 UTC (permalink / raw)
  To: Henrique de Moraes Holschuh
  Cc: Len Brown, linux-kernel, linux-acpi, Kay Sievers

[-- Attachment #1: Type: text/plain, Size: 22973 bytes --]

On Sun, 2007-06-17 at 19:49 -0300, Henrique de Moraes Holschuh wrote:
> On Sun, 17 Jun 2007, Thomas Renninger wrote:
> > Create __mod_acpi_device_table symbol for all acpi drivers.
> 
> thinkpad-acpi will autoload by DMI ids in 2.6.23, which is a much better
> solution for model-specific drivers like thinkpad-acpi than autoloading by
> HID, IMHO.
Yes, I saw some dmi udev strings on Kay's machine and for the thinkpad
module dmi autoloading is much better.
> model-specific drivers like thinkpad-acpi
Not in general, only if the driver provides additional functions and the
ACPI device does not appear on machines that need those additional
functions.
E.g. the asus driver AFAIK serves exactly the ACPI device it registers
for.

> Thus, I'd prefer if your patches did not make thinkpad-acpi autoload by HID.
It would not really hurt? At least thinkpad module is an acpi driver for
those two HIDs... But your are right, it's superfluous, here with
__mod_acpi_device_table symbol ripped out of thinkpad.ko.
Hmm, what do you think about splitting the Thinkpad driver into Hotkey,
PCI and rest? This one got a complicated beast...


Create __mod_acpi_device_table symbol for all acpi drivers.

modpost is going to use this one to create modules.alias

Hopefully thinkpad module still works.
IMO this one should get restructured and make use of acpi_bus_register_driver
and try to avoid to test for HIDs/CIDs for its own.

Signed-off-by: Thomas Renninger <trenn@suse.de>

---
 drivers/acpi/ac.c               |    9 +++++++--
 drivers/acpi/acpi_memhotplug.c  |    8 +++++++-
 drivers/acpi/asus_acpi.c        |   11 ++++++++---
 drivers/acpi/battery.c          |    9 +++++++--
 drivers/acpi/button.c           |   10 +++++++++-
 drivers/acpi/container.c        |   10 +++++++++-
 drivers/acpi/ec.c               |   15 +++++++++++++--
 drivers/acpi/fan.c              |    8 +++++++-
 drivers/acpi/pci_link.c         |    9 +++++++--
 drivers/acpi/pci_root.c         |    9 +++++++--
 drivers/acpi/power.c            |    8 +++++++-
 drivers/acpi/processor_core.c   |    8 +++++++-
 drivers/acpi/sbs.c              |    9 +++++++--
 drivers/acpi/thermal.c          |    8 +++++++-
 drivers/acpi/video.c            |    8 +++++++-
 drivers/char/hpet.c             |    8 +++++++-
 drivers/input/misc/atlas_btns.c |    9 +++++++--
 drivers/misc/asus-laptop.c      |    9 +++++++--
 drivers/misc/sony-laptop.c      |   21 +++++++++++++++++++--
 drivers/misc/thinkpad_acpi.c    |   24 ++++++++++++++++++++----
 drivers/misc/thinkpad_acpi.h    |    2 +-
 21 files changed, 177 insertions(+), 35 deletions(-)

Index: linux-2.6.22-rc5/drivers/acpi/button.c
===================================================================
--- linux-2.6.22-rc5.orig/drivers/acpi/button.c
+++ linux-2.6.22-rc5/drivers/acpi/button.c
@@ -66,6 +66,14 @@ MODULE_AUTHOR("Paul Diefenbaugh");
 MODULE_DESCRIPTION("ACPI Button Driver");
 MODULE_LICENSE("GPL");
 
+static const struct acpi_device_id button_device_ids[] = {
+	{ACPI_BUTTON_HID_LID, 0},
+	{ACPI_BUTTON_HID_SLEEP, 0},
+	{ACPI_BUTTON_HID_POWER, 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, button_device_ids);
+
 static int acpi_button_add(struct acpi_device *device);
 static int acpi_button_remove(struct acpi_device *device, int type);
 static int acpi_button_info_open_fs(struct inode *inode, struct file *file);
@@ -74,7 +82,7 @@ static int acpi_button_state_open_fs(str
 static struct acpi_driver acpi_button_driver = {
 	.name = "button",
 	.class = ACPI_BUTTON_CLASS,
-	.ids = "button_power,button_sleep,PNP0C0D,PNP0C0C,PNP0C0E",
+	.ids = button_device_ids,
 	.ops = {
 		.add = acpi_button_add,
 		.remove = acpi_button_remove,
Index: linux-2.6.22-rc5/drivers/acpi/asus_acpi.c
===================================================================
--- linux-2.6.22-rc5.orig/drivers/acpi/asus_acpi.c
+++ linux-2.6.22-rc5/drivers/acpi/asus_acpi.c
@@ -56,7 +56,6 @@
 #define ACPI_HOTK_NAME          "Asus Laptop ACPI Extras Driver"
 #define ACPI_HOTK_CLASS         "hotkey"
 #define ACPI_HOTK_DEVICE_NAME   "Hotkey"
-#define ACPI_HOTK_HID           "ATK0100"
 
 /*
  * Some events we use, same for all Asus
@@ -426,14 +425,20 @@ static struct acpi_table_header *asus_in
 static struct asus_hotk *hotk;
 
 /*
- * The hotkey driver declaration
+ * The hotkey driver and autoloading declaration
  */
 static int asus_hotk_add(struct acpi_device *device);
 static int asus_hotk_remove(struct acpi_device *device, int type);
+static const struct acpi_device_id asus_device_ids[] = {
+	{"ATK0100", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, asus_device_ids);
+
 static struct acpi_driver asus_hotk_driver = {
 	.name = "asus_acpi",
 	.class = ACPI_HOTK_CLASS,
-	.ids = ACPI_HOTK_HID,
+	.ids = asus_device_ids,
 	.ops = {
 		.add = asus_hotk_add,
 		.remove = asus_hotk_remove,
Index: linux-2.6.22-rc5/drivers/acpi/fan.c
===================================================================
--- linux-2.6.22-rc5.orig/drivers/acpi/fan.c
+++ linux-2.6.22-rc5/drivers/acpi/fan.c
@@ -50,10 +50,16 @@ static int acpi_fan_remove(struct acpi_d
 static int acpi_fan_suspend(struct acpi_device *device, pm_message_t state);
 static int acpi_fan_resume(struct acpi_device *device);
 
+static const struct acpi_device_id fan_device_ids[] = {
+	{"PNP0C0B", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, fan_device_ids);
+
 static struct acpi_driver acpi_fan_driver = {
 	.name = "fan",
 	.class = ACPI_FAN_CLASS,
-	.ids = "PNP0C0B",
+	.ids = fan_device_ids,
 	.ops = {
 		.add = acpi_fan_add,
 		.remove = acpi_fan_remove,
Index: linux-2.6.22-rc5/drivers/acpi/container.c
===================================================================
--- linux-2.6.22-rc5.orig/drivers/acpi/container.c
+++ linux-2.6.22-rc5/drivers/acpi/container.c
@@ -52,10 +52,18 @@ MODULE_LICENSE("GPL");
 static int acpi_container_add(struct acpi_device *device);
 static int acpi_container_remove(struct acpi_device *device, int type);
 
+static const struct acpi_device_id container_device_ids[] = {
+	{"ACPI0004", 0},
+	{"PNP0A05", 0},
+	{"PNP0A06", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, container_device_ids);
+
 static struct acpi_driver acpi_container_driver = {
 	.name = "container",
 	.class = ACPI_CONTAINER_CLASS,
-	.ids = "ACPI0004,PNP0A05,PNP0A06",
+	.ids = container_device_ids,
 	.ops = {
 		.add = acpi_container_add,
 		.remove = acpi_container_remove,
Index: linux-2.6.22-rc5/drivers/acpi/sbs.c
===================================================================
--- linux-2.6.22-rc5.orig/drivers/acpi/sbs.c
+++ linux-2.6.22-rc5/drivers/acpi/sbs.c
@@ -38,7 +38,6 @@
 #define ACPI_SBS_CLASS			"sbs"
 #define ACPI_AC_CLASS			"ac_adapter"
 #define ACPI_BATTERY_CLASS		"battery"
-#define ACPI_SBS_HID			"ACPI0002"
 #define ACPI_SBS_DEVICE_NAME		"Smart Battery System"
 #define ACPI_SBS_FILE_INFO		"info"
 #define ACPI_SBS_FILE_STATE		"state"
@@ -124,10 +123,16 @@ static int acpi_sbs_add(struct acpi_devi
 static int acpi_sbs_remove(struct acpi_device *device, int type);
 static int acpi_sbs_resume(struct acpi_device *device);
 
+static const struct acpi_device_id sbs_device_ids[] = {
+	{"ACPI0002", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, sbs_device_ids);
+
 static struct acpi_driver acpi_sbs_driver = {
 	.name = "sbs",
 	.class = ACPI_SBS_CLASS,
-	.ids = ACPI_SBS_HID,
+	.ids = sbs_device_ids,
 	.ops = {
 		.add = acpi_sbs_add,
 		.remove = acpi_sbs_remove,
Index: linux-2.6.22-rc5/drivers/acpi/battery.c
===================================================================
--- linux-2.6.22-rc5.orig/drivers/acpi/battery.c
+++ linux-2.6.22-rc5/drivers/acpi/battery.c
@@ -41,7 +41,6 @@
 
 #define ACPI_BATTERY_COMPONENT		0x00040000
 #define ACPI_BATTERY_CLASS		"battery"
-#define ACPI_BATTERY_HID		"PNP0C0A"
 #define ACPI_BATTERY_DEVICE_NAME	"Battery"
 #define ACPI_BATTERY_FILE_INFO		"info"
 #define ACPI_BATTERY_FILE_STATUS	"state"
@@ -65,10 +64,16 @@ static int acpi_battery_add(struct acpi_
 static int acpi_battery_remove(struct acpi_device *device, int type);
 static int acpi_battery_resume(struct acpi_device *device);
 
+static const struct acpi_device_id battery_device_ids[] = {
+	{"PNP0C0A", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, battery_device_ids);
+
 static struct acpi_driver acpi_battery_driver = {
 	.name = "battery",
 	.class = ACPI_BATTERY_CLASS,
-	.ids = ACPI_BATTERY_HID,
+	.ids = battery_device_ids,
 	.ops = {
 		.add = acpi_battery_add,
 		.resume = acpi_battery_resume,
Index: linux-2.6.22-rc5/drivers/acpi/thermal.c
===================================================================
--- linux-2.6.22-rc5.orig/drivers/acpi/thermal.c
+++ linux-2.6.22-rc5/drivers/acpi/thermal.c
@@ -92,10 +92,16 @@ static int acpi_thermal_polling_open_fs(
 static ssize_t acpi_thermal_write_polling(struct file *, const char __user *,
 					  size_t, loff_t *);
 
+static const struct acpi_device_id  thermal_device_ids[] = {
+	{ACPI_THERMAL_HID, 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, thermal_device_ids);
+
 static struct acpi_driver acpi_thermal_driver = {
 	.name = "thermal",
 	.class = ACPI_THERMAL_CLASS,
-	.ids = ACPI_THERMAL_HID,
+	.ids = thermal_device_ids,
 	.ops = {
 		.add = acpi_thermal_add,
 		.remove = acpi_thermal_remove,
Index: linux-2.6.22-rc5/drivers/acpi/ac.c
===================================================================
--- linux-2.6.22-rc5.orig/drivers/acpi/ac.c
+++ linux-2.6.22-rc5/drivers/acpi/ac.c
@@ -34,7 +34,6 @@
 
 #define ACPI_AC_COMPONENT		0x00020000
 #define ACPI_AC_CLASS			"ac_adapter"
-#define ACPI_AC_HID 			"ACPI0003"
 #define ACPI_AC_DEVICE_NAME		"AC Adapter"
 #define ACPI_AC_FILE_STATE		"state"
 #define ACPI_AC_NOTIFY_STATUS		0x80
@@ -56,10 +55,16 @@ static int acpi_ac_add(struct acpi_devic
 static int acpi_ac_remove(struct acpi_device *device, int type);
 static int acpi_ac_open_fs(struct inode *inode, struct file *file);
 
+const static struct acpi_device_id ac_device_ids[] = {
+	{"ACPI0003", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, ac_device_ids);
+
 static struct acpi_driver acpi_ac_driver = {
 	.name = "ac",
 	.class = ACPI_AC_CLASS,
-	.ids = ACPI_AC_HID,
+	.ids = ac_device_ids,
 	.ops = {
 		.add = acpi_ac_add,
 		.remove = acpi_ac_remove,
Index: linux-2.6.22-rc5/drivers/acpi/pci_link.c
===================================================================
--- linux-2.6.22-rc5.orig/drivers/acpi/pci_link.c
+++ linux-2.6.22-rc5/drivers/acpi/pci_link.c
@@ -46,7 +46,6 @@
 #define _COMPONENT		ACPI_PCI_COMPONENT
 ACPI_MODULE_NAME("pci_link");
 #define ACPI_PCI_LINK_CLASS		"pci_irq_routing"
-#define ACPI_PCI_LINK_HID		"PNP0C0F"
 #define ACPI_PCI_LINK_DEVICE_NAME	"PCI Interrupt Link"
 #define ACPI_PCI_LINK_FILE_INFO		"info"
 #define ACPI_PCI_LINK_FILE_STATUS	"state"
@@ -54,10 +53,16 @@ ACPI_MODULE_NAME("pci_link");
 static int acpi_pci_link_add(struct acpi_device *device);
 static int acpi_pci_link_remove(struct acpi_device *device, int type);
 
+static struct acpi_device_id link_device_ids[] = {
+	{"PNP0C0F", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, link_device_ids);
+
 static struct acpi_driver acpi_pci_link_driver = {
 	.name = "pci_link",
 	.class = ACPI_PCI_LINK_CLASS,
-	.ids = ACPI_PCI_LINK_HID,
+	.ids = link_device_ids,
 	.ops = {
 		.add = acpi_pci_link_add,
 		.remove = acpi_pci_link_remove,
Index: linux-2.6.22-rc5/drivers/acpi/pci_root.c
===================================================================
--- linux-2.6.22-rc5.orig/drivers/acpi/pci_root.c
+++ linux-2.6.22-rc5/drivers/acpi/pci_root.c
@@ -38,16 +38,21 @@
 #define _COMPONENT		ACPI_PCI_COMPONENT
 ACPI_MODULE_NAME("pci_root");
 #define ACPI_PCI_ROOT_CLASS		"pci_bridge"
-#define ACPI_PCI_ROOT_HID		"PNP0A03"
 #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);
 
+static struct acpi_device_id root_device_ids[] = {
+	{"PNP0A03", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, root_device_ids);
+
 static struct acpi_driver acpi_pci_root_driver = {
 	.name = "pci_root",
 	.class = ACPI_PCI_ROOT_CLASS,
-	.ids = ACPI_PCI_ROOT_HID,
+	.ids = root_device_ids,
 	.ops = {
 		.add = acpi_pci_root_add,
 		.remove = acpi_pci_root_remove,
Index: linux-2.6.22-rc5/drivers/acpi/power.c
===================================================================
--- linux-2.6.22-rc5.orig/drivers/acpi/power.c
+++ linux-2.6.22-rc5/drivers/acpi/power.c
@@ -59,10 +59,16 @@ static int acpi_power_remove(struct acpi
 static int acpi_power_resume(struct acpi_device *device);
 static int acpi_power_open_fs(struct inode *inode, struct file *file);
 
+static struct acpi_device_id power_device_ids[] = {
+	{ACPI_POWER_HID, 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, power_device_ids);
+
 static struct acpi_driver acpi_power_driver = {
 	.name = "power",
 	.class = ACPI_POWER_CLASS,
-	.ids = ACPI_POWER_HID,
+	.ids = power_device_ids,
 	.ops = {
 		.add = acpi_power_add,
 		.remove = acpi_power_remove,
Index: linux-2.6.22-rc5/drivers/acpi/acpi_memhotplug.c
===================================================================
--- linux-2.6.22-rc5.orig/drivers/acpi/acpi_memhotplug.c
+++ linux-2.6.22-rc5/drivers/acpi/acpi_memhotplug.c
@@ -53,10 +53,16 @@ static int acpi_memory_device_add(struct
 static int acpi_memory_device_remove(struct acpi_device *device, int type);
 static int acpi_memory_device_start(struct acpi_device *device);
 
+static const struct acpi_device_id memory_device_ids[] = {
+	{ACPI_MEMORY_DEVICE_HID, 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, memory_device_ids);
+
 static struct acpi_driver acpi_memory_device_driver = {
 	.name = "acpi_memhotplug",
 	.class = ACPI_MEMORY_DEVICE_CLASS,
-	.ids = ACPI_MEMORY_DEVICE_HID,
+	.ids = memory_device_ids,
 	.ops = {
 		.add = acpi_memory_device_add,
 		.remove = acpi_memory_device_remove,
Index: linux-2.6.22-rc5/drivers/acpi/processor_core.c
===================================================================
--- linux-2.6.22-rc5.orig/drivers/acpi/processor_core.c
+++ linux-2.6.22-rc5/drivers/acpi/processor_core.c
@@ -85,10 +85,16 @@ static void acpi_processor_notify(acpi_h
 static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu);
 static int acpi_processor_handle_eject(struct acpi_processor *pr);
 
+static const struct acpi_device_id processor_device_ids[] = {
+	{ACPI_PROCESSOR_HID, 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, processor_device_ids);
+
 static struct acpi_driver acpi_processor_driver = {
 	.name = "processor",
 	.class = ACPI_PROCESSOR_CLASS,
-	.ids = ACPI_PROCESSOR_HID,
+	.ids = processor_device_ids,
 	.ops = {
 		.add = acpi_processor_add,
 		.remove = acpi_processor_remove,
Index: linux-2.6.22-rc5/drivers/acpi/video.c
===================================================================
--- linux-2.6.22-rc5.orig/drivers/acpi/video.c
+++ linux-2.6.22-rc5/drivers/acpi/video.c
@@ -73,10 +73,16 @@ MODULE_LICENSE("GPL");
 static int acpi_video_bus_add(struct acpi_device *device);
 static int acpi_video_bus_remove(struct acpi_device *device, int type);
 
+static const struct acpi_device_id video_device_ids[] = {
+	{ACPI_VIDEO_HID, 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, video_device_ids);
+
 static struct acpi_driver acpi_video_bus = {
 	.name = "video",
 	.class = ACPI_VIDEO_CLASS,
-	.ids = ACPI_VIDEO_HID,
+	.ids = video_device_ids,
 	.ops = {
 		.add = acpi_video_bus_add,
 		.remove = acpi_video_bus_remove,
Index: linux-2.6.22-rc5/drivers/char/hpet.c
===================================================================
--- linux-2.6.22-rc5.orig/drivers/char/hpet.c
+++ linux-2.6.22-rc5/drivers/char/hpet.c
@@ -999,9 +999,15 @@ static int hpet_acpi_remove(struct acpi_
 	return -EINVAL;
 }
 
+static const struct acpi_device_id hpet_device_ids[] = {
+	{"PNP0103", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, hpet_device_ids);
+
 static struct acpi_driver hpet_acpi_driver = {
 	.name = "hpet",
-	.ids = "PNP0103",
+	.ids = hpet_device_ids,
 	.ops = {
 		.add = hpet_acpi_add,
 		.remove = hpet_acpi_remove,
Index: linux-2.6.22-rc5/drivers/input/misc/atlas_btns.c
===================================================================
--- linux-2.6.22-rc5.orig/drivers/input/misc/atlas_btns.c
+++ linux-2.6.22-rc5/drivers/input/misc/atlas_btns.c
@@ -31,7 +31,6 @@
 
 #define ACPI_ATLAS_NAME			"Atlas ACPI"
 #define ACPI_ATLAS_CLASS		"Atlas"
-#define ACPI_ATLAS_BUTTON_HID		"ASIM0000"
 
 static struct input_dev *input_dev;
 
@@ -130,10 +129,16 @@ static int atlas_acpi_button_remove(stru
 	return status;
 }
 
+static const struct acpi_device_id atlas_device_ids[] = {
+	{"ASIM0000", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, atlas_device_ids);
+
 static struct acpi_driver atlas_acpi_driver = {
 	.name	= ACPI_ATLAS_NAME,
 	.class	= ACPI_ATLAS_CLASS,
-	.ids	= ACPI_ATLAS_BUTTON_HID,
+	.ids	= atlas_device_ids,
 	.ops	= {
 		.add	= atlas_acpi_button_add,
 		.remove	= atlas_acpi_button_remove,
Index: linux-2.6.22-rc5/drivers/misc/asus-laptop.c
===================================================================
--- linux-2.6.22-rc5.orig/drivers/misc/asus-laptop.c
+++ linux-2.6.22-rc5/drivers/misc/asus-laptop.c
@@ -53,7 +53,6 @@
 #define ASUS_HOTK_NAME          "Asus Laptop Support"
 #define ASUS_HOTK_CLASS         "hotkey"
 #define ASUS_HOTK_DEVICE_NAME   "Hotkey"
-#define ASUS_HOTK_HID           "ATK0100"
 #define ASUS_HOTK_FILE          "asus-laptop"
 #define ASUS_HOTK_PREFIX        "\\_SB.ATKD."
 
@@ -197,12 +196,18 @@ static struct asus_hotk *hotk;
 /*
  * The hotkey driver declaration
  */
+static const struct acpi_device_id asus_device_ids[] = {
+	{"ATK0100", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, asus_device_ids);
+
 static int asus_hotk_add(struct acpi_device *device);
 static int asus_hotk_remove(struct acpi_device *device, int type);
 static struct acpi_driver asus_hotk_driver = {
 	.name = ASUS_HOTK_NAME,
 	.class = ASUS_HOTK_CLASS,
-	.ids = ASUS_HOTK_HID,
+	.ids = asus_device_ids,
 	.ops = {
 		.add = asus_hotk_add,
 		.remove = asus_hotk_remove,
Index: linux-2.6.22-rc5/drivers/acpi/ec.c
===================================================================
--- linux-2.6.22-rc5.orig/drivers/acpi/ec.c
+++ linux-2.6.22-rc5/drivers/acpi/ec.c
@@ -43,7 +43,6 @@
 ACPI_MODULE_NAME("ec");
 #define ACPI_EC_COMPONENT		0x00100000
 #define ACPI_EC_CLASS			"embedded_controller"
-#define ACPI_EC_HID			"PNP0C09"
 #define ACPI_EC_DEVICE_NAME		"Embedded Controller"
 #define ACPI_EC_FILE_INFO		"info"
 #undef PREFIX
@@ -80,10 +79,22 @@ static int acpi_ec_start(struct acpi_dev
 static int acpi_ec_stop(struct acpi_device *device, int type);
 static int acpi_ec_add(struct acpi_device *device);
 
+/*
+   ec never can be a module..., anyway let's keep the autoloading
+   things here, this line does not hurt.
+*/
+
+static const struct acpi_device_id ec_device_ids[] = {
+	{"PNP0C09", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, ec_device_ids);
+
+
 static struct acpi_driver acpi_ec_driver = {
 	.name = "ec",
 	.class = ACPI_EC_CLASS,
-	.ids = ACPI_EC_HID,
+	.ids = ec_device_ids,
 	.ops = {
 		.add = acpi_ec_add,
 		.remove = acpi_ec_remove,
Index: linux-2.6.22-rc5/drivers/misc/thinkpad_acpi.c
===================================================================
--- linux-2.6.22-rc5.orig/drivers/misc/thinkpad_acpi.c
+++ linux-2.6.22-rc5/drivers/misc/thinkpad_acpi.c
@@ -388,12 +388,13 @@ static int __init register_tpacpi_subdri
 
 	sprintf(ibm->acpi->driver->name, "%s_%s", IBM_NAME, ibm->name);
 	ibm->acpi->driver->ids = ibm->acpi->hid;
+
 	ibm->acpi->driver->ops.add = &tpacpi_device_add;
 
 	rc = acpi_bus_register_driver(ibm->acpi->driver);
 	if (rc < 0) {
 		printk(IBM_ERR "acpi_bus_register_driver(%s) failed: %d\n",
-		       ibm->acpi->hid, rc);
+		       ibm->name, rc);
 		kfree(ibm->acpi->driver);
 		ibm->acpi->driver = NULL;
 	} else if (!rc)
@@ -1000,8 +1001,17 @@ errexit:
 	return res;
 }
 
+static const struct acpi_device_id ibm_htk_device_ids[] = {
+	{IBM_HKEY_HID, 0},
+	{"", 0},
+};
+static const struct acpi_device_id ibm_pci_device_ids[] = {
+	{IBM_PCI_HID, 0},
+	{"", 0},
+};
+
 static struct tp_acpi_drv_struct ibm_hotkey_acpidriver = {
-	.hid = IBM_HKEY_HID,
+	.hid = ibm_htk_device_ids,
 	.notify = hotkey_notify,
 	.handle = &hkey_handle,
 	.type = ACPI_DEVICE_NOTIFY,
@@ -1763,6 +1773,11 @@ IBM_HANDLE(dock, root, "\\_SB.GDCK",	/* 
 /* don't list other alternatives as we install a notify handler on the 570 */
 IBM_HANDLE(pci, root, "\\_SB.PCI");	/* 570 */
 
+static const struct acpi_device_id ibm_pci_device_ids[] = {
+	{IBM_PCI_HID, 0},
+	{"", 0},
+};
+
 static struct tp_acpi_drv_struct ibm_dock_acpidriver[2] = {
 	{
 	 .notify = dock_notify,
@@ -1770,7 +1785,7 @@ static struct tp_acpi_drv_struct ibm_doc
 	 .type = ACPI_SYSTEM_NOTIFY,
 	},
 	{
-	 .hid = IBM_PCI_HID,
+	 .hid = ibm_pci_device_ids,
 	 .notify = dock_notify,
 	 .handle = &pci_handle,
 	 .type = ACPI_SYSTEM_NOTIFY,
@@ -1829,7 +1844,8 @@ static int __init dock_init2(struct ibm_
 static void dock_notify(struct ibm_struct *ibm, u32 event)
 {
 	int docked = dock_docked();
-	int pci = ibm->acpi->hid && strstr(ibm->acpi->hid, IBM_PCI_HID);
+	int pci = ibm->acpi->hid && ibm->acpi->device &&
+		acpi_match_device_ids(ibm->acpi->device, ibm_pci_device_ids);
 
 	if (event == 1 && !pci)	/* 570 */
 		acpi_bus_generate_event(ibm->acpi->device, event, 1);	/* button */
Index: linux-2.6.22-rc5/drivers/misc/thinkpad_acpi.h
===================================================================
--- linux-2.6.22-rc5.orig/drivers/misc/thinkpad_acpi.h
+++ linux-2.6.22-rc5/drivers/misc/thinkpad_acpi.h
@@ -182,7 +182,7 @@ static void thinkpad_acpi_module_exit(vo
 struct ibm_struct;
 
 struct tp_acpi_drv_struct {
-	char *hid;
+	const struct acpi_device_id *hid;
 	struct acpi_driver *driver;
 
 	void (*notify) (struct ibm_struct *, u32);
Index: linux-2.6.22-rc5/drivers/misc/sony-laptop.c
===================================================================
--- linux-2.6.22-rc5.orig/drivers/misc/sony-laptop.c
+++ linux-2.6.22-rc5/drivers/misc/sony-laptop.c
@@ -890,10 +890,22 @@ static int sony_nc_remove(struct acpi_de
 	return 0;
 }
 
+static const struct acpi_device_id sony_device_ids[] = {
+	{SONY_NC_HID, 0},
+	{SONY_PIC_HID, 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, sony_device_ids);
+
+static const struct acpi_device_id sony_nc_device_ids[] = {
+	{SONY_NC_HID, 0},
+	{"", 0},
+};
+
 static struct acpi_driver sony_nc_driver = {
 	.name = SONY_NC_DRIVER_NAME,
 	.class = SONY_NC_CLASS,
-	.ids = SONY_NC_HID,
+	.ids = sony_nc_device_ids,
 	.owner = THIS_MODULE,
 	.ops = {
 		.add = sony_nc_add,
@@ -2221,10 +2233,15 @@ static int sony_pic_resume(struct acpi_d
 	return 0;
 }
 
+static const struct acpi_device_id sony_pic_device_ids[] = {
+	{SONY_PIC_HID, 0},
+	{"", 0},
+};
+
 static struct acpi_driver sony_pic_driver = {
 	.name = SONY_PIC_DRIVER_NAME,
 	.class = SONY_PIC_CLASS,
-	.ids = SONY_PIC_HID,
+	.ids = sony_pic_device_ids,
 	.owner = THIS_MODULE,
 	.ops = {
 		.add = sony_pic_add,


[-- Attachment #2: acpi_autoloading_implement_device_ids.patch --]
[-- Type: text/x-patch, Size: 21841 bytes --]

Create __mod_acpi_device_table symbol for all acpi drivers.

modpost is going to use this one to create modules.alias

Hopefully thinkpad module still works.
IMO this one should get restructured and make use of acpi_bus_register_driver
and try to avoid to test for HIDs/CIDs for its own.

Signed-off-by: Thomas Renninger <trenn@suse.de>

---
 drivers/acpi/ac.c               |    9 +++++++--
 drivers/acpi/acpi_memhotplug.c  |    8 +++++++-
 drivers/acpi/asus_acpi.c        |   11 ++++++++---
 drivers/acpi/battery.c          |    9 +++++++--
 drivers/acpi/button.c           |   10 +++++++++-
 drivers/acpi/container.c        |   10 +++++++++-
 drivers/acpi/ec.c               |   15 +++++++++++++--
 drivers/acpi/fan.c              |    8 +++++++-
 drivers/acpi/pci_link.c         |    9 +++++++--
 drivers/acpi/pci_root.c         |    9 +++++++--
 drivers/acpi/power.c            |    8 +++++++-
 drivers/acpi/processor_core.c   |    8 +++++++-
 drivers/acpi/sbs.c              |    9 +++++++--
 drivers/acpi/thermal.c          |    8 +++++++-
 drivers/acpi/video.c            |    8 +++++++-
 drivers/char/hpet.c             |    8 +++++++-
 drivers/input/misc/atlas_btns.c |    9 +++++++--
 drivers/misc/asus-laptop.c      |    9 +++++++--
 drivers/misc/sony-laptop.c      |   21 +++++++++++++++++++--
 drivers/misc/thinkpad_acpi.c    |   24 ++++++++++++++++++++----
 drivers/misc/thinkpad_acpi.h    |    2 +-
 21 files changed, 177 insertions(+), 35 deletions(-)

Index: linux-2.6.22-rc5/drivers/acpi/button.c
===================================================================
--- linux-2.6.22-rc5.orig/drivers/acpi/button.c
+++ linux-2.6.22-rc5/drivers/acpi/button.c
@@ -66,6 +66,14 @@ MODULE_AUTHOR("Paul Diefenbaugh");
 MODULE_DESCRIPTION("ACPI Button Driver");
 MODULE_LICENSE("GPL");
 
+static const struct acpi_device_id button_device_ids[] = {
+	{ACPI_BUTTON_HID_LID, 0},
+	{ACPI_BUTTON_HID_SLEEP, 0},
+	{ACPI_BUTTON_HID_POWER, 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, button_device_ids);
+
 static int acpi_button_add(struct acpi_device *device);
 static int acpi_button_remove(struct acpi_device *device, int type);
 static int acpi_button_info_open_fs(struct inode *inode, struct file *file);
@@ -74,7 +82,7 @@ static int acpi_button_state_open_fs(str
 static struct acpi_driver acpi_button_driver = {
 	.name = "button",
 	.class = ACPI_BUTTON_CLASS,
-	.ids = "button_power,button_sleep,PNP0C0D,PNP0C0C,PNP0C0E",
+	.ids = button_device_ids,
 	.ops = {
 		.add = acpi_button_add,
 		.remove = acpi_button_remove,
Index: linux-2.6.22-rc5/drivers/acpi/asus_acpi.c
===================================================================
--- linux-2.6.22-rc5.orig/drivers/acpi/asus_acpi.c
+++ linux-2.6.22-rc5/drivers/acpi/asus_acpi.c
@@ -56,7 +56,6 @@
 #define ACPI_HOTK_NAME          "Asus Laptop ACPI Extras Driver"
 #define ACPI_HOTK_CLASS         "hotkey"
 #define ACPI_HOTK_DEVICE_NAME   "Hotkey"
-#define ACPI_HOTK_HID           "ATK0100"
 
 /*
  * Some events we use, same for all Asus
@@ -426,14 +425,20 @@ static struct acpi_table_header *asus_in
 static struct asus_hotk *hotk;
 
 /*
- * The hotkey driver declaration
+ * The hotkey driver and autoloading declaration
  */
 static int asus_hotk_add(struct acpi_device *device);
 static int asus_hotk_remove(struct acpi_device *device, int type);
+static const struct acpi_device_id asus_device_ids[] = {
+	{"ATK0100", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, asus_device_ids);
+
 static struct acpi_driver asus_hotk_driver = {
 	.name = "asus_acpi",
 	.class = ACPI_HOTK_CLASS,
-	.ids = ACPI_HOTK_HID,
+	.ids = asus_device_ids,
 	.ops = {
 		.add = asus_hotk_add,
 		.remove = asus_hotk_remove,
Index: linux-2.6.22-rc5/drivers/acpi/fan.c
===================================================================
--- linux-2.6.22-rc5.orig/drivers/acpi/fan.c
+++ linux-2.6.22-rc5/drivers/acpi/fan.c
@@ -50,10 +50,16 @@ static int acpi_fan_remove(struct acpi_d
 static int acpi_fan_suspend(struct acpi_device *device, pm_message_t state);
 static int acpi_fan_resume(struct acpi_device *device);
 
+static const struct acpi_device_id fan_device_ids[] = {
+	{"PNP0C0B", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, fan_device_ids);
+
 static struct acpi_driver acpi_fan_driver = {
 	.name = "fan",
 	.class = ACPI_FAN_CLASS,
-	.ids = "PNP0C0B",
+	.ids = fan_device_ids,
 	.ops = {
 		.add = acpi_fan_add,
 		.remove = acpi_fan_remove,
Index: linux-2.6.22-rc5/drivers/acpi/container.c
===================================================================
--- linux-2.6.22-rc5.orig/drivers/acpi/container.c
+++ linux-2.6.22-rc5/drivers/acpi/container.c
@@ -52,10 +52,18 @@ MODULE_LICENSE("GPL");
 static int acpi_container_add(struct acpi_device *device);
 static int acpi_container_remove(struct acpi_device *device, int type);
 
+static const struct acpi_device_id container_device_ids[] = {
+	{"ACPI0004", 0},
+	{"PNP0A05", 0},
+	{"PNP0A06", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, container_device_ids);
+
 static struct acpi_driver acpi_container_driver = {
 	.name = "container",
 	.class = ACPI_CONTAINER_CLASS,
-	.ids = "ACPI0004,PNP0A05,PNP0A06",
+	.ids = container_device_ids,
 	.ops = {
 		.add = acpi_container_add,
 		.remove = acpi_container_remove,
Index: linux-2.6.22-rc5/drivers/acpi/sbs.c
===================================================================
--- linux-2.6.22-rc5.orig/drivers/acpi/sbs.c
+++ linux-2.6.22-rc5/drivers/acpi/sbs.c
@@ -38,7 +38,6 @@
 #define ACPI_SBS_CLASS			"sbs"
 #define ACPI_AC_CLASS			"ac_adapter"
 #define ACPI_BATTERY_CLASS		"battery"
-#define ACPI_SBS_HID			"ACPI0002"
 #define ACPI_SBS_DEVICE_NAME		"Smart Battery System"
 #define ACPI_SBS_FILE_INFO		"info"
 #define ACPI_SBS_FILE_STATE		"state"
@@ -124,10 +123,16 @@ static int acpi_sbs_add(struct acpi_devi
 static int acpi_sbs_remove(struct acpi_device *device, int type);
 static int acpi_sbs_resume(struct acpi_device *device);
 
+static const struct acpi_device_id sbs_device_ids[] = {
+	{"ACPI0002", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, sbs_device_ids);
+
 static struct acpi_driver acpi_sbs_driver = {
 	.name = "sbs",
 	.class = ACPI_SBS_CLASS,
-	.ids = ACPI_SBS_HID,
+	.ids = sbs_device_ids,
 	.ops = {
 		.add = acpi_sbs_add,
 		.remove = acpi_sbs_remove,
Index: linux-2.6.22-rc5/drivers/acpi/battery.c
===================================================================
--- linux-2.6.22-rc5.orig/drivers/acpi/battery.c
+++ linux-2.6.22-rc5/drivers/acpi/battery.c
@@ -41,7 +41,6 @@
 
 #define ACPI_BATTERY_COMPONENT		0x00040000
 #define ACPI_BATTERY_CLASS		"battery"
-#define ACPI_BATTERY_HID		"PNP0C0A"
 #define ACPI_BATTERY_DEVICE_NAME	"Battery"
 #define ACPI_BATTERY_FILE_INFO		"info"
 #define ACPI_BATTERY_FILE_STATUS	"state"
@@ -65,10 +64,16 @@ static int acpi_battery_add(struct acpi_
 static int acpi_battery_remove(struct acpi_device *device, int type);
 static int acpi_battery_resume(struct acpi_device *device);
 
+static const struct acpi_device_id battery_device_ids[] = {
+	{"PNP0C0A", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, battery_device_ids);
+
 static struct acpi_driver acpi_battery_driver = {
 	.name = "battery",
 	.class = ACPI_BATTERY_CLASS,
-	.ids = ACPI_BATTERY_HID,
+	.ids = battery_device_ids,
 	.ops = {
 		.add = acpi_battery_add,
 		.resume = acpi_battery_resume,
Index: linux-2.6.22-rc5/drivers/acpi/thermal.c
===================================================================
--- linux-2.6.22-rc5.orig/drivers/acpi/thermal.c
+++ linux-2.6.22-rc5/drivers/acpi/thermal.c
@@ -92,10 +92,16 @@ static int acpi_thermal_polling_open_fs(
 static ssize_t acpi_thermal_write_polling(struct file *, const char __user *,
 					  size_t, loff_t *);
 
+static const struct acpi_device_id  thermal_device_ids[] = {
+	{ACPI_THERMAL_HID, 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, thermal_device_ids);
+
 static struct acpi_driver acpi_thermal_driver = {
 	.name = "thermal",
 	.class = ACPI_THERMAL_CLASS,
-	.ids = ACPI_THERMAL_HID,
+	.ids = thermal_device_ids,
 	.ops = {
 		.add = acpi_thermal_add,
 		.remove = acpi_thermal_remove,
Index: linux-2.6.22-rc5/drivers/acpi/ac.c
===================================================================
--- linux-2.6.22-rc5.orig/drivers/acpi/ac.c
+++ linux-2.6.22-rc5/drivers/acpi/ac.c
@@ -34,7 +34,6 @@
 
 #define ACPI_AC_COMPONENT		0x00020000
 #define ACPI_AC_CLASS			"ac_adapter"
-#define ACPI_AC_HID 			"ACPI0003"
 #define ACPI_AC_DEVICE_NAME		"AC Adapter"
 #define ACPI_AC_FILE_STATE		"state"
 #define ACPI_AC_NOTIFY_STATUS		0x80
@@ -56,10 +55,16 @@ static int acpi_ac_add(struct acpi_devic
 static int acpi_ac_remove(struct acpi_device *device, int type);
 static int acpi_ac_open_fs(struct inode *inode, struct file *file);
 
+const static struct acpi_device_id ac_device_ids[] = {
+	{"ACPI0003", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, ac_device_ids);
+
 static struct acpi_driver acpi_ac_driver = {
 	.name = "ac",
 	.class = ACPI_AC_CLASS,
-	.ids = ACPI_AC_HID,
+	.ids = ac_device_ids,
 	.ops = {
 		.add = acpi_ac_add,
 		.remove = acpi_ac_remove,
Index: linux-2.6.22-rc5/drivers/acpi/pci_link.c
===================================================================
--- linux-2.6.22-rc5.orig/drivers/acpi/pci_link.c
+++ linux-2.6.22-rc5/drivers/acpi/pci_link.c
@@ -46,7 +46,6 @@
 #define _COMPONENT		ACPI_PCI_COMPONENT
 ACPI_MODULE_NAME("pci_link");
 #define ACPI_PCI_LINK_CLASS		"pci_irq_routing"
-#define ACPI_PCI_LINK_HID		"PNP0C0F"
 #define ACPI_PCI_LINK_DEVICE_NAME	"PCI Interrupt Link"
 #define ACPI_PCI_LINK_FILE_INFO		"info"
 #define ACPI_PCI_LINK_FILE_STATUS	"state"
@@ -54,10 +53,16 @@ ACPI_MODULE_NAME("pci_link");
 static int acpi_pci_link_add(struct acpi_device *device);
 static int acpi_pci_link_remove(struct acpi_device *device, int type);
 
+static struct acpi_device_id link_device_ids[] = {
+	{"PNP0C0F", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, link_device_ids);
+
 static struct acpi_driver acpi_pci_link_driver = {
 	.name = "pci_link",
 	.class = ACPI_PCI_LINK_CLASS,
-	.ids = ACPI_PCI_LINK_HID,
+	.ids = link_device_ids,
 	.ops = {
 		.add = acpi_pci_link_add,
 		.remove = acpi_pci_link_remove,
Index: linux-2.6.22-rc5/drivers/acpi/pci_root.c
===================================================================
--- linux-2.6.22-rc5.orig/drivers/acpi/pci_root.c
+++ linux-2.6.22-rc5/drivers/acpi/pci_root.c
@@ -38,16 +38,21 @@
 #define _COMPONENT		ACPI_PCI_COMPONENT
 ACPI_MODULE_NAME("pci_root");
 #define ACPI_PCI_ROOT_CLASS		"pci_bridge"
-#define ACPI_PCI_ROOT_HID		"PNP0A03"
 #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);
 
+static struct acpi_device_id root_device_ids[] = {
+	{"PNP0A03", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, root_device_ids);
+
 static struct acpi_driver acpi_pci_root_driver = {
 	.name = "pci_root",
 	.class = ACPI_PCI_ROOT_CLASS,
-	.ids = ACPI_PCI_ROOT_HID,
+	.ids = root_device_ids,
 	.ops = {
 		.add = acpi_pci_root_add,
 		.remove = acpi_pci_root_remove,
Index: linux-2.6.22-rc5/drivers/acpi/power.c
===================================================================
--- linux-2.6.22-rc5.orig/drivers/acpi/power.c
+++ linux-2.6.22-rc5/drivers/acpi/power.c
@@ -59,10 +59,16 @@ static int acpi_power_remove(struct acpi
 static int acpi_power_resume(struct acpi_device *device);
 static int acpi_power_open_fs(struct inode *inode, struct file *file);
 
+static struct acpi_device_id power_device_ids[] = {
+	{ACPI_POWER_HID, 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, power_device_ids);
+
 static struct acpi_driver acpi_power_driver = {
 	.name = "power",
 	.class = ACPI_POWER_CLASS,
-	.ids = ACPI_POWER_HID,
+	.ids = power_device_ids,
 	.ops = {
 		.add = acpi_power_add,
 		.remove = acpi_power_remove,
Index: linux-2.6.22-rc5/drivers/acpi/acpi_memhotplug.c
===================================================================
--- linux-2.6.22-rc5.orig/drivers/acpi/acpi_memhotplug.c
+++ linux-2.6.22-rc5/drivers/acpi/acpi_memhotplug.c
@@ -53,10 +53,16 @@ static int acpi_memory_device_add(struct
 static int acpi_memory_device_remove(struct acpi_device *device, int type);
 static int acpi_memory_device_start(struct acpi_device *device);
 
+static const struct acpi_device_id memory_device_ids[] = {
+	{ACPI_MEMORY_DEVICE_HID, 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, memory_device_ids);
+
 static struct acpi_driver acpi_memory_device_driver = {
 	.name = "acpi_memhotplug",
 	.class = ACPI_MEMORY_DEVICE_CLASS,
-	.ids = ACPI_MEMORY_DEVICE_HID,
+	.ids = memory_device_ids,
 	.ops = {
 		.add = acpi_memory_device_add,
 		.remove = acpi_memory_device_remove,
Index: linux-2.6.22-rc5/drivers/acpi/processor_core.c
===================================================================
--- linux-2.6.22-rc5.orig/drivers/acpi/processor_core.c
+++ linux-2.6.22-rc5/drivers/acpi/processor_core.c
@@ -85,10 +85,16 @@ static void acpi_processor_notify(acpi_h
 static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu);
 static int acpi_processor_handle_eject(struct acpi_processor *pr);
 
+static const struct acpi_device_id processor_device_ids[] = {
+	{ACPI_PROCESSOR_HID, 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, processor_device_ids);
+
 static struct acpi_driver acpi_processor_driver = {
 	.name = "processor",
 	.class = ACPI_PROCESSOR_CLASS,
-	.ids = ACPI_PROCESSOR_HID,
+	.ids = processor_device_ids,
 	.ops = {
 		.add = acpi_processor_add,
 		.remove = acpi_processor_remove,
Index: linux-2.6.22-rc5/drivers/acpi/video.c
===================================================================
--- linux-2.6.22-rc5.orig/drivers/acpi/video.c
+++ linux-2.6.22-rc5/drivers/acpi/video.c
@@ -73,10 +73,16 @@ MODULE_LICENSE("GPL");
 static int acpi_video_bus_add(struct acpi_device *device);
 static int acpi_video_bus_remove(struct acpi_device *device, int type);
 
+static const struct acpi_device_id video_device_ids[] = {
+	{ACPI_VIDEO_HID, 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, video_device_ids);
+
 static struct acpi_driver acpi_video_bus = {
 	.name = "video",
 	.class = ACPI_VIDEO_CLASS,
-	.ids = ACPI_VIDEO_HID,
+	.ids = video_device_ids,
 	.ops = {
 		.add = acpi_video_bus_add,
 		.remove = acpi_video_bus_remove,
Index: linux-2.6.22-rc5/drivers/char/hpet.c
===================================================================
--- linux-2.6.22-rc5.orig/drivers/char/hpet.c
+++ linux-2.6.22-rc5/drivers/char/hpet.c
@@ -999,9 +999,15 @@ static int hpet_acpi_remove(struct acpi_
 	return -EINVAL;
 }
 
+static const struct acpi_device_id hpet_device_ids[] = {
+	{"PNP0103", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, hpet_device_ids);
+
 static struct acpi_driver hpet_acpi_driver = {
 	.name = "hpet",
-	.ids = "PNP0103",
+	.ids = hpet_device_ids,
 	.ops = {
 		.add = hpet_acpi_add,
 		.remove = hpet_acpi_remove,
Index: linux-2.6.22-rc5/drivers/input/misc/atlas_btns.c
===================================================================
--- linux-2.6.22-rc5.orig/drivers/input/misc/atlas_btns.c
+++ linux-2.6.22-rc5/drivers/input/misc/atlas_btns.c
@@ -31,7 +31,6 @@
 
 #define ACPI_ATLAS_NAME			"Atlas ACPI"
 #define ACPI_ATLAS_CLASS		"Atlas"
-#define ACPI_ATLAS_BUTTON_HID		"ASIM0000"
 
 static struct input_dev *input_dev;
 
@@ -130,10 +129,16 @@ static int atlas_acpi_button_remove(stru
 	return status;
 }
 
+static const struct acpi_device_id atlas_device_ids[] = {
+	{"ASIM0000", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, atlas_device_ids);
+
 static struct acpi_driver atlas_acpi_driver = {
 	.name	= ACPI_ATLAS_NAME,
 	.class	= ACPI_ATLAS_CLASS,
-	.ids	= ACPI_ATLAS_BUTTON_HID,
+	.ids	= atlas_device_ids,
 	.ops	= {
 		.add	= atlas_acpi_button_add,
 		.remove	= atlas_acpi_button_remove,
Index: linux-2.6.22-rc5/drivers/misc/asus-laptop.c
===================================================================
--- linux-2.6.22-rc5.orig/drivers/misc/asus-laptop.c
+++ linux-2.6.22-rc5/drivers/misc/asus-laptop.c
@@ -53,7 +53,6 @@
 #define ASUS_HOTK_NAME          "Asus Laptop Support"
 #define ASUS_HOTK_CLASS         "hotkey"
 #define ASUS_HOTK_DEVICE_NAME   "Hotkey"
-#define ASUS_HOTK_HID           "ATK0100"
 #define ASUS_HOTK_FILE          "asus-laptop"
 #define ASUS_HOTK_PREFIX        "\\_SB.ATKD."
 
@@ -197,12 +196,18 @@ static struct asus_hotk *hotk;
 /*
  * The hotkey driver declaration
  */
+static const struct acpi_device_id asus_device_ids[] = {
+	{"ATK0100", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, asus_device_ids);
+
 static int asus_hotk_add(struct acpi_device *device);
 static int asus_hotk_remove(struct acpi_device *device, int type);
 static struct acpi_driver asus_hotk_driver = {
 	.name = ASUS_HOTK_NAME,
 	.class = ASUS_HOTK_CLASS,
-	.ids = ASUS_HOTK_HID,
+	.ids = asus_device_ids,
 	.ops = {
 		.add = asus_hotk_add,
 		.remove = asus_hotk_remove,
Index: linux-2.6.22-rc5/drivers/acpi/ec.c
===================================================================
--- linux-2.6.22-rc5.orig/drivers/acpi/ec.c
+++ linux-2.6.22-rc5/drivers/acpi/ec.c
@@ -43,7 +43,6 @@
 ACPI_MODULE_NAME("ec");
 #define ACPI_EC_COMPONENT		0x00100000
 #define ACPI_EC_CLASS			"embedded_controller"
-#define ACPI_EC_HID			"PNP0C09"
 #define ACPI_EC_DEVICE_NAME		"Embedded Controller"
 #define ACPI_EC_FILE_INFO		"info"
 #undef PREFIX
@@ -80,10 +79,22 @@ static int acpi_ec_start(struct acpi_dev
 static int acpi_ec_stop(struct acpi_device *device, int type);
 static int acpi_ec_add(struct acpi_device *device);
 
+/*
+   ec never can be a module..., anyway let's keep the autoloading
+   things here, this line does not hurt.
+*/
+
+static const struct acpi_device_id ec_device_ids[] = {
+	{"PNP0C09", 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, ec_device_ids);
+
+
 static struct acpi_driver acpi_ec_driver = {
 	.name = "ec",
 	.class = ACPI_EC_CLASS,
-	.ids = ACPI_EC_HID,
+	.ids = ec_device_ids,
 	.ops = {
 		.add = acpi_ec_add,
 		.remove = acpi_ec_remove,
Index: linux-2.6.22-rc5/drivers/misc/thinkpad_acpi.c
===================================================================
--- linux-2.6.22-rc5.orig/drivers/misc/thinkpad_acpi.c
+++ linux-2.6.22-rc5/drivers/misc/thinkpad_acpi.c
@@ -388,12 +388,13 @@ static int __init register_tpacpi_subdri
 
 	sprintf(ibm->acpi->driver->name, "%s_%s", IBM_NAME, ibm->name);
 	ibm->acpi->driver->ids = ibm->acpi->hid;
+
 	ibm->acpi->driver->ops.add = &tpacpi_device_add;
 
 	rc = acpi_bus_register_driver(ibm->acpi->driver);
 	if (rc < 0) {
 		printk(IBM_ERR "acpi_bus_register_driver(%s) failed: %d\n",
-		       ibm->acpi->hid, rc);
+		       ibm->name, rc);
 		kfree(ibm->acpi->driver);
 		ibm->acpi->driver = NULL;
 	} else if (!rc)
@@ -1000,8 +1001,17 @@ errexit:
 	return res;
 }
 
+static const struct acpi_device_id ibm_htk_device_ids[] = {
+	{IBM_HKEY_HID, 0},
+	{"", 0},
+};
+static const struct acpi_device_id ibm_pci_device_ids[] = {
+	{IBM_PCI_HID, 0},
+	{"", 0},
+};
+
 static struct tp_acpi_drv_struct ibm_hotkey_acpidriver = {
-	.hid = IBM_HKEY_HID,
+	.hid = ibm_htk_device_ids,
 	.notify = hotkey_notify,
 	.handle = &hkey_handle,
 	.type = ACPI_DEVICE_NOTIFY,
@@ -1763,6 +1773,11 @@ IBM_HANDLE(dock, root, "\\_SB.GDCK",	/* 
 /* don't list other alternatives as we install a notify handler on the 570 */
 IBM_HANDLE(pci, root, "\\_SB.PCI");	/* 570 */
 
+static const struct acpi_device_id ibm_pci_device_ids[] = {
+	{IBM_PCI_HID, 0},
+	{"", 0},
+};
+
 static struct tp_acpi_drv_struct ibm_dock_acpidriver[2] = {
 	{
 	 .notify = dock_notify,
@@ -1770,7 +1785,7 @@ static struct tp_acpi_drv_struct ibm_doc
 	 .type = ACPI_SYSTEM_NOTIFY,
 	},
 	{
-	 .hid = IBM_PCI_HID,
+	 .hid = ibm_pci_device_ids,
 	 .notify = dock_notify,
 	 .handle = &pci_handle,
 	 .type = ACPI_SYSTEM_NOTIFY,
@@ -1829,7 +1844,8 @@ static int __init dock_init2(struct ibm_
 static void dock_notify(struct ibm_struct *ibm, u32 event)
 {
 	int docked = dock_docked();
-	int pci = ibm->acpi->hid && strstr(ibm->acpi->hid, IBM_PCI_HID);
+	int pci = ibm->acpi->hid && ibm->acpi->device &&
+		acpi_match_device_ids(ibm->acpi->device, ibm_pci_device_ids);
 
 	if (event == 1 && !pci)	/* 570 */
 		acpi_bus_generate_event(ibm->acpi->device, event, 1);	/* button */
Index: linux-2.6.22-rc5/drivers/misc/thinkpad_acpi.h
===================================================================
--- linux-2.6.22-rc5.orig/drivers/misc/thinkpad_acpi.h
+++ linux-2.6.22-rc5/drivers/misc/thinkpad_acpi.h
@@ -182,7 +182,7 @@ static void thinkpad_acpi_module_exit(vo
 struct ibm_struct;
 
 struct tp_acpi_drv_struct {
-	char *hid;
+	const struct acpi_device_id *hid;
 	struct acpi_driver *driver;
 
 	void (*notify) (struct ibm_struct *, u32);
Index: linux-2.6.22-rc5/drivers/misc/sony-laptop.c
===================================================================
--- linux-2.6.22-rc5.orig/drivers/misc/sony-laptop.c
+++ linux-2.6.22-rc5/drivers/misc/sony-laptop.c
@@ -890,10 +890,22 @@ static int sony_nc_remove(struct acpi_de
 	return 0;
 }
 
+static const struct acpi_device_id sony_device_ids[] = {
+	{SONY_NC_HID, 0},
+	{SONY_PIC_HID, 0},
+	{"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, sony_device_ids);
+
+static const struct acpi_device_id sony_nc_device_ids[] = {
+	{SONY_NC_HID, 0},
+	{"", 0},
+};
+
 static struct acpi_driver sony_nc_driver = {
 	.name = SONY_NC_DRIVER_NAME,
 	.class = SONY_NC_CLASS,
-	.ids = SONY_NC_HID,
+	.ids = sony_nc_device_ids,
 	.owner = THIS_MODULE,
 	.ops = {
 		.add = sony_nc_add,
@@ -2221,10 +2233,15 @@ static int sony_pic_resume(struct acpi_d
 	return 0;
 }
 
+static const struct acpi_device_id sony_pic_device_ids[] = {
+	{SONY_PIC_HID, 0},
+	{"", 0},
+};
+
 static struct acpi_driver sony_pic_driver = {
 	.name = SONY_PIC_DRIVER_NAME,
 	.class = SONY_PIC_CLASS,
-	.ids = SONY_PIC_HID,
+	.ids = sony_pic_device_ids,
 	.owner = THIS_MODULE,
 	.ops = {
 		.add = sony_pic_add,

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

* Re: [PATCH 3/3] ACPI autoloading - Create __mod_acpi_device_table symbol for all acpi drivers.
  2007-06-19 12:53       ` Thomas Renninger
@ 2007-06-19 16:23         ` Mattia Dongili
  2007-06-19 21:27         ` Henrique de Moraes Holschuh
  1 sibling, 0 replies; 19+ messages in thread
From: Mattia Dongili @ 2007-06-19 16:23 UTC (permalink / raw)
  To: Thomas Renninger
  Cc: Henrique de Moraes Holschuh, Len Brown, linux-kernel, linux-acpi,
	Kay Sievers

On Tue, Jun 19, 2007 at 02:53:27PM +0200, Thomas Renninger wrote:
> On Sun, 2007-06-17 at 19:49 -0300, Henrique de Moraes Holschuh wrote:
> > On Sun, 17 Jun 2007, Thomas Renninger wrote:
> > > Create __mod_acpi_device_table symbol for all acpi drivers.
...
> > model-specific drivers like thinkpad-acpi
> Not in general, only if the driver provides additional functions and the
> ACPI device does not appear on machines that need those additional
> functions.
> E.g. the asus driver AFAIK serves exactly the ACPI device it registers
> for.

and the sony-laptop as well. Thanks for doing that, will test as soon as
possible on my vaios here.

-- 
mattia
:wq!

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

* Re: [PATCH 3/3] ACPI autoloading - Create __mod_acpi_device_table symbol for all acpi drivers.
  2007-06-19 12:53       ` Thomas Renninger
  2007-06-19 16:23         ` Mattia Dongili
@ 2007-06-19 21:27         ` Henrique de Moraes Holschuh
  2007-07-03  7:11           ` Len Brown
  1 sibling, 1 reply; 19+ messages in thread
From: Henrique de Moraes Holschuh @ 2007-06-19 21:27 UTC (permalink / raw)
  To: Thomas Renninger; +Cc: Len Brown, linux-kernel, linux-acpi, Kay Sievers

On Tue, 19 Jun 2007, Thomas Renninger wrote:
> On Sun, 2007-06-17 at 19:49 -0300, Henrique de Moraes Holschuh wrote:
> > On Sun, 17 Jun 2007, Thomas Renninger wrote:
> > > Create __mod_acpi_device_table symbol for all acpi drivers.
> > 
> > thinkpad-acpi will autoload by DMI ids in 2.6.23, which is a much better
> > solution for model-specific drivers like thinkpad-acpi than autoloading by
> > HID, IMHO.

> Yes, I saw some dmi udev strings on Kay's machine and for the thinkpad
> module dmi autoloading is much better.

Yeah. The HIDs thinkpad-acpi binds to might exist on non-thinkpads, while
the DMI matching should be good for all new boxes, and all of the old ones
which I have some sort of data on.  The few very old thinkpads I am not
autoloading on are probably not going to care, wouldn't benefit much from
thinkpad-acpi anyway... or they will send me email about it.

> Not in general, only if the driver provides additional functions and the
> ACPI device does not appear on machines that need those additional
> functions.

Or, if you risk too many false positives.

> > Thus, I'd prefer if your patches did not make thinkpad-acpi autoload by HID.

> It would not really hurt? At least thinkpad module is an acpi driver for

It would, if we start trying to autoload on false positive matches.  If we
did not have any other way to autoload, that would be fine, but since we
will have DMI matches also in 2.6.23...

> those two HIDs... But your are right, it's superfluous, here with
> __mod_acpi_device_table symbol ripped out of thinkpad.ko.

Thank you. I did not test the patch, but I am ok with it, now.

> Hmm, what do you think about splitting the Thinkpad driver into Hotkey,
> PCI and rest? This one got a complicated beast...

It is cooking.  In fact, I was halfway through it, when Richard started
getting me fired up about improving the input layer support in
thinkpad-acpi, which is a damn more fun thing to do... so it stalled, but
now thinkpad-acpi has proper input support, which I will be sending for
acpi-test merging quite soon now.

Some sort of split will be done. Probably for 2.6.23, even.

-- 
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique Holschuh

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

* Re: [PATCH 2/3] ACPI autoloading - Create acpi alias interface
  2007-06-17 20:27 ` [PATCH 2/3] ACPI autoloading - Create acpi alias interface Thomas Renninger
  2007-06-17 20:24   ` [PATCH 3/3] ACPI autoloading - Create __mod_acpi_device_table symbol for all acpi drivers Thomas Renninger
@ 2007-06-20 15:52   ` Mattia Dongili
  2007-06-20 17:24     ` Thomas Renninger
  1 sibling, 1 reply; 19+ messages in thread
From: Mattia Dongili @ 2007-06-20 15:52 UTC (permalink / raw)
  To: Thomas Renninger; +Cc: Len Brown, linux-kernel, linux-acpi, Kay Sievers

On Sun, Jun 17, 2007 at 10:27:27PM +0200, Thomas Renninger wrote:
> Create acpi alias interface
...
> Index: linux-2.6.22-rc4/drivers/pnp/pnpacpi/core.c
> ===================================================================
> --- linux-2.6.22-rc4.orig/drivers/pnp/pnpacpi/core.c
> +++ linux-2.6.22-rc4/drivers/pnp/pnpacpi/core.c
> @@ -21,7 +21,10 @@
>  
>  #include <linux/acpi.h>
>  #include <linux/pnp.h>
> +#include <linux/mod_devicetable.h>
>  #include <acpi/acpi_bus.h>
> +#include <acpi/actypes.h>
> +
>  #include "pnpacpi.h"
>  
>  static int num = 0;
> @@ -33,15 +36,17 @@ static int num = 0;
>   * have irqs (PIC, Timer) because we call acpi_register_gsi.
>   * Finaly only devices that have a CRS method need to be in this list.
>   */
> -static char __initdata excluded_id_list[] =
> -	"PNP0C09," /* EC */
> -	"PNP0C0F," /* Link device */
> -	"PNP0000," /* PIC */
> -	"PNP0100," /* Timer */
> -	;
> +static __initdata struct acpi_device_id excluded_id_list[] ={
> +	{"PNP0C09", 0}, /* EC */
> +	{"PNP0C0F", 0}, /* Link device */
> +	{"PNP0000", 0}, /* PIC */
> +	{"PNP0100", 0}, /* Timer */
> +	{"", 0};
              ^^^
eeek!

> +};
> +
-- 
mattia
:wq!

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

* Re: [PATCH 3/3] ACPI autoloading - Create __mod_acpi_device_table symbol for all acpi drivers.
  2007-06-17 20:24   ` [PATCH 3/3] ACPI autoloading - Create __mod_acpi_device_table symbol for all acpi drivers Thomas Renninger
  2007-06-17 22:49     ` Henrique de Moraes Holschuh
@ 2007-06-20 17:06     ` Mattia Dongili
  2007-06-20 17:47       ` Thomas Renninger
  1 sibling, 1 reply; 19+ messages in thread
From: Mattia Dongili @ 2007-06-20 17:06 UTC (permalink / raw)
  To: Thomas Renninger
  Cc: Len Brown, linux-kernel, linux-acpi, Henrique de Moraes Holschuh

On Sun, Jun 17, 2007 at 10:24:23PM +0200, Thomas Renninger wrote:
> Create __mod_acpi_device_table symbol for all acpi drivers.
> 
> modpost is going to use this one to create modules.alias
> 
> Hopefully thinkpad module still works.
> IMO this one should get restructured and make use of acpi_bus_register_driver
> and try to avoid to test for HIDs/CIDs for its own.
> 
> Signed-off-by: Thomas Renninger <trenn@suse.de>

Tested, except for the compile error already reported it does its job on
my vaios.
A question though:

> Index: linux-2.6.22-rc4/drivers/misc/sony-laptop.c
> ===================================================================
> --- linux-2.6.22-rc4.orig/drivers/misc/sony-laptop.c
> +++ linux-2.6.22-rc4/drivers/misc/sony-laptop.c
> @@ -890,10 +890,22 @@ static int sony_nc_remove(struct acpi_de
>  	return 0;
>  }
>  
> +static const struct acpi_device_id sony_device_ids[] = {
> +	{SONY_NC_HID, 0},
> +	{SONY_PIC_HID, 0},
> +	{"", 0},
> +};
> +MODULE_DEVICE_TABLE(acpi, sony_device_ids);
> +
> +static const struct acpi_device_id sony_nc_device_ids[] = {
> +	{SONY_NC_HID, 0},
> +	{"", 0},
> +};
> +
...
> +static const struct acpi_device_id sony_pic_device_ids[] = {
> +	{SONY_PIC_HID, 0},
> +	{"", 0},
> +};
> +

is it really necessary to have those duplicate entries?

Also, I guess that when this patch set is applied we also should declare
sonypi obsolete as sony-laptop will grab the same device that sonypi
wants (the SPIC one). sony-laptop has options to avoid doing that would
make things clear to users.
I still haven't received reports of mafunctioning vaios using the new
sony-laptop instead of sonypi but 2.6.22 isn't final yet.

-- 
mattia
:wq!

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

* Re: [PATCH 2/3] ACPI autoloading - Create acpi alias interface
  2007-06-20 15:52   ` [PATCH 2/3] ACPI autoloading - Create acpi alias interface Mattia Dongili
@ 2007-06-20 17:24     ` Thomas Renninger
  0 siblings, 0 replies; 19+ messages in thread
From: Thomas Renninger @ 2007-06-20 17:24 UTC (permalink / raw)
  To: Mattia Dongili; +Cc: Len Brown, linux-kernel, linux-acpi, Kay Sievers

[-- Attachment #1: Type: text/plain, Size: 11564 bytes --]

On Thu, 2007-06-21 at 00:52 +0900, Mattia Dongili wrote:
> On Sun, Jun 17, 2007 at 10:27:27PM +0200, Thomas Renninger wrote:
> > Create acpi alias interface
> ...
> > +static __initdata struct acpi_device_id excluded_id_list[] ={
> > +	{"PNP0C09", 0}, /* EC */
> > +	{"PNP0C0F", 0}, /* Link device */
> > +	{"PNP0000", 0}, /* PIC */
> > +	{"PNP0100", 0}, /* Timer */
> > +	{"", 0};
>               ^^^
> eeek!

Autch... Did not even compile, right? I first forgot to initialise this
one at all with {"", 0}, then added it and did not test recompile, sorry
about that.

Thanks a lot for trying out!

That one is better:

Create acpi alias interface

Modify modpost (file2alias.c) to add acpi*:XYZ0001: alias in modules.alias
like:
grep acpi /lib/modules/2.6.22-rc4-default/modules.alias 
alias acpi*:SNY5001:* sony_laptop
alias acpi*:SNY6001:* sony_laptop
for e.g. the sony_laptop module.
This module matches against all ACPI devices with a HID or CID of SNY5001
or SNY6001

Export an uevent and modalias sysfs file containing the string:
[MODALIAS=]acpi:PNP0C0C:
additional CIDs are concatenated at the end.

Signed-off-by: Thomas Renninger <trenn@suse.de>

---
 drivers/acpi/scan.c             |  163 ++++++++++++++++++++++++++++------------
 drivers/pnp/pnpacpi/core.c      |   19 ++--
 include/linux/acpi.h            |    1 
 include/linux/mod_devicetable.h |   15 +++
 scripts/mod/file2alias.c        |   12 ++
 5 files changed, 158 insertions(+), 52 deletions(-)

Index: linux-2.6.22-rc5/include/linux/mod_devicetable.h
===================================================================
--- linux-2.6.22-rc5.orig/include/linux/mod_devicetable.h
+++ linux-2.6.22-rc5/include/linux/mod_devicetable.h
@@ -159,6 +159,21 @@ struct ap_device_id {
 
 #define AP_DEVICE_ID_MATCH_DEVICE_TYPE		0x01
 
+#define ACPI_ID_LEN	9
+
+/*
+  Similar exists in include/acpi/acmacros.h
+  use this one for acpi linux specific stuff e.g.
+  in ACPI modules and the other one inside the
+  interpreter
+*/
+
+/* Exists already in acpi includes (include/acpi/actypes.h) */
+
+struct acpi_device_id {
+	__u8 id[ACPI_ID_LEN];
+	kernel_ulong_t driver_data;
+};
 
 #define PNP_ID_LEN	8
 #define PNP_MAX_DEVICES	8
Index: linux-2.6.22-rc5/scripts/mod/file2alias.c
===================================================================
--- linux-2.6.22-rc5.orig/scripts/mod/file2alias.c
+++ linux-2.6.22-rc5/scripts/mod/file2alias.c
@@ -290,6 +290,14 @@ static int do_serio_entry(const char *fi
 	return 1;
 }
 
+/* looks like: "acpi:ACPI0003 or acpi:PNP0C0B" */
+static int do_acpi_entry(const char *filename,
+			struct acpi_device_id *id, char *alias)
+{
+	sprintf(alias, "acpi*:%s:", id->id);
+	return 1;
+}
+
 /* looks like: "pnp:dD" */
 static int do_pnp_entry(const char *filename,
 			struct pnp_device_id *id, char *alias)
@@ -551,6 +559,10 @@ void handle_moddevtable(struct module *m
 		do_table(symval, sym->st_size,
 			 sizeof(struct serio_device_id), "serio",
 			 do_serio_entry, mod);
+	else if (sym_is(symname, "__mod_acpi_device_table"))
+		do_table(symval, sym->st_size,
+			 sizeof(struct acpi_device_id), "acpi",
+			 do_acpi_entry, mod);
 	else if (sym_is(symname, "__mod_pnp_device_table"))
 		do_table(symval, sym->st_size,
 			 sizeof(struct pnp_device_id), "pnp",
Index: linux-2.6.22-rc5/drivers/acpi/scan.c
===================================================================
--- linux-2.6.22-rc5.orig/drivers/acpi/scan.c
+++ linux-2.6.22-rc5/drivers/acpi/scan.c
@@ -16,7 +16,7 @@ ACPI_MODULE_NAME("scan");
 extern struct acpi_device *acpi_root;
 
 #define ACPI_BUS_CLASS			"system_bus"
-#define ACPI_BUS_HID			"ACPI_BUS"
+#define ACPI_BUS_HID			"XBUS0001"
 #define ACPI_BUS_DEVICE_NAME		"System Bus"
 
 static LIST_HEAD(acpi_device_list);
@@ -29,6 +29,69 @@ struct acpi_device_bus_id{
 	unsigned int instance_no;
 	struct list_head node;
 };
+
+/*
+  Currently only handles ID strings, not compressed EISA, here the spec:
+
+  A _HID object evaluates to either a numeric 32-bit compressed EISA type ID
+  or a string. If a string, the format must be an alphanumeric PNP or ACPI ID
+  with no asterisk or other leading characters.
+
+  Why is hardware_id char[15] -> see include/acpi/acpi_bus.h ?!?
+
+  This function only handles devices correctly that have a HID.
+  If there are devices that have CID(s), but no HID work needs
+*/
+int create_modalias(struct acpi_device *acpi_dev, char *modalias, int size){
+
+	int len;
+
+	if (!acpi_dev->flags.hardware_id)
+		return -ENODEV;
+
+	len = snprintf(modalias, size, "acpi:%s:",
+		       acpi_dev->pnp.hardware_id);
+	if (len < 0 || len >= size)
+		return -EINVAL;
+	size -= len;
+
+	if (acpi_dev->flags.compatible_ids) {
+		struct acpi_compatible_id_list *cid_list;
+		int i;
+		int count;
+
+		cid_list = acpi_dev->pnp.cid_list;
+		for (i = 0; i < cid_list->count; i++) {
+			count = snprintf(&modalias[len], size, "%s:",
+					 cid_list->id[i].value);
+			if (count < 0 || count >= size) {
+				printk(KERN_ERR "acpi: %s cid[%i] exceeds event buffer size",
+				       acpi_dev->pnp.device_name, i);
+				break;
+			}
+			len += count;
+			size -= count;
+		}
+	}
+
+	modalias[len] = '\0';
+	return len;
+}
+
+static ssize_t
+acpi_device_modalias_show(struct device *dev, struct device_attribute *attr, char *buf) {
+	struct acpi_device *acpi_dev = to_acpi_device(dev);
+	int len;
+
+	/* Device has no HID and no CID or string is >1024 */
+	len = create_modalias(acpi_dev, buf, 1024);
+	if (len <= 0)
+		return 0;
+	buf[len++] = '\n';
+	return len;
+}
+static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL);
+
 static int acpi_eject_operation(acpi_handle handle, int lockable)
 {
 	struct acpi_object_list arg_list;
@@ -154,6 +217,12 @@ static int acpi_device_setup_files(struc
 			goto end;
 	}
 
+	if (dev->flags.hardware_id || dev->flags.compatible_ids){
+		result = device_create_file(&dev->dev, &dev_attr_modalias);
+		if(result)
+			goto end;
+	}
+
         /*
          * If device has _EJ0, 'eject' file is created that is used to trigger
          * hot-removal function from userland.
@@ -178,6 +247,9 @@ static void acpi_device_remove_files(str
 	if (ACPI_SUCCESS(status))
 		device_remove_file(&dev->dev, &dev_attr_eject);
 
+	if (dev->flags.hardware_id || dev->flags.compatible_ids)
+		device_remove_file(&dev->dev, &dev_attr_modalias);
+
 	if(dev->flags.hardware_id)
 		device_remove_file(&dev->dev, &dev_attr_hid);
 	if(dev->handle)
@@ -186,6 +258,37 @@ static void acpi_device_remove_files(str
 /* --------------------------------------------------------------------------
 			ACPI Bus operations
    -------------------------------------------------------------------------- */
+
+int acpi_match_device_ids(struct acpi_device *device,
+			  const struct acpi_device_id *ids)
+{
+	const struct acpi_device_id *id;
+
+	if (device->flags.hardware_id) {
+		for (id = ids; id->id[0]; id++) {
+			if (!strcmp((char*)id->id, device->pnp.hardware_id))
+				return 0;
+		}
+	}
+
+	if (device->flags.compatible_ids) {
+		struct acpi_compatible_id_list *cid_list = device->pnp.cid_list;
+		int i;
+
+		for (id = ids; id->id[0]; id++) {
+			/* compare multiple _CID entries against driver ids */
+			for (i = 0; i < cid_list->count; i++) {
+				if (!strcmp((char*)id->id,
+					    cid_list->id[i].value))
+					return 0;
+			}
+		}
+	}
+
+	return -ENOENT;
+}
+EXPORT_SYMBOL(acpi_match_device_ids);
+
 static void acpi_device_release(struct device *dev)
 {
 	struct acpi_device *acpi_dev = to_acpi_device(dev);
@@ -219,37 +322,19 @@ 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_match_ids(acpi_dev, acpi_drv->ids);
+	return !acpi_match_device_ids(acpi_dev, acpi_drv->ids);
 }
 
 static int acpi_device_uevent(struct device *dev, char **envp, int num_envp,
-	char *buffer, int buffer_size)
+			      char *buffer, int buffer_size)
 {
 	struct acpi_device *acpi_dev = to_acpi_device(dev);
-	int i = 0, length = 0, ret = 0;
-
-	if (acpi_dev->flags.hardware_id)
-		ret = add_uevent_var(envp, num_envp, &i,
-			buffer, buffer_size, &length,
-			"HWID=%s", acpi_dev->pnp.hardware_id);
-	if (ret)
-		return -ENOMEM;
-	if (acpi_dev->flags.compatible_ids) {
-		int j;
-		struct acpi_compatible_id_list *cid_list;
 
-		cid_list = acpi_dev->pnp.cid_list;
-
-		for (j = 0; j < cid_list->count; j++) {
-			ret = add_uevent_var(envp, num_envp, &i, buffer,
-				buffer_size, &length, "COMPTID=%s",
-				cid_list->id[j].value);
-			if (ret)
-				return -ENOMEM;
-		}
+	strcpy(buffer, "MODALIAS=");
+	if (create_modalias(acpi_dev, buffer + 9, buffer_size - 9) > 0) {
+		envp[0] = buffer;
+		envp[1] = NULL;
 	}
-
-	envp[i] = NULL;
 	return 0;
 }
 
@@ -543,25 +628,6 @@ void acpi_bus_data_handler(acpi_handle h
 	return;
 }
 
-int acpi_match_ids(struct acpi_device *device, char *ids)
-{
-	if (device->flags.hardware_id)
-		if (strstr(ids, device->pnp.hardware_id))
-			return 0;
-
-	if (device->flags.compatible_ids) {
-		struct acpi_compatible_id_list *cid_list = device->pnp.cid_list;
-		int i;
-
-		/* compare multiple _CID entries against driver ids */
-		for (i = 0; i < cid_list->count; i++) {
-			if (strstr(ids, cid_list->id[i].value))
-				return 0;
-		}
-	}
-	return -ENOENT;
-}
-
 static int acpi_bus_get_perf_flags(struct acpi_device *device)
 {
 	device->performance.state = ACPI_STATE_UNKNOWN;
@@ -624,6 +690,13 @@ static int acpi_bus_get_wakeup_device_fl
 	struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
 	union acpi_object *package = NULL;
 
+	struct acpi_device_id button_device_ids[] = {
+		{"PNP0C0D", 0},
+		{"PNP0C0C", 0},
+		{"PNP0C0E", 0},
+		{"", 0},
+	};
+
 
 	/* _PRW */
 	status = acpi_evaluate_object(device->handle, "_PRW", NULL, &buffer);
@@ -643,7 +716,7 @@ static int acpi_bus_get_wakeup_device_fl
 
 	device->wakeup.flags.valid = 1;
 	/* Power button, Lid switch always enable wakeup */
-	if (!acpi_match_ids(device, "PNP0C0D,PNP0C0C,PNP0C0E"))
+	if (!acpi_match_device_ids(device, button_device_ids))
 		device->wakeup.flags.run_wake = 1;
 
       end:
Index: linux-2.6.22-rc5/drivers/pnp/pnpacpi/core.c
===================================================================
--- linux-2.6.22-rc5.orig/drivers/pnp/pnpacpi/core.c
+++ linux-2.6.22-rc5/drivers/pnp/pnpacpi/core.c
@@ -21,7 +21,10 @@
 
 #include <linux/acpi.h>
 #include <linux/pnp.h>
+#include <linux/mod_devicetable.h>
 #include <acpi/acpi_bus.h>
+#include <acpi/actypes.h>
+
 #include "pnpacpi.h"
 
 static int num = 0;
@@ -33,15 +36,17 @@ static int num = 0;
  * have irqs (PIC, Timer) because we call acpi_register_gsi.
  * Finaly only devices that have a CRS method need to be in this list.
  */
-static char __initdata excluded_id_list[] =
-	"PNP0C09," /* EC */
-	"PNP0C0F," /* Link device */
-	"PNP0000," /* PIC */
-	"PNP0100," /* Timer */
-	;
+static __initdata struct acpi_device_id excluded_id_list[] ={
+	{"PNP0C09", 0}, /* EC */
+	{"PNP0C0F", 0}, /* Link device */
+	{"PNP0000", 0}, /* PIC */
+	{"PNP0100", 0}, /* Timer */
+	{"", 0},
+};
+
 static inline int is_exclusive_device(struct acpi_device *dev)
 {
-	return (!acpi_match_ids(dev, excluded_id_list));
+	return (!acpi_match_device_ids(dev, excluded_id_list));
 }
 
 /*
Index: linux-2.6.22-rc5/include/linux/acpi.h
===================================================================
--- linux-2.6.22-rc5.orig/include/linux/acpi.h
+++ linux-2.6.22-rc5/include/linux/acpi.h
@@ -33,6 +33,7 @@
 #endif
 
 #include <linux/list.h>
+#include <linux/mod_devicetable.h>
 
 #include <acpi/acpi.h>
 #include <acpi/acpi_bus.h>


[-- Attachment #2: acpi_autoloading_interface.patch --]
[-- Type: text/x-patch, Size: 10943 bytes --]

Create acpi alias interface

Modify modpost (file2alias.c) to add acpi*:XYZ0001: alias in modules.alias
like:
grep acpi /lib/modules/2.6.22-rc4-default/modules.alias 
alias acpi*:SNY5001:* sony_laptop
alias acpi*:SNY6001:* sony_laptop
for e.g. the sony_laptop module.
This module matches against all ACPI devices with a HID or CID of SNY5001
or SNY6001

Export an uevent and modalias sysfs file containing the string:
[MODALIAS=]acpi:PNP0C0C:
additional CIDs are concatenated at the end.

Signed-off-by: Thomas Renninger <trenn@suse.de>

---
 drivers/acpi/scan.c             |  163 ++++++++++++++++++++++++++++------------
 drivers/pnp/pnpacpi/core.c      |   19 ++--
 include/linux/acpi.h            |    1 
 include/linux/mod_devicetable.h |   15 +++
 scripts/mod/file2alias.c        |   12 ++
 5 files changed, 158 insertions(+), 52 deletions(-)

Index: linux-2.6.22-rc5/include/linux/mod_devicetable.h
===================================================================
--- linux-2.6.22-rc5.orig/include/linux/mod_devicetable.h
+++ linux-2.6.22-rc5/include/linux/mod_devicetable.h
@@ -159,6 +159,21 @@ struct ap_device_id {
 
 #define AP_DEVICE_ID_MATCH_DEVICE_TYPE		0x01
 
+#define ACPI_ID_LEN	9
+
+/*
+  Similar exists in include/acpi/acmacros.h
+  use this one for acpi linux specific stuff e.g.
+  in ACPI modules and the other one inside the
+  interpreter
+*/
+
+/* Exists already in acpi includes (include/acpi/actypes.h) */
+
+struct acpi_device_id {
+	__u8 id[ACPI_ID_LEN];
+	kernel_ulong_t driver_data;
+};
 
 #define PNP_ID_LEN	8
 #define PNP_MAX_DEVICES	8
Index: linux-2.6.22-rc5/scripts/mod/file2alias.c
===================================================================
--- linux-2.6.22-rc5.orig/scripts/mod/file2alias.c
+++ linux-2.6.22-rc5/scripts/mod/file2alias.c
@@ -290,6 +290,14 @@ static int do_serio_entry(const char *fi
 	return 1;
 }
 
+/* looks like: "acpi:ACPI0003 or acpi:PNP0C0B" */
+static int do_acpi_entry(const char *filename,
+			struct acpi_device_id *id, char *alias)
+{
+	sprintf(alias, "acpi*:%s:", id->id);
+	return 1;
+}
+
 /* looks like: "pnp:dD" */
 static int do_pnp_entry(const char *filename,
 			struct pnp_device_id *id, char *alias)
@@ -551,6 +559,10 @@ void handle_moddevtable(struct module *m
 		do_table(symval, sym->st_size,
 			 sizeof(struct serio_device_id), "serio",
 			 do_serio_entry, mod);
+	else if (sym_is(symname, "__mod_acpi_device_table"))
+		do_table(symval, sym->st_size,
+			 sizeof(struct acpi_device_id), "acpi",
+			 do_acpi_entry, mod);
 	else if (sym_is(symname, "__mod_pnp_device_table"))
 		do_table(symval, sym->st_size,
 			 sizeof(struct pnp_device_id), "pnp",
Index: linux-2.6.22-rc5/drivers/acpi/scan.c
===================================================================
--- linux-2.6.22-rc5.orig/drivers/acpi/scan.c
+++ linux-2.6.22-rc5/drivers/acpi/scan.c
@@ -16,7 +16,7 @@ ACPI_MODULE_NAME("scan");
 extern struct acpi_device *acpi_root;
 
 #define ACPI_BUS_CLASS			"system_bus"
-#define ACPI_BUS_HID			"ACPI_BUS"
+#define ACPI_BUS_HID			"XBUS0001"
 #define ACPI_BUS_DEVICE_NAME		"System Bus"
 
 static LIST_HEAD(acpi_device_list);
@@ -29,6 +29,69 @@ struct acpi_device_bus_id{
 	unsigned int instance_no;
 	struct list_head node;
 };
+
+/*
+  Currently only handles ID strings, not compressed EISA, here the spec:
+
+  A _HID object evaluates to either a numeric 32-bit compressed EISA type ID
+  or a string. If a string, the format must be an alphanumeric PNP or ACPI ID
+  with no asterisk or other leading characters.
+
+  Why is hardware_id char[15] -> see include/acpi/acpi_bus.h ?!?
+
+  This function only handles devices correctly that have a HID.
+  If there are devices that have CID(s), but no HID work needs
+*/
+int create_modalias(struct acpi_device *acpi_dev, char *modalias, int size){
+
+	int len;
+
+	if (!acpi_dev->flags.hardware_id)
+		return -ENODEV;
+
+	len = snprintf(modalias, size, "acpi:%s:",
+		       acpi_dev->pnp.hardware_id);
+	if (len < 0 || len >= size)
+		return -EINVAL;
+	size -= len;
+
+	if (acpi_dev->flags.compatible_ids) {
+		struct acpi_compatible_id_list *cid_list;
+		int i;
+		int count;
+
+		cid_list = acpi_dev->pnp.cid_list;
+		for (i = 0; i < cid_list->count; i++) {
+			count = snprintf(&modalias[len], size, "%s:",
+					 cid_list->id[i].value);
+			if (count < 0 || count >= size) {
+				printk(KERN_ERR "acpi: %s cid[%i] exceeds event buffer size",
+				       acpi_dev->pnp.device_name, i);
+				break;
+			}
+			len += count;
+			size -= count;
+		}
+	}
+
+	modalias[len] = '\0';
+	return len;
+}
+
+static ssize_t
+acpi_device_modalias_show(struct device *dev, struct device_attribute *attr, char *buf) {
+	struct acpi_device *acpi_dev = to_acpi_device(dev);
+	int len;
+
+	/* Device has no HID and no CID or string is >1024 */
+	len = create_modalias(acpi_dev, buf, 1024);
+	if (len <= 0)
+		return 0;
+	buf[len++] = '\n';
+	return len;
+}
+static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL);
+
 static int acpi_eject_operation(acpi_handle handle, int lockable)
 {
 	struct acpi_object_list arg_list;
@@ -154,6 +217,12 @@ static int acpi_device_setup_files(struc
 			goto end;
 	}
 
+	if (dev->flags.hardware_id || dev->flags.compatible_ids){
+		result = device_create_file(&dev->dev, &dev_attr_modalias);
+		if(result)
+			goto end;
+	}
+
         /*
          * If device has _EJ0, 'eject' file is created that is used to trigger
          * hot-removal function from userland.
@@ -178,6 +247,9 @@ static void acpi_device_remove_files(str
 	if (ACPI_SUCCESS(status))
 		device_remove_file(&dev->dev, &dev_attr_eject);
 
+	if (dev->flags.hardware_id || dev->flags.compatible_ids)
+		device_remove_file(&dev->dev, &dev_attr_modalias);
+
 	if(dev->flags.hardware_id)
 		device_remove_file(&dev->dev, &dev_attr_hid);
 	if(dev->handle)
@@ -186,6 +258,37 @@ static void acpi_device_remove_files(str
 /* --------------------------------------------------------------------------
 			ACPI Bus operations
    -------------------------------------------------------------------------- */
+
+int acpi_match_device_ids(struct acpi_device *device,
+			  const struct acpi_device_id *ids)
+{
+	const struct acpi_device_id *id;
+
+	if (device->flags.hardware_id) {
+		for (id = ids; id->id[0]; id++) {
+			if (!strcmp((char*)id->id, device->pnp.hardware_id))
+				return 0;
+		}
+	}
+
+	if (device->flags.compatible_ids) {
+		struct acpi_compatible_id_list *cid_list = device->pnp.cid_list;
+		int i;
+
+		for (id = ids; id->id[0]; id++) {
+			/* compare multiple _CID entries against driver ids */
+			for (i = 0; i < cid_list->count; i++) {
+				if (!strcmp((char*)id->id,
+					    cid_list->id[i].value))
+					return 0;
+			}
+		}
+	}
+
+	return -ENOENT;
+}
+EXPORT_SYMBOL(acpi_match_device_ids);
+
 static void acpi_device_release(struct device *dev)
 {
 	struct acpi_device *acpi_dev = to_acpi_device(dev);
@@ -219,37 +322,19 @@ 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_match_ids(acpi_dev, acpi_drv->ids);
+	return !acpi_match_device_ids(acpi_dev, acpi_drv->ids);
 }
 
 static int acpi_device_uevent(struct device *dev, char **envp, int num_envp,
-	char *buffer, int buffer_size)
+			      char *buffer, int buffer_size)
 {
 	struct acpi_device *acpi_dev = to_acpi_device(dev);
-	int i = 0, length = 0, ret = 0;
-
-	if (acpi_dev->flags.hardware_id)
-		ret = add_uevent_var(envp, num_envp, &i,
-			buffer, buffer_size, &length,
-			"HWID=%s", acpi_dev->pnp.hardware_id);
-	if (ret)
-		return -ENOMEM;
-	if (acpi_dev->flags.compatible_ids) {
-		int j;
-		struct acpi_compatible_id_list *cid_list;
 
-		cid_list = acpi_dev->pnp.cid_list;
-
-		for (j = 0; j < cid_list->count; j++) {
-			ret = add_uevent_var(envp, num_envp, &i, buffer,
-				buffer_size, &length, "COMPTID=%s",
-				cid_list->id[j].value);
-			if (ret)
-				return -ENOMEM;
-		}
+	strcpy(buffer, "MODALIAS=");
+	if (create_modalias(acpi_dev, buffer + 9, buffer_size - 9) > 0) {
+		envp[0] = buffer;
+		envp[1] = NULL;
 	}
-
-	envp[i] = NULL;
 	return 0;
 }
 
@@ -543,25 +628,6 @@ void acpi_bus_data_handler(acpi_handle h
 	return;
 }
 
-int acpi_match_ids(struct acpi_device *device, char *ids)
-{
-	if (device->flags.hardware_id)
-		if (strstr(ids, device->pnp.hardware_id))
-			return 0;
-
-	if (device->flags.compatible_ids) {
-		struct acpi_compatible_id_list *cid_list = device->pnp.cid_list;
-		int i;
-
-		/* compare multiple _CID entries against driver ids */
-		for (i = 0; i < cid_list->count; i++) {
-			if (strstr(ids, cid_list->id[i].value))
-				return 0;
-		}
-	}
-	return -ENOENT;
-}
-
 static int acpi_bus_get_perf_flags(struct acpi_device *device)
 {
 	device->performance.state = ACPI_STATE_UNKNOWN;
@@ -624,6 +690,13 @@ static int acpi_bus_get_wakeup_device_fl
 	struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
 	union acpi_object *package = NULL;
 
+	struct acpi_device_id button_device_ids[] = {
+		{"PNP0C0D", 0},
+		{"PNP0C0C", 0},
+		{"PNP0C0E", 0},
+		{"", 0},
+	};
+
 
 	/* _PRW */
 	status = acpi_evaluate_object(device->handle, "_PRW", NULL, &buffer);
@@ -643,7 +716,7 @@ static int acpi_bus_get_wakeup_device_fl
 
 	device->wakeup.flags.valid = 1;
 	/* Power button, Lid switch always enable wakeup */
-	if (!acpi_match_ids(device, "PNP0C0D,PNP0C0C,PNP0C0E"))
+	if (!acpi_match_device_ids(device, button_device_ids))
 		device->wakeup.flags.run_wake = 1;
 
       end:
Index: linux-2.6.22-rc5/drivers/pnp/pnpacpi/core.c
===================================================================
--- linux-2.6.22-rc5.orig/drivers/pnp/pnpacpi/core.c
+++ linux-2.6.22-rc5/drivers/pnp/pnpacpi/core.c
@@ -21,7 +21,10 @@
 
 #include <linux/acpi.h>
 #include <linux/pnp.h>
+#include <linux/mod_devicetable.h>
 #include <acpi/acpi_bus.h>
+#include <acpi/actypes.h>
+
 #include "pnpacpi.h"
 
 static int num = 0;
@@ -33,15 +36,17 @@ static int num = 0;
  * have irqs (PIC, Timer) because we call acpi_register_gsi.
  * Finaly only devices that have a CRS method need to be in this list.
  */
-static char __initdata excluded_id_list[] =
-	"PNP0C09," /* EC */
-	"PNP0C0F," /* Link device */
-	"PNP0000," /* PIC */
-	"PNP0100," /* Timer */
-	;
+static __initdata struct acpi_device_id excluded_id_list[] ={
+	{"PNP0C09", 0}, /* EC */
+	{"PNP0C0F", 0}, /* Link device */
+	{"PNP0000", 0}, /* PIC */
+	{"PNP0100", 0}, /* Timer */
+	{"", 0},
+};
+
 static inline int is_exclusive_device(struct acpi_device *dev)
 {
-	return (!acpi_match_ids(dev, excluded_id_list));
+	return (!acpi_match_device_ids(dev, excluded_id_list));
 }
 
 /*
Index: linux-2.6.22-rc5/include/linux/acpi.h
===================================================================
--- linux-2.6.22-rc5.orig/include/linux/acpi.h
+++ linux-2.6.22-rc5/include/linux/acpi.h
@@ -33,6 +33,7 @@
 #endif
 
 #include <linux/list.h>
+#include <linux/mod_devicetable.h>
 
 #include <acpi/acpi.h>
 #include <acpi/acpi_bus.h>

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

* Re: [PATCH 3/3] ACPI autoloading - Create __mod_acpi_device_table symbol for all acpi drivers.
  2007-06-20 17:06     ` Mattia Dongili
@ 2007-06-20 17:47       ` Thomas Renninger
  2007-06-21  4:16         ` Mattia Dongili
  2007-07-03  7:15         ` Len Brown
  0 siblings, 2 replies; 19+ messages in thread
From: Thomas Renninger @ 2007-06-20 17:47 UTC (permalink / raw)
  To: Mattia Dongili
  Cc: Len Brown, linux-kernel, linux-acpi, Henrique de Moraes Holschuh,
	acpi4asus-user

On Thu, 2007-06-21 at 02:06 +0900, Mattia Dongili wrote:
> On Sun, Jun 17, 2007 at 10:24:23PM +0200, Thomas Renninger wrote:
> > Create __mod_acpi_device_table symbol for all acpi drivers.
> > 
> > modpost is going to use this one to create modules.alias
> > 
> > Hopefully thinkpad module still works.
> > IMO this one should get restructured and make use of acpi_bus_register_driver
> > and try to avoid to test for HIDs/CIDs for its own.
> > 
> > Signed-off-by: Thomas Renninger <trenn@suse.de>
> 
> Tested, except for the compile error already reported it does its job on
> my vaios.

Thanks.

> A question though:
> 
> > Index: linux-2.6.22-rc4/drivers/misc/sony-laptop.c
> > ===================================================================
> > --- linux-2.6.22-rc4.orig/drivers/misc/sony-laptop.c
> > +++ linux-2.6.22-rc4/drivers/misc/sony-laptop.c
> > @@ -890,10 +890,22 @@ static int sony_nc_remove(struct acpi_de
> >  	return 0;
> >  }
> >  
> > +static const struct acpi_device_id sony_device_ids[] = {
> > +	{SONY_NC_HID, 0},
> > +	{SONY_PIC_HID, 0},
> > +	{"", 0},
> > +};
> > +MODULE_DEVICE_TABLE(acpi, sony_device_ids);
> > +
> > +static const struct acpi_device_id sony_nc_device_ids[] = {
> > +	{SONY_NC_HID, 0},
> > +	{"", 0},
> > +};
> > +
> ...
> > +static const struct acpi_device_id sony_pic_device_ids[] = {
> > +	{SONY_PIC_HID, 0},
> > +	{"", 0},
> > +};
> > +
> 
> is it really necessary to have those duplicate entries?
In this case, yes.

It's because two independent ACPI drivers are set up here.
If you could put these together, only set up
acpi_bus_register_driver(..) once in .init and get the pic and nc driver
handled together it would work.

I don't know whether this could be done.
If not, IMO this driver should get split up in two separate drivers, one
serving SONY_PIC_HID and one serving SONY_NC_HID.
> 
> Also, I guess that when this patch set is applied we also should declare
> sonypi obsolete as sony-laptop will grab the same device that sonypi
> wants (the SPIC one). sony-laptop has options to avoid doing that would
> make things clear to users.
> I still haven't received reports of mafunctioning vaios using the new
> sony-laptop instead of sonypi but 2.6.22 isn't final yet.

Sounds sane.
Another problem that could come up in future is that new laptops could
make use of the ACPI video spec (Appendix B) and of these vendor
specific devices (I already saw this on an ASUS).
While autoloading should still be ok (both are tried, maybe even both
are needed), we need to find out which one need to be used in which
condition.
I could imagine if we pass some kind of "Vista" OSI string, the ACPI
video spec stuff is used otherwise e.g. the ATK Asus specific things...

It might even be mixed up, that some functions of the video device
driver are provided, but hotkeys are still working with the other
driver...

I fear getting this right for all kind of laptops won't be that easy.

   Thomas

BTW: I also saw a laptop (IIRC it was a sony) with asus and sony ACPI
device.
When both drivers got loaded things broke.
A solution was to only let the asus driver get active if the device is
known. Currently, not sure whether still (I sent a patch a while ago),
the Asus driver falls back to a default ("M6N"?) configuration. IMO this
is a bit too dangerous and instead a message like "unsupported ASUS
model found, please send acpidump to linux-acpi@vger.kernel.org".


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

* Re: [PATCH 3/3] ACPI autoloading - Create __mod_acpi_device_table symbol for all acpi drivers.
  2007-06-20 17:47       ` Thomas Renninger
@ 2007-06-21  4:16         ` Mattia Dongili
  2007-07-03  7:15         ` Len Brown
  1 sibling, 0 replies; 19+ messages in thread
From: Mattia Dongili @ 2007-06-21  4:16 UTC (permalink / raw)
  To: Thomas Renninger
  Cc: Len Brown, linux-kernel, linux-acpi, Henrique de Moraes Holschuh,
	acpi4asus-user

On Wed, Jun 20, 2007 at 07:47:23PM +0200, Thomas Renninger wrote:
> On Thu, 2007-06-21 at 02:06 +0900, Mattia Dongili wrote:
> > On Sun, Jun 17, 2007 at 10:24:23PM +0200, Thomas Renninger wrote:
...
> > > +static const struct acpi_device_id sony_device_ids[] = {
> > > +	{SONY_NC_HID, 0},
> > > +	{SONY_PIC_HID, 0},
> > > +	{"", 0},
> > > +};
> > > +MODULE_DEVICE_TABLE(acpi, sony_device_ids);
> > > +
> > > +static const struct acpi_device_id sony_nc_device_ids[] = {
> > > +	{SONY_NC_HID, 0},
> > > +	{"", 0},
> > > +};
> > > +
> > ...
> > > +static const struct acpi_device_id sony_pic_device_ids[] = {
> > > +	{SONY_PIC_HID, 0},
> > > +	{"", 0},
> > > +};
> > > +
> > 
> > is it really necessary to have those duplicate entries?
> In this case, yes.
> 
> It's because two independent ACPI drivers are set up here.
> If you could put these together, only set up
> acpi_bus_register_driver(..) once in .init and get the pic and nc driver
> handled together it would work.
> 
> I don't know whether this could be done.

probably, I guess the the acpi_device.pnp structs contain enough
informations to detect which one is being handled. I'll get to that
later.

> If not, IMO this driver should get split up in two separate drivers, one
> serving SONY_PIC_HID and one serving SONY_NC_HID.

Oh no, we just merged them :)
Anyway, please feel free to add
Acked-by: Mattia Dongili <malattia@linux.it>
to this patch.

> > Also, I guess that when this patch set is applied we also should declare
> > sonypi obsolete as sony-laptop will grab the same device that sonypi
> > wants (the SPIC one). sony-laptop has options to avoid doing that would
> > make things clear to users.
> > I still haven't received reports of mafunctioning vaios using the new
> > sony-laptop instead of sonypi but 2.6.22 isn't final yet.
> 
> Sounds sane.
> Another problem that could come up in future is that new laptops could
> make use of the ACPI video spec (Appendix B) and of these vendor
> specific devices (I already saw this on an ASUS).
> While autoloading should still be ok (both are tried, maybe even both
> are needed), we need to find out which one need to be used in which
> condition.

AFAIK as far as vaios are concerned the spic device (ioport) is mostly
disappearing from newer models and most of the platform specific
operations are gathered through the methods of the acpi only SNC.
I'm also trying to get as many reports as possible[1] from vaio users to
build dmi {black,white}list for functionalities.
So I guess we are going the right direction.

[1]: with the help of TJ who has setup this nice page:
http://tjworld.net/sony-laptop/

Cheers
-- 
mattia
:wq!

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

* Re: [PATCH 3/3] ACPI autoloading - Create __mod_acpi_device_table symbol for all acpi drivers.
  2007-06-19 21:27         ` Henrique de Moraes Holschuh
@ 2007-07-03  7:11           ` Len Brown
  2007-07-03 15:06             ` Henrique de Moraes Holschuh
  0 siblings, 1 reply; 19+ messages in thread
From: Len Brown @ 2007-07-03  7:11 UTC (permalink / raw)
  To: Henrique de Moraes Holschuh
  Cc: Thomas Renninger, linux-kernel, linux-acpi, Kay Sievers

My $0.02 on thinkpad_acpi & HID's...

1. moving to DMI binding from PNP-id binding
sounds like a step in the wrong direction.

Are there thinkpads that you need to support that don't export IBM0068?

There is a long tradition of DMI information being copy/pasted
and being invalid.  While the thinkpad BIOS guys are probably
above average here, they're probably not immune from this issue.

At the end of the day, I'd be astonished if somebody told me that
the Windows thinkpad platform driver binds via DMI strings instead
of binding to IBM0068 -- which was likely invented for this sole purpose.

2. IBM_PCI_HID = ACPI_PCI_HOST_HID = PCI_ROOT_HID_STRING = "PNP0A03"

There is nothing IBM specific about a PCI root bridge.
If you need to use this one, please call it PCI_ROOT_HID_STRING.

thanks,
-Len

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

* Re: [PATCH 3/3] ACPI autoloading - Create __mod_acpi_device_table symbol for all acpi drivers.
  2007-06-20 17:47       ` Thomas Renninger
  2007-06-21  4:16         ` Mattia Dongili
@ 2007-07-03  7:15         ` Len Brown
  2007-07-04  7:33           ` Mattia Dongili
  1 sibling, 1 reply; 19+ messages in thread
From: Len Brown @ 2007-07-03  7:15 UTC (permalink / raw)
  To: trenn
  Cc: Mattia Dongili, linux-kernel, linux-acpi,
	Henrique de Moraes Holschuh, acpi4asus-user


> BTW: I also saw a laptop (IIRC it was a sony) with asus and sony ACPI
> device.
> When both drivers got loaded things broke.
> A solution was to only let the asus driver get active if the device is
> known. Currently, not sure whether still (I sent a patch a while ago),
> the Asus driver falls back to a default ("M6N"?) configuration. IMO this
> is a bit too dangerous and instead a message like "unsupported ASUS
> model found, please send acpidump to linux-acpi@vger.kernel.org".

This is pretty scary.
Can you drop the acpidump output into a bugzilla?

thanks,
-Len

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

* Re: [PATCH 1/3] ACPI autoloading - ACPICA adjustance
  2007-06-17 20:24 [PATCH 1/3] ACPI autoloading - ACPICA adjustance Thomas Renninger
  2007-06-17 20:27 ` [PATCH 2/3] ACPI autoloading - Create acpi alias interface Thomas Renninger
@ 2007-07-03  7:58 ` Len Brown
  2007-07-03 12:23   ` Thomas Renninger
  1 sibling, 1 reply; 19+ messages in thread
From: Len Brown @ 2007-07-03  7:58 UTC (permalink / raw)
  To: trenn; +Cc: linux-kernel, linux-acpi

On Sunday 17 June 2007 16:24, Thomas Renninger wrote:
> Define standardized HIDs ...

> Index: linux-2.6.22-rc4/include/acpi/acpi_drivers.h
> ===================================================================
> --- linux-2.6.22-rc4.orig/include/acpi/acpi_drivers.h
> +++ linux-2.6.22-rc4/include/acpi/acpi_drivers.h
> @@ -34,16 +34,33 @@
>  #define ACPI_BUS_COMPONENT		0x00010000
>  #define ACPI_SYSTEM_COMPONENT		0x02000000
>  
> -/* _HID definitions */
> +/*
> +  _HID definitions
> +  HIDs starting with 'X' are self defined here and are used for devices where
> +  a HID does not exist in spec.
> +  HIDs must conform to (ACPI spec - 6.1.4):
>  
> -#define ACPI_POWER_HID			"power_resource"
> +  Numeric 32-bit compressed EISA type ID are not supported (never seen one as
> +  an ACPI HID?)
> +
> +  A valid PNP ID must be of the form AAA#### where A is an uppercase letter
> +  and # is a hex digit.
> +  A valid ACPI ID must be of the form ACPI#### where # is a hex digit.
> +
> +  and our self-defined: XAAA#### where A is an uppercase letter and # is a hex
> +  digit.

What was the criteria for inventing the XAAA#### format?
It doesn't comply with the PNP standard format above, since
it starts with four letters instead of three.

I don't think that "XVID0001" will be more meaningful than "video"
when seen in sysfs...

> +*/
> +
> +#define ACPI_POWER_HID			"XPWR0001"
>  #define ACPI_PROCESSOR_HID		"ACPI0007"
> -#define ACPI_SYSTEM_HID			"acpi_system"
> -#define ACPI_THERMAL_HID		"thermal"
> -#define ACPI_BUTTON_HID_POWERF		"button_power"
> -#define ACPI_BUTTON_HID_SLEEPF		"button_sleep"
> -#define ACPI_VIDEO_HID			"video"
> -#define ACPI_BAY_HID			"bay"
> +#define ACPI_SYSTEM_HID			"XSYS0001"
> +#define ACPI_THERMAL_HID		"XTHM0001"
> +#define ACPI_BUTTON_HID_POWERF		"XPBT0001"
> +#define ACPI_BUTTON_HID_SLEEPF		"XSBT0001"
> +#define ACPI_VIDEO_HID			"XVID0001"
> +#define ACPI_BAY_HID			"XBAY0001"
> +

If the criteria is to stay within an 8 character id length,
I'd rather spell a word with capital letters, and stick
in 0's where we don't need more letters:

POWER000
SYSTEM00
THERMAL0
PWRBTN00
SLEEPBTN
VIDEO000
DRIVEBAY

Or when we discussed this before, we though about not conflicting
with a standard (or vendor standard) name by becoming the Linux vendor --
say using  the "LNX" prefix, and trying to spell something useful
in the remaining 5 characters. eg.

LNXPOWER
LNXSYSTM
LNXTHERM
LNXSLPBN
LNXPWRBN
LNXVIDEO
LNXIOBAY

-Len

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

* Re: [PATCH 1/3] ACPI autoloading - ACPICA adjustance
  2007-07-03  7:58 ` [PATCH 1/3] ACPI autoloading - ACPICA adjustance Len Brown
@ 2007-07-03 12:23   ` Thomas Renninger
  0 siblings, 0 replies; 19+ messages in thread
From: Thomas Renninger @ 2007-07-03 12:23 UTC (permalink / raw)
  To: Len Brown; +Cc: linux-kernel, linux-acpi, Kay Sievers

On Tue, 2007-07-03 at 03:58 -0400, Len Brown wrote:
> On Sunday 17 June 2007 16:24, Thomas Renninger wrote:
> > Define standardized HIDs ...
> 
> > Index: linux-2.6.22-rc4/include/acpi/acpi_drivers.h
> > ===================================================================
> > --- linux-2.6.22-rc4.orig/include/acpi/acpi_drivers.h
> > +++ linux-2.6.22-rc4/include/acpi/acpi_drivers.h
> > @@ -34,16 +34,33 @@
> >  #define ACPI_BUS_COMPONENT		0x00010000
> >  #define ACPI_SYSTEM_COMPONENT		0x02000000
> >  
> > -/* _HID definitions */
> > +/*
> > +  _HID definitions
> > +  HIDs starting with 'X' are self defined here and are used for devices where
> > +  a HID does not exist in spec.
> > +  HIDs must conform to (ACPI spec - 6.1.4):
> >  
> > -#define ACPI_POWER_HID			"power_resource"
> > +  Numeric 32-bit compressed EISA type ID are not supported (never seen one as
> > +  an ACPI HID?)
> > +
> > +  A valid PNP ID must be of the form AAA#### where A is an uppercase letter
> > +  and # is a hex digit.
> > +  A valid ACPI ID must be of the form ACPI#### where # is a hex digit.
> > +
> > +  and our self-defined: XAAA#### where A is an uppercase letter and # is a hex
> > +  digit.
> 
> What was the criteria for inventing the XAAA#### format?
> It doesn't comply with the PNP standard format above, since
> it starts with four letters instead of three.
Yes, it still violates the standard, intend was to not do so.
And to stick to the 8/9 bytes.
The X has the same meaning as your suggestion below, starting with LNX,
it should be visible that it is an out of spec, linux only hid.
> 
> I don't think that "XVID0001" will be more meaningful than "video"
> when seen in sysfs...
> 
> > +*/
> > +
> > +#define ACPI_POWER_HID			"XPWR0001"
> >  #define ACPI_PROCESSOR_HID		"ACPI0007"
> > -#define ACPI_SYSTEM_HID			"acpi_system"
> > -#define ACPI_THERMAL_HID		"thermal"
> > -#define ACPI_BUTTON_HID_POWERF		"button_power"
> > -#define ACPI_BUTTON_HID_SLEEPF		"button_sleep"
> > -#define ACPI_VIDEO_HID			"video"
> > -#define ACPI_BAY_HID			"bay"
> > +#define ACPI_SYSTEM_HID			"XSYS0001"
> > +#define ACPI_THERMAL_HID		"XTHM0001"
> > +#define ACPI_BUTTON_HID_POWERF		"XPBT0001"
> > +#define ACPI_BUTTON_HID_SLEEPF		"XSBT0001"
> > +#define ACPI_VIDEO_HID			"XVID0001"
> > +#define ACPI_BAY_HID			"XBAY0001"
> > +
> 
> If the criteria is to stay within an 8 character id length,
> I'd rather spell a word with capital letters, and stick
> in 0's where we don't need more letters:
> 
> POWER000
> SYSTEM00
> THERMAL0
> PWRBTN00
> SLEEPBTN
> VIDEO000
> DRIVEBAY
> 
> Or when we discussed this before, we though about not conflicting
> with a standard (or vendor standard) name by becoming the Linux vendor --
> say using  the "LNX" prefix, and trying to spell something useful
> in the remaining 5 characters. eg.
> 
> LNXPOWER
> LNXSYSTM
> LNXTHERM
> LNXSLPBN
> LNXPWRBN
> LNXVIDEO
> LNXIOBAY

Don't know what is better, the first solution looks nicer...
Just tell me the final suggestion and I redo the patch.

    Thomas

PS: What is your general impression of the patches, will you add the
next series to acpi-test?
Shall I wait for some other patch(es) and then rebase, this one touches
nearly every file in /drivers/acpi/*.c and could end up in some merge
work for me or others.


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

* Re: [PATCH 3/3] ACPI autoloading - Create __mod_acpi_device_table symbol for all acpi drivers.
  2007-07-03  7:11           ` Len Brown
@ 2007-07-03 15:06             ` Henrique de Moraes Holschuh
  0 siblings, 0 replies; 19+ messages in thread
From: Henrique de Moraes Holschuh @ 2007-07-03 15:06 UTC (permalink / raw)
  To: Len Brown; +Cc: Thomas Renninger, linux-kernel, linux-acpi, Kay Sievers

On Tue, 03 Jul 2007, Len Brown wrote:
> My $0.02 on thinkpad_acpi & HID's...
> 
> 1. moving to DMI binding from PNP-id binding
> sounds like a step in the wrong direction.

IBM made real use of the DMI data, so they even issued BIOS fixes to get it
right when crap made it to the DMI tables.  I am not sure Lenovo will keep
up the good work, but so far they did not do anything braindamaged to the
DMI tables AFAIK.

And we have a damn good table of the more interesting DMI data, which the
community maintains.  It is at http://www.thinkwiki.org/wiki/List_of_DMI_IDs
so I have a lot of support to take DMI-based decisions.

Note that I can use PNP-id autoload as well as the DMI-based one, it just
won't buy much.  AFAIK the driver already auto-loads on every supported
thinkpad, including new ones.

As for using PNP-id autoloading instead of DMI-based autoloading, I have two
problems with it:

	1. I don't trust IBM0068 more than the dmi data.  If you can assure
	me IBM0068 is only used for thinkpad laptops, because that's how
	these things work or somesuch, then I might change my mind.

	2. Lots of what thinkpad-acpi does has nothing to do with IBM0068.
	Autoloading based only on IBM0068 seems wrong to me, in this case.

> Are there thinkpads that you need to support that don't export IBM0068?

There could be, especially the very old ones that thinkpad-acpi partially
supports.  AFAIK, IBM0068 is a firmware-OS message-passing device, and also
hot key handler.  But it does little else.  Most of the other stuff is done
by directly poking stuff in different ACPI subtrees, or ACPI EC registers,
or accessing the CMOS NVRAM, and those have no unique HIDs...

> There is a long tradition of DMI information being copy/pasted
> and being invalid.  While the thinkpad BIOS guys are probably
> above average here, they're probably not immune from this issue.

No, they are not imune :-)  Some thinkpads have had slightly screwed up dmi
tables, but none due to something as ridiculous as copy-and-paste, and IBM
issued BIOS updates to fix the breakages.  Lenovo didn't break anything in
DMI so far, either (AFAIK, anyway).

> At the end of the day, I'd be astonished if somebody told me that
> the Windows thinkpad platform driver binds via DMI strings instead
> of binding to IBM0068 -- which was likely invented for this sole purpose.

They bind by HID, I think.  But I don't know what *else* they check before
they decide to load sucessfully.  If anyone would like to do some clean-room
reverse engineering of the windows drivers and send us the information,
fine, I'd welcome the information and use it.  But I am not touching the
Windows drivers.

Also, there are a number of different drivers, and AFAIK only the hot keys
one bind by HID.  I have not ever touched the Windows drivers, I just used
the thinkpad for a while with Windows to learn how it was supposed to act to
different events, but that's it.

> 2. IBM_PCI_HID = ACPI_PCI_HOST_HID = PCI_ROOT_HID_STRING = "PNP0A03"
> 
> There is nothing IBM specific about a PCI root bridge.
> If you need to use this one, please call it PCI_ROOT_HID_STRING.

Sure, it is something internal to the driver, and *IT MUST NOT BE USED FOR
AUTOLOADING*.  I will rename it, or get rid of it.

-- 
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique Holschuh

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

* Re: [PATCH 3/3] ACPI autoloading - Create __mod_acpi_device_table symbol for all acpi drivers.
  2007-07-03  7:15         ` Len Brown
@ 2007-07-04  7:33           ` Mattia Dongili
  2007-07-04 10:17             ` Thomas Renninger
  0 siblings, 1 reply; 19+ messages in thread
From: Mattia Dongili @ 2007-07-04  7:33 UTC (permalink / raw)
  To: Len Brown
  Cc: trenn, linux-kernel, linux-acpi, Henrique de Moraes Holschuh,
	acpi4asus-user

On Tue, Jul 03, 2007 at 03:15:33AM -0400, Len Brown wrote:
> 
> > BTW: I also saw a laptop (IIRC it was a sony) with asus and sony ACPI
> > device.
> > When both drivers got loaded things broke.
> > A solution was to only let the asus driver get active if the device is
> > known. Currently, not sure whether still (I sent a patch a while ago),
> > the Asus driver falls back to a default ("M6N"?) configuration. IMO this
> > is a bit too dangerous and instead a message like "unsupported ASUS
> > model found, please send acpidump to linux-acpi@vger.kernel.org".
> 
> This is pretty scary.
> Can you drop the acpidump output into a bugzilla?

and add myself to the cc-list?

thanks
-- 
mattia
:wq!

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

* Re: [PATCH 3/3] ACPI autoloading - Create __mod_acpi_device_table symbol for all acpi drivers.
  2007-07-04  7:33           ` Mattia Dongili
@ 2007-07-04 10:17             ` Thomas Renninger
  0 siblings, 0 replies; 19+ messages in thread
From: Thomas Renninger @ 2007-07-04 10:17 UTC (permalink / raw)
  To: Mattia Dongili
  Cc: Len Brown, linux-kernel, linux-acpi, Henrique de Moraes Holschuh,
	acpi4asus-user

On Wed, 2007-07-04 at 16:33 +0900, Mattia Dongili wrote:
> On Tue, Jul 03, 2007 at 03:15:33AM -0400, Len Brown wrote:
> > 
> > > BTW: I also saw a laptop (IIRC it was a sony) with asus and sony ACPI
> > > device.
> > > When both drivers got loaded things broke.
> > > A solution was to only let the asus driver get active if the device is
> > > known. Currently, not sure whether still (I sent a patch a while ago),
> > > the Asus driver falls back to a default ("M6N"?) configuration. IMO this
> > > is a bit too dangerous and instead a message like "unsupported ASUS
> > > model found, please send acpidump to linux-acpi@vger.kernel.org".
> > 
> > This is pretty scary.
> > Can you drop the acpidump output into a bugzilla?
> 
> and add myself to the cc-list?
I don't have such a machine, opening a bug does not make much sense.
Acpidump and more info is here:
https://bugzilla.novell.com/show_bug.cgi?id=166920

Thanks,

   Thomas


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

end of thread, other threads:[~2007-07-04 10:17 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-17 20:24 [PATCH 1/3] ACPI autoloading - ACPICA adjustance Thomas Renninger
2007-06-17 20:27 ` [PATCH 2/3] ACPI autoloading - Create acpi alias interface Thomas Renninger
2007-06-17 20:24   ` [PATCH 3/3] ACPI autoloading - Create __mod_acpi_device_table symbol for all acpi drivers Thomas Renninger
2007-06-17 22:49     ` Henrique de Moraes Holschuh
2007-06-19 12:53       ` Thomas Renninger
2007-06-19 16:23         ` Mattia Dongili
2007-06-19 21:27         ` Henrique de Moraes Holschuh
2007-07-03  7:11           ` Len Brown
2007-07-03 15:06             ` Henrique de Moraes Holschuh
2007-06-20 17:06     ` Mattia Dongili
2007-06-20 17:47       ` Thomas Renninger
2007-06-21  4:16         ` Mattia Dongili
2007-07-03  7:15         ` Len Brown
2007-07-04  7:33           ` Mattia Dongili
2007-07-04 10:17             ` Thomas Renninger
2007-06-20 15:52   ` [PATCH 2/3] ACPI autoloading - Create acpi alias interface Mattia Dongili
2007-06-20 17:24     ` Thomas Renninger
2007-07-03  7:58 ` [PATCH 1/3] ACPI autoloading - ACPICA adjustance Len Brown
2007-07-03 12:23   ` Thomas Renninger

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).