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. We keep /sys/class as a fallback if /sys/dev
is nonexisting.

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

Cc: Isaac Dunham <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Jonathan Cameron <[email protected]>
Signed-off-by: Linus Walleij <[email protected]>
---
If you prefer that I delete the code searching for devices in
/sys/class with sys/block as fallback, I will happily do so.
---
 util-linux/mdev.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/util-linux/mdev.c b/util-linux/mdev.c
index 37fa56827520..f833d9730ea5 100644
--- a/util-linux/mdev.c
+++ b/util-linux/mdev.c
@@ -1079,9 +1079,16 @@ int mdev_main(int argc UNUSED_PARAM, char **argv)
                                ACTION_RECURSE | ACTION_FOLLOWLINKS | 
ACTION_QUIET,
                                fileAction, dirAction, temp, 0);
                }
-               recursive_action("/sys/class",
-                       ACTION_RECURSE | ACTION_FOLLOWLINKS,
-                       fileAction, dirAction, temp, 0);
+               /* If /sys/dev does not exist, use /sys/class */
+               if (access("/sys/dev", F_OK) != 0) {
+                       recursive_action("/sys/class",
+                                        ACTION_RECURSE | ACTION_FOLLOWLINKS,
+                                        fileAction, dirAction, temp, 0);
+               }
+               /* By default create all devices from /sys/dev hierarchy */
+               recursive_action("/sys/dev",
+                                ACTION_RECURSE | ACTION_FOLLOWLINKS,
+                                fileAction, dirAction, temp, 0);
        } else {
                char *fw;
                char *seq;
-- 
2.4.3

_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to