blob: fddc25f601fabc31b6809b9ec09b3d99855de5e3 [file] [log] [blame]
Patrick Williamsb48b7b42016-08-17 15:04:38 -05001make init script be able to automatically load EDAC module.
2
3Upstream-Status: Inappropriate [embedded specific]
4
5Signed-off-by: Roy.Li <rongqing.li@windriver.com>
6---
7 src/etc/edac.init.in | 49 +++++++++++++++++++++++++++++++++++++++++++++++--
8 1 file changed, 47 insertions(+), 2 deletions(-)
9
10diff --git a/src/etc/edac.init.in b/src/etc/edac.init.in
11index 7a51da9..5b568c4 100644
12--- a/src/etc/edac.init.in
13+++ b/src/etc/edac.init.in
14@@ -42,7 +42,6 @@ for dir in "$sysconfdir/default" "$sysconfdir/sysconfig"; do
15 [ -f "$dir/$SERVICE" ] && . "$dir/$SERVICE"
16 done
17
18-
19 ###############################################################################
20
21 service_start ()
22@@ -52,6 +51,46 @@ service_start ()
23 # Assume that if EDAC_DRIVER is not set, then EDAC is configured
24 # automatically, thus return successfully, but don't do anything.
25 #
26+ if [ ! -f /etc/edac/edac-driver ]; then
27+ [ -d /sys/bus/edac/devices/mc/mc0 ] && \
28+ echo `lsmod | grep _edac | cut -d" " -f1` > /etc/edac/edac-driver
29+ fi
30+
31+ [ -f /etc/edac/edac-driver ] && EDAC_DRIVER=`cat /etc/edac/edac-driver`
32+
33+ if [ -z "$EDAC_DRIVER" ]; then
34+
35+ DRIVER_PATH=/lib/modules/`uname -r`/kernel/drivers/edac
36+ oldpath=`pwd`
37+ if [ -d $DRIVER_PATH ]; then
38+
39+ cd $DRIVER_PATH
40+
41+ for i in $(/bin/ls | /usr/bin/cut -d. -f1) ; do
42+ /sbin/modprobe $i 2>/dev/null
43+ if [ -d /sys/bus/edac/devices/mc/mc0 ]; then
44+ echo $i> /etc/edac/edac-driver
45+ EDAC_DRIVER=$i
46+ break
47+ fi
48+ /sbin/modprobe -r $i 2>/dev/null
49+ done
50+
51+ cd "$oldpath"
52+
53+
54+ if [ -z "$EDAC_DRIVER" ]; then
55+ echo "This board may not support EDAC, or EDAC module may not be compiled in"
56+ exit
57+ fi
58+
59+ else
60+ echo "This board may not support EDAC, or EDAC module may not be compiled in"
61+ exit
62+ fi
63+
64+ fi
65+
66 if [ -n "$EDAC_DRIVER" ]; then
67 echo -n "Starting ${SERVICE}: "
68 modprobe $EDAC_DRIVER
69@@ -76,12 +115,15 @@ service_start ()
70 service_stop ()
71 {
72 echo -n "Disabling ${SERVICE}: "
73+
74+ [ -f /etc/edac/edac-driver ] && EDAC_DRIVER=`cat /etc/edac/edac-driver`
75+
76 if [ -n "$EDAC_DRIVER" ]; then
77 modprobe -r $EDAC_DRIVER
78 STATUS=$?
79 [ $STATUS -eq 0 ] && echo success || echo failure
80 else
81- echo "Not supported for this configuration."
82+ echo "Not supported for this configuration, or EDAC Module is not loaded."
83 STATUS=6
84 fi
85 }
86@@ -92,6 +134,9 @@ service_status ()
87 {
88 # Print the current status of the service. Required by LSB.
89 #
90+ [ -f /etc/edac/edac-driver ] && EDAC_DRIVER=`cat /etc/edac/edac-driver`
91+ [ -z "$EDAC_DRIVER" ] && STATUS=1 && exit
92+
93 edac-ctl --status
94 STATUS=0
95 }
96--
971.7.10.4
98