acpi/pci: Inherit methods from pci_driver, instead of setting them manually
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Thu, 7 Apr 2011 08:29:03 +0000 (16:29 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Thu, 7 Apr 2011 10:27:15 +0000 (18:27 +0800)
Manually setting all of the necessary methods is error prone, e.g. previously
pci_find_extcap is not set, which causes agp(4) not being attached.

sys/dev/acpica5/acpi_pci.c

index e9dab6a..bf760af 100644 (file)
@@ -84,49 +84,23 @@ static device_method_t acpi_pci_methods[] = {
        /* Device interface */
        DEVMETHOD(device_probe,         acpi_pci_probe),
        DEVMETHOD(device_attach,        acpi_pci_attach),
-       DEVMETHOD(device_shutdown,      bus_generic_shutdown),
        DEVMETHOD(device_suspend,       acpi_pci_suspend),
        DEVMETHOD(device_resume,        acpi_pci_resume),
 
        /* Bus interface */
-       DEVMETHOD(bus_print_child,      pci_print_child),
-       DEVMETHOD(bus_get_resource_list,pci_get_resource_list),
-       DEVMETHOD(bus_set_resource,     bus_generic_rl_set_resource),
-       DEVMETHOD(bus_get_resource,     bus_generic_rl_get_resource),
-       DEVMETHOD(bus_delete_resource,  pci_delete_resource),
-       DEVMETHOD(bus_alloc_resource,   pci_alloc_resource),
-       DEVMETHOD(bus_release_resource, bus_generic_rl_release_resource),
-       DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
-       DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
        DEVMETHOD(bus_read_ivar,        acpi_pci_read_ivar),
        DEVMETHOD(bus_write_ivar,       acpi_pci_write_ivar),
-       DEVMETHOD(bus_driver_added,     bus_generic_driver_added),
-       DEVMETHOD(bus_setup_intr,       bus_generic_setup_intr),
-       DEVMETHOD(bus_teardown_intr,    bus_generic_teardown_intr),
        DEVMETHOD(bus_child_location_str, acpi_pci_child_location_str_method),
 
        /* PCI interface */
-       DEVMETHOD(pci_read_config,      pci_read_config_method),
-       DEVMETHOD(pci_write_config,     pci_write_config_method),
-       DEVMETHOD(pci_enable_busmaster, pci_enable_busmaster_method),
-       DEVMETHOD(pci_disable_busmaster, pci_disable_busmaster_method),
-       DEVMETHOD(pci_enable_io,        pci_enable_io_method),
-       DEVMETHOD(pci_disable_io,       pci_disable_io_method),
-       DEVMETHOD(pci_get_powerstate,   pci_get_powerstate_method),
        DEVMETHOD(pci_set_powerstate,   acpi_pci_set_powerstate_method),
-       DEVMETHOD(pci_assign_interrupt, pci_assign_interrupt_method),
 
        { 0, 0 }
 };
 
-static driver_t acpi_pci_driver = {
-       "pci",
-       acpi_pci_methods,
-       0,      /* no softc */
-};
-
 static devclass_t pci_devclass;
 
+DEFINE_CLASS_1(pci, acpi_pci_driver, acpi_pci_methods, 0, pci_driver);
 DRIVER_MODULE(acpi_pci, pcib, acpi_pci_driver, pci_devclass, 0, 0);
 MODULE_DEPEND(acpi_pci, acpi, 1, 1, 1);
 MODULE_DEPEND(acpi_pci, pci, 1, 1, 1);