Skip to contentSkip to conversation

replace modprobe -l with modinfo

PATCH In review Rick Farina 2 participants 6 messages Feb 3, 2012 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 replace modprobe -l with modinfo

modprobe -l is either deprecated or removed, so let's replace it.

---
 Makefile |   11 ++---------
 1 files changed, 2 insertions(+), 9 deletions(-)
Makefile +2 -9
index e3d9128..1f8ab91 100644
@@ -6,13 +6,6 @@ else
 export KLIB:=          /lib/modules/$(shell uname -r)
 endif
 export KLIB_BUILD ?=	$(KLIB)/build
-# Sometimes not available in the path
-MODPROBE := /sbin/modprobe
-
-ifneq ($(wildcard $(MODPROBE)),)
-MADWIFI=$(shell $(MODPROBE) -l ath_pci)
-OLD_IWL=$(shell $(MODPROBE) -l iwl4965)
-endif
 
 DESTDIR?=
 
@@ -188,7 +181,7 @@ install-scripts: $(MODPROBE)
 	@install scripts/athload	$(DESTDIR)/usr/sbin/
 	@install scripts/b43load	$(DESTDIR)/usr/sbin/
 	@install scripts/iwl-load	$(DESTDIR)/usr/sbin/
-	@if [ ! -z "$(MADWIFI)" ] && [ -z "$(DESTDIR)" ]; then \
+	@if `modinfo ath_pci > /dev/null 2>&1` && [ -z "$(DESTDIR)" ]; then \
 		echo ;\
 		echo -n "Note: madwifi detected, we're going to disable it. "  ;\
 		echo "If you would like to enable it later you can run:"  ;\
@@ -197,7 +190,7 @@ install-scripts: $(MODPROBE)
 		echo Running athenable ath5k...;\
 		/usr/sbin/athenable ath5k ;\
 	fi
-	@if [ ! -z "$(OLD_IWL)" ] && [ -z "$(DESTDIR)" ]; then \
+	@if `modinfo iwl4965 > /dev/null 2>&1` && [ -z "$(DESTDIR)" ]; 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:"  ;\
Signature · 1 line
1.7.3.4
#1 lore raw

PATCH 2/2 cleanup modprobe calls

There were a lot of needless calls to "modprobe -l <drivername>" and even more confusingly $(MODPROBE). None of this is needed on a modern distro, and it errors on when modprobe -l is removed (such as KMOD in Arch Linux)

---
 Makefile |  260 +-------------------------------------------------------------
 1 files changed, 4 insertions(+), 256 deletions(-)
Makefile +4 -256
index 1f8ab91..d586f45 100644
@@ -91,34 +91,11 @@ $(CREL_CHECK):
 
 btinstall: btuninstall bt-install-modules
 
-bt-install-modules: bt $(MODPROBE)
+bt-install-modules: bt
 	$(MAKE) -C $(KLIB_BUILD) M=$(PWD) $(KMODDIR_ARG) $(KMODPATH_ARG) BT=TRUE \
 		modules_install
 	@/sbin/depmod -ae
 	@echo
-	@echo "Currently detected bluetooth subsystem modules:"
-	@echo
-	@$(MODPROBE) -l ath3k       
-	@$(MODPROBE) -l bcm203x
-	@$(MODPROBE) -l bluecard_cs
-	@$(MODPROBE) -l bluetooth
-	@$(MODPROBE) -l bnep
-	@$(MODPROBE) -l bpa10x
-	@$(MODPROBE) -l bt3c_cs
-	@$(MODPROBE) -l btmrvl
-	@$(MODPROBE) -l btmrvl_sdio
-	@$(MODPROBE) -l btsdio
-	@$(MODPROBE) -l btusb
-	@$(MODPROBE) -l btuart_cs
-	@$(MODPROBE) -l	cmtp
-	@$(MODPROBE) -l	dtl1_cs
-	@$(MODPROBE) -l hidp
-	@$(MODPROBE) -l	hci_vhci
-	@$(MODPROBE) -l	hci_uart
-	@$(MODPROBE) -l l2cap
-	@$(MODPROBE) -l rfcomm
-	@$(MODPROBE) -l sco
-	@echo
 	@echo Now run:
 	@echo
 	@echo sudo make btunload:
@@ -126,7 +103,7 @@ bt-install-modules: bt $(MODPROBE)
 	@echo And then load the needed bluetooth modules. If unsure reboot.
 	@echo
 
