diff mbox series

[net-next,v6,05/13] net: dsa: realtek: convert subdrivers into modules

Message ID 20220128060509.13800-6-luizluca@gmail.com (mailing list archive)
State Accepted
Commit 765c39a4fafe6f7ea0d370aa5f30c811579cf8eb
Delegated to: Netdev Maintainers
Headers show
Series net: dsa: realtek: MDIO interface and RTL8367S,RTL8367RB-VB | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch warning WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? WARNING: please write a help paragraph that fully describes the config symbol
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Luiz Angelo Daros de Luca Jan. 28, 2022, 6:05 a.m. UTC
Preparing for multiple interfaces support, the drivers
must be independent of realtek-smi.

Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
Tested-by: Arınç ÜNAL <arinc.unal@arinc9.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Alvin Šipraga <alsi@bang-olufsen.dk>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/dsa/realtek/Kconfig               | 20 +++++++++++++++++--
 drivers/net/dsa/realtek/Makefile              |  4 +++-
 .../{realtek-smi-core.c => realtek-smi.c}     |  6 ++++++
 drivers/net/dsa/realtek/rtl8365mb.c           |  4 ++++
 .../dsa/realtek/{rtl8366.c => rtl8366-core.c} |  0
 drivers/net/dsa/realtek/rtl8366rb.c           |  4 ++++
 6 files changed, 35 insertions(+), 3 deletions(-)
 rename drivers/net/dsa/realtek/{realtek-smi-core.c => realtek-smi.c} (97%)
 rename drivers/net/dsa/realtek/{rtl8366.c => rtl8366-core.c} (100%)

Comments

Jakub Kicinski Feb. 4, 2022, 1:58 a.m. UTC | #1
On Fri, 28 Jan 2022 03:05:01 -0300 Luiz Angelo Daros de Luca wrote:
> diff --git a/drivers/net/dsa/realtek/Kconfig b/drivers/net/dsa/realtek/Kconfig
> index 1c62212fb0ec..cd1aa95b7bf0 100644
> --- a/drivers/net/dsa/realtek/Kconfig
> +++ b/drivers/net/dsa/realtek/Kconfig
> @@ -2,8 +2,6 @@
>  menuconfig NET_DSA_REALTEK
>  	tristate "Realtek Ethernet switch family support"
>  	depends on NET_DSA
> -	select NET_DSA_TAG_RTL4_A
> -	select NET_DSA_TAG_RTL8_4
>  	select FIXED_PHY
>  	select IRQ_DOMAIN
>  	select REALTEK_PHY
> @@ -18,3 +16,21 @@ config NET_DSA_REALTEK_SMI
>  	help
>  	  Select to enable support for registering switches connected
>  	  through SMI.
> +
> +config NET_DSA_REALTEK_RTL8365MB
> +	tristate "Realtek RTL8365MB switch subdriver"
> +	default y
> +	depends on NET_DSA_REALTEK
> +	depends on NET_DSA_REALTEK_SMI
> +	select NET_DSA_TAG_RTL8_4
> +	help
> +	  Select to enable support for Realtek RTL8365MB
> +
> +config NET_DSA_REALTEK_RTL8366RB
> +	tristate "Realtek RTL8366RB switch subdriver"
> +	default y
> +	depends on NET_DSA_REALTEK
> +	depends on NET_DSA_REALTEK_SMI
> +	select NET_DSA_TAG_RTL4_A
> +	help
> +	  Select to enable support for Realtek RTL8366RB

