firmware.sh 564 B

123456789101112131415161718192021222324252627
  1. #!/bin/sh -e
  2. FIRMWARE_DIRS="/lib/firmware /usr/local/lib/firmware"
  3. err() {
  4. echo "$@" >&2
  5. if [ -x /bin/logger ]; then
  6. /bin/logger -t "${0##*/}[$$]" "$@"
  7. fi
  8. }
  9. if [ ! -e /sys$DEVPATH/loading ]; then
  10. err "udev firmware loader misses sysfs directory"
  11. exit 1
  12. fi
  13. for DIR in $FIRMWARE_DIRS; do
  14. [ -e "$DIR/$FIRMWARE" ] || continue
  15. echo 1 > /sys$DEVPATH/loading
  16. cat "$DIR/$FIRMWARE" > /sys$DEVPATH/data
  17. echo 0 > /sys$DEVPATH/loading
  18. exit 0
  19. done
  20. echo -1 > /sys$DEVPATH/loading
  21. err "Cannot find firmware file '$FIRMWARE'"
  22. exit 1