]> git.pld-linux.org Git - projects/rc-scripts.git/blame - firmware-loader.sh
handle only firmware add requests
[projects/rc-scripts.git] / firmware-loader.sh
CommitLineData
caec3c40
ER
1#!/bin/sh
2set -e
f71c07f8 3
5a873f5d
ER
4# handle only firmware add requests
5if [ "$SUBSYSTEM" != "firmware" ]; then
6 exit 0
7fi
8if [ "$ACTION" != "add" ]; then
9 exit 0
10fi
11
f71c07f8 12FIRMWARE_DIRS="/lib/firmware/updates/$(uname -r) /lib/firmware/updates \
13 /lib/firmware/$(uname -r) /lib/firmware"
14
caec3c40
ER
15# @param string message
16# @param int loglevel. defaults to "6" (info)
17# Log levels can be:
18# Name String Meaning
19# KERN_EMERG "0" Emergency messages, system is about to crash or is unstable
20# KERN_ALERT "1" Something bad happened and action must be taken immediately
21# KERN_CRIT "2" A critical condition occurred like a serious hardware/software failure
22# KERN_ERR "3" An error condition, often used by drivers to indicate difficulties with the hardware
23# KERN_WARNING "4" A warning, meaning nothing serious by itself but might indicate problems
24# KERN_NOTICE "5" Nothing serious, but notably nevertheless. Often used to report security events.
25# KERN_INFO "6" Informational message e.g. startup information at driver initialization
26# KERN_DEBUG "7" Debug messages
27# KERN_CONT "c" "continued" line of log printout (only done after a line that had no enclosing \n)
28kmsg() {
29 local msg="$1" level=${2:-3}
30 echo "<$level>$msg" > /dev/kmsg
31}
32
f71c07f8 33err() {
caec3c40
ER
34 echo >&2 "$*"
35 kmsg "${0##*/}[$$] $*"
f71c07f8 36}
37
38if [ ! -e /sys$DEVPATH/loading ]; then
39 err "firmware loader misses sysfs directory"
40 exit 1
41fi
42
43for DIR in $FIRMWARE_DIRS; do
44 [ -e "$DIR/$FIRMWARE" ] || continue
45 echo 1 > /sys$DEVPATH/loading
46 cat "$DIR/$FIRMWARE" > /sys$DEVPATH/data
47 echo 0 > /sys$DEVPATH/loading
48 exit 0
49done
50
51echo -1 > /sys$DEVPATH/loading
e92fa90d 52err "Cannot find firmware file '$FIRMWARE'"
f71c07f8 53exit 1
This page took 0.94949 seconds and 4 git commands to generate.