X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fbase%2Fbus.c;h=ef522ae5548092f83ddabcbf36d7a54ad56f7282;hb=2ddfd20e7c55421435cbf95a5ed3dd6e423cf934;hp=055989e94799eff3fb6e0b44823835257e8feb28;hpb=6e5565f949af1322f8f3d3f43d044645ae448499;p=linux-2.6 diff --git a/drivers/base/bus.c b/drivers/base/bus.c index 055989e947..ef522ae554 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c @@ -79,7 +79,7 @@ static void driver_release(struct kobject *kobj) { struct driver_private *drv_priv = to_driver(kobj); - pr_debug("driver: '%s': %s\n", kobject_name(kobj), __FUNCTION__); + pr_debug("driver: '%s': %s\n", kobject_name(kobj), __func__); kfree(drv_priv); } @@ -505,14 +505,11 @@ void bus_attach_device(struct device *dev) int ret = 0; if (bus) { - dev->is_registered = 1; if (bus->p->drivers_autoprobe) ret = device_attach(dev); WARN_ON(ret < 0); if (ret >= 0) klist_add_tail(&dev->knode_bus, &bus->p->klist_devices); - else - dev->is_registered = 0; } } @@ -533,10 +530,9 @@ void bus_remove_device(struct device *dev) sysfs_remove_link(&dev->bus->p->devices_kset->kobj, dev->bus_id); device_remove_attrs(dev->bus, dev); - if (dev->is_registered) { - dev->is_registered = 0; + if (klist_node_attached(&dev->knode_bus)) klist_del(&dev->knode_bus); - } + pr_debug("bus: '%s': remove device %s\n", dev->bus->name, dev->bus_id); device_release_driver(dev); @@ -658,9 +654,10 @@ int bus_add_driver(struct device_driver *drv) pr_debug("bus: '%s': add driver %s\n", bus->name, drv->name); priv = kzalloc(sizeof(*priv), GFP_KERNEL); - if (!priv) - return -ENOMEM; - + if (!priv) { + error = -ENOMEM; + goto out_put_bus; + } klist_init(&priv->klist_devices, NULL, NULL); priv->driver = drv; drv->p = priv; @@ -668,7 +665,7 @@ int bus_add_driver(struct device_driver *drv) error = kobject_init_and_add(&priv->kobj, &driver_ktype, NULL, "%s", drv->name); if (error) - goto out_put_bus; + goto out_unregister; if (drv->bus->p->drivers_autoprobe) { error = driver_attach(drv); @@ -681,19 +678,19 @@ int bus_add_driver(struct device_driver *drv) error = driver_create_file(drv, &driver_attr_uevent); if (error) { printk(KERN_ERR "%s: uevent attr (%s) failed\n", - __FUNCTION__, drv->name); + __func__, drv->name); } error = driver_add_attrs(bus, drv); if (error) { /* How the hell do we get out of this pickle? Give up */ printk(KERN_ERR "%s: driver_add_attrs(%s) failed\n", - __FUNCTION__, drv->name); + __func__, drv->name); } error = add_bind_files(drv); if (error) { /* Ditto */ printk(KERN_ERR "%s: add_bind_files(%s) failed\n", - __FUNCTION__, drv->name); + __func__, drv->name); } kobject_uevent(&priv->kobj, KOBJ_ADD);