power: supply: bq24190_charger: Add disable-reset device-property
[linux/fpc-iii.git] / tools / testing / selftests / firmware / fw_filesystem.sh
blob17e16fcaa0cc5b73c7eda5ced589f680d3c3be11
1 #!/bin/sh
2 # This validates that the kernel will load firmware out of its list of
3 # firmware locations on disk. Since the user helper does similar work,
4 # we reset the custom load directory to a location the user helper doesn't
5 # know so we can be sure we're not accidentally testing the user helper.
6 set -e
8 modprobe test_firmware
10 DIR=/sys/devices/virtual/misc/test_firmware
12 # CONFIG_FW_LOADER_USER_HELPER has a sysfs class under /sys/class/firmware/
13 # These days no one enables CONFIG_FW_LOADER_USER_HELPER so check for that
14 # as an indicator for CONFIG_FW_LOADER_USER_HELPER.
15 HAS_FW_LOADER_USER_HELPER=$(if [ -d /sys/class/firmware/ ]; then echo yes; else echo no; fi)
17 if [ "$HAS_FW_LOADER_USER_HELPER" = "yes" ]; then
18 OLD_TIMEOUT=$(cat /sys/class/firmware/timeout)
21 OLD_FWPATH=$(cat /sys/module/firmware_class/parameters/path)
23 FWPATH=$(mktemp -d)
24 FW="$FWPATH/test-firmware.bin"
26 test_finish()
28 if [ "$HAS_FW_LOADER_USER_HELPER" = "yes" ]; then
29 echo "$OLD_TIMEOUT" >/sys/class/firmware/timeout
31 if [ "$OLD_FWPATH" = "" ]; then
32 OLD_FWPATH=" "
34 echo -n "$OLD_FWPATH" >/sys/module/firmware_class/parameters/path
35 rm -f "$FW"
36 rmdir "$FWPATH"
39 trap "test_finish" EXIT
41 if [ "$HAS_FW_LOADER_USER_HELPER" = "yes" ]; then
42 # Turn down the timeout so failures don't take so long.
43 echo 1 >/sys/class/firmware/timeout
46 # Set the kernel search path.
47 echo -n "$FWPATH" >/sys/module/firmware_class/parameters/path
49 # This is an unlikely real-world firmware content. :)
50 echo "ABCD0123" >"$FW"
52 NAME=$(basename "$FW")
54 if printf '\000' >"$DIR"/trigger_request 2> /dev/null; then
55 echo "$0: empty filename should not succeed" >&2
56 exit 1
59 if printf '\000' >"$DIR"/trigger_async_request 2> /dev/null; then
60 echo "$0: empty filename should not succeed (async)" >&2
61 exit 1
64 # Request a firmware that doesn't exist, it should fail.
65 if echo -n "nope-$NAME" >"$DIR"/trigger_request 2> /dev/null; then
66 echo "$0: firmware shouldn't have loaded" >&2
67 exit 1
69 if diff -q "$FW" /dev/test_firmware >/dev/null ; then
70 echo "$0: firmware was not expected to match" >&2
71 exit 1
72 else
73 if [ "$HAS_FW_LOADER_USER_HELPER" = "yes" ]; then
74 echo "$0: timeout works"
78 # This should succeed via kernel load or will fail after 1 second after
79 # being handed over to the user helper, which won't find the fw either.
80 if ! echo -n "$NAME" >"$DIR"/trigger_request ; then
81 echo "$0: could not trigger request" >&2
82 exit 1
85 # Verify the contents are what we expect.
86 if ! diff -q "$FW" /dev/test_firmware >/dev/null ; then
87 echo "$0: firmware was not loaded" >&2
88 exit 1
89 else
90 echo "$0: filesystem loading works"
93 # Try the asynchronous version too
94 if ! echo -n "$NAME" >"$DIR"/trigger_async_request ; then
95 echo "$0: could not trigger async request" >&2
96 exit 1
99 # Verify the contents are what we expect.
100 if ! diff -q "$FW" /dev/test_firmware >/dev/null ; then
101 echo "$0: firmware was not loaded (async)" >&2
102 exit 1
103 else
104 echo "$0: async filesystem loading works"
107 exit 0