Skip to contentSkip to conversation

ACPI in linux PnP layer

RFC/patch [email protected] 2 participants 3 messages Sep 8, 2004 – Sep 9, 2004 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi,

I have started to plug acpi in PnP layer.
A first patch add the function acpi_driver_scan, that allow to call a function for each acpi device.
I have to do that because acpi is load before PnP, and it can't add my function in acpi_bus_add (driver/acpi/scan.c).

The second patch is the PnP acpi driver.
It parse possible and activated resources.
It use acpi_register_gsi to activate irq (is that need ???)

Also there are no disable/set acpi resource support, nor ADDRESS resource support.

But it work well with drivers that work with pnpbios(parport, serial, ...).

What do you think of it ?
Any comment ?

Matthieu

drivers/acpi/scan.c +19 -0
diff -ruN --exclude='*.cmd' --exclude='*.o' --exclude='*.ko' linux.old/drivers/acpi/scan.c linux-2.6.9/drivers/acpi/scan.c
@@ -8,6 +8,7 @@
 #include <acpi/acpi_drivers.h>
 #include <acpi/acinterp.h>	/* for acpi_ex_eisa_id_to_string() */
 
+#include <linux/module.h>
 
 #define _COMPONENT		ACPI_BUS_COMPONENT
 ACPI_MODULE_NAME		("scan")
@@ -1070,4 +1071,22 @@
 	return_VALUE(result);
 }
 
+int acpi_driver_scan(void (* handler)(struct acpi_device * dev))
+{
+	struct list_head * node, * next;
+	if (!handler)
+		 return_VALUE(-EINVAL);
+
+	spin_lock(&acpi_device_lock);
+	list_for_each_safe(node, next, &acpi_device_list) {
+		struct acpi_device * dev = container_of(node, struct acpi_device, g_list);
+		spin_unlock(&acpi_device_lock);
+		handler(dev);
+		spin_lock(&acpi_device_lock);
+	}
+	spin_unlock(&acpi_device_lock);
+	return_VALUE(0);
+}
+
 subsys_initcall(acpi_scan_init);
+EXPORT_SYMBOL(acpi_driver_scan);
drivers/pnp/Kconfig +2 -0
diff -ruN --exclude='*.cmd' --exclude='*.o' --exclude='*.ko' linux.old/drivers/pnp/Kconfig linux-2.6.9/drivers/pnp/Kconfig
@@ -35,5 +35,7 @@
 
 source "drivers/pnp/pnpbios/Kconfig"
 
+source "drivers/pnp/pnpacpi/Kconfig"
+
 endmenu
 
drivers/pnp/Makefile +1 -0
diff -ruN --exclude='*.cmd' --exclude='*.o' --exclude='*.ko' linux.old/drivers/pnp/Makefile linux-2.6.9/drivers/pnp/Makefile
@@ -6,3 +6,4 @@
 
 obj-$(CONFIG_PNPBIOS)		+= pnpbios/
 obj-$(CONFIG_ISAPNP)		+= isapnp/
+obj-$(CONFIG_PNPACPI)		+= pnpacpi/
drivers/pnp/pnpacpi/core.c +608 -0

608 lines not on this page · raw message

drivers/pnp/pnpacpi/Kconfig +10 -0
diff -ruN --exclude='*.cmd' --exclude='*.o' --exclude='*.ko' linux.old/drivers/pnp/pnpacpi/Kconfig linux-2.6.9/drivers/pnp/pnpacpi/Kconfig
@@ -0,0 +1,10 @@
+#
+# Plug and Play ACPI configuration
+#
+config PNPACPI
+	bool "Plug and Play ACPI support (EXPERIMENTAL)"
+	depends on PNP && X86 && ACPI_BUS && EXPERIMENTAL
+	depends on !PNPBIOS
+	default y
+	---help---
+	Todo
drivers/pnp/pnpacpi/Makefile +5 -0
diff -ruN --exclude='*.cmd' --exclude='*.o' --exclude='*.ko' linux.old/drivers/pnp/pnpacpi/Makefile linux-2.6.9/drivers/pnp/pnpacpi/Makefile
@@ -0,0 +1,5 @@
+#
+# Makefile for the kernel PNPACPI driver.
+#
+
+obj-y := core.o
drivers/pnp/pnpbios/Kconfig +2 -0
diff -ruN --exclude='*.cmd' --exclude='*.o' --exclude='*.ko' linux.old/drivers/pnp/pnpbios/Kconfig linux-2.6.9/drivers/pnp/pnpbios/Kconfig
@@ -4,6 +4,8 @@
 config PNPBIOS
 	bool "Plug and Play BIOS support (EXPERIMENTAL)"
 	depends on PNP && X86 && EXPERIMENTAL
+	depends on !PNPACPI
+	default n
 	---help---
 	  Linux uses the PNPBIOS as defined in "Plug and Play BIOS
 	  Specification Version 1.0A May 5, 1994" to autodetect built-in
#2 lore raw
In reply to a message not in the archive

It is just an update version with some bugfix.