-btuninstall: $(MODPROBE)
+btuninstall:
 	@# New location, matches upstream
 	@rm -rf $(KLIB)/$(KMODDIR)/net/bluetooth/
 	@rm -rf $(KLIB)/$(KMODDIR)/drivers/bluetooth/
@@ -136,27 +113,6 @@ btuninstall: $(MODPROBE)
 	@echo
 	@echo "Your old bluetooth subsystem modules were left intact:"
 	@echo
-	@$(MODPROBE) -l ath3k       
-	@$(MODPROBE) -l bcm203x
-	@$(MODPROBE) -l bluecard_cs
-	@$(MODPROBE) -l bluetooth
-	@$(MODPROBE) -l bnep
-	@$(MODPROBE) -l bpa10x
-	@$(MODPROBE) -l bt3c_cs
-	@$(MODPROBE) -l btmrvl
-	@$(MODPROBE) -l btmrvl_sdio
-	@$(MODPROBE) -l btsdio
-	@$(MODPROBE) -l btusb
-	@$(MODPROBE) -l btuart_cs
-	@$(MODPROBE) -l	cmtp
-	@$(MODPROBE) -l	dtl1_cs
-	@$(MODPROBE) -l hidp
-	@$(MODPROBE) -l	hci_vhci
-	@$(MODPROBE) -l	hci_uart
-	@$(MODPROBE) -l l2cap
-	@$(MODPROBE) -l rfcomm
-	@$(MODPROBE) -l sco
-	@echo
 
 btclean:
 	make -C /lib/modules/$(shell uname -r)/build M=$(PWD) BT=TRUE clean
@@ -169,7 +125,7 @@ install-modules: modules
 		modules_install
 	@./scripts/update-initramfs
 
-install-scripts: $(MODPROBE)
+install-scripts:
 	@# All the scripts we can use
 	@mkdir -p $(DESTDIR)/usr/lib/compat-wireless/
 	@install scripts/modlib.sh	$(DESTDIR)/usr/lib/compat-wireless/
@@ -212,109 +168,6 @@ install-scripts: $(MODPROBE)
 	@# Udev stuff needed for the new compat_firmware_class.
 	@./compat/scripts/compat_firmware_install
 	@/sbin/depmod -a
