blob: 7278ab04bb90eeaa101d7180516cbc292b7d54cd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
#!/bin/bash
# Register for with radio-reset-monitor to
# get a signal when radio-reset occurs.
# Child process exists so the parent
# does not need to worry about resets
# starting before it can get through
# checks, and possibly sleeping forever.
# pgrep was needed to kill the sleep.
# wait is called to wait for the SIGUSR1 signal.
# The child never terminates.
# The hope is that the parent will fall into wait
# before the child registers for the radio-reset.
# checking for do_wait is risky if the kernel ever
# changes. The child will exit if the reset is not
# in process.
#
USR1=10
TERM=15
function sleep_reset
{
# Wait for parent to enter wait.
trap "exit 0" $TERM
while [[ $(ps -h -o wchan -p $PPID) != do_wait ]] ; do usleep 100 ; done
echo Register parent for SIGUSR1
echo "$$" "$USR1" >/sys/devices/platform/mts-io/radio-reset-monitor
discovered=$(cat /sys/devices/platform/mts-io/radio-udev-discovery)
if ((discovered == 1)) ; then
# reset is not in progress.
exit 0
fi
sleep 4294967295 # Hopefully forever
exit 0
}
date
trap ":" $USR1
in_reset=$(cat /sys/devices/platform/mts-io/radio-udev-discovery)
if ((in_reset == 0)) ; then
sleep_reset &
wait $!
# pgrep is needed to find the sleep process
pgrep -P $! | xargs kill
fi
echo "$$" "0" >/sys/devices/platform/mts-io/radio-reset-monitor
echo Radio Reset is done.
date
sleep 30
|