blob: 8f039d4ce4f02c29a9fdeef00f0512b6382e1959 [file] [log] [blame]
#! /bin/sh
#
# Laptop mode tools module: bluetooth
#
if [ x$CONTROL_BLUETOOTH = x1 ] ; then
ENABLE_BLUETOOTH=$BATT_ENABLE_BLUETOOTH
if [ $ON_AC -eq 1 ] ; then
ENABLE_BLUETOOTH=$AC_ENABLE_BLUETOOTH
fi
if [ x$ENABLE_BLUETOOTH = x1 ] ; then
log "VERBOSE" "Enabling bluetooth."
modprobe -q hci_usb
for INTF in $BLUETOOTH_INTERFACES ; do
[ -d /sys/class/bluetooth/$INTF ] || continue
log "VERBOSE" "`hciconfig $INTF up 2>&1`"
done
else
log "VERBOSE" "Disabling bluetooth."
for INTF in $BLUETOOTH_INTERFACES ; do
[ -d /sys/class/bluetooth/$INTF ] || continue
log "VERBOSE" "`hciconfig $INTF down 2>&1`"
done
# This may take a while to work because the module may be
# temporarily in use; we try three times. We don't use rmmod
# --wait, because that might hang!
modprobe -rq hci_usb || (sleep 1 ; modprobe -rq hci_usb) || (sleep 1 ; modprobe -rq hci_usb)
fi
fi