-	@echo
-	@echo "Currently detected wireless subsystem modules:"
-	@echo 
-	@$(MODPROBE) -l mac80211
-	@$(MODPROBE) -l cfg80211
-	@$(MODPROBE) -l lib80211
-	@$(MODPROBE) -l adm8211
-	@$(MODPROBE) -l ar9170usb
-	@$(MODPROBE) -l at76c50x-usb
-	@$(MODPROBE) -l ath
-	@$(MODPROBE) -l ath5k
-	@$(MODPROBE) -l ath6kl
-	@$(MODPROBE) -l ath9k
-	@$(MODPROBE) -l ath9k_htc
-	@$(MODPROBE) -l b43
-	@$(MODPROBE) -l b43legacy
-	@$(MODPROBE) -l b44
-	@$(MODPROBE) -l carl9170
-	@$(MODPROBE) -l brcm80211
-	@$(MODPROBE) -l cdc_ether
-	@$(MODPROBE) -l eeprom_93cx6
-	@$(MODPROBE) -l ipw2100
-	@$(MODPROBE) -l ipw2200
-	@$(MODPROBE) -l iwl3945
-	@$(MODPROBE) -l iwlagn
-	@$(MODPROBE) -l iwlcore
-	@$(MODPROBE) -l iwmc3200wifi
-	@$(MODPROBE) -l lib80211_crypt_ccmp
-	@$(MODPROBE) -l lib80211_crypt_tkip
-	@$(MODPROBE) -l lib80211_crypt_wep
-	@$(MODPROBE) -l libertas
-	@$(MODPROBE) -l libertas_cs
-	@$(MODPROBE) -l libertas_sdio
-	@$(MODPROBE) -l libertas_spi
-	@$(MODPROBE) -l libertas_tf
-	@$(MODPROBE) -l libertas_tf_usb
-	@$(MODPROBE) -l libipw
-	@$(MODPROBE) -l mac80211_hwsim
-	@$(MODPROBE) -l mwl8k
-	@$(MODPROBE) -l orinoco_cs
-	@$(MODPROBE) -l orinoco_nortel
-	@$(MODPROBE) -l orinoco_pci
-	@$(MODPROBE) -l orinoco_plx
-	@$(MODPROBE) -l orinoco_tld
-	@$(MODPROBE) -l orinoco_usb
-	@$(MODPROBE) -l orinoco
-	@$(MODPROBE) -l p54common
-	@$(MODPROBE) -l p54pci
-	@$(MODPROBE) -l p54spi
-	@$(MODPROBE) -l p54usb
-	@$(MODPROBE) -l rndis_host
-	@$(MODPROBE) -l rndis_wlan
-	@$(MODPROBE) -l rt2400pci
-	@$(MODPROBE) -l rt2500pci
-	@$(MODPROBE) -l rt2500usb
-	@$(MODPROBE) -l rt2800pci
-	@$(MODPROBE) -l rt2800usb
-	@$(MODPROBE) -l rt2x00lib
-	@$(MODPROBE) -l rt2x00pci
-	@$(MODPROBE) -l rt2x00usb
-	@$(MODPROBE) -l rt61pci
-	@$(MODPROBE) -l rt73usb
-	@$(MODPROBE) -l rtl8180
-	@$(MODPROBE) -l rtl8187
-	@$(MODPROBE) -l rtlwifi
-	@$(MODPROBE) -l rtl8192ce
-	@$(MODPROBE) -l spectrum_cs
-	@$(MODPROBE) -l ssb
-	@$(MODPROBE) -l usb8xxx
-	@$(MODPROBE) -l usbnet
-	@$(MODPROBE) -l wl1251
-	@$(MODPROBE) -l wl12xx
-	@$(MODPROBE) -l zd1211rw
-	@echo
-	@echo "Currently detected ethernet subsystem modules:"
-	@echo
-	@$(MODPROBE) -l atl1
-	@$(MODPROBE) -l atl2
-	@$(MODPROBE) -l atl1e
-	@$(MODPROBE) -l atl1c
-	@echo
-	@echo "Currently detected bluetooth subsystem modules:"
-	@echo
-	@$(MODPROBE) -l ath3k           
-	@$(MODPROBE) -l bcm203x
-	@$(MODPROBE) -l bluecard_cs
-	@$(MODPROBE) -l bluetooth
-	@$(MODPROBE) -l bnep
-	@$(MODPROBE) -l bpa10x
-	@$(MODPROBE) -l bt3c_cs
-	@$(MODPROBE) -l btmrvl
-	@$(MODPROBE) -l btmrvl_sdio
-	@$(MODPROBE) -l btsdio
-	@$(MODPROBE) -l btusb
-	@$(MODPROBE) -l btuart_cs
-	@$(MODPROBE) -l	cmtp
-	@$(MODPROBE) -l	dtl1_cs
-	@$(MODPROBE) -l hidp
-	@$(MODPROBE) -l	hci_vhci
-	@$(MODPROBE) -l	hci_uart
-	@$(MODPROBE) -l l2cap
-	@$(MODPROBE) -l rfcomm
-	@$(MODPROBE) -l sco
 	@echo 
 	@echo Now run:
 	@echo 
@@ -326,7 +179,7 @@ install-scripts: $(MODPROBE)
 	@echo If unsure reboot.
 	@echo
 
-uninstall: $(MODPROBE)
+uninstall:
 	@# New location, matches upstream
 	@rm -rf $(KLIB)/$(KMODDIR)/compat/
 	@rm -rf $(KLIB)/$(KMODDIR)/net/mac80211/
@@ -343,111 +196,6 @@ uninstall: $(MODPROBE)
 	@rm -f $(KLIB)/$(KMODDIR)/drivers/misc/eeprom_93cx6.ko*
 	@rm -f $(KLIB)/$(KMODDIR)/drivers/net/b44.ko*
 	@/sbin/depmod -a
