summaryrefslogtreecommitdiff
path: root/recipes/linux-hotplug/files/usbd.agent
blob: 6613b4810aed1da2416c47bfac8f102ce969c838 (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/ash

# DEBUG=yes export DEBUG
#set -x

. /etc/hotplug/hotplug.functions
. /etc/default/usbd
cd $HOTPLUG_DIR

[ -z "$INTERFACE" ] && exit 1
[ -z "$ACTION" ] && exit 1
[ -z "$usbdmodule" ] && exit 0

debug_mesg "USBD $ACTION Action Recived"

case $INTERFACE in

monitor)
	case $ACTION in
		# called to load all usb device modules
	load)	
		modprobe usbdcore
		modprobe net_fd
		modprobe $usbdmodule
		;;
	
		# called to handle suspend power management event
	suspend) 
		rmmod $usbdmodule
		;;

		# called to reload after resume power management event
	restore-loaded)
		modprobe $usbdmodule
		sleep 2
		;;

		# called to unload after resume power management event
	restore-unloaded)
		modprobe -r net_fd
		;;

		# called to unload all usb device modules
	unload)
		modprobe -r $usbdmodule
		;;

	*)
		debug_mesg USBD $ACTION event not handled
		exit 1
		;;
	esac
	;;
*)
	debug_mesg USBD $INTERFACE-$ACTION event not handled
	exit 1
	;;
esac

[ -e /proc/usb-monitor ] && echo "Done" > /proc/usb-monitor

exit 0