X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;ds=sidebyside;f=drivers%2Fpci%2Fpci-driver.c;h=8a09a953b358cfb48a4c5f918b0adc547123f0d5;hb=6a77f38946aaee1cd85eeec6cf4229b204c15071;hp=64195d6d6828f44a4e68086c66bd20c7edb7a1d2;hpb=87fc8d1bb10cd459024a742c6a10961fefcef18f;p=linux-2.6.git diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index 64195d6d6..8a09a953b 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -14,27 +14,6 @@ * Registration of PCI drivers and handling of hot-pluggable devices. */ -/** - * pci_match_one_device - Tell if a PCI device structure has a matching - * PCI device id structure - * @id: single PCI device id structure to match - * @dev: the PCI device structure to match against - * - * Returns the matching pci_device_id structure or %NULL if there is no match. - */ - -static inline const struct pci_device_id * -pci_match_one_device(const struct pci_device_id *id, const struct pci_dev *dev) -{ - if ((id->vendor == PCI_ANY_ID || id->vendor == dev->vendor) && - (id->device == PCI_ANY_ID || id->device == dev->device) && - (id->subvendor == PCI_ANY_ID || id->subvendor == dev->subsystem_vendor) && - (id->subdevice == PCI_ANY_ID || id->subdevice == dev->subsystem_device) && - !((id->class ^ dev->class) & id->class_mask)) - return id; - return NULL; -} - /* * Dynamic device IDs are disabled for !CONFIG_HOTPLUG */ @@ -291,33 +270,30 @@ static int pci_device_remove(struct device * dev) drv->remove(pci_dev); pci_dev->driver = NULL; } + + /* + * We would love to complain here if pci_dev->is_enabled is set, that + * the driver should have called pci_disable_device(), but the + * unfortunate fact is there are too many odd BIOS and bridge setups + * that don't like drivers doing that all of the time. + * Oh well, we can dream of sane hardware when we sleep, no matter how + * horrible the crap we have to deal with is when we are awake... + */ + pci_dev_put(pci_dev); return 0; } -static int pci_device_suspend(struct device * dev, u32 state) +static int pci_device_suspend(struct device * dev, pm_message_t state) { struct pci_dev * pci_dev = to_pci_dev(dev); struct pci_driver * drv = pci_dev->driver; - u32 dev_state; int i = 0; - /* Translate PM_SUSPEND_xx states to PCI device states */ - static u32 state_conversion[] = { - [PM_SUSPEND_ON] = 0, - [PM_SUSPEND_STANDBY] = 1, - [PM_SUSPEND_MEM] = 3, - [PM_SUSPEND_DISK] = 3, - }; - - if (state >= sizeof(state_conversion) / sizeof(state_conversion[1])) - return -EINVAL; - - dev_state = state_conversion[state]; if (drv && drv->suspend) - i = drv->suspend(pci_dev, dev_state); - - pci_save_state(pci_dev, pci_dev->saved_config_space); + i = drv->suspend(pci_dev, state); + else + pci_save_state(pci_dev); return i; } @@ -329,7 +305,7 @@ static int pci_device_suspend(struct device * dev, u32 state) static void pci_default_resume(struct pci_dev *pci_dev) { /* restore the PCI config space */ - pci_restore_state(pci_dev, pci_dev->saved_config_space); + pci_restore_state(pci_dev); /* if the device was enabled before suspend, reenable */ if (pci_dev->is_enabled) pci_enable_device(pci_dev); @@ -404,30 +380,30 @@ pci_populate_driver_dir(struct pci_driver *drv) * @drv: the driver structure to register * * Adds the driver structure to the list of registered drivers. - * Returns a negative value on error. The driver remains registered - * even if no device was claimed during registration. + * Returns a negative value on error, otherwise 0. + * If no error occured, the driver remains registered even if + * no device was claimed during registration. */ -int -pci_register_driver(struct pci_driver *drv) +int pci_register_driver(struct pci_driver *drv) { - int count = 0; + int error; /* initialize common driver fields */ drv->driver.name = drv->name; drv->driver.bus = &pci_bus_type; drv->driver.probe = pci_device_probe; drv->driver.remove = pci_device_remove; + drv->driver.owner = drv->owner; drv->driver.kobj.ktype = &pci_driver_kobj_type; pci_init_dynids(&drv->dynids); /* register with core */ - count = driver_register(&drv->driver); + error = driver_register(&drv->driver); - if (count >= 0) { + if (!error) pci_populate_driver_dir(drv); - } - return count ? count : 1; + return error; } /** @@ -512,16 +488,9 @@ static int pci_bus_match(struct device * dev, struct device_driver * drv) */ struct pci_dev *pci_dev_get(struct pci_dev *dev) { - struct device *tmp; - - if (!dev) - return NULL; - - tmp = get_device(&dev->dev); - if (tmp) - return to_pci_dev(tmp); - else - return NULL; + if (dev) + get_device(&dev->dev); + return dev; } /**