* [11/12] acpi: acpi pci bridge driver
@ 2006-09-22 9:51 Zhang Rui
2006-11-24 3:39 ` Len Brown
0 siblings, 1 reply; 3+ messages in thread
From: Zhang Rui @ 2006-09-22 9:51 UTC (permalink / raw)
To: linux-acpi; +Cc: len.brown
From: Li Shaohua <shaohua.li@intel.com>
acpi_device had a .bind/.unbind methods, but Linux driver model does not.
Cut ACPI PCI code over to use the Linux driver model methods.
Convert bin/unbind to use a new pci bridge driver.
The driver will add/remove _PRT, so we can eventually
remove .bind/.unbind methods.
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
---
drivers/acpi/pci_bind.c | 56 ++++++++++++++++++++++++++++++++++++++++++++----
drivers/acpi/pci_root.c | 5 ----
drivers/acpi/scan.c | 17 ++------------
3 files changed, 55 insertions(+), 23 deletions(-)
Index: linux-2.6.18-rc7/drivers/acpi/pci_bind.c
===================================================================
--- linux-2.6.18-rc7.orig/drivers/acpi/pci_bind.c 2006-09-14 13:26:47.000000000 +0800
+++ linux-2.6.18-rc7/drivers/acpi/pci_bind.c 2006-09-19 19:55:52.000000000 +0800
@@ -223,8 +223,6 @@ int acpi_pci_bind(struct acpi_device *de
data->id.segment, data->id.bus,
data->id.device, data->id.function));
data->bus = data->dev->subordinate;
- device->ops.bind = acpi_pci_bind;
- device->ops.unbind = acpi_pci_unbind;
}
/*
@@ -354,8 +352,6 @@ acpi_pci_bind_root(struct acpi_device *d
data->id = *id;
data->bus = bus;
- device->ops.bind = acpi_pci_bind;
- device->ops.unbind = acpi_pci_unbind;
acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer);
@@ -378,3 +374,55 @@ acpi_pci_bind_root(struct acpi_device *d
return result;
}
+
+#define ACPI_PCI_BRIDGE_DRIVER_NAME "ACPI PCI Bridge Driver"
+
+static int acpi_pci_bridge_add(struct acpi_device *device);
+static int acpi_pci_bridge_remove(struct acpi_device *device, int type);
+static int acpi_pci_bridge_match(struct acpi_device *device,
+ struct acpi_driver *driver);
+static struct acpi_driver acpi_pci_bridge_driver = {
+ .name = ACPI_PCI_BRIDGE_DRIVER_NAME,
+ .ops = {
+ .add = acpi_pci_bridge_add,
+ .remove = acpi_pci_bridge_remove,
+ .match = acpi_pci_bridge_match,
+ },
+};
+
+static int acpi_pci_bridge_match(struct acpi_device *device,
+ struct acpi_driver *driver)
+{
+ acpi_status status;
+ acpi_handle handle;
+
+ /* pci bridge has _PRT but isn't PNP0A03 */
+ status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle);
+ if (ACPI_FAILURE(status))
+ return -ENODEV;
+ if (!acpi_match_ids(device, "PNP0A03"))
+ return -ENODEV;
+ return 0;
+}
+
+static int acpi_pci_bridge_add(struct acpi_device *device)
+{
+ return acpi_pci_bind(device);
+}
+
+static int acpi_pci_bridge_remove(struct acpi_device *device, int type)
+{
+ return acpi_pci_unbind(device);
+}
+
+static int __init acpi_pci_bridge_init(void)
+{
+ if (acpi_pci_disabled)
+ return 0;
+ if (acpi_bus_register_driver(&acpi_pci_bridge_driver) < 0)
+ return -ENODEV;
+ return 0;
+}
+
+/* Should be called after ACPI pci root driver */
+subsys_initcall(acpi_pci_bridge_init);
Index: linux-2.6.18-rc7/drivers/acpi/pci_root.c
===================================================================
--- linux-2.6.18-rc7.orig/drivers/acpi/pci_root.c 2006-09-14 13:26:47.000000000 +0800
+++ linux-2.6.18-rc7/drivers/acpi/pci_root.c 2006-09-19 19:55:52.000000000 +0800
@@ -175,11 +175,6 @@ static int acpi_pci_root_add(struct acpi
strcpy(acpi_device_class(device), ACPI_PCI_ROOT_CLASS);
acpi_driver_data(device) = root;
- /*
- * TBD: Doesn't the bus driver automatically set this?
- */
- device->ops.bind = acpi_pci_bind;
-
/*
* Segment
* -------
Index: linux-2.6.18-rc7/drivers/acpi/scan.c
===================================================================
--- linux-2.6.18-rc7.orig/drivers/acpi/scan.c 2006-09-19 19:55:25.000000000 +0800
+++ linux-2.6.18-rc7/drivers/acpi/scan.c 2006-09-19 19:55:52.000000000 +0800
@@ -865,12 +865,13 @@ static int acpi_bus_remove(struct acpi_d
if (!rmdevice)
return 0;
-
+ /* FIXME: device_release_driver will automically call unbind, is this ok */
+#if 0
if (dev->flags.bus_address) {
if ((dev->parent) && (dev->parent->ops.unbind))
dev->parent->ops.unbind(dev);
}
-
+#endif
acpi_device_unregister(dev, ACPI_BUS_REMOVAL_EJECT);
return 0;
@@ -987,18 +988,6 @@ acpi_add_single_object(struct acpi_devic
acpi_device_register(device, parent);
- /*
- * Bind _ADR-Based Devices
- * -----------------------
- * If there's a a bus address (_ADR) then we utilize the parent's
- * 'bind' function (if exists) to bind the ACPI- and natively-
- * enumerated device representations.
- */
- if (device->flags.bus_address) {
- if (device->parent && device->parent->ops.bind)
- device->parent->ops.bind(device);
- }
-
end:
if (!result)
*child = device;
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [11/12] acpi: acpi pci bridge driver
2006-09-22 9:51 [11/12] acpi: acpi pci bridge driver Zhang Rui
@ 2006-11-24 3:39 ` Len Brown
2006-11-24 5:32 ` Zhang Rui
0 siblings, 1 reply; 3+ messages in thread
From: Len Brown @ 2006-11-24 3:39 UTC (permalink / raw)
To: Zhang Rui; +Cc: linux-acpi
> Index: linux-2.6.18-rc7/drivers/acpi/scan.c
> ===================================================================
> --- linux-2.6.18-rc7.orig/drivers/acpi/scan.c 2006-09-19 19:55:25.000000000 +0800
> +++ linux-2.6.18-rc7/drivers/acpi/scan.c 2006-09-19 19:55:52.000000000 +0800
> @@ -865,12 +865,13 @@ static int acpi_bus_remove(struct acpi_d
>
> if (!rmdevice)
> return 0;
> -
> + /* FIXME: device_release_driver will automically call unbind, is this ok */
> +#if 0
> if (dev->flags.bus_address) {
> if ((dev->parent) && (dev->parent->ops.unbind))
> dev->parent->ops.unbind(dev);
> }
> -
> +#endif
eh?
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [11/12] acpi: acpi pci bridge driver
2006-11-24 3:39 ` Len Brown
@ 2006-11-24 5:32 ` Zhang Rui
0 siblings, 0 replies; 3+ messages in thread
From: Zhang Rui @ 2006-11-24 5:32 UTC (permalink / raw)
To: Len Brown; +Cc: linux-acpi@vger
On Thu, 2006-11-23 at 22:39 -0500, Len Brown wrote:
> > Index: linux-2.6.18-rc7/drivers/acpi/scan.c
> > ===================================================================
> > --- linux-2.6.18-rc7.orig/drivers/acpi/scan.c 2006-09-19 19:55:25.000000000 +0800
> > +++ linux-2.6.18-rc7/drivers/acpi/scan.c 2006-09-19 19:55:52.000000000 +0800
> > @@ -865,12 +865,13 @@ static int acpi_bus_remove(struct acpi_d
> >
> > if (!rmdevice)
> > return 0;
> > -
> > + /* FIXME: device_release_driver will automically call unbind, is this ok */
> > +#if 0
> > if (dev->flags.bus_address) {
> > if ((dev->parent) && (dev->parent->ops.unbind))
> > dev->parent->ops.unbind(dev);
> > }
> > -
> > +#endif
>
> eh?
Code here should never be executed.
all the acpi-pci bridges(except root bridge) are managed by this acpi-
pci bridge driver . The bind and unbind methods are called automatically
in the .add/.remove method now.
> -
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-11-24 5:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-22 9:51 [11/12] acpi: acpi pci bridge driver Zhang Rui
2006-11-24 3:39 ` Len Brown
2006-11-24 5:32 ` Zhang Rui
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox