aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/core.c
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2010-09-05 01:33:14 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2010-10-22 13:16:43 -0400
commit39aba963d937edb20db7d9d93e6dda5d2adfdcdd (patch)
tree7aa1898634ed6f6ece3e48f4b5464fcbcb4f49a5 /drivers/base/core.c
parent807508c8ff9af6ce8f25c5ca5f3eb06a8e7d3286 (diff)
driver core: remove CONFIG_SYSFS_DEPRECATED_V2 but keep it for block devices
This patch removes the old CONFIG_SYSFS_DEPRECATED_V2 config option, but it keeps the logic around to handle block devices in the old manner as some people like to run new kernel versions on old (pre 2007/2008) distros. Signed-off-by: Kay Sievers <kay.sievers@vrfy.org> Cc: Jens Axboe <axboe@kernel.dk> Cc: Stephen Hemminger <shemminger@vyatta.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Alan Stern <stern@rowland.harvard.edu> Cc: "James E.J. Bottomley" <James.Bottomley@suse.de> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru> Cc: Randy Dunlap <randy.dunlap@oracle.com> Cc: Tejun Heo <tj@kernel.org> Cc: "David S. Miller" <davem@davemloft.net> Cc: Jaroslav Kysela <perex@perex.cz> Cc: Takashi Iwai <tiwai@suse.de> Cc: Ingo Molnar <mingo@elte.hu> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: David Howells <dhowells@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base/core.c')
-rw-r--r--drivers/base/core.c194
1 files changed, 25 insertions, 169 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c
index d1b2c9adc271..6cf9069f3150 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -203,37 +203,6 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj,
203 if (dev->driver) 203 if (dev->driver)
204 add_uevent_var(env, "DRIVER=%s", dev->driver->name); 204 add_uevent_var(env, "DRIVER=%s", dev->driver->name);
205 205
206#ifdef CONFIG_SYSFS_DEPRECATED
207 if (dev->class) {
208 struct device *parent = dev->parent;
209
210 /* find first bus device in parent chain */
211 while (parent && !parent->bus)
212 parent = parent->parent;
213 if (parent && parent->bus) {
214 const char *path;
215
216 path = kobject_get_path(&parent->kobj, GFP_KERNEL);
217 if (path) {
218 add_uevent_var(env, "PHYSDEVPATH=%s", path);
219 kfree(path);
220 }
221
222 add_uevent_var(env, "PHYSDEVBUS=%s", parent->bus->name);
223
224 if (parent->driver)
225 add_uevent_var(env, "PHYSDEVDRIVER=%s",
226 parent->driver->name);
227 }
228 } else if (dev->bus) {
229 add_uevent_var(env, "PHYSDEVBUS=%s", dev->bus->name);
230
231 if (dev->driver)
232 add_uevent_var(env, "PHYSDEVDRIVER=%s",
233 dev->driver->name);
234 }
235#endif
236
237 /* have the bus specific function add its stuff */ 206 /* have the bus specific function add its stuff */
238 if (dev->bus && dev->bus->uevent) { 207 if (dev->bus && dev->bus->uevent) {
239 retval = dev->bus->uevent(dev, env); 208 retval = dev->bus->uevent(dev, env);
@@ -578,24 +547,6 @@ void device_initialize(struct device *dev)
578 set_dev_node(dev, -1); 547 set_dev_node(dev, -1);
579} 548}
580 549
581#ifdef CONFIG_SYSFS_DEPRECATED
582static struct kobject *get_device_parent(struct device *dev,
583 struct device *parent)
584{
585 /* class devices without a parent live in /sys/class/<classname>/ */
586 if (dev->class && (!parent || parent->class != dev->class))
587 return &dev->class->p->class_subsys.kobj;
588 /* all other devices keep their parent */
589 else if (parent)
590 return &parent->kobj;
591
592 return NULL;
593}
594
595static inline void cleanup_device_parent(struct device *dev) {}
596static inline void cleanup_glue_dir(struct device *dev,
597 struct kobject *glue_dir) {}
598#else
599static struct kobject *virtual_device_parent(struct device *dev) 550static struct kobject *virtual_device_parent(struct device *dev)
600{ 551{
601 static struct kobject *virtual_dir = NULL; 552 static struct kobject *virtual_dir = NULL;
@@ -666,6 +617,14 @@ static struct kobject *get_device_parent(struct device *dev,
666 struct kobject *parent_kobj; 617 struct kobject *parent_kobj;
667 struct kobject *k; 618 struct kobject *k;
668 619
620#ifdef CONFIG_SYSFS_DEPRECATED
621 /* block disks show up in /sys/block */
622 if (dev->class == &block_class) {
623 if (parent && parent->class == &block_class)
624 return &parent->kobj;
625 return &block_class.p->class_subsys.kobj;
626 }
627#endif
669 /* 628 /*
670 * If we have no parent, we live in "virtual". 629 * If we have no parent, we live in "virtual".
671 * Class-devices with a non class-device as parent, live 630 * Class-devices with a non class-device as parent, live
@@ -719,7 +678,6 @@ static void cleanup_device_parent(struct device *dev)
719{ 678{
720 cleanup_glue_dir(dev, dev->kobj.parent); 679 cleanup_glue_dir(dev, dev->kobj.parent);
721} 680}
722#endif
723 681
724static void setup_parent(struct device *dev, struct device *parent) 682static void setup_parent(struct device *dev, struct device *parent)
725{ 683{
@@ -742,70 +700,29 @@ static int device_add_class_symlinks(struct device *dev)
742 if (error) 700 if (error)
743 goto out; 701 goto out;
744 702
745#ifdef CONFIG_SYSFS_DEPRECATED
746 /* stacked class devices need a symlink in the class directory */
747 if (dev->kobj.parent != &dev->class->p->class_subsys.kobj &&
748 device_is_not_partition(dev)) {
749 error = sysfs_create_link(&dev->class->p->class_subsys.kobj,
750 &dev->kobj, dev_name(dev));
751 if (error)
752 goto out_subsys;
753 }
754
755 if (dev->parent && device_is_not_partition(dev)) { 703 if (dev->parent && device_is_not_partition(dev)) {
756 struct device *parent = dev->parent; 704 error = sysfs_create_link(&dev->kobj, &dev->parent->kobj,
757 char *class_name;
758
759 /*
760 * stacked class devices have the 'device' link
761 * pointing to the bus device instead of the parent
762 */
763 while (parent->class && !parent->bus && parent->parent)
764 parent = parent->parent;
765
766 error = sysfs_create_link(&dev->kobj,
767 &parent->kobj,
768 "device"); 705 "device");
769 if (error) 706 if (error)
770 goto out_busid; 707 goto out_subsys;
771
772 class_name = make_class_name(dev->class->name,
773 &dev->kobj);
774 if (class_name)
775 error = sysfs_create_link(&dev->parent->kobj,
776 &dev->kobj, class_name);
777 kfree(class_name);
778 if (error)
779 goto out_device;
780 } 708 }
781 return 0;
782 709
783out_device: 710#ifdef CONFIG_SYSFS_DEPRECATED
784 if (dev->parent && device_is_not_partition(dev)) 711 /* /sys/block has directories and does not need symlinks */
785 sysfs_remove_link(&dev->kobj, "device"); 712 if (dev->class == &block_class)
786out_busid: 713 return 0;
787 if (dev->kobj.parent != &dev->class->p->class_subsys.kobj && 714#endif
788 device_is_not_partition(dev)) 715
789 sysfs_delete_link(&dev->class->p->class_subsys.kobj, &dev->kobj,
790 dev_name(dev));
791#else
792 /* link in the class directory pointing to the device */ 716 /* link in the class directory pointing to the device */
793 error = sysfs_create_link(&dev->class->p->class_subsys.kobj, 717 error = sysfs_create_link(&dev->class->p->class_subsys.kobj,
794 &dev->kobj, dev_name(dev)); 718 &dev->kobj, dev_name(dev));
795 if (error) 719 if (error)
796 goto out_subsys; 720 goto out_device;
797 721
798 if (dev->parent && device_is_not_partition(dev)) {
799 error = sysfs_create_link(&dev->kobj, &dev->parent->kobj,
800 "device");
801 if (error)
802 goto out_busid;
803 }
804 return 0; 722 return 0;
805 723
806out_busid: 724out_device:
807 sysfs_delete_link(&dev->class->p->class_subsys.kobj, &dev->kobj, dev_name(dev)); 725 sysfs_remove_link(&dev->kobj, "device");
808#endif
809 726
810out_subsys: 727out_subsys:
811 sysfs_remove_link(&dev->kobj, "subsystem"); 728 sysfs_remove_link(&dev->kobj, "subsystem");
@@ -818,30 +735,14 @@ static void device_remove_class_symlinks(struct device *dev)
818 if (!dev->class) 735 if (!dev->class)
819 return; 736 return;
820 737
821#ifdef CONFIG_SYSFS_DEPRECATED
822 if (dev->parent && device_is_not_partition(dev)) {
823 char *class_name;
824
825 class_name = make_class_name(dev->class->name, &dev->kobj);
826 if (class_name) {
827 sysfs_remove_link(&dev->parent->kobj, class_name);
828 kfree(class_name);
829 }
830 sysfs_remove_link(&dev->kobj, "device");
831 }
832
833 if (dev->kobj.parent != &dev->class->p->class_subsys.kobj &&
834 device_is_not_partition(dev))
835 sysfs_delete_link(&dev->class->p->class_subsys.kobj, &dev->kobj,
836 dev_name(dev));
837#else
838 if (dev->parent && device_is_not_partition(dev)) 738 if (dev->parent && device_is_not_partition(dev))
839 sysfs_remove_link(&dev->kobj, "device"); 739 sysfs_remove_link(&dev->kobj, "device");
840
841 sysfs_delete_link(&dev->class->p->class_subsys.kobj, &dev->kobj, dev_name(dev));
842#endif
843
844 sysfs_remove_link(&dev->kobj, "subsystem"); 740 sysfs_remove_link(&dev->kobj, "subsystem");
741#ifdef CONFIG_SYSFS_DEPRECATED
742 if (dev->class == &block_class)
743 return;
744#endif
745 sysfs_delete_link(&dev->class->p->class_subsys.kobj, &dev->kobj, dev_name(dev));
845} 746}
846 747
847/** 748/**
@@ -1613,41 +1514,23 @@ int device_rename(struct device *dev, const char *new_name)
1613 pr_debug("device: '%s': %s: renaming to '%s'\n", dev_name(dev), 1514 pr_debug("device: '%s': %s: renaming to '%s'\n", dev_name(dev),
1614 __func__, new_name); 1515 __func__, new_name);
1615 1516
1616#ifdef CONFIG_SYSFS_DEPRECATED
1617 if ((dev->class) && (dev->parent))
1618 old_class_name = make_class_name(dev->class->name, &dev->kobj);
1619#endif
1620
1621 old_device_name = kstrdup(dev_name(dev), GFP_KERNEL); 1517 old_device_name = kstrdup(dev_name(dev), GFP_KERNEL);
1622 if (!old_device_name) { 1518 if (!old_device_name) {
1623 error = -ENOMEM; 1519 error = -ENOMEM;
1624 goto out; 1520 goto out;
1625 } 1521 }
1626 1522
1627#ifndef CONFIG_SYSFS_DEPRECATED
1628 if (dev->class) { 1523 if (dev->class) {
1629 error = sysfs_rename_link(&dev->class->p->class_subsys.kobj, 1524 error = sysfs_rename_link(&dev->class->p->class_subsys.kobj,
1630 &dev->kobj, old_device_name, new_name); 1525 &dev->kobj, old_device_name, new_name);
1631 if (error) 1526 if (error)
1632 goto out; 1527 goto out;
1633 } 1528 }
1634#endif 1529
1635 error = kobject_rename(&dev->kobj, new_name); 1530 error = kobject_rename(&dev->kobj, new_name);
1636 if (error) 1531 if (error)
1637 goto out; 1532 goto out;
1638 1533
1639#ifdef CONFIG_SYSFS_DEPRECATED
1640 if (old_class_name) {
1641 new_class_name = make_class_name(dev->class->name, &dev->kobj);
1642 if (new_class_name) {
1643 error = sysfs_rename_link(&dev->parent->kobj,
1644 &dev->kobj,
1645 old_class_name,
1646 new_class_name);
1647 }
1648 }
1649#endif
1650
1651out: 1534out:
1652 put_device(dev); 1535 put_device(dev);
1653 1536
@@ -1664,40 +1547,13 @@ static int device_move_class_links(struct device *dev,
1664 struct device *new_parent) 1547 struct device *new_parent)
1665{ 1548{
1666 int error = 0; 1549 int error = 0;
1667#ifdef CONFIG_SYSFS_DEPRECATED
1668 char *class_name;
1669 1550
1670 class_name = make_class_name(dev->class->name, &dev->kobj);
1671 if (!class_name) {
1672 error = -ENOMEM;
1673 goto out;
1674 }
1675 if (old_parent) {
1676 sysfs_remove_link(&dev->kobj, "device");
1677 sysfs_remove_link(&old_parent->kobj, class_name);
1678 }
1679 if (new_parent) {
1680 error = sysfs_create_link(&dev->kobj, &new_parent->kobj,
1681 "device");
1682 if (error)
1683 goto out;
1684 error = sysfs_create_link(&new_parent->kobj, &dev->kobj,
1685 class_name);
1686 if (error)
1687 sysfs_remove_link(&dev->kobj, "device");
1688 } else
1689 error = 0;
1690out:
1691 kfree(class_name);
1692 return error;
1693#else
1694 if (old_parent) 1551 if (old_parent)
1695 sysfs_remove_link(&dev->kobj, "device"); 1552 sysfs_remove_link(&dev->kobj, "device");
1696 if (new_parent) 1553 if (new_parent)
1697 error = sysfs_create_link(&dev->kobj, &new_parent->kobj, 1554 error = sysfs_create_link(&dev->kobj, &new_parent->kobj,
1698 "device"); 1555 "device");
1699 return error; 1556 return error;
1700#endif
1701} 1557}
1702 1558
1703/** 1559/**