diff options
-rw-r--r-- | drivers/base/class.c | 2 | ||||
-rw-r--r-- | drivers/base/core.c | 30 |
2 files changed, 20 insertions, 12 deletions
diff --git a/drivers/base/class.c b/drivers/base/class.c index 59cf35894cfc..d916bbf5b72a 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c | |||
@@ -149,7 +149,7 @@ int class_register(struct class *cls) | |||
149 | if (error) | 149 | if (error) |
150 | return error; | 150 | return error; |
151 | 151 | ||
152 | #ifdef CONFIG_SYSFS_DEPRECATED | 152 | #if defined(CONFIG_SYSFS_DEPRECATED) && defined(CONFIG_BLOCK) |
153 | /* let the block class directory show up in the root of sysfs */ | 153 | /* let the block class directory show up in the root of sysfs */ |
154 | if (cls != &block_class) | 154 | if (cls != &block_class) |
155 | cls->subsys.kobj.kset = class_kset; | 155 | cls->subsys.kobj.kset = class_kset; |
diff --git a/drivers/base/core.c b/drivers/base/core.c index edf3bbeb8d6a..b1727876182c 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
@@ -27,9 +27,17 @@ | |||
27 | int (*platform_notify)(struct device *dev) = NULL; | 27 | int (*platform_notify)(struct device *dev) = NULL; |
28 | int (*platform_notify_remove)(struct device *dev) = NULL; | 28 | int (*platform_notify_remove)(struct device *dev) = NULL; |
29 | 29 | ||
30 | /* | 30 | #ifdef CONFIG_BLOCK |
31 | * sysfs bindings for devices. | 31 | static inline int device_is_not_partition(struct device *dev) |
32 | */ | 32 | { |
33 | return !(dev->type == &part_type); | ||
34 | } | ||
35 | #else | ||
36 | static inline int device_is_not_partition(struct device *dev) | ||
37 | { | ||
38 | return 1; | ||
39 | } | ||
40 | #endif | ||
33 | 41 | ||
34 | /** | 42 | /** |
35 | * dev_driver_string - Return a device's driver name, if at all possible | 43 | * dev_driver_string - Return a device's driver name, if at all possible |
@@ -652,14 +660,14 @@ static int device_add_class_symlinks(struct device *dev) | |||
652 | #ifdef CONFIG_SYSFS_DEPRECATED | 660 | #ifdef CONFIG_SYSFS_DEPRECATED |
653 | /* stacked class devices need a symlink in the class directory */ | 661 | /* stacked class devices need a symlink in the class directory */ |
654 | if (dev->kobj.parent != &dev->class->subsys.kobj && | 662 | if (dev->kobj.parent != &dev->class->subsys.kobj && |
655 | dev->type != &part_type) { | 663 | device_is_not_partition(dev)) { |
656 | error = sysfs_create_link(&dev->class->subsys.kobj, &dev->kobj, | 664 | error = sysfs_create_link(&dev->class->subsys.kobj, &dev->kobj, |
657 | dev->bus_id); | 665 | dev->bus_id); |
658 | if (error) | 666 | if (error) |
659 | goto out_subsys; | 667 | goto out_subsys; |
660 | } | 668 | } |
661 | 669 | ||
662 | if (dev->parent && dev->type != &part_type) { | 670 | if (dev->parent && device_is_not_partition(dev)) { |
663 | struct device *parent = dev->parent; | 671 | struct device *parent = dev->parent; |
664 | char *class_name; | 672 | char *class_name; |
665 | 673 | ||
@@ -688,11 +696,11 @@ static int device_add_class_symlinks(struct device *dev) | |||
688 | return 0; | 696 | return 0; |
689 | 697 | ||
690 | out_device: | 698 | out_device: |
691 | if (dev->parent && dev->type != &part_type) | 699 | if (dev->parent && device_is_not_partition(dev)) |
692 | sysfs_remove_link(&dev->kobj, "device"); | 700 | sysfs_remove_link(&dev->kobj, "device"); |
693 | out_busid: | 701 | out_busid: |
694 | if (dev->kobj.parent != &dev->class->subsys.kobj && | 702 | if (dev->kobj.parent != &dev->class->subsys.kobj && |
695 | dev->type != &part_type) | 703 | device_is_not_partition(dev)) |
696 | sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id); | 704 | sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id); |
697 | #else | 705 | #else |
698 | /* link in the class directory pointing to the device */ | 706 | /* link in the class directory pointing to the device */ |
@@ -701,7 +709,7 @@ out_busid: | |||
701 | if (error) | 709 | if (error) |
702 | goto out_subsys; | 710 | goto out_subsys; |
703 | 711 | ||
704 | if (dev->parent && dev->type != &part_type) { | 712 | if (dev->parent && device_is_not_partition(dev)) { |
705 | error = sysfs_create_link(&dev->kobj, &dev->parent->kobj, | 713 | error = sysfs_create_link(&dev->kobj, &dev->parent->kobj, |
706 | "device"); | 714 | "device"); |
707 | if (error) | 715 | if (error) |
@@ -725,7 +733,7 @@ static void device_remove_class_symlinks(struct device *dev) | |||
725 | return; | 733 | return; |
726 | 734 | ||
727 | #ifdef CONFIG_SYSFS_DEPRECATED | 735 | #ifdef CONFIG_SYSFS_DEPRECATED |
728 | if (dev->parent && dev->type != &part_type) { | 736 | if (dev->parent && device_is_not_partition(dev)) { |
729 | char *class_name; | 737 | char *class_name; |
730 | 738 | ||
731 | class_name = make_class_name(dev->class->name, &dev->kobj); | 739 | class_name = make_class_name(dev->class->name, &dev->kobj); |
@@ -737,10 +745,10 @@ static void device_remove_class_symlinks(struct device *dev) | |||
737 | } | 745 | } |
738 | 746 | ||
739 | if (dev->kobj.parent != &dev->class->subsys.kobj && | 747 | if (dev->kobj.parent != &dev->class->subsys.kobj && |
740 | dev->type != &part_type) | 748 | device_is_not_partition(dev)) |
741 | sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id); | 749 | sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id); |
742 | #else | 750 | #else |
743 | if (dev->parent && dev->type != &part_type) | 751 | if (dev->parent && device_is_not_partition(dev)) |
744 | sysfs_remove_link(&dev->kobj, "device"); | 752 | sysfs_remove_link(&dev->kobj, "device"); |
745 | 753 | ||
746 | sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id); | 754 | sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id); |