aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/core.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-01-10 19:10:33 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2011-01-10 19:10:33 -0500
commite54be894eae10eca9892e965cc9532f5d5a11767 (patch)
tree27ace4446e42058ef4813a34bf63b55a870e7a12 /drivers/base/core.c
parent949f6711b83d2809d1ccb9d830155a65fdacdff9 (diff)
parentc6c0ac664c86ff6408fadbed4913938c8a732e26 (diff)
Merge branch 'driver-core-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6
* 'driver-core-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6: driver core: Document that device_rename() is only for networking sysfs: remove useless test from sysfs_merge_group driver-core: merge private parts of class and bus driver core: fix whitespace in class_attr_string
Diffstat (limited to 'drivers/base/core.c')
-rw-r--r--drivers/base/core.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 761359261589..080e9ca11017 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -647,7 +647,7 @@ class_dir_create_and_add(struct class *class, struct kobject *parent_kobj)
647 dir->class = class; 647 dir->class = class;
648 kobject_init(&dir->kobj, &class_dir_ktype); 648 kobject_init(&dir->kobj, &class_dir_ktype);
649 649
650 dir->kobj.kset = &class->p->class_dirs; 650 dir->kobj.kset = &class->p->glue_dirs;
651 651
652 retval = kobject_add(&dir->kobj, parent_kobj, "%s", class->name); 652 retval = kobject_add(&dir->kobj, parent_kobj, "%s", class->name);
653 if (retval < 0) { 653 if (retval < 0) {
@@ -672,7 +672,7 @@ static struct kobject *get_device_parent(struct device *dev,
672 if (sysfs_deprecated && dev->class == &block_class) { 672 if (sysfs_deprecated && dev->class == &block_class) {
673 if (parent && parent->class == &block_class) 673 if (parent && parent->class == &block_class)
674 return &parent->kobj; 674 return &parent->kobj;
675 return &block_class.p->class_subsys.kobj; 675 return &block_class.p->subsys.kobj;
676 } 676 }
677#endif 677#endif
678 678
@@ -691,13 +691,13 @@ static struct kobject *get_device_parent(struct device *dev,
691 mutex_lock(&gdp_mutex); 691 mutex_lock(&gdp_mutex);
692 692
693 /* find our class-directory at the parent and reference it */ 693 /* find our class-directory at the parent and reference it */
694 spin_lock(&dev->class->p->class_dirs.list_lock); 694 spin_lock(&dev->class->p->glue_dirs.list_lock);
695 list_for_each_entry(k, &dev->class->p->class_dirs.list, entry) 695 list_for_each_entry(k, &dev->class->p->glue_dirs.list, entry)
696 if (k->parent == parent_kobj) { 696 if (k->parent == parent_kobj) {
697 kobj = kobject_get(k); 697 kobj = kobject_get(k);
698 break; 698 break;
699 } 699 }
700 spin_unlock(&dev->class->p->class_dirs.list_lock); 700 spin_unlock(&dev->class->p->glue_dirs.list_lock);
701 if (kobj) { 701 if (kobj) {
702 mutex_unlock(&gdp_mutex); 702 mutex_unlock(&gdp_mutex);
703 return kobj; 703 return kobj;
@@ -719,7 +719,7 @@ static void cleanup_glue_dir(struct device *dev, struct kobject *glue_dir)
719{ 719{
720 /* see if we live in a "glue" directory */ 720 /* see if we live in a "glue" directory */
721 if (!glue_dir || !dev->class || 721 if (!glue_dir || !dev->class ||
722 glue_dir->kset != &dev->class->p->class_dirs) 722 glue_dir->kset != &dev->class->p->glue_dirs)
723 return; 723 return;
724 724
725 kobject_put(glue_dir); 725 kobject_put(glue_dir);
@@ -746,7 +746,7 @@ static int device_add_class_symlinks(struct device *dev)
746 return 0; 746 return 0;
747 747
748 error = sysfs_create_link(&dev->kobj, 748 error = sysfs_create_link(&dev->kobj,
749 &dev->class->p->class_subsys.kobj, 749 &dev->class->p->subsys.kobj,
750 "subsystem"); 750 "subsystem");
751 if (error) 751 if (error)
752 goto out; 752 goto out;
@@ -765,7 +765,7 @@ static int device_add_class_symlinks(struct device *dev)
765#endif 765#endif
766 766
767 /* link in the class directory pointing to the device */ 767 /* link in the class directory pointing to the device */
768 error = sysfs_create_link(&dev->class->p->class_subsys.kobj, 768 error = sysfs_create_link(&dev->class->p->subsys.kobj,
769 &dev->kobj, dev_name(dev)); 769 &dev->kobj, dev_name(dev));
770 if (error) 770 if (error)
771 goto out_device; 771 goto out_device;
@@ -793,7 +793,7 @@ static void device_remove_class_symlinks(struct device *dev)
793 if (sysfs_deprecated && dev->class == &block_class) 793 if (sysfs_deprecated && dev->class == &block_class)
794 return; 794 return;
795#endif 795#endif
796 sysfs_delete_link(&dev->class->p->class_subsys.kobj, &dev->kobj, dev_name(dev)); 796 sysfs_delete_link(&dev->class->p->subsys.kobj, &dev->kobj, dev_name(dev));
797} 797}
798 798
799/** 799/**
@@ -984,7 +984,7 @@ int device_add(struct device *dev)
984 mutex_lock(&dev->class->p->class_mutex); 984 mutex_lock(&dev->class->p->class_mutex);
985 /* tie the class to the device */ 985 /* tie the class to the device */
986 klist_add_tail(&dev->knode_class, 986 klist_add_tail(&dev->knode_class,
987 &dev->class->p->class_devices); 987 &dev->class->p->klist_devices);
988 988
989 /* notify any interfaces that the device is here */ 989 /* notify any interfaces that the device is here */
990 list_for_each_entry(class_intf, 990 list_for_each_entry(class_intf,
@@ -1550,6 +1550,8 @@ EXPORT_SYMBOL_GPL(device_destroy);
1550 * exclusion between two different calls of device_rename 1550 * exclusion between two different calls of device_rename
1551 * on the same device to ensure that new_name is valid and 1551 * on the same device to ensure that new_name is valid and
1552 * won't conflict with other devices. 1552 * won't conflict with other devices.
1553 *
1554 * "Never use this function, bad things will happen" - gregkh
1553 */ 1555 */
1554int device_rename(struct device *dev, const char *new_name) 1556int device_rename(struct device *dev, const char *new_name)
1555{ 1557{
@@ -1572,7 +1574,7 @@ int device_rename(struct device *dev, const char *new_name)
1572 } 1574 }
1573 1575
1574 if (dev->class) { 1576 if (dev->class) {
1575 error = sysfs_rename_link(&dev->class->p->class_subsys.kobj, 1577 error = sysfs_rename_link(&dev->class->p->subsys.kobj,
1576 &dev->kobj, old_device_name, new_name); 1578 &dev->kobj, old_device_name, new_name);
1577 if (error) 1579 if (error)
1578 goto out; 1580 goto out;