Skip to content

Commit 39aba96

Browse files
kaysieversgregkh
authored andcommitted
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 <[email protected]> Cc: Jens Axboe <[email protected]> Cc: Stephen Hemminger <[email protected]> Cc: "Eric W. Biederman" <[email protected]> Cc: Alan Stern <[email protected]> Cc: "James E.J. Bottomley" <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Alexey Kuznetsov <[email protected]> Cc: Randy Dunlap <[email protected]> Cc: Tejun Heo <[email protected]> Cc: "David S. Miller" <[email protected]> Cc: Jaroslav Kysela <[email protected]> Cc: Takashi Iwai <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: David Howells <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 807508c commit 39aba96

File tree

8 files changed

+43
-259
lines changed

8 files changed

+43
-259
lines changed

drivers/base/bus.c

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -440,22 +440,6 @@ static void device_remove_attrs(struct bus_type *bus, struct device *dev)
440440
}
441441
}
442442

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-
459443
/**
460444
* bus_add_device - add device to bus
461445
* @dev: device being added
@@ -482,15 +466,10 @@ int bus_add_device(struct device *dev)
482466
&dev->bus->p->subsys.kobj, "subsystem");
483467
if (error)
484468
goto out_subsys;
485-
error = make_deprecated_bus_links(dev);
486-
if (error)
487-
goto out_deprecated;
488469
klist_add_tail(&dev->p->knode_bus, &bus->p->klist_devices);
489470
}
490471
return 0;
491472

492-
out_deprecated:
493-
sysfs_remove_link(&dev->kobj, "subsystem");
494473
out_subsys:
495474
sysfs_remove_link(&bus->p->devices_kset->kobj, dev_name(dev));
496475
out_id:
@@ -530,7 +509,6 @@ void bus_remove_device(struct device *dev)
530509
{
531510
if (dev->bus) {
532511
sysfs_remove_link(&dev->kobj, "subsystem");
533-
remove_deprecated_bus_links(dev);
534512
sysfs_remove_link(&dev->bus->p->devices_kset->kobj,
535513
dev_name(dev));
536514
device_remove_attrs(dev->bus, dev);

drivers/base/class.c

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -276,25 +276,6 @@ void class_destroy(struct class *cls)
276276
class_unregister(cls);
277277
}
278278

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-
298279
/**
299280
* class_dev_iter_init - initialize class device iterator
300281
* @iter: class iterator to initialize

drivers/base/core.c

Lines changed: 25 additions & 169 deletions
Original file line numberDiff line numberDiff line change
@@ -203,37 +203,6 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj,
203203
if (dev->driver)
204204
add_uevent_var(env, "DRIVER=%s", dev->driver->name);
205205

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-
237206
/* have the bus specific function add its stuff */
238207
if (dev->bus && dev->bus->uevent) {
239208
retval = dev->bus->uevent(dev, env);
@@ -578,24 +547,6 @@ void device_initialize(struct device *dev)
578547
set_dev_node(dev, -1);
579548
}
580549

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
599550
static struct kobject *virtual_device_parent(struct device *dev)
600551
{
601552
static struct kobject *virtual_dir = NULL;
@@ -666,6 +617,14 @@ static struct kobject *get_device_parent(struct device *dev,
666617
struct kobject *parent_kobj;
667618
struct kobject *k;
668619

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
669628
/*
670629
* If we have no parent, we live in "virtual".
671630
* Class-devices with a non class-device as parent, live
@@ -719,7 +678,6 @@ static void cleanup_device_parent(struct device *dev)
719678
{
720679
cleanup_glue_dir(dev, dev->kobj.parent);
721680
}
722-
#endif
723681

724682
static void setup_parent(struct device *dev, struct device *parent)
725683
{
@@ -742,70 +700,29 @@ static int device_add_class_symlinks(struct device *dev)
742700
if (error)
743701
goto out;
744702

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-
755703
if (dev->parent && device_is_not_partition(dev)) {
756-
struct device *parent = dev->parent;
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,
704+
error = sysfs_create_link(&dev->kobj, &dev->parent->kobj,
768705
"device");
769706
if (error)
770-
goto out_busid;
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;
707+
goto out_subsys;
780708
}
781-
return 0;
782709

783-
out_device:
784-
if (dev->parent && device_is_not_partition(dev))
785-
sysfs_remove_link(&dev->kobj, "device");
786-
out_busid:
787-
if (dev->kobj.parent != &dev->class->p->class_subsys.kobj &&
788-
device_is_not_partition(dev))
789-
sysfs_delete_link(&dev->class->p->class_subsys.kobj, &dev->kobj,
790-
dev_name(dev));
791-
#else
710+
#ifdef CONFIG_SYSFS_DEPRECATED
711+
/* /sys/block has directories and does not need symlinks */
712+
if (dev->class == &block_class)
713+
return 0;
714+
#endif
715+
792716
/* link in the class directory pointing to the device */
793717
error = sysfs_create_link(&dev->class->p->class_subsys.kobj,
794718
&dev->kobj, dev_name(dev));
795719
if (error)
796-
goto out_subsys;
720+
goto out_device;
797721

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-
}
804722
return 0;
805723

806-
out_busid:
807-
sysfs_delete_link(&dev->class->p->class_subsys.kobj, &dev->kobj, dev_name(dev));
808-
#endif
724+
out_device:
725+
sysfs_remove_link(&dev->kobj, "device");
809726

810727
out_subsys:
811728
sysfs_remove_link(&dev->kobj, "subsystem");
@@ -818,30 +735,14 @@ static void device_remove_class_symlinks(struct device *dev)
818735
if (!dev->class)
819736
return;
820737

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
838738
if (dev->parent && device_is_not_partition(dev))
839739
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-
844740
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));
845746
}
846747

