summaryrefslogtreecommitdiff
path: root/scripts/b43load
blob: 3e7a4d99b702174e6173c72f66ad5bb4a443e08e (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
64
65
#!/bin/bash
# Copyright 2007	Luis R. Rodriguez <mcgrof@winlab.rutgers.edu>
#
# Loads new broadcom drivers (b43 and b43legacy) or the old ones (bcm43xx)

. /usr/lib/compat-drivers/modlib.sh

if [[ $UID -ne 0 ]]; then
	echo "Run with root privileges"
	exit
fi


USAGE="Usage: $0 [ b43 | bcm43xx ]"

# Default behavior: unload bcm43xx and load b43 and b43legacy
if [ $# -eq 0 ]; then
	1=b43
elif [ $# -ne 1 ]; then
	echo "$USAGE"
	exit
fi

MODULE=$1
if [ "$MODULE" == "b43" ]; then
        grep bcm43xx /proc/modules 2>&1 > /dev/null
        if [ $? -eq 0 ]; then
                echo Unloading $i...
		modprobe -r --ignore-remove bcm43xx
        fi
	# Enables both b43 and b43legacy
	b43enable b43
	modprobe b43
	modprobe b43legacy
	CHECK=`modprobe -l b43`
	if [ ! -z $CHECK ]; then
		echo "b43 loaded successfully"
	fi
	CHECK=`modprobe -l b43legacy`
	if [ ! -z $CHECK ]; then
		echo "b43legacy loaded successfully"
	fi
elif [ "$MODULE" == "bcm43xx" ]; then
	CHECK=`modprobe -l b43`
	if [ ! -z $CHECK ]; then
		echo "b43 currently loaded, going to try to unload the module..."
		modprobe -r --ignore-remove b43
	fi
	CHECK=`modprobe -l b43legacy`
	if [ ! -z $CHECK ]; then
		echo "b43legacy currently loaded, going to try to unload the module..."
		modprobe -r --ignore-remove b43legacy
	fi
	b43enable bcm43xx
	# bcm43xx may be loaded already lets remove them first
	modprobe -r --ignore-remov bcm43xx 2>&1 > /dev/null
	modprobe bcm43xx
	CHECK=`modprobe -l bcm43xx`
	if [ ! -z $CHECK ]; then
		echo "bcm43xx loaded successfully!"
	fi
else
	echo "$USAGE"
	exit
fi