diff options
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/class.c | 7 | ||||
-rw-r--r-- | drivers/base/core.c | 20 |
2 files changed, 19 insertions, 8 deletions
diff --git a/drivers/base/class.c b/drivers/base/class.c index ba6745b0fd2f..624b3316e938 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/kdev_t.h> | 17 | #include <linux/kdev_t.h> |
18 | #include <linux/err.h> | 18 | #include <linux/err.h> |
19 | #include <linux/slab.h> | 19 | #include <linux/slab.h> |
20 | #include <linux/genhd.h> | ||
20 | #include "base.h" | 21 | #include "base.h" |
21 | 22 | ||
22 | #define to_class_attr(_attr) container_of(_attr, struct class_attribute, attr) | 23 | #define to_class_attr(_attr) container_of(_attr, struct class_attribute, attr) |
@@ -149,7 +150,13 @@ int class_register(struct class * cls) | |||
149 | if (error) | 150 | if (error) |
150 | return error; | 151 | return error; |
151 | 152 | ||
153 | #ifdef CONFIG_SYSFS_DEPRECATED | ||
154 | /* let the block class directory show up in the root of sysfs */ | ||
155 | if (cls != &block_class) | ||
156 | cls->subsys.kobj.kset = class_kset; | ||
157 | #else | ||
152 | cls->subsys.kobj.kset = class_kset; | 158 | cls->subsys.kobj.kset = class_kset; |
159 | #endif | ||
153 | cls->subsys.kobj.ktype = &class_ktype; | 160 | cls->subsys.kobj.ktype = &class_ktype; |
154 | 161 | ||
155 | error = kset_register(&cls->subsys); | 162 | error = kset_register(&cls->subsys); |
diff --git a/drivers/base/core.c b/drivers/base/core.c index 13cae18936c5..06e8738ab263 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
@@ -671,14 +671,15 @@ static int device_add_class_symlinks(struct device *dev) | |||
671 | 671 | ||
672 | #ifdef CONFIG_SYSFS_DEPRECATED | 672 | #ifdef CONFIG_SYSFS_DEPRECATED |
673 | /* stacked class devices need a symlink in the class directory */ | 673 | /* stacked class devices need a symlink in the class directory */ |
674 | if (dev->kobj.parent != &dev->class->subsys.kobj) { | 674 | if (dev->kobj.parent != &dev->class->subsys.kobj && |
675 | dev->type != &part_type) { | ||
675 | error = sysfs_create_link(&dev->class->subsys.kobj, &dev->kobj, | 676 | error = sysfs_create_link(&dev->class->subsys.kobj, &dev->kobj, |
676 | dev->bus_id); | 677 | dev->bus_id); |
677 | if (error) | 678 | if (error) |
678 | goto out_subsys; | 679 | goto out_subsys; |
679 | } | 680 | } |
680 | 681 | ||
681 | if (dev->parent) { | 682 | if (dev->parent && dev->type != &part_type) { |
682 | struct device *parent = dev->parent; | 683 | struct device *parent = dev->parent; |
683 | char *class_name; | 684 | char *class_name; |
684 | 685 | ||
@@ -707,10 +708,11 @@ static int device_add_class_symlinks(struct device *dev) | |||
707 | return 0; | 708 | return 0; |
708 | 709 | ||
709 | out_device: | 710 | out_device: |
710 | if (dev->parent) | 711 | if (dev->parent && dev->type != &part_type) |
711 | sysfs_remove_link(&dev->kobj, "device"); | 712 | sysfs_remove_link(&dev->kobj, "device"); |
712 | out_busid: | 713 | out_busid: |
713 | if (dev->kobj.parent != &dev->class->subsys.kobj) | 714 | if (dev->kobj.parent != &dev->class->subsys.kobj && |
715 | dev->type != &part_type) | ||
714 | sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id); | 716 | sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id); |
715 | #else | 717 | #else |
716 | /* link in the class directory pointing to the device */ | 718 | /* link in the class directory pointing to the device */ |
@@ -719,7 +721,7 @@ out_busid: | |||
719 | if (error) | 721 | if (error) |
720 | goto out_subsys; | 722 | goto out_subsys; |
721 | 723 | ||
722 | if (dev->parent) { | 724 | if (dev->parent && dev->type != &part_type) { |
723 | error = sysfs_create_link(&dev->kobj, &dev->parent->kobj, | 725 | error = sysfs_create_link(&dev->kobj, &dev->parent->kobj, |
724 | "device"); | 726 | "device"); |
725 | if (error) | 727 | if (error) |
@@ -743,7 +745,7 @@ static void device_remove_class_symlinks(struct device *dev) | |||
743 | return; | 745 | return; |
744 | 746 | ||
745 | #ifdef CONFIG_SYSFS_DEPRECATED | 747 | #ifdef CONFIG_SYSFS_DEPRECATED |
746 | if (dev->parent) { | 748 | if (dev->parent && dev->type != &part_type) { |
747 | char *class_name; | 749 | char *class_name; |
748 | 750 | ||
749 | class_name = make_class_name(dev->class->name, &dev->kobj); | 751 | class_name = make_class_name(dev->class->name, &dev->kobj); |
@@ -754,10 +756,11 @@ static void device_remove_class_symlinks(struct device *dev) | |||
754 | sysfs_remove_link(&dev->kobj, "device"); | 756 | sysfs_remove_link(&dev->kobj, "device"); |
755 | } | 757 | } |
756 | 758 | ||
757 | if (dev->kobj.parent != &dev->class->subsys.kobj) | 759 | if (dev->kobj.parent != &dev->class->subsys.kobj && |
760 | dev->type != &part_type) | ||
758 | sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id); | 761 | sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id); |
759 | #else | 762 | #else |
760 | if (dev->parent) | 763 | if (dev->parent && dev->type != &part_type) |
761 | sysfs_remove_link(&dev->kobj, "device"); | 764 | sysfs_remove_link(&dev->kobj, "device"); |
762 | 765 | ||
763 | sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id); | 766 | sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id); |
@@ -925,6 +928,7 @@ struct device * get_device(struct device * dev) | |||
925 | */ | 928 | */ |
926 | void put_device(struct device * dev) | 929 | void put_device(struct device * dev) |
927 | { | 930 | { |
931 | /* might_sleep(); */ | ||
928 | if (dev) | 932 | if (dev) |
929 | kobject_put(&dev->kobj); | 933 | kobject_put(&dev->kobj); |
930 | } | 934 | } |