Why did all these new config options grow a 'default y'? Our usual
policy is to default drivers to disabled.
Arınç ÜNAL Feb. 4, 2022, 7:57 a.m. UTC | #2
On 04/02/2022 04:58, Jakub Kicinski wrote:
> On Fri, 28 Jan 2022 03:05:01 -0300 Luiz Angelo Daros de Luca wrote:
>> diff --git a/drivers/net/dsa/realtek/Kconfig b/drivers/net/dsa/realtek/Kconfig
>> index 1c62212fb0ec..cd1aa95b7bf0 100644
>> --- a/drivers/net/dsa/realtek/Kconfig
>> +++ b/drivers/net/dsa/realtek/Kconfig
>> @@ -2,8 +2,6 @@
>>   menuconfig NET_DSA_REALTEK
>>   	tristate "Realtek Ethernet switch family support"
>>   	depends on NET_DSA
>> -	select NET_DSA_TAG_RTL4_A
>> -	select NET_DSA_TAG_RTL8_4
>>   	select FIXED_PHY
>>   	select IRQ_DOMAIN
>>   	select REALTEK_PHY
>> @@ -18,3 +16,21 @@ config NET_DSA_REALTEK_SMI
>>   	help
>>   	  Select to enable support for registering switches connected
>>   	  through SMI.
>> +
>> +config NET_DSA_REALTEK_RTL8365MB
>> +	tristate "Realtek RTL8365MB switch subdriver"
>> +	default y
>> +	depends on NET_DSA_REALTEK
>> +	depends on NET_DSA_REALTEK_SMI
>> +	select NET_DSA_TAG_RTL8_4
>> +	help
>> +	  Select to enable support for Realtek RTL8365MB
>> +
>> +config NET_DSA_REALTEK_RTL8366RB
>> +	tristate "Realtek RTL8366RB switch subdriver"
>> +	default y
>> +	depends on NET_DSA_REALTEK
>> +	depends on NET_DSA_REALTEK_SMI
>> +	select NET_DSA_TAG_RTL4_A
>> +	help
>> +	  Select to enable support for Realtek RTL8366RB
> 
> Why did all these new config options grow a 'default y'? Our usual
> policy is to default drivers to disabled.

NET_DSA_REALTEK_SMI and NET_DSA_REALTEK_MDIO also have got "default y".

Respectively:
319a70a5fea9 ("net: dsa: realtek-smi: move to subdirectory")
aac94001067d ("net: dsa: realtek: add new mdio interface for drivers")

https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/diff/drivers/net/dsa/realtek/Kconfig?id=319a70a5fea9590e9431dd57f56191996c4787f4

https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/diff/drivers/net/dsa/realtek/Kconfig?id=aac94001067da183455d6d37959892744fa01d9d
Jakub Kicinski Feb. 4, 2022, 3:53 p.m. UTC | #3
On Fri, 4 Feb 2022 10:57:22 +0300 Arınç ÜNAL wrote:
> > Why did all these new config options grow a 'default y'? Our usual
> > policy is to default drivers to disabled.  
> 
> NET_DSA_REALTEK_SMI and NET_DSA_REALTEK_MDIO also have got "default y".
> 
> Respectively:
> 319a70a5fea9 ("net: dsa: realtek-smi: move to subdirectory")
> aac94001067d ("net: dsa: realtek: add new mdio interface for drivers")
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/diff/drivers/net/dsa/realtek/Kconfig?id=319a70a5fea9590e9431dd57f56191996c4787f4
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/diff/drivers/net/dsa/realtek/Kconfig?id=aac94001067da183455d6d37959892744fa01d9d

Indeed, so far we had been doing the opposite what this driver has done
- set the "vendor selection" i.e. NET_DSA_REALTEK default to y since it
doesn't build any code, and the actual code default to n. We are
considering defaulting everything to n now, but it's WIP.

Let me send a patch dropping the default y, please object if there was
a strong reason to do it this way!
diff mbox series

Patch

diff --git a/drivers/net/dsa/realtek/Kconfig b/drivers/net/dsa/realtek/Kconfig
index 1c62212fb0ec..cd1aa95b7bf0 100644
--- a/drivers/net/dsa/realtek/Kconfig
+++ b/drivers/net/dsa/realtek/Kconfig
@@ -2,8 +2,6 @@ 
 menuconfig NET_DSA_REALTEK
 	tristate "Realtek Ethernet switch family support"
 	depends on NET_DSA
-	select NET_DSA_TAG_RTL4_A
-	select NET_DSA_TAG_RTL8_4
 	select FIXED_PHY
 	select IRQ_DOMAIN
 	select REALTEK_PHY
@@ -18,3 +16,21 @@  config NET_DSA_REALTEK_SMI
 	help
 	  Select to enable support for registering switches connected
 	  through SMI.
+
+config NET_DSA_REALTEK_RTL8365MB
+	tristate "Realtek RTL8365MB switch subdriver"
+	default y
+	depends on NET_DSA_REALTEK
+	depends on NET_DSA_REALTEK_SMI
+	select NET_DSA_TAG_RTL8_4
+	help
+	  Select to enable support for Realtek RTL8365MB
+
+config NET_DSA_REALTEK_RTL8366RB
+	tristate "Realtek RTL8366RB switch subdriver"
+	default y
+	depends on NET_DSA_REALTEK
+	depends on NET_DSA_REALTEK_SMI
+	select NET_DSA_TAG_RTL4_A
+	help
+	  Select to enable support for Realtek RTL8366RB
diff --git a/drivers/net/dsa/realtek/Makefile b/drivers/net/dsa/realtek/Makefile
index 323b921bfce0..8b5a4abcedd3 100644
--- a/drivers/net/dsa/realtek/Makefile
+++ b/drivers/net/dsa/realtek/Makefile
@@ -1,3 +1,5 @@ 
 # SPDX-License-Identifier: GPL-2.0
 obj-$(CONFIG_NET_DSA_REALTEK_SMI) 	+= realtek-smi.o
