X-Git-Url: http://ftp.safe.ca/?a=blobdiff_plain;f=drivers%2Fbase%2Fdriver.c;h=90c9fff09eadff6fbbd2e554e39db3653867ea9c;hb=ae926976ac362efc9db2365a07891cc52414f2ec;hp=b76cc69f11067801e85f830573d098561eb97727;hpb=93e746db183b3bdbbda67900f79b5835f9cb388f;p=safe%2Fjmp%2Flinux-2.6 diff --git a/drivers/base/driver.c b/drivers/base/driver.c index b76cc69..90c9fff 100644 --- a/drivers/base/driver.c +++ b/drivers/base/driver.c @@ -98,7 +98,7 @@ EXPORT_SYMBOL_GPL(driver_find_device); * @attr: driver attribute descriptor. */ int driver_create_file(struct device_driver *drv, - struct driver_attribute *attr) + const struct driver_attribute *attr) { int error; if (drv) @@ -115,7 +115,7 @@ EXPORT_SYMBOL_GPL(driver_create_file); * @attr: driver attribute descriptor. */ void driver_remove_file(struct device_driver *drv, - struct driver_attribute *attr) + const struct driver_attribute *attr) { if (drv) sysfs_remove_file(&drv->p->kobj, &attr->attr); @@ -181,7 +181,7 @@ void put_driver(struct device_driver *drv) EXPORT_SYMBOL_GPL(put_driver); static int driver_add_groups(struct device_driver *drv, - struct attribute_group **groups) + const struct attribute_group **groups) { int error = 0; int i; @@ -201,7 +201,7 @@ static int driver_add_groups(struct device_driver *drv, } static void driver_remove_groups(struct device_driver *drv, - struct attribute_group **groups) + const struct attribute_group **groups) { int i; @@ -223,6 +223,8 @@ int driver_register(struct device_driver *drv) int ret; struct device_driver *other; + BUG_ON(!drv->bus->p); + if ((drv->bus->probe && drv->probe) || (drv->bus->remove && drv->remove) || (drv->bus->shutdown && drv->shutdown)) @@ -234,7 +236,7 @@ int driver_register(struct device_driver *drv) put_driver(other); printk(KERN_ERR "Error: Driver '%s' is already registered, " "aborting...\n", drv->name); - return -EEXIST; + return -EBUSY; } ret = bus_add_driver(drv); @@ -255,6 +257,10 @@ EXPORT_SYMBOL_GPL(driver_register); */ void driver_unregister(struct device_driver *drv) { + if (!drv || !drv->p) { + WARN(1, "Unexpected driver unregister!\n"); + return; + } driver_remove_groups(drv, drv->groups); bus_remove_driver(drv); }