netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 1/1] net: phylink: Add module_exit()
@ 2023-11-27 10:16 Gan Yi Fang
  2023-11-27 10:27 ` Russell King (Oracle)
  2023-11-27 13:01 ` Alexander Lobakin
  0 siblings, 2 replies; 3+ messages in thread
From: Gan Yi Fang @ 2023-11-27 10:16 UTC (permalink / raw)
  To: Russell King, Andrew Lunn, Heiner Kallweit, David S . Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Marek Behún,
	netdev, linux-kernel
  Cc: Looi Hong Aun, Voon Weifeng, Song Yoong Siang, Gan Yi Fang,
	Lai Peter Jun Ann

From: "Gan, Yi Fang" <yi.fang.gan@intel.com>

In free_module(), if mod->init callback is defined but mod->exit callback
is not defined, it will assume the module cannot be removed and return
EBUSY. The module_exit() is missing from current phylink module drive
causing failure while unloading it.

This patch introduces phylink_exit() for phylink module removal.

Fixes: eca68a3c7d05 ("net: phylink: pass supported host PHY interface modes to phylib for SFP's PHYs")
Cc: <stable@vger.kernel.org> # 6.1+
Signed-off-by: Lai Peter Jun Ann <jun.ann.lai@intel.com>
Signed-off-by: Gan, Yi Fang <yi.fang.gan@intel.com>
---
 drivers/net/phy/phylink.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 25c19496a336..7121503c9259 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -3724,7 +3724,10 @@ static int __init phylink_init(void)
 	return 0;
 }
 
+static void __exit phylink_exit(void){}
+
 module_init(phylink_init);
+module_exit(phylink_exit);
 
 MODULE_LICENSE("GPL v2");
 MODULE_DESCRIPTION("phylink models the MAC to optional PHY connection");
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net 1/1] net: phylink: Add module_exit()
  2023-11-27 10:16 [PATCH net 1/1] net: phylink: Add module_exit() Gan Yi Fang
@ 2023-11-27 10:27 ` Russell King (Oracle)
  2023-11-27 13:01 ` Alexander Lobakin
  1 sibling, 0 replies; 3+ messages in thread
From: Russell King (Oracle) @ 2023-11-27 10:27 UTC (permalink / raw)
  To: Gan Yi Fang
  Cc: Andrew Lunn, Heiner Kallweit, David S . Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Marek Behún, netdev,
	linux-kernel, Looi Hong Aun, Voon Weifeng, Song Yoong Siang,
	Lai Peter Jun Ann

On Mon, Nov 27, 2023 at 06:16:03PM +0800, Gan Yi Fang wrote:
> diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
> index 25c19496a336..7121503c9259 100644
> --- a/drivers/net/phy/phylink.c
> +++ b/drivers/net/phy/phylink.c
> @@ -3724,7 +3724,10 @@ static int __init phylink_init(void)
>  	return 0;
>  }
>  
> +static void __exit phylink_exit(void){}

Please format that as:

static void __exit phylink_exit(void)
{
}

and move it _after_ module_init().

Thanks.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net 1/1] net: phylink: Add module_exit()
  2023-11-27 10:16 [PATCH net 1/1] net: phylink: Add module_exit() Gan Yi Fang
  2023-11-27 10:27 ` Russell King (Oracle)
@ 2023-11-27 13:01 ` Alexander Lobakin
  1 sibling, 0 replies; 3+ messages in thread
From: Alexander Lobakin @ 2023-11-27 13:01 UTC (permalink / raw)
  To: Gan Yi Fang
  Cc: Looi Hong Aun, Voon Weifeng, Song Yoong Siang, Lai Peter Jun Ann,
	Russell King, Andrew Lunn, Heiner Kallweit, David S . Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Marek Behún,
	netdev, linux-kernel

From: Gan Yi Fang <yi.fang.gan@intel.com>
Date: Mon, 27 Nov 2023 18:16:03 +0800

> From: "Gan, Yi Fang" <yi.fang.gan@intel.com>

Please fix your Git vs mail client settings, so that your own patches
won't contain "From:" with your own name.
I'd suggest using "Gan Yi Fang", as that Intel's versions with commas
(,) aren't optimal for mailing lists and development.

> 
> In free_module(), if mod->init callback is defined but mod->exit callback
> is not defined, it will assume the module cannot be removed and return
> EBUSY. The module_exit() is missing from current phylink module drive
> causing failure while unloading it.
> 
> This patch introduces phylink_exit() for phylink module removal.
> 
> Fixes: eca68a3c7d05 ("net: phylink: pass supported host PHY interface modes to phylib for SFP's PHYs")
> Cc: <stable@vger.kernel.org> # 6.1+
> Signed-off-by: Lai Peter Jun Ann <jun.ann.lai@intel.com>
> Signed-off-by: Gan, Yi Fang <yi.fang.gan@intel.com>
> ---
>  drivers/net/phy/phylink.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
> index 25c19496a336..7121503c9259 100644
> --- a/drivers/net/phy/phylink.c
> +++ b/drivers/net/phy/phylink.c
> @@ -3724,7 +3724,10 @@ static int __init phylink_init(void)
>  	return 0;
>  }
>  
> +static void __exit phylink_exit(void){}
> +
>  module_init(phylink_init);
> +module_exit(phylink_exit);

This pattern (empty __exit function + module_exit()) is +/- common in
the kernel. How about making a macro from it, just like it's done with
e.g. module_platform_driver() etc.?
So that you could just add to phylink.c something like:

module_exit_stub(phylink);

>  
>  MODULE_LICENSE("GPL v2");
>  MODULE_DESCRIPTION("phylink models the MAC to optional PHY connection");

Thanks,
Olek

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-11-27 13:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-27 10:16 [PATCH net 1/1] net: phylink: Add module_exit() Gan Yi Fang
2023-11-27 10:27 ` Russell King (Oracle)
2023-11-27 13:01 ` Alexander Lobakin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).