Skip to contentSkip to conversation

wifi: ath9k_htc: use module_usb_driver

PATCH In review Rosen Penev 3 participants 4 messages Aug 26, 2023 – Sep 4, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 wifi: ath9k_htc: use module_usb_driver

This follows the pattern with other USB Wifi drivers. There is nothing special being done in the _init and _exit functions here. Simplifies and saves some lines of code.

---
 drivers/net/wireless/ath/ath9k/hif_usb.c      | 10 ----------
 drivers/net/wireless/ath/ath9k/hif_usb.h      |  2 --
 drivers/net/wireless/ath/ath9k/htc_drv_init.c | 18 +-----------------
 3 files changed, 1 insertion(+), 29 deletions(-)
drivers/net/wireless/ath/ath9k/hif_usb.c +0 -10
index 27ff1ca2631f..e261e4258f0a 100644
@@ -1535,13 +1535,3 @@ static struct usb_driver ath9k_hif_usb_driver = {
 	.soft_unbind = 1,
 	.disable_hub_initiated_lpm = 1,
 };
-
-int ath9k_hif_usb_init(void)
-{
-	return usb_register(&ath9k_hif_usb_driver);
-}
-
-void ath9k_hif_usb_exit(void)
-{
-	usb_deregister(&ath9k_hif_usb_driver);
-}
drivers/net/wireless/ath/ath9k/hif_usb.h +0 -2
index 5985aa15ca93..6a7da71c9da6 100644
@@ -136,8 +136,6 @@ struct hif_device_usb {
 	u8 flags; /* HIF_USB_* */
 };
 
-int ath9k_hif_usb_init(void);
-void ath9k_hif_usb_exit(void);
 void ath9k_hif_usb_dealloc_urbs(struct hif_device_usb *hif_dev);
 
 #endif /* HTC_USB_H */
drivers/net/wireless/ath/ath9k/htc_drv_init.c +1 -17
index dae3d9c7b640..beaaa31f32a5 100644
@@ -1018,20 +1018,4 @@ int ath9k_htc_resume(struct htc_target *htc_handle)
 }
 #endif
 
-static int __init ath9k_htc_init(void)
-{
-	if (ath9k_hif_usb_init() < 0) {
-		pr_err("No USB devices found, driver not installed\n");
-		return -ENODEV;
-	}
-
-	return 0;
-}
-module_init(ath9k_htc_init);
-
-static void __exit ath9k_htc_exit(void)
-{
-	ath9k_hif_usb_exit();
-	pr_info("Driver unloaded\n");
-}
-module_exit(ath9k_htc_exit);
+module_usb_driver(ath9k_hif_usb_driver)
Signature · 1 line
2.41.0
#1 lore raw

PATCH 2/2 wifi: purelifi: use module_usb_driver

This follows the pattern with other USB Wifi drivers. There is nothing special being done in the _init and _exit functions here. Simplifies and saves some lines of code.

---
 drivers/net/wireless/purelifi/plfxlc/usb.c | 23 +---------------------
 1 file changed, 1 insertion(+), 22 deletions(-)
drivers/net/wireless/purelifi/plfxlc/usb.c +1 -22
index 76d0a778636a..b4bb32911d9f 100644
@@ -861,26 +861,6 @@ static struct usb_driver driver = {
 	.disable_hub_initiated_lpm = 1,
 };
 
-static int __init usb_init(void)
-{
-	int r;
-
-	r = usb_register(&driver);
-	if (r) {
-		pr_err("%s usb_register() failed %d\n", driver.name, r);
-		return r;
-	}
-
-	pr_debug("Driver initialized :%s\n", driver.name);
-	return 0;
-}
-
-static void __exit usb_exit(void)
-{
-	usb_deregister(&driver);
-	pr_debug("%s %s\n", driver.name, __func__);
-}
-
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("USB driver for pureLiFi devices");
 MODULE_AUTHOR("pureLiFi");
@@ -888,5 +868,4 @@ MODULE_VERSION("1.0");
 MODULE_FIRMWARE("plfxlc/lifi-x.bin");
 MODULE_DEVICE_TABLE(usb, usb_ids);
 
-module_init(usb_init);
-module_exit(usb_exit);
+module_usb_driver(driver);
Signature · 1 line
2.41.0
#2 lore raw

Re: [2/2] wifi: plfxlc: use module_usb_driver()

Quoted 5 lines · Rosen Penev

This follows the pattern with other USB Wifi drivers. There is nothing special being done in the _init and _exit functions here. Simplifies and saves some lines of code.

Fails to compile:

In file included from ./include/linux/device.h:32,
from drivers/net/wireless/purelifi/plfxlc/usb.c:8:
drivers/net/wireless/purelifi/plfxlc/usb.c:871:19: error: conflicting types for 'driver_init'; have 'int(void)'

  871 | module_usb_driver(driver);
      |                   ^~~~~~
./include/linux/device/driver.h:258:19: note: in definition of macro 'module_driver'
  258 | static int __init __driver##_init(void) \
      |                   ^~~~~~~~
drivers/net/wireless/purelifi/plfxlc/usb.c:871:1: note: in expansion of macro 'module_usb_driver'
  871 | module_usb_driver(driver);
      | ^~~~~~~~~~~~~~~~~
./include/linux/device/driver.h:241:6: note: previous declaration of 'driver_init' with type 'void(void)'
  241 | void driver_init(void);
      |      ^~~~~~~~~~~

make[7]: *** [scripts/Makefile.build:243: drivers/net/wireless/purelifi/plfxlc/usb.o] Error 1 make[6]: *** [scripts/Makefile.build:480: drivers/net/wireless/purelifi/plfxlc] Error 2 make[5]: *** [scripts/Makefile.build:480: drivers/net/wireless/purelifi] Error 2 make[4]: *** [scripts/Makefile.build:480: drivers/net/wireless] Error 2
make[3]: *** [scripts/Makefile.build:480: drivers/net] Error 2
make[2]: *** [scripts/Makefile.build:480: drivers] Error 2
make[1]: *** [/home/kvalo/projects/personal/wireless-drivers/src/wireless-next/Makefile:2032: .] Error 2
make: *** [Makefile:234: __sub-make] Error 2

Patch set to Changes Requested.

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#3 lore raw
In reply to Rosen Penev
kernel test robot noticed the following build warnings:

Hi Rosen,

kernel test robot noticed the following build warnings:

[auto build test WARNING on kvalo-ath/ath-next]
[also build test WARNING on wireless-next/main wireless/main linus/master v6.5-rc7 next-20230825] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Rosen-Penev/wifi-purelifi-use-module_usb_driver/20230827-041155
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git ath-next
patch link:    https://lore.kernel.org/r/20230826200929.9756-1-rosenp%40gmail.com
patch subject: [PATCH 1/2] wifi: ath9k_htc: use module_usb_driver
config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20230827/[email protected]/config)
compiler: m68k-linux-gcc (GCC) 13.2.0
reproduce: (https://download.01.org/0day-ci/archive/20230827/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> drivers/net/wireless/ath/ath9k/hif_usb.c:1525:26: warning: 'ath9k_hif_usb_driver' defined but not used [-Wunused-variable]
    1525 | static struct usb_driver ath9k_hif_usb_driver = {
         |                          ^~~~~~~~~~~~~~~~~~~~

vim +/ath9k_hif_usb_driver +1525 drivers/net/wireless/ath/ath9k/hif_usb.c

fb9987d0f748c9 Sujith 2010-03-17 1524
fb9987d0f748c9 Sujith 2010-03-17 @1525 static struct usb_driver ath9k_hif_usb_driver = {

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki