me8100-driver
changeset 0 c9b8efdb5369
child 3 fc24e3b47731
equal deleted inserted replaced
-1:000000000000 0:c9b8efdb5369
       
     1 #! /bin/sh
       
     2 # You can use this script to install the device driver
       
     3 # with automatically assigned major number. 
       
     4 
       
     5 # Please modify these lines according to your needs
       
     6 PATH=/sbin:/bin:/usr/bin
       
     7 module="me8100"
       
     8 device="me8100"
       
     9 group="users"
       
    10 mode="664"
       
    11 
       
    12 
       
    13 ### I hope you don't have to modify anything below this line ###
       
    14 rc_done="\033[71G\033[32mdone\033[m"
       
    15 rc_failed="\033[71G\033[31m\033[1mfailed\033[m"   
       
    16 
       
    17 return=$rc_done
       
    18 
       
    19 case "$1" in
       
    20     start)
       
    21 	echo -n "Starting me8100 driver "
       
    22 	/sbin/insmod -f $module.o || return=$rc_failed
       
    23 	rm -f /dev/${device}
       
    24 	rm -f /dev/${device}_[0-3]
       
    25 	major=`cat /proc/devices | awk "\\$2==\"$module\" {print \\$1}"`
       
    26 
       
    27 	echo -n "with major number $major"
       
    28 
       
    29 	# Make the device nodes in the dev. file system for 4 boards
       
    30 	mknod /dev/${device}_0 c $major 0
       
    31 	mknod /dev/${device}_1 c $major 1
       
    32 	mknod /dev/${device}_2 c $major 2
       
    33 	mknod /dev/${device}_3 c $major 3
       
    34 	
       
    35 	# Set a default link to the first dev
       
    36 	ln -s /dev/${device}_0 /dev/${device}
       
    37 
       
    38 	# Give appropriate group permissions
       
    39 	chgrp $group /dev/${device}_?
       
    40 	chmod $mode  /dev/${device}_?
       
    41 
       
    42 	;;
       
    43     stop)
       
    44 	echo -n "Removing me8100 driver "
       
    45 	/sbin/rmmod $module
       
    46 
       
    47 	# Remove the default link
       
    48 	rm -f /dev/${device}
       
    49 	# Remove the nodes
       
    50 	rm -f /dev/${device}_[0-3]
       
    51 
       
    52 	;;
       
    53     restart)
       
    54 	## If first returns OK call the second, if first or
       
    55 	## second command fails, set echo return value.
       
    56 	$0 stop  &&  $0 start  ||  return=$rc_failed
       
    57 	;;
       
    58     status)
       
    59 	echo -e "Enty in /proc/modules is:"
       
    60 	cat /proc/modules | grep $module
       
    61 	echo -e "Entry in /proc/devices is:"
       
    62 	cat /proc/devices | grep $module
       
    63 	echo -e "Entry in /proc/interrupts is:"
       
    64 	cat /proc/interrupts | grep $module
       
    65 
       
    66 	;;
       
    67     *)
       
    68 	echo "Usage: $0 {start|stop|restart|status}"
       
    69 	exit 1
       
    70 	;;
       
    71 esac
       
    72 
       
    73 # Inform the caller not only verbosely and set an exit status.
       
    74 echo -e "$return"
       
    75 test "$return" = "$rc_done" || exit 1
       
    76 exit 0
       
    77 
       
    78 
       
    79