-realtek-smi-objs			:= realtek-smi-core.o rtl8366.o rtl8366rb.o rtl8365mb.o
+obj-$(CONFIG_NET_DSA_REALTEK_RTL8366RB) += rtl8366.o
+rtl8366-objs 				:= rtl8366-core.o rtl8366rb.o
+obj-$(CONFIG_NET_DSA_REALTEK_RTL8365MB) += rtl8365mb.o
diff --git a/drivers/net/dsa/realtek/realtek-smi-core.c b/drivers/net/dsa/realtek/realtek-smi.c
similarity index 97%
rename from drivers/net/dsa/realtek/realtek-smi-core.c
rename to drivers/net/dsa/realtek/realtek-smi.c
index 5fb86ae2339c..04df06e352d3 100644
--- a/drivers/net/dsa/realtek/realtek-smi-core.c
+++ b/drivers/net/dsa/realtek/realtek-smi.c
@@ -494,19 +494,23 @@  static void realtek_smi_shutdown(struct platform_device *pdev)
 }
 
 static const struct of_device_id realtek_smi_of_match[] = {
+#if IS_ENABLED(CONFIG_NET_DSA_REALTEK_RTL8366RB)
 	{
 		.compatible = "realtek,rtl8366rb",
 		.data = &rtl8366rb_variant,
 	},
+#endif
 	{
 		/* FIXME: add support for RTL8366S and more */
 		.compatible = "realtek,rtl8366s",
 		.data = NULL,
 	},
+#if IS_ENABLED(CONFIG_NET_DSA_REALTEK_RTL8365MB)
 	{
 		.compatible = "realtek,rtl8365mb",
 		.data = &rtl8365mb_variant,
 	},
+#endif
 	{ /* sentinel */ },
 };
 MODULE_DEVICE_TABLE(of, realtek_smi_of_match);
@@ -522,4 +526,6 @@  static struct platform_driver realtek_smi_driver = {
 };
 module_platform_driver(realtek_smi_driver);
 
+MODULE_AUTHOR("Linus Walleij <linus.walleij@linaro.org>");
+MODULE_DESCRIPTION("Driver for Realtek ethernet switch connected via SMI interface");
 MODULE_LICENSE("GPL");
diff --git a/drivers/net/dsa/realtek/rtl8365mb.c b/drivers/net/dsa/realtek/rtl8365mb.c
index a50cae28b7ae..f91763029dd4 100644
--- a/drivers/net/dsa/realtek/rtl8365mb.c
+++ b/drivers/net/dsa/realtek/rtl8365mb.c
@@ -1986,3 +1986,7 @@  const struct realtek_variant rtl8365mb_variant = {
 	.chip_data_sz = sizeof(struct rtl8365mb),
 };
 EXPORT_SYMBOL_GPL(rtl8365mb_variant);
+
+MODULE_AUTHOR("Alvin Šipraga <alsi@bang-olufsen.dk>");
+MODULE_DESCRIPTION("Driver for RTL8365MB-VC ethernet switch");
+MODULE_LICENSE("GPL");
diff --git a/drivers/net/dsa/realtek/rtl8366.c b/drivers/net/dsa/realtek/rtl8366-core.c
similarity index 100%
rename from drivers/net/dsa/realtek/rtl8366.c
rename to drivers/net/dsa/realtek/rtl8366-core.c
diff --git a/drivers/net/dsa/realtek/rtl8366rb.c b/drivers/net/dsa/realtek/rtl8366rb.c
index b301408028ef..7dea8db56b6c 100644
--- a/drivers/net/dsa/realtek/rtl8366rb.c
+++ b/drivers/net/dsa/realtek/rtl8366rb.c
@@ -1816,3 +1816,7 @@  const struct realtek_variant rtl8366rb_variant = {
 	.chip_data_sz = sizeof(struct rtl8366rb),
 };
 EXPORT_SYMBOL_GPL(rtl8366rb_variant);
+
+MODULE_AUTHOR("Linus Walleij <linus.walleij@linaro.org>");
+MODULE_DESCRIPTION("Driver for RTL8366RB ethernet switch");
+MODULE_LICENSE("GPL");