drivers/pnp/interface.c +12 -0
diff -ruN --exclude='*.cmd' --exclude='*.o' --exclude='*.ko' linux.old/drivers/pnp/interface.c linux-2.6.9/drivers/pnp/interface.c
@@ -457,10 +457,22 @@
 
 static DEVICE_ATTR(id,S_IRUGO,pnp_show_current_ids,NULL);
 
+static ssize_t pnp_show_current_name(struct device *dmdev, char *buf)
+{
+	char *str = buf;
+	struct pnp_dev *dev = to_pnp_dev(dmdev);
+
+	str += sprintf(str,"%s\n", dev->name);
+	return (str - buf);
+}
+
+static DEVICE_ATTR(name,S_IRUGO,pnp_show_current_name,NULL);
+
 int pnp_interface_attach_device(struct pnp_dev *dev)
 {
 	device_create_file(&dev->dev,&dev_attr_options);
 	device_create_file(&dev->dev,&dev_attr_resources);
 	device_create_file(&dev->dev,&dev_attr_id);
+	device_create_file(&dev->dev,&dev_attr_name);
 	return 0;
 }
drivers/pnp/Kconfig +2 -0
diff -ruN --exclude='*.cmd' --exclude='*.o' --exclude='*.ko' linux.old/drivers/pnp/Kconfig linux-2.6.9/drivers/pnp/Kconfig
@@ -35,5 +35,7 @@
 
 source "drivers/pnp/pnpbios/Kconfig"
 
+source "drivers/pnp/pnpacpi/Kconfig"
+
 endmenu
 
drivers/pnp/Makefile +1 -0
diff -ruN --exclude='*.cmd' --exclude='*.o' --exclude='*.ko' linux.old/drivers/pnp/Makefile linux-2.6.9/drivers/pnp/Makefile
@@ -6,3 +6,4 @@
 
 obj-$(CONFIG_PNPBIOS)		+= pnpbios/
 obj-$(CONFIG_ISAPNP)		+= isapnp/
+obj-$(CONFIG_PNPACPI)		+= pnpacpi/
drivers/pnp/pnpacpi/core.c +628 -0

628 lines not on this page · raw message

drivers/pnp/pnpacpi/Kconfig +10 -0
diff -ruN --exclude='*.cmd' --exclude='*.o' --exclude='*.ko' linux.old/drivers/pnp/pnpacpi/Kconfig linux-2.6.9/drivers/pnp/pnpacpi/Kconfig
@@ -0,0 +1,10 @@
+#
+# Plug and Play ACPI configuration
+#
+config PNPACPI
+	bool "Plug and Play ACPI support (EXPERIMENTAL)"
+	depends on PNP && X86 && ACPI_BUS && EXPERIMENTAL
+	depends on !PNPBIOS
+	default y
+	---help---
+	Todo
drivers/pnp/pnpacpi/Makefile +5 -0
diff -ruN --exclude='*.cmd' --exclude='*.o' --exclude='*.ko' linux.old/drivers/pnp/pnpacpi/Makefile linux-2.6.9/drivers/pnp/pnpacpi/Makefile
@@ -0,0 +1,5 @@
+#
+# Makefile for the kernel PNPACPI driver.
+#
+
+obj-y := core.o
drivers/pnp/pnpbios/Kconfig +2 -0
diff -ruN --exclude='*.cmd' --exclude='*.o' --exclude='*.ko' linux.old/drivers/pnp/pnpbios/Kconfig linux-2.6.9/drivers/pnp/pnpbios/Kconfig
@@ -4,6 +4,8 @@
 config PNPBIOS
 	bool "Plug and Play BIOS support (EXPERIMENTAL)"
 	depends on PNP && X86 && EXPERIMENTAL
+	depends on !PNPACPI
+	default n
 	---help---
 	  Linux uses the PNPBIOS as defined in "Plug and Play BIOS
 	  Specification Version 1.0A May 5, 1994" to autodetect built-in
#3 lore raw
In reply to a message not in the archive

drivers/acpi/scan.c line 1087

Quoted 12 lines · On Wednesday 08 September 2004 06:00 am…

Any comment ?

drivers/acpi/scan.c +8 -0
+	spin_lock(&acpi_device_lock);
+	list_for_each_safe(node, next, &acpi_device_list) {
+		struct acpi_device * dev = container_of(node, struct acpi_device, g_list);
+		spin_unlock(&acpi_device_lock);
+		handler(dev);
+		spin_lock(&acpi_device_lock);
+	}
+	spin_unlock(&acpi_device_lock);

What exactly that does spinlock do? Note that list_for_each_safe is only "safe" in sense that the current element can be deleted from the list _by the same thread_ that is doing iteration. That is it. If some other thread accesses the same list it is not safe at all and that spinlock is next to useless because it is dropped in the middle of the loop. The whole construct should be protected by a semaphore, acpi_subsys.rewsem is a good candidate (I hope Len will eventually apply my patch to the scan.c that does just that).

Signature · 8 lines
Dmitry


-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click