aboutsummaryrefslogtreecommitdiffstats
path: root/main/busybox-initscripts/usbdev
blob: c811736ddaef1c362c762518e347ba767912511c (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
#!/bin/sh

# mdev -s will not set SUBSYSTEM or DEVNAME so we trigger a hotplug event
if [ "$SUBSYSTEM" != "usb" ] || [ "$DEVTYPE" != "usb_device" ]; then
	uev=/sys/bus/usb/devices/$MDEV/uevent
	[ -e "$uev" ] && echo "add" > "$uev"
	exit
fi

[ -n "$DEVNAME" ] || exit

case "$ACTION" in
add)
	mkdir -p "${DEVNAME%/*}"
	mv $MDEV $DEVNAME
	# autoload driver
	for i in /sys/$DEVPATH/*/modalias; do
		[ -e "$i" ] && echo $i
	done | xargs sort -u | xargs modprobe -a 2>/dev/null
	;;
remove)
	rm $DEVNAME
	;;
esac