aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/core.c
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2007-05-21 16:08:01 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2008-01-24 23:40:36 -0500
commitedfaa7c36574f1bf09c65ad602412db9da5f96bf (patch)
treed591b80ff9229e4845e41d68e2f4c5aadb017027 /drivers/base/core.c
parent09f82ea92822a7bbb7e816508abbda47ed54a77f (diff)
Driver core: convert block from raw kobjects to core devices
This moves the block devices to /sys/class/block. It will create a flat list of all block devices, with the disks and partitions in one directory. For compatibility /sys/block is created and contains symlinks to the disks. /sys/class/block |-- sda -> ../../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda |-- sda1 -> ../../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1 |-- sda10 -> ../../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda10 |-- sda5 -> ../../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5 |-- sda6 -> ../../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda6 |-- sda7 -> ../../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda7 |-- sda8 -> ../../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda8 |-- sda9 -> ../../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda9 `-- sr0 -> ../../devices/pci0000:00/0000:00:1f.2/host1/target1:0:0/1:0:0:0/block/sr0 /sys/block/ |-- sda -> ../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda `-- sr0 -> ../devices/pci0000:00/0000:00:1f.2/host1/target1:0:0/1:0:0:0/block/sr0 Signed-off-by: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base/core.c')
-rw-r--r--drivers/base/core.c20
1 files changed, 12 insertions, 8 deletions
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
709out_device: 710out_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");
712out_busid: 713out_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 */
926void put_device(struct device * dev) 929void 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}