diff options
Diffstat (limited to 'drivers/base/core.c')
-rw-r--r-- | drivers/base/core.c | 57 |
1 files changed, 30 insertions, 27 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c index 9f05de6f80b5..64c150b5a883 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
@@ -551,7 +551,7 @@ static struct kobject *get_device_parent(struct device *dev, | |||
551 | { | 551 | { |
552 | /* class devices without a parent live in /sys/class/<classname>/ */ | 552 | /* class devices without a parent live in /sys/class/<classname>/ */ |
553 | if (dev->class && (!parent || parent->class != dev->class)) | 553 | if (dev->class && (!parent || parent->class != dev->class)) |
554 | return &dev->class->subsys.kobj; | 554 | return &dev->class->p->subsys.kobj; |
555 | /* all other devices keep their parent */ | 555 | /* all other devices keep their parent */ |
556 | else if (parent) | 556 | else if (parent) |
557 | return &parent->kobj; | 557 | return &parent->kobj; |
@@ -597,13 +597,13 @@ static struct kobject *get_device_parent(struct device *dev, | |||
597 | parent_kobj = &parent->kobj; | 597 | parent_kobj = &parent->kobj; |
598 | 598 | ||
599 | /* find our class-directory at the parent and reference it */ | 599 | /* find our class-directory at the parent and reference it */ |
600 | spin_lock(&dev->class->class_dirs.list_lock); | 600 | spin_lock(&dev->class->p->class_dirs.list_lock); |
601 | list_for_each_entry(k, &dev->class->class_dirs.list, entry) | 601 | list_for_each_entry(k, &dev->class->p->class_dirs.list, entry) |
602 | if (k->parent == parent_kobj) { | 602 | if (k->parent == parent_kobj) { |
603 | kobj = kobject_get(k); | 603 | kobj = kobject_get(k); |
604 | break; | 604 | break; |
605 | } | 605 | } |
606 | spin_unlock(&dev->class->class_dirs.list_lock); | 606 | spin_unlock(&dev->class->p->class_dirs.list_lock); |
607 | if (kobj) | 607 | if (kobj) |
608 | return kobj; | 608 | return kobj; |
609 | 609 | ||
@@ -611,7 +611,7 @@ static struct kobject *get_device_parent(struct device *dev, | |||
611 | k = kobject_create(); | 611 | k = kobject_create(); |
612 | if (!k) | 612 | if (!k) |
613 | return NULL; | 613 | return NULL; |
614 | k->kset = &dev->class->class_dirs; | 614 | k->kset = &dev->class->p->class_dirs; |
615 | retval = kobject_add(k, parent_kobj, "%s", dev->class->name); | 615 | retval = kobject_add(k, parent_kobj, "%s", dev->class->name); |
616 | if (retval < 0) { | 616 | if (retval < 0) { |
617 | kobject_put(k); | 617 | kobject_put(k); |
@@ -630,7 +630,7 @@ static void cleanup_glue_dir(struct device *dev, struct kobject *glue_dir) | |||
630 | { | 630 | { |
631 | /* see if we live in a "glue" directory */ | 631 | /* see if we live in a "glue" directory */ |
632 | if (!glue_dir || !dev->class || | 632 | if (!glue_dir || !dev->class || |
633 | glue_dir->kset != &dev->class->class_dirs) | 633 | glue_dir->kset != &dev->class->p->class_dirs) |
634 | return; | 634 | return; |
635 | 635 | ||
636 | kobject_put(glue_dir); | 636 | kobject_put(glue_dir); |
@@ -657,17 +657,17 @@ static int device_add_class_symlinks(struct device *dev) | |||
657 | if (!dev->class) | 657 | if (!dev->class) |
658 | return 0; | 658 | return 0; |
659 | 659 | ||
660 | error = sysfs_create_link(&dev->kobj, &dev->class->subsys.kobj, | 660 | error = sysfs_create_link(&dev->kobj, &dev->class->p->subsys.kobj, |
661 | "subsystem"); | 661 | "subsystem"); |
662 | if (error) | 662 | if (error) |
663 | goto out; | 663 | goto out; |
664 | 664 | ||
665 | #ifdef CONFIG_SYSFS_DEPRECATED | 665 | #ifdef CONFIG_SYSFS_DEPRECATED |
666 | /* stacked class devices need a symlink in the class directory */ | 666 | /* stacked class devices need a symlink in the class directory */ |
667 | if (dev->kobj.parent != &dev->class->subsys.kobj && | 667 | if (dev->kobj.parent != &dev->class->p->subsys.kobj && |
668 | device_is_not_partition(dev)) { | 668 | device_is_not_partition(dev)) { |
669 | error = sysfs_create_link(&dev->class->subsys.kobj, &dev->kobj, | 669 | error = sysfs_create_link(&dev->class->p->subsys.kobj, |
670 | dev->bus_id); | 670 | &dev->kobj, dev->bus_id); |
671 | if (error) | 671 | if (error) |
672 | goto out_subsys; | 672 | goto out_subsys; |
673 | } | 673 | } |
@@ -704,12 +704,12 @@ out_device: | |||
704 | if (dev->parent && device_is_not_partition(dev)) | 704 | if (dev->parent && device_is_not_partition(dev)) |
705 | sysfs_remove_link(&dev->kobj, "device"); | 705 | sysfs_remove_link(&dev->kobj, "device"); |
706 | out_busid: | 706 | out_busid: |
707 | if (dev->kobj.parent != &dev->class->subsys.kobj && | 707 | if (dev->kobj.parent != &dev->class->p->subsys.kobj && |
708 | device_is_not_partition(dev)) | 708 | device_is_not_partition(dev)) |
709 | sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id); | 709 | sysfs_remove_link(&dev->class->p->subsys.kobj, dev->bus_id); |
710 | #else | 710 | #else |
711 | /* link in the class directory pointing to the device */ | 711 | /* link in the class directory pointing to the device */ |
712 | error = sysfs_create_link(&dev->class->subsys.kobj, &dev->kobj, | 712 | error = sysfs_create_link(&dev->class->p->subsys.kobj, &dev->kobj, |
713 | dev->bus_id); | 713 | dev->bus_id); |
714 | if (error) | 714 | if (error) |
715 | goto out_subsys; | 715 | goto out_subsys; |
@@ -723,7 +723,7 @@ out_busid: | |||
723 | return 0; | 723 | return 0; |
724 | 724 | ||
725 | out_busid: | 725 | out_busid: |
726 | sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id); | 726 | sysfs_remove_link(&dev->class->p->subsys.kobj, dev->bus_id); |
727 | #endif | 727 | #endif |
728 | 728 | ||
729 | out_subsys: | 729 | out_subsys: |
@@ -749,14 +749,14 @@ static void device_remove_class_symlinks(struct device *dev) | |||
749 | sysfs_remove_link(&dev->kobj, "device"); | 749 | sysfs_remove_link(&dev->kobj, "device"); |
750 | } | 750 | } |
751 | 751 | ||
752 | if (dev->kobj.parent != &dev->class->subsys.kobj && | 752 | if (dev->kobj.parent != &dev->class->p->subsys.kobj && |
753 | device_is_not_partition(dev)) | 753 | device_is_not_partition(dev)) |
754 | sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id); | 754 | sysfs_remove_link(&dev->class->p->subsys.kobj, dev->bus_id); |
755 | #else | 755 | #else |
756 | if (dev->parent && device_is_not_partition(dev)) | 756 | if (dev->parent && device_is_not_partition(dev)) |
757 | sysfs_remove_link(&dev->kobj, "device"); | 757 | sysfs_remove_link(&dev->kobj, "device"); |
758 | 758 | ||
759 | sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id); | 759 | sysfs_remove_link(&dev->class->p->subsys.kobj, dev->bus_id); |
760 | #endif | 760 | #endif |
761 | 761 | ||
762 | sysfs_remove_link(&dev->kobj, "subsystem"); | 762 | sysfs_remove_link(&dev->kobj, "subsystem"); |
@@ -904,15 +904,16 @@ int device_add(struct device *dev) | |||
904 | klist_add_tail(&dev->knode_parent, &parent->klist_children); | 904 | klist_add_tail(&dev->knode_parent, &parent->klist_children); |
905 | 905 | ||
906 | if (dev->class) { | 906 | if (dev->class) { |
907 | down(&dev->class->sem); | 907 | down(&dev->class->p->sem); |
908 | /* tie the class to the device */ | 908 | /* tie the class to the device */ |
909 | list_add_tail(&dev->node, &dev->class->devices); | 909 | list_add_tail(&dev->node, &dev->class->p->devices); |
910 | 910 | ||
911 | /* notify any interfaces that the device is here */ | 911 | /* notify any interfaces that the device is here */ |
912 | list_for_each_entry(class_intf, &dev->class->interfaces, node) | 912 | list_for_each_entry(class_intf, &dev->class->p->interfaces, |
913 | node) | ||
913 | if (class_intf->add_dev) | 914 | if (class_intf->add_dev) |
914 | class_intf->add_dev(dev, class_intf); | 915 | class_intf->add_dev(dev, class_intf); |
915 | up(&dev->class->sem); | 916 | up(&dev->class->p->sem); |
916 | } | 917 | } |
917 | Done: | 918 | Done: |
918 | put_device(dev); | 919 | put_device(dev); |
@@ -1013,14 +1014,15 @@ void device_del(struct device *dev) | |||
1013 | if (dev->class) { | 1014 | if (dev->class) { |
1014 | device_remove_class_symlinks(dev); | 1015 | device_remove_class_symlinks(dev); |
1015 | 1016 | ||
1016 | down(&dev->class->sem); | 1017 | down(&dev->class->p->sem); |
1017 | /* notify any interfaces that the device is now gone */ | 1018 | /* notify any interfaces that the device is now gone */ |
1018 | list_for_each_entry(class_intf, &dev->class->interfaces, node) | 1019 | list_for_each_entry(class_intf, &dev->class->p->interfaces, |
1020 | node) | ||
1019 | if (class_intf->remove_dev) | 1021 | if (class_intf->remove_dev) |
1020 | class_intf->remove_dev(dev, class_intf); | 1022 | class_intf->remove_dev(dev, class_intf); |
1021 | /* remove the device from the class list */ | 1023 | /* remove the device from the class list */ |
1022 | list_del_init(&dev->node); | 1024 | list_del_init(&dev->node); |
1023 | up(&dev->class->sem); | 1025 | up(&dev->class->p->sem); |
1024 | } | 1026 | } |
1025 | device_remove_file(dev, &uevent_attr); | 1027 | device_remove_file(dev, &uevent_attr); |
1026 | device_remove_attrs(dev); | 1028 | device_remove_attrs(dev); |
@@ -1348,11 +1350,12 @@ int device_rename(struct device *dev, char *new_name) | |||
1348 | } | 1350 | } |
1349 | #else | 1351 | #else |
1350 | if (dev->class) { | 1352 | if (dev->class) { |
1351 | error = sysfs_create_link(&dev->class->subsys.kobj, &dev->kobj, | 1353 | error = sysfs_create_link(&dev->class->p->subsys.kobj, |
1352 | dev->bus_id); | 1354 | &dev->kobj, dev->bus_id); |
1353 | if (error) | 1355 | if (error) |
1354 | goto out; | 1356 | goto out; |
1355 | sysfs_remove_link(&dev->class->subsys.kobj, old_device_name); | 1357 | sysfs_remove_link(&dev->class->p->subsys.kobj, |
1358 | old_device_name); | ||
1356 | } | 1359 | } |
1357 | #endif | 1360 | #endif |
1358 | 1361 | ||