-	@echo
-	@echo "Your old wireless subsystem modules were left intact:"
-	@echo 
-	@$(MODPROBE) -l mac80211
-	@$(MODPROBE) -l cfg80211
-	@$(MODPROBE) -l lib80211
-	@$(MODPROBE) -l adm8211
-	@$(MODPROBE) -l ar9170usb
-	@$(MODPROBE) -l at76c50x-usb
-	@$(MODPROBE) -l ath
-	@$(MODPROBE) -l ath5k
-	@$(MODPROBE) -l ath6kl
-	@$(MODPROBE) -l ath9k
-	@$(MODPROBE) -l ath9k_htc
-	@$(MODPROBE) -l b43
-	@$(MODPROBE) -l b43legacy
-	@$(MODPROBE) -l b44
-	@$(MODPROBE) -l carl9170
-	@$(MODPROBE) -l brcm80211
-	@$(MODPROBE) -l cdc_ether
-	@$(MODPROBE) -l eeprom_93cx6
-	@$(MODPROBE) -l ipw2100
-	@$(MODPROBE) -l ipw2200
-	@$(MODPROBE) -l iwl3945
-	@$(MODPROBE) -l iwlagn
-	@$(MODPROBE) -l iwlcore
-	@$(MODPROBE) -l iwmc3200wifi
-	@$(MODPROBE) -l lib80211_crypt_ccmp
-	@$(MODPROBE) -l lib80211_crypt_tkip
-	@$(MODPROBE) -l lib80211_crypt_wep
-	@$(MODPROBE) -l libertas
-	@$(MODPROBE) -l libertas_cs
-	@$(MODPROBE) -l libertas_sdio
-	@$(MODPROBE) -l libertas_spi
-	@$(MODPROBE) -l libertas_tf
-	@$(MODPROBE) -l libertas_tf_usb
-	@$(MODPROBE) -l libipw
-	@$(MODPROBE) -l mac80211_hwsim
-	@$(MODPROBE) -l mwl8k
-	@$(MODPROBE) -l orinoco_cs
-	@$(MODPROBE) -l orinoco_nortel
-	@$(MODPROBE) -l orinoco_pci
-	@$(MODPROBE) -l orinoco_plx
-	@$(MODPROBE) -l orinoco_tld
-	@$(MODPROBE) -l orinoco_usb
-	@$(MODPROBE) -l orinoco
-	@$(MODPROBE) -l p54common
-	@$(MODPROBE) -l p54pci
-	@$(MODPROBE) -l p54spi
-	@$(MODPROBE) -l p54usb
-	@$(MODPROBE) -l rndis_host
-	@$(MODPROBE) -l rndis_wlan
-	@$(MODPROBE) -l rt2400pci
-	@$(MODPROBE) -l rt2500pci
-	@$(MODPROBE) -l rt2500usb
-	@$(MODPROBE) -l rt2800pci
-	@$(MODPROBE) -l rt2800usb
-	@$(MODPROBE) -l rt2x00lib
-	@$(MODPROBE) -l rt2x00pci
-	@$(MODPROBE) -l rt2x00usb
-	@$(MODPROBE) -l rt61pci
-	@$(MODPROBE) -l rt73usb
-	@$(MODPROBE) -l rtl8180
-	@$(MODPROBE) -l rtl8187
-	@$(MODPROBE) -l rtlwifi
-	@$(MODPROBE) -l rtl8192ce
-	@$(MODPROBE) -l spectrum_cs
-	@$(MODPROBE) -l ssb
-	@$(MODPROBE) -l usb8xxx
-	@$(MODPROBE) -l usbnet
-	@$(MODPROBE) -l wl1251
-	@$(MODPROBE) -l wl12xx
-	@$(MODPROBE) -l zd1211rw
-	@echo
-	@echo "Your old ethernet subsystem modules are left intact:"
-	@echo
-	@$(MODPROBE) -l atl1
-	@$(MODPROBE) -l atl2
-	@$(MODPROBE) -l atl1e
-	@$(MODPROBE) -l atl1c
-	@echo
-	@echo "Your old bluetooth subsystem modules were left intact:"
-	@echo
-	@$(MODPROBE) -l ath3k           
-	@$(MODPROBE) -l bcm203x
-	@$(MODPROBE) -l bluecard_cs
-	@$(MODPROBE) -l bluetooth
-	@$(MODPROBE) -l bnep
-	@$(MODPROBE) -l bpa10x
-	@$(MODPROBE) -l bt3c_cs
-	@$(MODPROBE) -l btmrvl
-	@$(MODPROBE) -l btmrvl_sdio
-	@$(MODPROBE) -l btsdio
-	@$(MODPROBE) -l btusb
-	@$(MODPROBE) -l btuart_cs
-	@$(MODPROBE) -l	cmtp
-	@$(MODPROBE) -l	dtl1_cs
-	@$(MODPROBE) -l hidp
-	@$(MODPROBE) -l	hci_vhci
-	@$(MODPROBE) -l	hci_uart
-	@$(MODPROBE) -l l2cap
-	@$(MODPROBE) -l rfcomm
-	@$(MODPROBE) -l sco
-	@
-	@echo 
 
 clean:
 	@if [ -d net -a -d $(KLIB_BUILD) ]; then \
