busybox/util-linux
Denys Vlasenko 20a3262cd7 mdev: create devices from /sys/dev
Currently some new devices that have a bus but no class will
be missed by mdev coldplug device creation after boot. This
happens because mdev recursively searches /sys/class which will
by definition only find class devices.

Some important devices such as iio and gpiochip does not have
a class. But users will need them.

This switches from using /sys/class as the place to look for
devices to create to using /sys/dev where all char and block
devices are listed.

The subsystem lookup code that provide the G.subsystem
environment variable is changed from using the directory
name of the class device to instead dereference the
"subsystem" symlink for the device, and look at the last
element of the path of the symlink for the subsystem, which
will work with class devices and bus devices alike. (The new
bus-only devices only symlink to the /sys/bus/* hierarchy.)

We delete the legacy kernel v2.6.2x /sys/block device path
code as part of this change. It's too old to be kept alive.

Tested on kernel v4.6-rc2 with a bunch of devices, including
some IIO and gpiochip devices.

With a print inserted before make_device() the log looks
like so:

Create device from "/sys/dev/char/1:1", subsystem "mem"
Create device from "/sys/dev/char/1:2", subsystem "mem"
Create device from "/sys/dev/char/1:3", subsystem "mem"
Create device from "/sys/dev/char/1:5", subsystem "mem"
(...)
Create device from "/sys/dev/block/179:56", subsystem "block"
Create device from "/sys/dev/block/179:64", subsystem "block"

function                                             old     new   delta
mdev_main                                           1388    1346     -42
dirAction                                            134      14    -120
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-162)           Total: -162 bytes

Cc: Isaac Dunham <ibid.ag@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-07 14:09:01 +02:00
..
2016-01-02 01:18:32 +01:00
2016-06-19 18:15:33 +02:00
2015-10-07 22:42:45 +02:00
2015-10-07 22:42:45 +02:00
2016-06-19 18:15:33 +02:00
2016-06-19 18:15:33 +02:00
2013-02-11 00:22:59 +01:00
2016-08-23 17:18:45 +02:00
2015-10-07 22:42:45 +02:00
2015-02-04 15:19:38 +01:00
2015-03-12 20:18:51 +01:00
2015-10-07 22:42:45 +02:00
2013-06-27 03:45:16 +02:00
2013-01-14 01:34:48 +01:00
2016-09-07 14:09:01 +02:00
2016-03-14 19:34:15 +01:00
2015-02-18 13:47:46 +01:00
2011-12-15 12:39:25 +01:00
2015-10-13 12:34:35 +02:00