diff options
Diffstat (limited to 'drivers/base/bus.c')
-rw-r--r-- | drivers/base/bus.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/drivers/base/bus.c b/drivers/base/bus.c index 80ce88de56fa..aa27f76d28cd 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c | |||
@@ -283,18 +283,22 @@ void device_bind_driver(struct device * dev) | |||
283 | */ | 283 | */ |
284 | int driver_probe_device(struct device_driver * drv, struct device * dev) | 284 | int driver_probe_device(struct device_driver * drv, struct device * dev) |
285 | { | 285 | { |
286 | int error = 0; | ||
287 | |||
286 | if (drv->bus->match && !drv->bus->match(dev, drv)) | 288 | if (drv->bus->match && !drv->bus->match(dev, drv)) |
287 | return -ENODEV; | 289 | return -ENODEV; |
288 | 290 | ||
291 | down(&dev->sem); | ||
289 | dev->driver = drv; | 292 | dev->driver = drv; |
290 | if (drv->probe) { | 293 | if (drv->probe) { |
291 | int error = drv->probe(dev); | 294 | error = drv->probe(dev); |
292 | if (error) { | 295 | if (error) { |
293 | dev->driver = NULL; | 296 | dev->driver = NULL; |
297 | up(&dev->sem); | ||
294 | return error; | 298 | return error; |
295 | } | 299 | } |
296 | } | 300 | } |
297 | 301 | up(&dev->sem); | |
298 | device_bind_driver(dev); | 302 | device_bind_driver(dev); |
299 | return 0; | 303 | return 0; |
300 | } | 304 | } |
@@ -385,7 +389,10 @@ void driver_attach(struct device_driver * drv) | |||
385 | 389 | ||
386 | void device_release_driver(struct device * dev) | 390 | void device_release_driver(struct device * dev) |
387 | { | 391 | { |
388 | struct device_driver * drv = dev->driver; | 392 | struct device_driver * drv; |
393 | |||
394 | down(&dev->sem); | ||
395 | drv = dev->driver; | ||
389 | if (drv) { | 396 | if (drv) { |
390 | sysfs_remove_link(&drv->kobj, kobject_name(&dev->kobj)); | 397 | sysfs_remove_link(&drv->kobj, kobject_name(&dev->kobj)); |
391 | sysfs_remove_link(&dev->kobj, "driver"); | 398 | sysfs_remove_link(&dev->kobj, "driver"); |
@@ -394,6 +401,7 @@ void device_release_driver(struct device * dev) | |||
394 | drv->remove(dev); | 401 | drv->remove(dev); |
395 | dev->driver = NULL; | 402 | dev->driver = NULL; |
396 | } | 403 | } |
404 | up(&dev->sem); | ||
397 | } | 405 | } |
398 | 406 | ||
399 | 407 | ||