compat/nes: Adding pci_zalloc_consistent backport
[~tnikolova/compat/.git] / udev / ubuntu / compat_firmware.sh
1 #!/bin/sh -e
2
3 FIRMWARE_DIRS="/lib/firmware/updates/$(uname -r) /lib/firmware/updates \
4                /lib/firmware/$(uname -r) /lib/firmware"
5
6 err() {
7         echo "$@" >&2
8         logger -t "${0##*/}[$$]" "$@" 2>/dev/null || true
9 }
10
11 if [ ! -e /sys$DEVPATH/loading ]; then
12         err "udev firmware loader misses sysfs directory"
13         exit 1
14 fi
15
16 for DIR in $FIRMWARE_DIRS; do
17         [ -e "$DIR/$FIRMWARE" ] || continue
18         echo 1 > /sys$DEVPATH/loading
19         cat "$DIR/$FIRMWARE" > /sys$DEVPATH/data
20         echo 0 > /sys$DEVPATH/loading
21         exit 0
22 done
23
24 echo -1 > /sys$DEVPATH/loading
25 err "Cannot find  firmware file '$FIRMWARE'"
26 mkdir -p /dev/.udev/firmware-missing
27 file=$(echo "$FIRMWARE" | sed 's:/:\\x2f:g')
28 ln -s -f "$DEVPATH" /dev/.udev/firmware-missing/$file
29 exit 1