]> git.openfabrics.org - ~emulex/for-vlad/compat.git/commitdiff
Install udev rules and scripts needed for compat_firmware_class
authorLuis R. Rodriguez <lrodriguez@atheros.com>
Wed, 20 Jan 2010 19:03:49 +0000 (11:03 -0800)
committerLuis R. Rodriguez <lrodriguez@atheros.com>
Wed, 20 Jan 2010 19:03:49 +0000 (11:03 -0800)
If you are a distribution maintainer and your distribution has
lsb_release and if you disagree with the way we handle the
uknown case just go ahead and add a case for yourself in
scripts/compat_firmware_install along with a directory and
your own files.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Makefile
scripts/compat_firmware_install [new file with mode: 0755]
udev/50-compat_firmware.rules [new file with mode: 0644]
udev/compat_firmware.sh [new file with mode: 0755]
udev/ubuntu/50-compat_firmware.rules [new file with mode: 0644]
udev/ubuntu/compat_firmware.sh [new file with mode: 0755]

index be2fdc5e59f73ab804fefe2040ca2133841b0594..3692f966770c3f20f0afebf10c3eded8e3f20537 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -37,6 +37,7 @@ install: modules
        $(MAKE) -C $(KLIB_BUILD) M=$(PWD) $(KMODDIR_ARG) $(KMODPATH_ARG) \
                modules_install
        depmod -a
+       @./scripts/compat_firmware_install
 clean:
        $(MAKE) -C $(KLIB_BUILD) M=$(PWD) clean
 all: modules
diff --git a/scripts/compat_firmware_install b/scripts/compat_firmware_install
new file mode 100755 (executable)
index 0000000..d92961a
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+if [ -f /usr/bin/lsb_release ]; then
+       LSB_RED_ID=$(/usr/bin/lsb_release -i -s)
+else
+       LSB_RED_ID="Unknown"
+fi
+
+case $LSB_RED_ID in
+"Ubuntu")
+       cp udev/ubuntu/compat_firmware.sh /lib/udev/
+       cp udev/ubuntu/50-compat_firmware.rules /lib/udev/rules.d/
+        ;;
+*)
+       cp udev/compat_firmware.sh /lib/udev/
+       cp udev/50-compat_firmware.rules /lib/udev/rules.d/
+        ;;
+esac
+
diff --git a/udev/50-compat_firmware.rules b/udev/50-compat_firmware.rules
new file mode 100644 (file)
index 0000000..6473788
--- /dev/null
@@ -0,0 +1,4 @@
+# do not edit this file, it will be overwritten on update
+
+# compat_firmware-class requests, copies files into the kernel
+SUBSYSTEM=="compat_firmware", ACTION=="add", RUN+="compat_firmware.sh"
diff --git a/udev/compat_firmware.sh b/udev/compat_firmware.sh
new file mode 100755 (executable)
index 0000000..ef609e7
--- /dev/null
@@ -0,0 +1,35 @@
+#!/bin/sh -e
+
+# This is ported from Ubuntu but ubuntu uses these directories which
+# other distributions don't care about:
+# FIRMWARE_DIRS="/lib/firmware/updates/$(uname -r) /lib/firmware/updates \
+#               /lib/firmware/$(uname -r) /lib/firmware"
+# If your distribution looks for firmware in other directories
+# feel free to extend this and add your own directory here.
+#
+FIRMWARE_DIRS="/lib/firmware"
+
+err() {
+       echo "$@" >&2
+       logger -t "${0##*/}[$$]" "$@" 2>/dev/null || true
+}
+
+if [ ! -e /sys$DEVPATH/loading ]; then
+       err "udev firmware loader misses sysfs directory"
+       exit 1
+fi
+
+for DIR in $FIRMWARE_DIRS; do
+       [ -e "$DIR/$FIRMWARE" ] || continue
+       echo 1 > /sys$DEVPATH/loading
+       cat "$DIR/$FIRMWARE" > /sys$DEVPATH/data
+       echo 0 > /sys$DEVPATH/loading
+       exit 0
+done
+
+echo -1 > /sys$DEVPATH/loading
+err "Cannot find  firmware file '$FIRMWARE'"
+mkdir -p /dev/.udev/firmware-missing
+file=$(echo "$FIRMWARE" | sed 's:/:\\x2f:g')
+ln -s -f "$DEVPATH" /dev/.udev/firmware-missing/$file
+exit 1
diff --git a/udev/ubuntu/50-compat_firmware.rules b/udev/ubuntu/50-compat_firmware.rules
new file mode 100644 (file)
index 0000000..6473788
--- /dev/null
@@ -0,0 +1,4 @@
+# do not edit this file, it will be overwritten on update
+
+# compat_firmware-class requests, copies files into the kernel
+SUBSYSTEM=="compat_firmware", ACTION=="add", RUN+="compat_firmware.sh"
diff --git a/udev/ubuntu/compat_firmware.sh b/udev/ubuntu/compat_firmware.sh
new file mode 100755 (executable)
index 0000000..9d4659a
--- /dev/null
@@ -0,0 +1,29 @@
+#!/bin/sh -e
+
+FIRMWARE_DIRS="/lib/firmware/updates/$(uname -r) /lib/firmware/updates \
+               /lib/firmware/$(uname -r) /lib/firmware"
+
+err() {
+       echo "$@" >&2
+       logger -t "${0##*/}[$$]" "$@" 2>/dev/null || true
+}
+
+if [ ! -e /sys$DEVPATH/loading ]; then
+       err "udev firmware loader misses sysfs directory"
+       exit 1
+fi
+
+for DIR in $FIRMWARE_DIRS; do
+       [ -e "$DIR/$FIRMWARE" ] || continue
+       echo 1 > /sys$DEVPATH/loading
+       cat "$DIR/$FIRMWARE" > /sys$DEVPATH/data
+       echo 0 > /sys$DEVPATH/loading
+       exit 0
+done
+
+echo -1 > /sys$DEVPATH/loading
+err "Cannot find  firmware file '$FIRMWARE'"
+mkdir -p /dev/.udev/firmware-missing
+file=$(echo "$FIRMWARE" | sed 's:/:\\x2f:g')
+ln -s -f "$DEVPATH" /dev/.udev/firmware-missing/$file
+exit 1