From 2c10be357babf7bb1b228eac423d7e27fe672702 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 11 Nov 2008 15:08:04 -0800 Subject: [PATCH] Add iwl-load, and make sure we disable iwl4965 upon install We now has two drivers for different kernel releases for the Intel 4965 device. To account for this we add a script to allow us to disable and enable one or each other. By default we disable iwl4965 as we are replacing it with iwlagn. If you want to enable iwl4965: iwl-load iwl4965 If you want to enable iwlagn: iwl-load iwlagn By default we'll use iwlagn. Signed-off-by: Luis R. Rodriguez --- Makefile | 14 +++++++++++ scripts/iwl-enable | 47 +++++++++++++++++++++++++++++++++++++ scripts/iwl-load | 58 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 119 insertions(+) create mode 100755 scripts/iwl-enable create mode 100755 scripts/iwl-load diff --git a/Makefile b/Makefile index c0ccbd5c94e1..738321487cfd 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,7 @@ export KLIB_BUILD ?= $(KLIB)/build # Sometimes not available in the path MODPROBE := /sbin/modprobe MADWIFI=$(shell $(MODPROBE) -l ath_pci) +OLD_IWL=$(shell $(MODPROBE) -l iwl4965) ifneq ($(KERNELRELEASE),) @@ -67,8 +68,10 @@ install: uninstall modules @# This is to allow switching between drivers without blacklisting @install scripts/athenable /usr/sbin/ @install scripts/b43enable /usr/sbin/ + @install scripts/iwl-enable /usr/sbin/ @install scripts/athload /usr/sbin/ @install scripts/b43load /usr/sbin/ + @install scripts/iwl-load /usr/sbin/ @if [ ! -z $(MADWIFI) ]; then \ echo ;\ echo -n "Note: madwifi detected, we're going to disable it. " ;\ @@ -79,6 +82,15 @@ install: uninstall modules /usr/sbin/athenable ath5k ;\ fi @/sbin/depmod -ae + @if [ ! -z $(OLD_IWL) ]; then \ + echo ;\ + echo -n "Note: iwl4965 detected, we're going to disable it. " ;\ + echo "If you would like to enable it later you can run:" ;\ + echo " sudo iwl-load iwl4965" ;\ + echo ;\ + echo Running iwl-enable iwlagn...;\ + /usr/sbin/iwl-enable iwlagn ;\ + fi @echo @echo "Currently detected wireless subsystem modules:" @echo @@ -95,6 +107,7 @@ install: uninstall modules @$(MODPROBE) -l ssb @$(MODPROBE) -l iwl3945 @$(MODPROBE) -l iwl4965 + @$(MODPROBE) -l iwlagn @$(MODPROBE) -l ipw2100 @$(MODPROBE) -l ipw2200 @$(MODPROBE) -l ieee80211 @@ -153,6 +166,7 @@ uninstall: @$(MODPROBE) -l rc80211_simple @$(MODPROBE) -l iwl3945 @$(MODPROBE) -l iwl4965 + @$(MODPROBE) -l iwlagn @$(MODPROBE) -l ipw2100 @$(MODPROBE) -l ipw2200 @$(MODPROBE) -l ieee80211 diff --git a/scripts/iwl-enable b/scripts/iwl-enable new file mode 100755 index 000000000000..1236debcc4ff --- /dev/null +++ b/scripts/iwl-enable @@ -0,0 +1,47 @@ +#!/bin/bash +# +# Copyright 2007 Luis R. Rodriguez +# +# Makes sure either iwlagn (new) or iwl4965 (old) +# is enabled to be used. This allows us to choose any driver without +# blacklisting each other. + +. /usr/lib/compat-wireless/modlib.sh + +if [[ $UID -ne 0 ]]; then + echo "Run with root privileges" + exit +fi + +IWL_NEW="iwlagn" +IWL_OLD="iwl4965" + +# Appended to module file at the end when we want to ignore one +USAGE="Usage: $0 [ $IWL | $IWL_OLD ]" + +function enable_iwlagn { + module_disable $IWL_OLD + for i in $IWL_NEW; do + module_enable $i + done +} + +# Default behavior: disables the old iwl4965 driver and enables iwlagn +if [ $# -eq 0 ]; then + enable_iwlagn + exit +elif [ $# -ne 1 ]; then + echo "$USAGE" + exit +fi + +MODULE=$1 +if [ "$MODULE" == "iwl4954" ]; then + module_disable $IWL_NEW + module_enable $IWL_OLD +elif [ "$MODULE" == "iwlagn" ]; then + enable_iwlagn +else + echo "$USAGE" + exit +fi diff --git a/scripts/iwl-load b/scripts/iwl-load new file mode 100755 index 000000000000..96b6d8918263 --- /dev/null +++ b/scripts/iwl-load @@ -0,0 +1,58 @@ +#!/bin/bash +# Copyright 2008 Luis R. Rodriguez +# +# Loads new Intel iwl (iwlagn) or the old ones (iwl4965) + +. /usr/lib/compat-wireless/modlib.sh + +IWL_OLD="iwl4965" +IWL_NEW="iwlagn" + +if [[ $UID -ne 0 ]]; then + echo "Run with root privileges" + exit +fi + + +USAGE="Usage: $0 [ iwlagn | iwl4965 ]" + +# Default behavior: unload iwl4965 and load iwlagn +if [ $# -eq 0 ]; then + 1=iwlagn +elif [ $# -ne 1 ]; then + echo "$USAGE" + exit +fi + +MODULE=$1 +if [ "$MODULE" == "iwlagn" ]; then + grep iwl4965 /proc/modules 2>&1 > /dev/null + if [ $? -eq 0 ]; then + echo Unloading $i... + modprobe -r --ignore-remove iwl4965 + fi + # Enables both b43 and b43legacy + iwl-enable iwlagn + modprobe iwlagn + CHECK=`modprobe -l iwlagn` + if [ ! -z $CHECK ]; then + echo "iwlagn loaded successfully" + fi +elif [ "$MODULE" == "iwl4965" ]; then + CHECK=`modprobe -l iwlagn` + if [ ! -z $CHECK ]; then + echo "iwlagn currently loaded, going to try to unload the module..." + modprobe -r --ignore-remove iwlagn + fi + iwl-enable iwl4965 + # iwl4965 may be loaded already lets remove it first + modprobe -r --ignore-remov iwl4965 2>&1 > /dev/null + modprobe iwl4965 + CHECK=`modprobe -l iwl4965` + if [ ! -z $CHECK ]; then + echo "iwl4965 loaded successfully!" + fi +else + echo "$USAGE" + exit +fi -- 2.30.2