847748
/**
@@ -1613,41 +1514,23 @@ int device_rename(struct device *dev, const char *new_name)
16131514
pr_debug("device: '%s': %s: renaming to '%s'\n", dev_name(dev),
16141515
__func__, new_name);
16151516

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-
16211517
old_device_name = kstrdup(dev_name(dev), GFP_KERNEL);
16221518
if (!old_device_name) {
16231519
error = -ENOMEM;
16241520
goto out;
16251521
}
16261522

1627-
#ifndef CONFIG_SYSFS_DEPRECATED
16281523
if (dev->class) {
16291524
error = sysfs_rename_link(&dev->class->p->class_subsys.kobj,
16301525
&dev->kobj, old_device_name, new_name);
16311526
if (error)
16321527
goto out;
16331528
}
1634-
#endif
1529+
16351530
error = kobject_rename(&dev->kobj, new_name);
16361531
if (error)
16371532
goto out;
16381533

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-
16511534
out:
16521535
put_device(dev);
16531536

@@ -1664,40 +1547,13 @@ static int device_move_class_links(struct device *dev,
16641547
struct device *new_parent)
16651548
{
16661549
int error = 0;
1667-
#ifdef CONFIG_SYSFS_DEPRECATED
1668-
char *class_name;
16691550

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
16941551
if (old_parent)
16951552
sysfs_remove_link(&dev->kobj, "device");
16961553
if (new_parent)
16971554
error = sysfs_create_link(&dev->kobj, &new_parent->kobj,
16981555
"device");
16991556
return error;
1700-
#endif
17011557
}
17021558

17031559
/**

drivers/scsi/hosts.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,9 +411,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
411411

412412
device_initialize(&shost->shost_gendev);
413413
dev_set_name(&shost->shost_gendev, "host%d", shost->host_no);
414-
#ifndef CONFIG_SYSFS_DEPRECATED
415414
shost->shost_gendev.bus = &scsi_bus_type;
416-
#endif
417415
shost->shost_gendev.type = &scsi_host_type;
418416

419417
device_initialize(&shost->shost_dev);

drivers/scsi/scsi_scan.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,9 +417,7 @@ static struct scsi_target *scsi_alloc_target(struct device *parent,
417417
starget->reap_ref = 1;
418418
dev->parent = get_device(parent);
419419
dev_set_name(dev, "target%d:%d:%d", shost->host_no, channel, id);
420-
#ifndef CONFIG_SYSFS_DEPRECATED
421420
dev->bus = &scsi_bus_type;
422-
#endif
423421
dev->type = &scsi_target_type;
424422
starget->id = id;
425423
starget->channel = channel;

0 commit comments

Comments
 (0)