Răsfoiți Sursa

PNP: add interface to retrieve ACPI device from a PNPACPI device

Add pnp_acpi_device(pnp_dev), which takes a PNP device and returns the
associated ACPI device (or NULL, if the device is not a PNPACPI device).

This allows us to write a PNP driver that can manage both traditional
PNPBIOS and ACPI devices, treating ACPI-only functionality as an optional
extension.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: Len Brown <len.brown@intel.com>
Bjorn Helgaas 15 ani în urmă
părinte
comite
9065ce4500
2 a modificat fișierele cu 15 adăugiri și 1 ștergeri
  1. 2 1
      drivers/pnp/pnpacpi/core.c
  2. 13 0
      include/linux/pnp.h

+ 2 - 1
drivers/pnp/pnpacpi/core.c

@@ -144,7 +144,7 @@ static int pnpacpi_resume(struct pnp_dev *dev)
 }
 }
 #endif
 #endif
 
 
-static struct pnp_protocol pnpacpi_protocol = {
+struct pnp_protocol pnpacpi_protocol = {
 	.name	 = "Plug and Play ACPI",
 	.name	 = "Plug and Play ACPI",
 	.get	 = pnpacpi_get_resources,
 	.get	 = pnpacpi_get_resources,
 	.set	 = pnpacpi_set_resources,
 	.set	 = pnpacpi_set_resources,
@@ -154,6 +154,7 @@ static struct pnp_protocol pnpacpi_protocol = {
 	.resume = pnpacpi_resume,
 	.resume = pnpacpi_resume,
 #endif
 #endif
 };
 };
+EXPORT_SYMBOL(pnpacpi_protocol);
 
 
 static int __init pnpacpi_add_device(struct acpi_device *device)
 static int __init pnpacpi_add_device(struct acpi_device *device)
 {
 {

+ 13 - 0
include/linux/pnp.h

@@ -334,6 +334,19 @@ extern struct pnp_protocol pnpbios_protocol;
 #define pnp_device_is_pnpbios(dev) 0
 #define pnp_device_is_pnpbios(dev) 0
 #endif
 #endif
 
 
+#ifdef CONFIG_PNPACPI
+extern struct pnp_protocol pnpacpi_protocol;
+
+static inline struct acpi_device *pnp_acpi_device(struct pnp_dev *dev)
+{
+	if (dev->protocol == &pnpacpi_protocol)
+		return dev->data;
+	return NULL;
+}
+#else
+#define pnp_acpi_device(dev) 0
+#endif
+
 /* status */
 /* status */
 #define PNP_READY		0x0000
 #define PNP_READY		0x0000
 #define PNP_ATTACHED		0x0001
 #define PNP_ATTACHED		0x0001