From: Luis R. Rodriguez Date: Wed, 20 Jan 2010 19:03:49 +0000 (-0800) Subject: Install udev rules and scripts needed for compat_firmware_class X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=96c8b2c208fee5a33e9c7b7a1d8e129d1aefe21b;p=openwrt%2Fstaging%2Fblogic.git Install udev rules and scripts needed for compat_firmware_class 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 --- diff --git a/Makefile b/Makefile index be2fdc5e59f7..3692f966770c 100644 --- 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 index 000000000000..d92961a62f05 --- /dev/null +++ b/scripts/compat_firmware_install @@ -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 index 000000000000..6473788ec464 --- /dev/null +++ b/udev/50-compat_firmware.rules @@ -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 index 000000000000..ef609e71c6df --- /dev/null +++ b/udev/compat_firmware.sh @@ -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 index 000000000000..6473788ec464 --- /dev/null +++ b/udev/ubuntu/50-compat_firmware.rules @@ -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 index 000000000000..9d4659a34d78 --- /dev/null +++ b/udev/ubuntu/compat_firmware.sh @@ -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