Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>


authored by

Kay Sievers and committed by
Greg Kroah-Hartman
39aba963 807508c8

+44 -260
-22
drivers/base/bus.c
··· 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 444 * bus_add_device - add device to bus 461 445 * @dev: device being added ··· 466 482 &dev->bus->p->subsys.kobj, "subsystem"); 467 483 if (error) 468 484 goto out_subsys; 469 - error = make_deprecated_bus_links(dev); 470 - if (error) 471 - goto out_deprecated; 472 485 klist_add_tail(&dev->p->knode_bus, &bus->p->klist_devices); 473 486 } 474 487 return 0; 475 488 476 - out_deprecated: 477 - sysfs_remove_link(&dev->kobj, "subsystem"); 478 489 out_subsys: 479 490 sysfs_remove_link(&bus->p->devices_kset->kobj, dev_name(dev)); 480 491 out_id: ··· 509 530 { 510 531 if (dev->bus) { 511 532 sysfs_remove_link(&dev->kobj, "subsystem"); 512 - remove_deprecated_bus_links(dev); 513 533 sysfs_remove_link(&dev->bus->p->devices_kset->kobj, 514 534 dev_name(dev)); 515 535 device_remove_attrs(dev->bus, dev);
-19
drivers/base/class.c
··· 276 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 280 * class_dev_iter_init - initialize class device iterator 300 281 * @iter: class iterator to initialize
+30 -174
drivers/base/core.c
··· 203 203 if (dev->driver) 204 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 206 /* have the bus specific function add its stuff */ 238 207 if (dev->bus && dev->bus->uevent) { 239 208 retval = dev->bus->uevent(dev, env); ··· 547 578 set_dev_node(dev, -1); 548 579 } 549 580 550 - #ifdef CONFIG_SYSFS_DEPRECATED 551 - static struct kobject *get_device_parent(struct device *dev, 552 - struct device *parent) 553 - { 554 - /* class devices without a parent live in /sys/class/<classname>/ */ 555 - if (dev->class && (!parent || parent->class != dev->class)) 556 - return &dev->class->p->class_subsys.kobj; 557 - /* all other devices keep their parent */ 558 - else if (parent) 559 - return &parent->kobj; 560 - 561 - return NULL; 562 - } 563 - 564 - static inline void cleanup_device_parent(struct device *dev) {} 565 - static inline void cleanup_glue_dir(struct device *dev, 566 - struct kobject *glue_dir) {} 567 - #else 568 581 static struct kobject *virtual_device_parent(struct device *dev) 569 582 { 570 583 static struct kobject *virtual_dir = NULL; ··· 617 666 struct kobject *parent_kobj; 618 667 struct kobject *k; 619 668 669 + #ifdef CONFIG_SYSFS_DEPRECATED 670 + /* block disks show up in /sys/block */ 671 + if (dev->class == &block_class) { 672 + if (parent && parent->class == &block_class) 673 + return &parent->kobj; 674 + return &block_class.p->class_subsys.kobj; 675 + } 676 + #endif 620 677 /* 621 678 * If we have no parent, we live in "virtual". 622 679 * Class-devices with a non class-device as parent, live ··· 678 719 { 679 720 cleanup_glue_dir(dev, dev->kobj.parent); 680 721 } 681 - #endif 682 722 683 723 static void setup_parent(struct device *dev, struct device *parent) 684 724 { ··· 700 742 if (error) 701 743 goto out; 702 744 703 - #ifdef CONFIG_SYSFS_DEPRECATED 704 - /* stacked class devices need a symlink in the class directory */ 705 - if (dev->kobj.parent != &dev->class->p->class_subsys.kobj && 706 - device_is_not_partition(dev)) { 707 - error = sysfs_create_link(&dev->class->p->class_subsys.kobj, 708 - &dev->kobj, dev_name(dev)); 709 - if (error) 710 - goto out_subsys; 711 - } 712 - 713 - if (dev->parent && device_is_not_partition(dev)) { 714 - struct device *parent = dev->parent; 715 - char *class_name; 716 - 717 - /* 718 - * stacked class devices have the 'device' link 719 - * pointing to the bus device instead of the parent 720 - */ 721 - while (parent->class && !parent->bus && parent->parent) 722 - parent = parent->parent; 723 - 724 - error = sysfs_create_link(&dev->kobj, 725 - &parent->kobj, 726 - "device"); 727 - if (error) 728 - goto out_busid; 729 - 730 - class_name = make_class_name(dev->class->name, 731 - &dev->kobj); 732 - if (class_name) 733 - error = sysfs_create_link(&dev->parent->kobj, 734 - &dev->kobj, class_name); 735 - kfree(class_name); 736 - if (error) 737 - goto out_device; 738 - } 739 - return 0; 740 - 741 - out_device: 742 - if (dev->parent && device_is_not_partition(dev)) 743 - sysfs_remove_link(&dev->kobj, "device"); 744 - out_busid: 745 - if (dev->kobj.parent != &dev->class->p->class_subsys.kobj && 746 - device_is_not_partition(dev)) 747 - sysfs_delete_link(&dev->class->p->class_subsys.kobj, &dev->kobj, 748 - dev_name(dev)); 749 - #else 750 - /* link in the class directory pointing to the device */ 751 - error = sysfs_create_link(&dev->class->p->class_subsys.kobj, 752 - &dev->kobj, dev_name(dev)); 753 - if (error) 754 - goto out_subsys; 755 - 756 745 if (dev->parent && device_is_not_partition(dev)) { 757 746 error = sysfs_create_link(&dev->kobj, &dev->parent->kobj, 758 747 "device"); 759 748 if (error) 760 - goto out_busid; 749 + goto out_subsys; 761 750 } 751 + 752 + #ifdef CONFIG_SYSFS_DEPRECATED 753 + /* /sys/block has directories and does not need symlinks */ 754 + if (dev->class == &block_class) 755 + return 0; 756 + #endif 757 + 758 + /* link in the class directory pointing to the device */ 759 + error = sysfs_create_link(&dev->class->p->class_subsys.kobj, 760 + &dev->kobj, dev_name(dev)); 761 + if (error) 762 + goto out_device; 763 + 762 764 return 0; 763 765 764 - out_busid: 765 - sysfs_delete_link(&dev->class->p->class_subsys.kobj, &dev->kobj, dev_name(dev)); 766 - #endif 766 + out_device: 767 + sysfs_remove_link(&dev->kobj, "device"); 767 768 768 769 out_subsys: 769 770 sysfs_remove_link(&dev->kobj, "subsystem"); ··· 735 818 if (!dev->class) 736 819 return; 737 820 738 - #ifdef CONFIG_SYSFS_DEPRECATED 739 - if (dev->parent && device_is_not_partition(dev)) { 740 - char *class_name; 741 - 742 - class_name = make_class_name(dev->class->name, &dev->kobj); 743 - if (class_name) { 744 - sysfs_remove_link(&dev->parent->kobj, class_name); 745 - kfree(class_name); 746 - } 747 - sysfs_remove_link(&dev->kobj, "device"); 748 - } 749 - 750 - if (dev->kobj.parent != &dev->class->p->class_subsys.kobj && 751 - device_is_not_partition(dev)) 752 - sysfs_delete_link(&dev->class->p->class_subsys.kobj, &dev->kobj, 753 - dev_name(dev)); 754 - #else 755 821 if (dev->parent && device_is_not_partition(dev)) 756 822 sysfs_remove_link(&dev->kobj, "device"); 757 - 758 - sysfs_delete_link(&dev->class->p->class_subsys.kobj, &dev->kobj, dev_name(dev)); 759 - #endif 760 - 761 823 sysfs_remove_link(&dev->kobj, "subsystem"); 824 + #ifdef CONFIG_SYSFS_DEPRECATED 825 + if (dev->class == &block_class) 826 + return; 827 + #endif 828 + sysfs_delete_link(&dev->class->p->class_subsys.kobj, &dev->kobj, dev_name(dev)); 762 829 } 763 830 764 831 /** ··· 1514 1613 pr_debug("device: '%s': %s: renaming to '%s'\n", dev_name(dev), 1515 1614 __func__, new_name); 1516 1615 1517 - #ifdef CONFIG_SYSFS_DEPRECATED 1518 - if ((dev->class) && (dev->parent)) 1519 - old_class_name = make_class_name(dev->class->name, &dev->kobj); 1520 - #endif 1521 - 1522 1616 old_device_name = kstrdup(dev_name(dev), GFP_KERNEL); 1523 1617 if (!old_device_name) { 1524 1618 error = -ENOMEM; 1525 1619 goto out; 1526 1620 } 1527 1621 1528 - #ifndef CONFIG_SYSFS_DEPRECATED 1529 1622 if (dev->class) { 1530 1623 error = sysfs_rename_link(&dev->class->p->class_subsys.kobj, 1531 1624 &dev->kobj, old_device_name, new_name); 1532 1625 if (error) 1533 1626 goto out; 1534 1627 } 1535 - #endif 1628 + 1536 1629 error = kobject_rename(&dev->kobj, new_name); 1537 1630 if (error) 1538 1631 goto out; 1539 - 1540 - #ifdef CONFIG_SYSFS_DEPRECATED 1541 - if (old_class_name) { 1542 - new_class_name = make_class_name(dev->class->name, &dev->kobj); 1543 - if (new_class_name) { 1544 - error = sysfs_rename_link(&dev->parent->kobj, 1545 - &dev->kobj, 1546 - old_class_name, 1547 - new_class_name); 1548 - } 1549 - } 1550 - #endif 1551 1632 1552 1633 out: 1553 1634 put_device(dev); ··· 1547 1664 struct device *new_parent) 1548 1665 { 1549 1666 int error = 0; 1550 - #ifdef CONFIG_SYSFS_DEPRECATED 1551 - char *class_name; 1552 1667 1553 - class_name = make_class_name(dev->class->name, &dev->kobj); 1554 - if (!class_name) { 1555 - error = -ENOMEM; 1556 - goto out; 1557 - } 1558 - if (old_parent) { 1559 - sysfs_remove_link(&dev->kobj, "device"); 1560 - sysfs_remove_link(&old_parent->kobj, class_name); 1561 - } 1562 - if (new_parent) { 1563 - error = sysfs_create_link(&dev->kobj, &new_parent->kobj, 1564 - "device"); 1565 - if (error) 1566 - goto out; 1567 - error = sysfs_create_link(&new_parent->kobj, &dev->kobj, 1568 - class_name); 1569 - if (error) 1570 - sysfs_remove_link(&dev->kobj, "device"); 1571 - } else 1572 - error = 0; 1573 - out: 1574 - kfree(class_name); 1575 - return error; 1576 - #else 1577 1668 if (old_parent) 1578 1669 sysfs_remove_link(&dev->kobj, "device"); 1579 1670 if (new_parent) 1580 1671 error = sysfs_create_link(&dev->kobj, &new_parent->kobj, 1581 1672 "device"); 1582 1673 return error; 1583 - #endif 1584 1674 } 1585 1675 1586 1676 /**
-2
drivers/scsi/hosts.c
··· 411 411 412 412 device_initialize(&shost->shost_gendev); 413 413 dev_set_name(&shost->shost_gendev, "host%d", shost->host_no); 414 - #ifndef CONFIG_SYSFS_DEPRECATED 415 414 shost->shost_gendev.bus = &scsi_bus_type; 416 - #endif 417 415 shost->shost_gendev.type = &scsi_host_type; 418 416 419 417 device_initialize(&shost->shost_dev);
-2
drivers/scsi/scsi_scan.c
··· 417 417 starget->reap_ref = 1; 418 418 dev->parent = get_device(parent); 419 419 dev_set_name(dev, "target%d:%d:%d", shost->host_no, channel, id); 420 - #ifndef CONFIG_SYSFS_DEPRECATED 421 420 dev->bus = &scsi_bus_type; 422 - #endif 423 421 dev->type = &scsi_target_type; 424 422 starget->id = id; 425 423 starget->channel = channel;
-6
include/sound/core.h
··· 133 133 int free_on_last_close; /* free in context of file_release */ 134 134 wait_queue_head_t shutdown_sleep; 135 135 struct device *dev; /* device assigned to this card */ 136 - #ifndef CONFIG_SYSFS_DEPRECATED 137 136 struct device *card_dev; /* cardX object for sysfs */ 138 - #endif 139 137 140 138 #ifdef CONFIG_PM 141 139 unsigned int power_state; /* power state */ ··· 194 196 /* return a device pointer linked to each sound device as a parent */ 195 197 static inline struct device *snd_card_get_device_link(struct snd_card *card) 196 198 { 197 - #ifdef CONFIG_SYSFS_DEPRECATED 198 - return card ? card->dev : NULL; 199 - #else 200 199 return card ? card->card_dev : NULL; 201 - #endif 202 200 } 203 201 204 202 /* sound.c */
+11 -27
init/Kconfig
··· 656 656 bool 657 657 658 658 config SYSFS_DEPRECATED 659 - bool 660 - 661 - config SYSFS_DEPRECATED_V2 662 659 bool "enable deprecated sysfs features to support old userspace tools" 663 660 depends on SYSFS 664 661 default n 665 - select SYSFS_DEPRECATED 666 662 help 667 - This option switches the layout of sysfs to the deprecated 668 - version. Do not use it on recent distributions. 663 + This option switches the layout of the "block" class devices, to not 664 + show up in /sys/class/block/, but only in /sys/block/. 669 665 670 - The current sysfs layout features a unified device tree at 671 - /sys/devices/, which is able to express a hierarchy between 672 - class devices. If the deprecated option is set to Y, the 673 - unified device tree is split into a bus device tree at 674 - /sys/devices/ and several individual class device trees at 675 - /sys/class/. The class and bus devices will be connected by 676 - "<subsystem>:<name>" and the "device" links. The "block" 677 - class devices, will not show up in /sys/class/block/. Some 678 - subsystems will suppress the creation of some devices which 679 - depend on the unified device tree. 666 + This option allows new kernels to run on old distributions and tools, 667 + which might get confused by /sys/class/block/. Since 2007/2008 all 668 + major distributions and tools handle this just fine. 680 669 681 - This option is not a pure compatibility option that can 682 - be safely enabled on newer distributions. It will change the 683 - layout of sysfs to the non-extensible deprecated version, 684 - and disable some features, which can not be exported without 685 - confusing older userspace tools. Since 2007/2008 all major 686 - distributions do not enable this option, and ship no tools which 687 - depend on the deprecated layout or this option. 670 + Recent distributions and userspace tools after 2009/2010 depend on 671 + the existence of /sys/class/block/, and will not work with this 672 + option enabled. 688 673 689 - If you are using a new kernel on an older distribution, or use 690 - older userspace tools, you might need to say Y here. Do not say Y, 691 - if the original kernel, that came with your distribution, has 692 - this option set to N. 674 + Only if you are using a new kernel on an old distribution, you might 675 + need to say Y here. Never say Y, if the original kernel, that came 676 + with your distribution, has not set this option. 693 677 694 678 config RELAY 695 679 bool "Kernel->user space relay support (formerly relayfs)"
+3 -8
sound/core/init.c
··· 395 395 snd_printk(KERN_ERR "not all devices for card %i can be disconnected\n", card->number); 396 396 397 397 snd_info_card_disconnect(card); 398 - #ifndef CONFIG_SYSFS_DEPRECATED 399 398 if (card->card_dev) { 400 399 device_unregister(card->card_dev); 401 400 card->card_dev = NULL; 402 401 } 403 - #endif 404 402 #ifdef CONFIG_PM 405 403 wake_up(&card->power_sleep); 406 404 #endif ··· 571 573 } 572 574 EXPORT_SYMBOL(snd_card_set_id); 573 575 574 - #ifndef CONFIG_SYSFS_DEPRECATED 575 576 static ssize_t 576 577 card_id_show_attr(struct device *dev, 577 578 struct device_attribute *attr, char *buf) ··· 627 630 628 631 static struct device_attribute card_number_attrs = 629 632 __ATTR(number, S_IRUGO, card_number_show_attr, NULL); 630 - #endif /* CONFIG_SYSFS_DEPRECATED */ 631 633 632 634 /** 633 635 * snd_card_register - register the soundcard ··· 645 649 646 650 if (snd_BUG_ON(!card)) 647 651 return -EINVAL; 648 - #ifndef CONFIG_SYSFS_DEPRECATED 652 + 649 653 if (!card->card_dev) { 650 654 card->card_dev = device_create(sound_class, card->dev, 651 655 MKDEV(0, 0), card, ··· 653 657 if (IS_ERR(card->card_dev)) 654 658 card->card_dev = NULL; 655 659 } 656 - #endif 660 + 657 661 if ((err = snd_device_register_all(card)) < 0) 658 662 return err; 659 663 mutex_lock(&snd_card_mutex); ··· 670 674 if (snd_mixer_oss_notify_callback) 671 675 snd_mixer_oss_notify_callback(card, SND_MIXER_OSS_NOTIFY_REGISTER); 672 676 #endif 673 - #ifndef CONFIG_SYSFS_DEPRECATED 674 677 if (card->card_dev) { 675 678 err = device_create_file(card->card_dev, &card_id_attrs); 676 679 if (err < 0) ··· 678 683 if (err < 0) 679 684 return err; 680 685 } 681 - #endif 686 + 682 687 return 0; 683 688 } 684 689