diff options
Diffstat (limited to 'drivers/base/core.c')
-rw-r--r-- | drivers/base/core.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c index e21a65fc043e..1d3d3582fcca 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
@@ -372,6 +372,7 @@ int device_add(struct device *dev) | |||
372 | { | 372 | { |
373 | struct device *parent = NULL; | 373 | struct device *parent = NULL; |
374 | char *class_name = NULL; | 374 | char *class_name = NULL; |
375 | struct class_interface *class_intf; | ||
375 | int error = -EINVAL; | 376 | int error = -EINVAL; |
376 | 377 | ||
377 | dev = get_device(dev); | 378 | dev = get_device(dev); |
@@ -451,9 +452,14 @@ int device_add(struct device *dev) | |||
451 | klist_add_tail(&dev->knode_parent, &parent->klist_children); | 452 | klist_add_tail(&dev->knode_parent, &parent->klist_children); |
452 | 453 | ||
453 | if (dev->class) { | 454 | if (dev->class) { |
454 | /* tie the class to the device */ | ||
455 | down(&dev->class->sem); | 455 | down(&dev->class->sem); |
456 | /* tie the class to the device */ | ||
456 | list_add_tail(&dev->node, &dev->class->devices); | 457 | list_add_tail(&dev->node, &dev->class->devices); |
458 | |||
459 | /* notify any interfaces that the device is here */ | ||
460 | list_for_each_entry(class_intf, &dev->class->interfaces, node) | ||
461 | if (class_intf->add_dev) | ||
462 | class_intf->add_dev(dev, class_intf); | ||
457 | up(&dev->class->sem); | 463 | up(&dev->class->sem); |
458 | } | 464 | } |
459 | 465 | ||
@@ -548,6 +554,7 @@ void device_del(struct device * dev) | |||
548 | { | 554 | { |
549 | struct device * parent = dev->parent; | 555 | struct device * parent = dev->parent; |
550 | char *class_name = NULL; | 556 | char *class_name = NULL; |
557 | struct class_interface *class_intf; | ||
551 | 558 | ||
552 | if (parent) | 559 | if (parent) |
553 | klist_del(&dev->knode_parent); | 560 | klist_del(&dev->knode_parent); |
@@ -563,6 +570,11 @@ void device_del(struct device * dev) | |||
563 | } | 570 | } |
564 | kfree(class_name); | 571 | kfree(class_name); |
565 | down(&dev->class->sem); | 572 | down(&dev->class->sem); |
573 | /* notify any interfaces that the device is now gone */ | ||
574 | list_for_each_entry(class_intf, &dev->class->interfaces, node) | ||
575 | if (class_intf->remove_dev) | ||
576 | class_intf->remove_dev(dev, class_intf); | ||
577 | /* remove the device from the class list */ | ||
566 | list_del_init(&dev->node); | 578 | list_del_init(&dev->node); |
567 | up(&dev->class->sem); | 579 | up(&dev->class->sem); |
568 | } | 580 | } |