diff options
Diffstat (limited to 'recipes-bsp/multitech/mts-io/mts-io.init')
-rw-r--r-- | recipes-bsp/multitech/mts-io/mts-io.init | 57 |
1 files changed, 52 insertions, 5 deletions
diff --git a/recipes-bsp/multitech/mts-io/mts-io.init b/recipes-bsp/multitech/mts-io/mts-io.init index ee127a5..03a4590 100644 --- a/recipes-bsp/multitech/mts-io/mts-io.init +++ b/recipes-bsp/multitech/mts-io/mts-io.init @@ -19,6 +19,31 @@ else LOGDBG=":" fi +hw="" +hw_name="" +MTAC_MODULES="" +((HASAP=0)) + +sethwtype() { + # mts-io must be loaded before trying this + hw=$(${SYSFS} show hw-version) + hw_name=(${hw//-/ }) + + # Only MTCDT and MTCDTIP have accessory cards, and + # MTCDTIPHP does not have accessory cards. + ((HASAP==0)) + case $hw_name in + MTCDTIPHP) + ;; + MTCDT|MTCDTIP) + ((HASAP = 1)) + ;; + *) + ;; + esac + MTAC_MODULES=$(cd /lib/modules/$(uname -r)/extra/;ls mtac_* 2>/dev/null) +} + SYSFS="/usr/sbin/mts-io-sysfs" LRST="/usr/sbin/mts-util-lora2-reset" @@ -183,10 +208,8 @@ mfser_init() { } set_gpslink() { - hw=$(${SYSFS} show hw-version) - hw_name=(${hw//-/ }) gpscap=$(cat ${sysdir}/capability/gps) - + if ((gpscap == 0)) ; then return fi @@ -220,6 +243,17 @@ case $1 in if ! modprobe mts_io ; then ((fail++)) fi + + sethwtype + + if ((HASAP == 1)) ; then + # install mtac explicitly or any unused modules will cause + # junk to the log as mtac is loaded and unloaded each time. + modprobe mtac + for f in ${MTAC_MODULES} ; do + modprobe ${f//.ko} 2>&1 | grep -v 'No such device or address' + done + fi set_gpslink # Set GPS symlink. /usr/bin/logger -t "mts-io" -p daemon.info -s "Resetting system modules" read_card_info @@ -252,8 +286,21 @@ case $1 in ;; stop) - /usr/bin/logger -t "mts-io" -p daemon.info -s "Unloading mts-io module" - modprobe -r mts_io + /usr/bin/logger -t "mts-io" -p daemon.info -s "Unloading mtac modules and mts-io module" + MTAC_MODULES=$(lsmod | grep '^mtac_' | sed -e 's/_/-/' -e 's/ .*//') + + for f in ${MTAC_MODULES} ; do + if ! modprobe -r "$f" ; then + rmmod "$f" + fi + done + if ! modprobe -r mtac ; then + rmmod mtac + fi + + if ! modprobe -r mts-io ; then + rmmod mtsio + fi RETVAL=$? if ((RETVAL == 0)) ; then echo "OK" |