diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2010-09-05 01:33:14 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-10-22 13:16:43 -0400 |
commit | 39aba963d937edb20db7d9d93e6dda5d2adfdcdd (patch) | |
tree | 7aa1898634ed6f6ece3e48f4b5464fcbcb4f49a5 /drivers/base | |
parent | 807508c8ff9af6ce8f25c5ca5f3eb06a8e7d3286 (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')
-rw-r--r-- | drivers/base/bus.c | 22 | ||||
-rw-r--r-- | drivers/base/class.c | 19 | ||||
-rw-r--r-- | drivers/base/core.c | 194 |
3 files changed, 25 insertions, 210 deletions
diff --git a/drivers/base/bus.c b/drivers/base/bus.c index eb1b7fa20dce..33c270a64db7 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c | |||
@@ -440,22 +440,6 @@ static void device_remove_attrs(struct bus_type *bus, struct device *dev) | |||
440 | } | 440 | } |
441 | } | 441 | } |
442 | 442 | ||
443 | #ifdef CONFIG_SYSFS_DEPRECATED | ||
444 | static int make_deprecated_bus_links(struct device *dev) | ||
445 | { | ||
446 | return sysfs_create_link(&dev->kobj, | ||
447 | &dev->bus->p->subsys.kobj, "bus"); | ||
448 | } | ||
449 | |||
450 | static void remove_deprecated_bus_links(struct device *dev) | ||
451 | { | ||
452 | sysfs_remove_link(&dev->kobj, "bus"); | ||
453 | } | ||
454 | #else | ||
455 | static inline int make_deprecated_bus_links(struct device *dev) { return 0; } | ||
456 | static inline void remove_deprecated_bus_links(struct device *dev) { } | ||
457 | #endif | ||
458 | |||
459 | /** | 443 | /** |
460 | * bus_add_device - add device to bus | 444 | * bus_add_device - add device to bus |
461 | * @dev: device being added | 445 | * @dev: device being added |
@@ -482,15 +466,10 @@ int bus_add_device(struct device *dev) | |||
482 | &dev->bus->p->subsys.kobj, "subsystem"); | 466 | &dev->bus->p->subsys.kobj, "subsystem"); |
483 | if (error) | 467 | if (error) |
484 | goto out_subsys; | 468 | goto out_subsys; |
485 | error = make_deprecated_bus_links(dev); | ||
486 | if (error) | ||
487 | goto out_deprecated; | ||
488 | klist_add_tail(&dev->p->knode_bus, &bus->p->klist_devices); | 469 | klist_add_tail(&dev->p->knode_bus, &bus->p->klist_devices); |
489 | } | 470 | } |
490 | return 0; | 471 | return 0; |
491 | 472 | ||
492 | out_deprecated: | ||
493 | sysfs_remove_link(&dev->kobj, "subsystem"); | ||
494 | out_subsys: | 473 | out_subsys: |
495 | sysfs_remove_link(&bus->p->devices_kset->kobj, dev_name(dev)); | 474 | sysfs_remove_link(&bus->p->devices_kset->kobj, dev_name(dev)); |
496 | out_id: | 475 | out_id: |
@@ -530,7 +509,6 @@ void bus_remove_device(struct device *dev) | |||
530 | { | 509 | { |
531 | if (dev->bus) { | 510 | if (dev->bus) { |
532 | sysfs_remove_link(&dev->kobj, "subsystem"); | 511 | sysfs_remove_link(&dev->kobj, "subsystem"); |
533 | remove_deprecated_bus_links(dev); | ||
534 | sysfs_remove_link(&dev->bus->p->devices_kset->kobj, | 512 | sysfs_remove_link(&dev->bus->p->devices_kset->kobj, |
535 | dev_name(dev)); | 513 | dev_name(dev)); |
536 | device_remove_attrs(dev->bus, dev); | 514 | device_remove_attrs(dev->bus, dev); |
diff --git a/drivers/base/class.c b/drivers/base/class.c index 8e231d05b400..1078969889fd 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c | |||
@@ -276,25 +276,6 @@ void class_destroy(struct class *cls) | |||
276 | class_unregister(cls); | 276 | class_unregister(cls); |
277 | } | 277 | } |
278 | 278 | ||
279 | #ifdef CONFIG_SYSFS_DEPRECATED | ||
280 | char *make_class_name(const char *name, struct kobject *kobj) | ||
281 | { | ||
282 | char *class_name; | ||
283 | int size; | ||
284 | |||
285 | size = strlen(name) + strlen(kobject_name(kobj)) + 2; | ||
286 | |||
287 | class_name = kmalloc(size, GFP_KERNEL); | ||
288 | if (!class_name) | ||
289 | return NULL; | ||
290 | |||
291 | strcpy(class_name, name); | ||
292 | strcat(class_name, ":"); | ||
293 | strcat(class_name, kobject_name(kobj)); | ||
294 | return class_name; | ||
295 | } | ||
296 | #endif | ||
297 | |||
298 | /** | 279 | /** |
299 | * class_dev_iter_init - initialize class device iterator | 280 | * class_dev_iter_init - initialize class device iterator |
300 | * @iter: class iterator to initialize | 281 | * @iter: class iterator to initialize |
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 | ||
582 | static 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 | |||
595 | static inline void cleanup_device_parent(struct device *dev) {} | ||
596 | static inline void cleanup_glue_dir(struct device *dev, | ||
597 | struct kobject *glue_dir) {} | ||
598 | #else | ||
599 | static struct kobject *virtual_device_parent(struct device *dev) | 550 | static 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 | ||
724 | static void setup_parent(struct device *dev, struct device *parent) | 682 | static 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 | ||
783 | out_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) |
786 | out_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 | ||
806 | out_busid: | 724 | out_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 | ||
810 | out_subsys: | 727 | out_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 | |||
1651 | out: | 1534 | out: |
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; | ||
1690 | out: | ||
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 | /** |