- if (bus) {
- pr_debug("bus %s: add driver %s\n", bus->name, drv->name);
- error = kobject_set_name(&drv->kobj, "%s", drv->name);
- if (error) {
- put_bus(bus);
- return error;
- }
- drv->kobj.kset = &bus->drivers;
- if ((error = kobject_register(&drv->kobj))) {
- put_bus(bus);
- return error;
- }
-
- driver_attach(drv);
- klist_add_tail(&drv->knode_bus, &bus->klist_drivers);
- module_add_driver(drv->owner, drv);
-
- driver_add_attrs(bus, drv);
- add_bind_files(drv);
+ if (!bus)
+ return 0;
+
+ pr_debug("bus %s: add driver %s\n", bus->name, drv->name);
+ error = kobject_set_name(&drv->kobj, "%s", drv->name);
+ if (error)
+ goto out_put_bus;
+ drv->kobj.kset = &bus->drivers;
+ if ((error = kobject_register(&drv->kobj)))
+ goto out_put_bus;
+
+ error = driver_attach(drv);
+ if (error)
+ goto out_unregister;
+ klist_add_tail(&drv->knode_bus, &bus->klist_drivers);
+ module_add_driver(drv->owner, drv);
+
+ 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);