aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLi Shaohua <shaohua.li@intel.com>2006-12-07 07:57:05 -0500
committerLen Brown <len.brown@intel.com>2006-12-15 23:38:35 -0500
commitdb3e1cc3257758d8a694d0a6ab29f109fb019853 (patch)
tree04acebdac81e32af4ce8eea2c4e04efdeead26f3 /drivers
parent54a07001b9efb6a3bb9a9d8ac9ddb226e29b5406 (diff)
ACPI: Convert ACPI PCI .bind/.unbind to use PCI bridge driver
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 bind/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> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/pci_bind.c56
-rw-r--r--drivers/acpi/pci_root.c5
-rw-r--r--drivers/acpi/scan.c17
3 files changed, 52 insertions, 26 deletions
diff --git a/drivers/acpi/pci_bind.c b/drivers/acpi/pci_bind.c
index 1e2ae6e7a7e4..d83327468358 100644
--- a/drivers/acpi/pci_bind.c
+++ b/drivers/acpi/pci_bind.c
@@ -223,8 +223,6 @@ int acpi_pci_bind(struct acpi_device *device)
223 data->id.segment, data->id.bus, 223 data->id.segment, data->id.bus,
224 data->id.device, data->id.function)); 224 data->id.device, data->id.function));
225 data->bus = data->dev->subordinate; 225 data->bus = data->dev->subordinate;
226 device->ops.bind = acpi_pci_bind;
227 device->ops.unbind = acpi_pci_unbind;
228 } 226 }
229 227
230 /* 228 /*
@@ -354,8 +352,6 @@ acpi_pci_bind_root(struct acpi_device *device,
354 352
355 data->id = *id; 353 data->id = *id;
356 data->bus = bus; 354 data->bus = bus;
357 device->ops.bind = acpi_pci_bind;
358 device->ops.unbind = acpi_pci_unbind;
359 355
360 acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer); 356 acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer);
361 357
@@ -378,3 +374,55 @@ acpi_pci_bind_root(struct acpi_device *device,
378 374
379 return result; 375 return result;
380} 376}
377
378#define ACPI_PCI_BRIDGE_DRIVER_NAME "ACPI PCI Bridge Driver"
379
380static int acpi_pci_bridge_add(struct acpi_device *device);
381static int acpi_pci_bridge_remove(struct acpi_device *device, int type);
382static int acpi_pci_bridge_match(struct acpi_device *device,
383 struct acpi_driver *driver);
384static struct acpi_driver acpi_pci_bridge_driver = {
385 .name = ACPI_PCI_BRIDGE_DRIVER_NAME,
386 .ops = {
387 .add = acpi_pci_bridge_add,
388 .remove = acpi_pci_bridge_remove,
389 .match = acpi_pci_bridge_match,
390 },
391};
392
393static int acpi_pci_bridge_match(struct acpi_device *device,
394 struct acpi_driver *driver)
395{
396 acpi_status status;
397 acpi_handle handle;
398
399 /* pci bridge has _PRT but isn't PNP0A03 */
400 status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle);
401 if (ACPI_FAILURE(status))
402 return -ENODEV;
403 if (!acpi_match_ids(device, "PNP0A03"))
404 return -ENODEV;
405 return 0;
406}
407
408static int acpi_pci_bridge_add(struct acpi_device *device)
409{
410 return acpi_pci_bind(device);
411}
412
413static int acpi_pci_bridge_remove(struct acpi_device *device, int type)
414{
415 return acpi_pci_unbind(device);
416}
417
418static int __init acpi_pci_bridge_init(void)
419{
420 if (acpi_pci_disabled)
421 return 0;
422 if (acpi_bus_register_driver(&acpi_pci_bridge_driver) < 0)
423 return -ENODEV;
424 return 0;
425}
426
427/* Should be called after ACPI pci root driver */
428subsys_initcall(acpi_pci_bridge_init);
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index 0984a1ee24ed..9cfc74192419 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -175,11 +175,6 @@ static int acpi_pci_root_add(struct acpi_device *device)
175 strcpy(acpi_device_class(device), ACPI_PCI_ROOT_CLASS); 175 strcpy(acpi_device_class(device), ACPI_PCI_ROOT_CLASS);
176 acpi_driver_data(device) = root; 176 acpi_driver_data(device) = root;
177 177
178 /*
179 * TBD: Doesn't the bus driver automatically set this?
180 */
181 device->ops.bind = acpi_pci_bind;
182
183 /* 178 /*
184 * Segment 179 * Segment
185 * ------- 180 * -------
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 06b86faf037f..c566c74e8a31 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -866,11 +866,6 @@ static int acpi_bus_remove(struct acpi_device *dev, int rmdevice)
866 if (!rmdevice) 866 if (!rmdevice)
867 return 0; 867 return 0;
868 868
869 if (dev->flags.bus_address) {
870 if ((dev->parent) && (dev->parent->ops.unbind))
871 dev->parent->ops.unbind(dev);
872 }
873
874 acpi_device_unregister(dev, ACPI_BUS_REMOVAL_EJECT); 869 acpi_device_unregister(dev, ACPI_BUS_REMOVAL_EJECT);
875 870
876 return 0; 871 return 0;
@@ -987,18 +982,6 @@ acpi_add_single_object(struct acpi_device **child,
987 982
988 acpi_device_register(device, parent); 983 acpi_device_register(device, parent);
989 984
990 /*
991 * Bind _ADR-Based Devices
992 * -----------------------
993 * If there's a a bus address (_ADR) then we utilize the parent's
994 * 'bind' function (if exists) to bind the ACPI- and natively-
995 * enumerated device representations.
996 */
997 if (device->flags.bus_address) {
998 if (device->parent && device->parent->ops.bind)
999 device->parent->ops.bind(device);
1000 }
1001
1002 end: 985 end:
1003 if (!result) 986 if (!result)
1004 *child = device; 987 *child = device;