Signature · 1 line
1.7.3.4
#2 lore raw

Re: [PATCH 2/2] cleanup modprobe calls

Quoted 5 lines · Rick Farina

There were a lot of needless calls to "modprobe -l <drivername>" and even more confusingly $(MODPROBE). None of this is needed on a modern distro, and it errors on when modprobe -l is removed (such as KMOD in Arch Linux)

---

I agree with this. The modprobes are just there in order to list which of the relevant modules you have in your system. There is little value in this and, if considered really necessary, there surely must be other ways to find out?

Signature · 2 lines
Cheers,
Luca.
#3 lore raw

Re: [PATCH 2/2] cleanup modprobe calls

Quoted 11 lines · Luciano Coelho
Quoted 5 lines · Rick Farina

There were a lot of needless calls to "modprobe -l <drivername>" and even more confusingly $(MODPROBE). None of this is needed on a modern distro, and it errors on when modprobe -l is removed (such as KMOD in Arch Linux)

---

I agree with this. The modprobes are just there in order to list which of the relevant modules you have in your system. There is little value in this and, if considered really necessary, there surely must be other ways to find out?

Although I've never liked all this scrolling, I would have recoded it rather than removed it if I knew how. At the present time there is no way which I know to replicate this functionality. I suppose a find statement could be added but honestly I just don't see it as necessary, or any cleaner.

thanks,
Rick Farina

#4 lore raw

Re: [PATCH 2/2] cleanup modprobe calls

Quoted 12 lines · Richard Farina
Quoted 11 lines · Luciano Coelho
Quoted 5 lines · Rick Farina

There were a lot of needless calls to "modprobe -l <drivername>" and even more confusingly $(MODPROBE). None of this is needed on a modern distro, and it errors on when modprobe -l is removed (such as KMOD in Arch Linux)

---

I agree with this. The modprobes are just there in order to list which of the relevant modules you have in your system. There is little value in this and, if considered really necessary, there surely must be other ways to find out?

Quoted 5 lines

Although I've never liked all this scrolling, I would have recoded it rather than removed it if I knew how. At the present time there is no way which I know to replicate this functionality. I suppose a find statement could be added but honestly I just don't see it as necessary, or any cleaner.

Well, at least we should use something else then $(MODPROBE) -l. It would be nice to make it more generic. "-l" is a modprobe specific option, maybe it could be moved to the variable itself so it could be changed for another command with the same effect? Maybe change it to $(FINDMODULE) and assign it to "modprobe -l" by default?

Signature · 2 lines
Cheers,
Luca.
#5 lore raw

Re: [PATCH 2/2] cleanup modprobe calls

Quoted 18 lines · Luciano Coelho
Quoted 12 lines · Richard Farina
Quoted 11 lines · Luciano Coelho
Quoted 5 lines · Rick Farina

There were a lot of needless calls to "modprobe -l <drivername>" and even more confusingly $(MODPROBE). None of this is needed on a modern distro, and it errors on when modprobe -l is removed (such as KMOD in Arch Linux)

---

I agree with this. The modprobes are just there in order to list which of the relevant modules you have in your system. There is little value in this and, if considered really necessary, there surely must be other ways to find out?

Quoted 5 lines

Although I've never liked all this scrolling, I would have recoded it rather than removed it if I knew how. At the present time there is no way which I know to replicate this functionality. I suppose a find statement could be added but honestly I just don't see it as necessary, or any cleaner.

Quoted 5 lines

Well, at least we should use something else then $(MODPROBE) -l. It would be nice to make it more generic. "-l" is a modprobe specific option, maybe it could be moved to the variable itself so it could be changed for another command with the same effect? Maybe change it to $(FINDMODULE) and assign it to "modprobe -l" by default?

I still don't think all that output has any use at all, but if you find a way to replicate the behavior of modprobe -l you are certainly welcome to use that in place of one or both of my patches. The command run in patch 1 is the closest I was able to come to replicating modprobe -l and the output is huge (hence the > /dev/null) so I just read the exit code.

The patchset I sent is one possible solution, and in my eyes the cleanest one. Please feel free to push these fixes, use my patches as a base for a changeset of your own, or completely ignore my patches and solve the issue completely as you see fit :-) I take no offense in any of these cases, but I lack the ability to (even remotely) cleanly replicate the modprobe -l functionality so I simply removed all the (useless in my eyes) print statements.

Thanks,
Rick Farina