* [PATCH] net/at91_ether: fix loading when macb is compiled as a module
@ 2014-11-16 18:05 Gilles Chanteperdrix
2014-11-16 18:53 ` David Miller
0 siblings, 1 reply; 3+ messages in thread
From: Gilles Chanteperdrix @ 2014-11-16 18:05 UTC (permalink / raw)
To: Nicolas Ferre, netdev; +Cc: Gilles Chanteperdrix
The at91_ether driver depends on symbols defined in the macb driver.
Currently, when compiling both at91_ether and macb as module, starting
the at91_ether module fails, because the macb module can not be loaded
with a macb interface.
Avoid this issue by getting the macb module initialization routine to
always return 0, even when no macb device is detected.
Signed-off-by: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
---
drivers/net/ethernet/cadence/macb.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
index 4d9fc05..f70228c 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -2327,7 +2327,20 @@ static struct platform_driver macb_driver = {
},
};
-module_platform_driver_probe(macb_driver, macb_probe);
+static bool found;
+static int __init macb_driver_init(void)
+{
+ found = platform_driver_probe(&macb_driver, macb_probe) == 0;
+ return 0;
+}
+module_init(macb_driver_init);
+
+static void __exit macb_driver_exit(void)
+{
+ if (found)
+ platform_driver_unregister(&macb_driver);
+}
+module_exit(macb_driver_exit);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Cadence MACB/GEM Ethernet driver");
--
1.7.10.4
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] net/at91_ether: fix loading when macb is compiled as a module
2014-11-16 18:05 [PATCH] net/at91_ether: fix loading when macb is compiled as a module Gilles Chanteperdrix
@ 2014-11-16 18:53 ` David Miller
2014-11-16 20:32 ` Gilles Chanteperdrix
0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2014-11-16 18:53 UTC (permalink / raw)
To: gilles.chanteperdrix; +Cc: nicolas.ferre, netdev
From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
Date: Sun, 16 Nov 2014 19:05:06 +0100
> The at91_ether driver depends on symbols defined in the macb driver.
>
> Currently, when compiling both at91_ether and macb as module, starting
> the at91_ether module fails, because the macb module can not be loaded
> with a macb interface.
>
> Avoid this issue by getting the macb module initialization routine to
> always return 0, even when no macb device is detected.
>
> Signed-off-by: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
This is not acceptable, sorry.
This means the module stays in memory even if nobody has a real use
for it.
You'll need to find another solution, and I'll say in passing that this
was very poorly designed and that's why the problem exists.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] net/at91_ether: fix loading when macb is compiled as a module
2014-11-16 18:53 ` David Miller
@ 2014-11-16 20:32 ` Gilles Chanteperdrix
0 siblings, 0 replies; 3+ messages in thread
From: Gilles Chanteperdrix @ 2014-11-16 20:32 UTC (permalink / raw)
To: David Miller; +Cc: nicolas.ferre, netdev
On Sun, Nov 16, 2014 at 01:53:02PM -0500, David Miller wrote:
> From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
> Date: Sun, 16 Nov 2014 19:05:06 +0100
>
> > The at91_ether driver depends on symbols defined in the macb driver.
> >
> > Currently, when compiling both at91_ether and macb as module, starting
> > the at91_ether module fails, because the macb module can not be loaded
> > with a macb interface.
> >
> > Avoid this issue by getting the macb module initialization routine to
> > always return 0, even when no macb device is detected.
> >
> > Signed-off-by: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
>
> This is not acceptable, sorry.
>
> This means the module stays in memory even if nobody has a real use
> for it.
>
> You'll need to find another solution, and I'll say in passing that this
> was very poorly designed and that's why the problem exists.
>
Ok, I see multiple possible other fixes:
- inline the shared functions in the macb.h driver or move them to a
library, this effectively means duplication, but who is going to
enable both drivers anyway?
- when both drivers are compiled as module, make one module
containing both drivers say at91+macb.ko
- modify the code I posted so that it only keeps the macb driver
loaded without macb device if IS_ENABLED(CONFIG_ARM_AT91_ETHER)
and probably many others I do not see.
I just do not know which one you would find acceptable.
Regards.
--
Gilles.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-11-16 20:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-16 18:05 [PATCH] net/at91_ether: fix loading when macb is compiled as a module Gilles Chanteperdrix
2014-11-16 18:53 ` David Miller
2014-11-16 20:32 ` Gilles Chanteperdrix
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox