#!/bin/bash


# rc.sdio
#
#  boot script of SD/SDIO driver for C-guys SDlink-11b SDIO WLAN Cards
#
#

. /etc/rc.d/init.d/functions

KERNEL=`/bin/uname -r`
MDIR=/lib/modules/$KERNEL/kernel/drivers/sdcard/
MODS_LOAD="sd_linux sd_core sd_memory sdmmc_linux sdlink sd_pxahci"
MODS_UNLOAD="sd_pxahci sdlink sdmmc_linux sd_memory sd_core sd_linux" 


usage()
{
  echo "Usage: $0 {start|stop|status|restart|reload}"
}

if [ $# -lt 1 ]; then usage ; exit 1; fi

action=$1


case x"$action" in 

xstart)
  ## make sure that preinstalled sd driver is not running
  /etc/rc.d/init.d/sd stop
  if grep -q sharp_mmcsd_m /proc/modules ; then
     msg -n "Failed to start SDIO drivers."
     exit 1
  fi

  msg -n "Start SDIO drivers:"
  for f in $MODS_LOAD; do insmod $f ; done
  ;;

xstop)
  msg -n "Stop SDIO drivers:"
  for f in $MODS_UNLOAD; do rmmod $f ; done
  ;;

xstatus)
  ;;


xrestart|xreload)
  $0 stop
  $0 start
  ;;

*)
  usage
  ;; 

esac

exit 0