[PATCH] Add subsystem support to mdev (firmware loading)
Michael-Luke Jones
jonesml at fastmail.to
Fri Sep 29 10:31:59 UTC 2006
Hi there,
I'm enclosing a patch that allows mdev to call external scripts to
deal with 'subsystem' hotplug requests. I also enclose a script to
handle firmware loading (via firmware_class) which has been tested
with the 2.6.18 kernel on an NSLU2.
--- busybox-1.2.1.orig/util-linux/mdev.c 2006-07-01
00:42:13.000000000 +0200
+++ busybox-1.2.1/util-linux/mdev.c 2006-09-26 17:42:38.414162744 +0200
@@ -255,7 +255,16 @@
bb_show_usage();
sprintf(temp, "/sys%s", env_path);
- if (!strcmp(action, "add")) make_device(temp,0);
+ if (!strcmp(action, "add")) {
+ struct stat st;
+ make_device(temp,0);
+ sprintf(temp, "/lib/mdev/%s", getenv("SUBSYSTEM"));
+ if (stat(temp, &st) == 0) {
+ if ((st.st_mode & S_IXUSR) && S_ISREG(st.st_mode)) {
+ system(temp);
+ }
+ }
+ }
else if (!strcmp(action, "remove")) make_device(temp,1);
}
--Script should be dropped into /lib/mdev/firmware--
#!/bin/sh
firmwaredir=/lib/firmware
if test "$SUBSYSTEM" = "firmware" -a "$ACTION" = "add"; then
if test -f $firmwaredir/$FIRMWARE; then
echo 1 > /sys/$DEVPATH/loading
cat $firmwaredir/$FIRMWARE > /sys/$DEVPATH/data
echo 0 > /sys/$DEVPATH/loading
else
echo -1 > /sys/$DEVPATH/loading
fi
fi
Firmware loading is vital for certain embedded systems such as all
IXP4xx boards when the GPL Ethernet driver is used. I hope that this
patch or a variation can be included in BusyBox 1.3.0. Christian
Hohnstaedt is the author of this patch and he is CCed on this email.
I've got his permission to send them to you.
Michael-Luke Jones
More information about the busybox
mailing list