summaryrefslogtreecommitdiffstats
path: root/bluetopia_usb_driver/files/bind_driver.sh
blob: 3d9221b4305d7e1176f188785851333ec152bc59 (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
#!/bin/sh
# This script will unbind the bt driver (built in the kernel), and bind the SS1 BT USB Driver

DRIVER_PATH="/lib/modules/`uname -r`/SS1BTUSBM.ko"

# Make sure the module is loaded
if lsmod | grep SS1BTUSBM > /dev/null 2>&1
then
	echo "Driver already loaded."
else
   echo "Loading driver..."
	insmod "$DRIVER_PATH"/SS1BTUSBM.ko
fi

# Go through the btusb directory and find the devices
DEVICES=$(ls /sys/bus/usb/drivers/btusb/ | grep '[0-9]')

echo "Rebinding existing Bluetooth devices:"

if [ -n "$DEVICES" ] ; then
   for dir in $DEVICES; do
      # unbind the current btdevice
      echo "   $dir"

      if [ -d /sys/bus/usb/drivers/btusb/"$dir" ] ; then
         echo "$dir" > /sys/bus/usb/drivers/btusb/unbind
         sleep 1
      fi

      # now bind the current to the SS1BTUSB driver
      if [ ! -d /sys/bus/usb/drivers/SS1BTUSB/"$dir" ] ; then
         echo "$dir" > /sys/bus/usb/drivers/SS1BTUSB/bind
      fi
   done
else
   echo "  None"
fi