diff options
Diffstat (limited to 'drivers/base/dd.c')
-rw-r--r-- | drivers/base/dd.c | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 889c71111239..9f6f11ca0ab6 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c | |||
@@ -38,17 +38,29 @@ | |||
38 | * | 38 | * |
39 | * This function must be called with @dev->sem held. | 39 | * This function must be called with @dev->sem held. |
40 | */ | 40 | */ |
41 | void device_bind_driver(struct device * dev) | 41 | int device_bind_driver(struct device *dev) |
42 | { | 42 | { |
43 | if (klist_node_attached(&dev->knode_driver)) | 43 | int ret; |
44 | return; | 44 | |
45 | if (klist_node_attached(&dev->knode_driver)) { | ||
46 | printk(KERN_WARNING "%s: device %s already bound\n", | ||
47 | __FUNCTION__, kobject_name(&dev->kobj)); | ||
48 | return 0; | ||
49 | } | ||
45 | 50 | ||
46 | pr_debug("bound device '%s' to driver '%s'\n", | 51 | pr_debug("bound device '%s' to driver '%s'\n", |
47 | dev->bus_id, dev->driver->name); | 52 | dev->bus_id, dev->driver->name); |
48 | klist_add_tail(&dev->knode_driver, &dev->driver->klist_devices); | 53 | klist_add_tail(&dev->knode_driver, &dev->driver->klist_devices); |
49 | sysfs_create_link(&dev->driver->kobj, &dev->kobj, | 54 | ret = sysfs_create_link(&dev->driver->kobj, &dev->kobj, |
50 | kobject_name(&dev->kobj)); | 55 | kobject_name(&dev->kobj)); |
51 | sysfs_create_link(&dev->kobj, &dev->driver->kobj, "driver"); | 56 | if (ret == 0) { |
57 | ret = sysfs_create_link(&dev->kobj, &dev->driver->kobj, | ||
58 | "driver"); | ||
59 | if (ret) | ||
60 | sysfs_remove_link(&dev->driver->kobj, | ||
61 | kobject_name(&dev->kobj)); | ||
62 | } | ||
63 | return ret; | ||
52 | } | 64 | } |
53 | 65 | ||
54 | /** | 66 | /** |
@@ -91,7 +103,11 @@ int driver_probe_device(struct device_driver * drv, struct device * dev) | |||
91 | goto ProbeFailed; | 103 | goto ProbeFailed; |
92 | } | 104 | } |
93 | } | 105 | } |
94 | device_bind_driver(dev); | 106 | if (device_bind_driver(dev)) { |
107 | printk(KERN_ERR "%s: device_bind_driver(%s) failed\n", | ||
108 | __FUNCTION__, dev->bus_id); | ||
109 | /* How does undo a ->probe? We're screwed. */ | ||
110 | } | ||
95 | ret = 1; | 111 | ret = 1; |
96 | pr_debug("%s: Bound Device %s to Driver %s\n", | 112 | pr_debug("%s: Bound Device %s to Driver %s\n", |
97 | drv->bus->name, dev->bus_id, drv->name); | 113 | drv->bus->name, dev->bus_id, drv->name); |
@@ -139,8 +155,9 @@ int device_attach(struct device * dev) | |||
139 | 155 | ||
140 | down(&dev->sem); | 156 | down(&dev->sem); |
141 | if (dev->driver) { | 157 | if (dev->driver) { |
142 | device_bind_driver(dev); | 158 | ret = device_bind_driver(dev); |
143 | ret = 1; | 159 | if (ret == 0) |
160 | ret = 1; | ||
144 | } else | 161 | } else |
145 | ret = bus_for_each_drv(dev->bus, NULL, dev, __device_attach); | 162 | ret = bus_for_each_drv(dev->bus, NULL, dev, __device_attach); |
146 | up(&dev->sem); | 163 | up(&dev->sem); |
@@ -182,9 +199,9 @@ static int __driver_attach(struct device * dev, void * data) | |||
182 | * returns 0 and the @dev->driver is set, we've found a | 199 | * returns 0 and the @dev->driver is set, we've found a |
183 | * compatible pair. | 200 | * compatible pair. |
184 | */ | 201 | */ |
185 | void driver_attach(struct device_driver * drv) | 202 | int driver_attach(struct device_driver * drv) |
186 | { | 203 | { |
187 | bus_for_each_dev(drv->bus, NULL, drv, __driver_attach); | 204 | return bus_for_each_dev(drv->bus, NULL, drv, __driver_attach); |
188 | } | 205 | } |
189 | 206 | ||
190 | /** | 207 | /** |