diff mbox series

wifi: rtl8xxxu: use module_usb_driver

Message ID 20230307195718.168021-1-martin@kaiser.cx (mailing list archive)
State Accepted
Commit 0606b344021a37140ef467ddf30d4b8182e7bbe1
Delegated to: Kalle Valo
Headers show
Series wifi: rtl8xxxu: use module_usb_driver | expand

Commit Message

Martin Kaiser March 7, 2023, 7:57 p.m. UTC
We can use the module_usb_driver macro instead of open-coding the driver's
init and exit functions. This is simpler and saves some lines of code.
Other realtek wireless drivers use module_usb_driver as well.

Signed-off-by: Martin Kaiser <martin@kaiser.cx>
---
 .../wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 20 +------------------
 1 file changed, 1 insertion(+), 19 deletions(-)

Comments

Ping-Ke Shih March 8, 2023, 6:21 a.m. UTC | #1
> -----Original Message-----
> From: Martin Kaiser <martin@kaiser.cx>
> Sent: Wednesday, March 8, 2023 3:57 AM
> To: Jes Sorensen <Jes.Sorensen@gmail.com>; Kalle Valo <kvalo@kernel.org>; David S. Miller
> <davem@davemloft.net>; Eric Dumazet <edumazet@google.com>; Jakub Kicinski <kuba@kernel.org>; Paolo Abeni
> <pabeni@redhat.com>
> Cc: Martin Kaiser <martin@kaiser.cx>; linux-wireless@vger.kernel.org; netdev@vger.kernel.org;
> linux-kernel@vger.kernel.org
> Subject: [PATCH] wifi: rtl8xxxu: use module_usb_driver
> 
> We can use the module_usb_driver macro instead of open-coding the driver's
> init and exit functions. This is simpler and saves some lines of code.
> Other realtek wireless drivers use module_usb_driver as well.
> 
> Signed-off-by: Martin Kaiser <martin@kaiser.cx>

Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>


> ---
>  .../wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 20 +------------------
>  1 file changed, 1 insertion(+), 19 deletions(-)
> 
> diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
> b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
> index e619ed21fbfe..58dbad9a14c2 100644
> --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
> +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
> @@ -7455,24 +7455,6 @@ static struct usb_driver rtl8xxxu_driver = {
>         .disable_hub_initiated_lpm = 1,
>  };
> 
> -static int __init rtl8xxxu_module_init(void)
> -{
> -       int res;
> -
> -       res = usb_register(&rtl8xxxu_driver);
> -       if (res < 0)
> -               pr_err(DRIVER_NAME ": usb_register() failed (%i)\n", res);
> -
> -       return res;
> -}
> -
> -static void __exit rtl8xxxu_module_exit(void)
> -{
> -       usb_deregister(&rtl8xxxu_driver);
> -}
> -
> -
>  MODULE_DEVICE_TABLE(usb, dev_table);
> 
> -module_init(rtl8xxxu_module_init);
> -module_exit(rtl8xxxu_module_exit);
> +module_usb_driver(rtl8xxxu_driver);
> --
> 2.30.2
Philipp Hortmann March 8, 2023, 11:05 p.m. UTC | #2
On Tue, Mar 07, 2023 at 08:57:17PM +0100, Martin Kaiser wrote:
> We can use the module_usb_driver macro instead of open-coding the driver's
> init and exit functions. This is simpler and saves some lines of code.
> Other realtek wireless drivers use module_usb_driver as well.
> 
> Signed-off-by: Martin Kaiser <martin@kaiser.cx>
> ---
>  .../wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 20 +------------------
>  1 file changed, 1 insertion(+), 19 deletions(-)
> 
> diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
> index e619ed21fbfe..58dbad9a14c2 100644
> --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
> +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
> @@ -7455,24 +7455,6 @@ static struct usb_driver rtl8xxxu_driver = {
>  	.disable_hub_initiated_lpm = 1,
>  };
>  
> -static int __init rtl8xxxu_module_init(void)
> -{
> -	int res;
> -
> -	res = usb_register(&rtl8xxxu_driver);
> -	if (res < 0)
> -		pr_err(DRIVER_NAME ": usb_register() failed (%i)\n", res);
> -
> -	return res;
> -}
> -
> -static void __exit rtl8xxxu_module_exit(void)
> -{
> -	usb_deregister(&rtl8xxxu_driver);
> -}
> -
> -
>  MODULE_DEVICE_TABLE(usb, dev_table);
>  
> -module_init(rtl8xxxu_module_init);
> -module_exit(rtl8xxxu_module_exit);
> +module_usb_driver(rtl8xxxu_driver);
> -- 
> 2.30.2

Tested-by: Philipp Hortmann <philipp.g.hortmann@gmail.com> # Edimax N150
Kalle Valo March 13, 2023, 1:44 p.m. UTC | #3
Martin Kaiser <martin@kaiser.cx> wrote:

> We can use the module_usb_driver macro instead of open-coding the driver's
> init and exit functions. This is simpler and saves some lines of code.
> Other realtek wireless drivers use module_usb_driver as well.
> 
> Signed-off-by: Martin Kaiser <martin@kaiser.cx>
> Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>
> Tested-by: Philipp Hortmann <philipp.g.hortmann@gmail.com> # Edimax N150

Patch applied to wireless-next.git, thanks.

0606b344021a wifi: rtl8xxxu: use module_usb_driver
diff mbox series

Patch

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index e619ed21fbfe..58dbad9a14c2 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -7455,24 +7455,6 @@  static struct usb_driver rtl8xxxu_driver = {
 	.disable_hub_initiated_lpm = 1,
 };
 
-static int __init rtl8xxxu_module_init(void)
-{
-	int res;
-
-	res = usb_register(&rtl8xxxu_driver);
-	if (res < 0)
-		pr_err(DRIVER_NAME ": usb_register() failed (%i)\n", res);
-
-	return res;
-}
-
-static void __exit rtl8xxxu_module_exit(void)
-{
-	usb_deregister(&rtl8xxxu_driver);
-}
-
-
 MODULE_DEVICE_TABLE(usb, dev_table);
 
-module_init(rtl8xxxu_module_init);
-module_exit(rtl8xxxu_module_exit);
+module_usb_driver(rtl8xxxu_driver);