X-Git-Url: http://pilppa.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fpnp%2Fdriver.c;h=e161423b4300d7f76c6f2b5a207362e2e4688ed1;hb=c401110186cc0ce2f0e4a03695af115e6c177d95;hp=33da25f3213f4614a6dc338b9743034452dab3de;hpb=d7f6884ae0ae6e406ec3500fcde16e8f51642460;p=linux-2.6-omap-h63xx.git diff --git a/drivers/pnp/driver.c b/drivers/pnp/driver.c index 33da25f3213..e161423b430 100644 --- a/drivers/pnp/driver.c +++ b/drivers/pnp/driver.c @@ -5,7 +5,6 @@ * */ -#include #include #include #include @@ -146,39 +145,69 @@ static int pnp_bus_match(struct device *dev, struct device_driver *drv) return 1; } +static int pnp_bus_suspend(struct device *dev, pm_message_t state) +{ + struct pnp_dev * pnp_dev = to_pnp_dev(dev); + struct pnp_driver * pnp_drv = pnp_dev->driver; + int error; -struct bus_type pnp_bus_type = { - .name = "pnp", - .match = pnp_bus_match, -}; + if (!pnp_drv) + return 0; + if (pnp_drv->suspend) { + error = pnp_drv->suspend(pnp_dev, state); + if (error) + return error; + } + + if (!(pnp_drv->flags & PNP_DRIVER_RES_DO_NOT_CHANGE) && + pnp_can_disable(pnp_dev)) { + error = pnp_stop_dev(pnp_dev); + if (error) + return error; + } -static int count_devices(struct device * dev, void * c) + return 0; +} + +static int pnp_bus_resume(struct device *dev) { - int * count = c; - (*count)++; + struct pnp_dev * pnp_dev = to_pnp_dev(dev); + struct pnp_driver * pnp_drv = pnp_dev->driver; + int error; + + if (!pnp_drv) + return 0; + + if (!(pnp_drv->flags & PNP_DRIVER_RES_DO_NOT_CHANGE)) { + error = pnp_start_dev(pnp_dev); + if (error) + return error; + } + + if (pnp_drv->resume) + return pnp_drv->resume(pnp_dev); + return 0; } +struct bus_type pnp_bus_type = { + .name = "pnp", + .match = pnp_bus_match, + .probe = pnp_device_probe, + .remove = pnp_device_remove, + .suspend = pnp_bus_suspend, + .resume = pnp_bus_resume, +}; + int pnp_register_driver(struct pnp_driver *drv) { - int count; - pnp_dbg("the driver '%s' has been registered", drv->name); drv->driver.name = drv->name; drv->driver.bus = &pnp_bus_type; - drv->driver.probe = pnp_device_probe; - drv->driver.remove = pnp_device_remove; - count = driver_register(&drv->driver); - - /* get the number of initial matches */ - if (count >= 0){ - count = 0; - driver_for_each_device(&drv->driver, NULL, &count, count_devices); - } - return count; + return driver_register(&drv->driver); } void pnp_unregister_driver(struct pnp_driver *drv) @@ -214,6 +243,8 @@ int pnp_add_id(struct pnp_id *id, struct pnp_dev *dev) EXPORT_SYMBOL(pnp_register_driver); EXPORT_SYMBOL(pnp_unregister_driver); +#if 0 EXPORT_SYMBOL(pnp_add_id); +#endif EXPORT_SYMBOL(pnp_device_attach); EXPORT_SYMBOL(pnp_device_detach);