Subject: Re: [PATCH RFC 26/28] dsa: Convert mv88e6xxx into a library allowing driver modules

From: Florian Fainelli <[email-masked]>
Date: Fri, 25 Dec 2015 13:47:55 -0800

Le 23/12/2015 04:56, Andrew Lunn a écrit :
> Turn mv88e6xxx into a library module, by exporting its symbols.  Have
> each driver register their own driver functions with the DSA core in
> there init function.
> 
> This results in each driver being a loadable module.
> 
> Signed-off-by: Andrew Lunn <[email-masked]>
> ---

[snip]

> +obj-$(CONFIG_NET_DSA_MV88E6XXX) += mv88e6xxx.o
> +obj-$(CONFIGNET_DSA_MV88E6131)  += mv88e6123.o

Missing underscore here between CONFIG and NET.

> +obj-$(CONFIG_NET_DSA_MV88E6131) += mv88e6131.o
> +obj-$(CONFIG_NET_DSA_MV88E6352) += mv88e6352.o
> +obj-$(CONFIG_NET_DSA_MV88E6171) += mv88e6171.o
>  obj-$(CONFIG_NET_DSA_BCM_SF2)	+= bcm_sf2.o
> diff --git a/drivers/net/dsa/mv88e6123.c b/drivers/net/dsa/mv88e6123.c
> index bb39720f3e8b..9680e59fd2ae 100644
> --- a/drivers/net/dsa/mv88e6123.c
> +++ b/drivers/net/dsa/mv88e6123.c
> @@ -167,7 +167,21 @@ static struct platform_driver mv88e6123_driver = {
>  		.of_match_table = mv88e6123_of_match,
>  	},
>  };
> -module_platform_driver(mv88e6123_driver);
>  
> +static int __init mv88e6123_init(void)
> +{
> +	register_switch_driver(&mv88e6123_switch_driver);
> +
> +	return platform_driver_register(&mv88e6123_driver);
> +}
> +
> +static void __exit mv88e6123_exit(void)
> +{
> +	platform_driver_unregister(&mv88e6123_driver);
> +	unregister_switch_driver(&mv88e6123_switch_driver);
> +}

I think Vivien had started something like this, but it could be nice to
have a helper function/macro which reduces the boilerplate code, not
critical for now though.
-- 
Florian