diff mbox series

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

Message ID 20211216201342.25587-5-luizluca@gmail.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net: dsa: realtek: MDIO interface and RTL8367S | 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: 4 this patch: 4
netdev/cc_maintainers warning 2 maintainers not CCed: kuba@kernel.org davem@davemloft.net
netdev/build_clang success Errors and warnings before: 3 this patch: 3
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: 4 this patch: 4
netdev/checkpatch fail ERROR: spaces required around that '=' (ctx:VxV) WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? WARNING: please write a paragraph that describes the config symbol fully
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 Dec. 16, 2021, 8:13 p.m. UTC
From: Luiz Angelo Daros de Luca <luizluca@gmail.com>

Preparing for multiple interfaces support, the drivers
must be independent of realtek-smi.

Tested-by: Arınç ÜNAL <arinc.unal@arinc9.com>
Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
---
 drivers/net/dsa/realtek/Kconfig               | 20 +++++++++++++++++--
 drivers/net/dsa/realtek/Makefile              |  4 +++-
 .../{realtek-smi-core.c => realtek-smi.c}     | 15 ++++++++++----
 drivers/net/dsa/realtek/rtl8365mb.c           |  2 ++
 .../dsa/realtek/{rtl8366.c => rtl8366-core.c} |  0
 drivers/net/dsa/realtek/rtl8366rb.c           |  2 ++
 6 files changed, 36 insertions(+), 7 deletions(-)
 rename drivers/net/dsa/realtek/{realtek-smi-core.c => realtek-smi.c} (96%)
 rename drivers/net/dsa/realtek/{rtl8366.c => rtl8366-core.c} (100%)

Comments

Alvin Šipraga Dec. 16, 2021, 11:29 p.m. UTC | #1
On 12/16/21 21:13, luizluca@gmail.com wrote:
> From: Luiz Angelo Daros de Luca <luizluca@gmail.com>
> 
> Preparing for multiple interfaces support, the drivers
> must be independent of realtek-smi.
> 
> Tested-by: Arınç ÜNAL <arinc.unal@arinc9.com>
> Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
> ---
>   drivers/net/dsa/realtek/Kconfig               | 20 +++++++++++++++++--
>   drivers/net/dsa/realtek/Makefile              |  4 +++-
>   .../{realtek-smi-core.c => realtek-smi.c}     | 15 ++++++++++----
>   drivers/net/dsa/realtek/rtl8365mb.c           |  2 ++
>   .../dsa/realtek/{rtl8366.c => rtl8366-core.c} |  0
>   drivers/net/dsa/realtek/rtl8366rb.c           |  2 ++
>   6 files changed, 36 insertions(+), 7 deletions(-)
>   rename drivers/net/dsa/realtek/{realtek-smi-core.c => realtek-smi.c} (96%)
>   rename drivers/net/dsa/realtek/{rtl8366.c => rtl8366-core.c} (100%)
> 
> diff --git a/drivers/net/dsa/realtek/Kconfig b/drivers/net/dsa/realtek/Kconfig
> index bbc6e918baa6..c002a84a00f5 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
> @@ -17,3 +15,21 @@ config NET_DSA_REALTEK_SMI
>   	default y
>   	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

Maybe this should be CONFIG_NET_DSA_REALTEK_RTL8366 (no RB)? Not that I 
put my faith in Realtek's naming scheme...

> +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 96%
> rename from drivers/net/dsa/realtek/realtek-smi-core.c
> rename to drivers/net/dsa/realtek/realtek-smi.c
> index 2c78eb5c0bdc..11447096c8dc 100644
> --- a/drivers/net/dsa/realtek/realtek-smi-core.c
> +++ b/drivers/net/dsa/realtek/realtek-smi.c
> @@ -297,7 +297,6 @@ int realtek_smi_write_reg_noack(struct realtek_priv *priv, u32 addr,
>   {
>   	return realtek_smi_write_reg(priv, addr, data, false);
>   }
> -EXPORT_SYMBOL_GPL(realtek_smi_write_reg_noack);
>   
>   /* Regmap accessors */
>   
> @@ -342,8 +341,9 @@ static int realtek_smi_mdio_write(struct mii_bus *bus, int addr, int regnum,
>   	return priv->ops->phy_write(priv, addr, regnum, val);
>   }
>   
> -int realtek_smi_setup_mdio(struct realtek_priv *priv)
> +int realtek_smi_setup_mdio(struct dsa_switch *ds)
>   {
> +	struct realtek_priv *priv =  (struct realtek_priv *)ds->priv;
>   	struct device_node *mdio_np;
>   	int ret;
>   
> @@ -363,10 +363,10 @@ int realtek_smi_setup_mdio(struct realtek_priv *priv)
>   	priv->slave_mii_bus->read = realtek_smi_mdio_read;
>   	priv->slave_mii_bus->write = realtek_smi_mdio_write;
>   	snprintf(priv->slave_mii_bus->id, MII_BUS_ID_SIZE, "SMI-%d",
> -		 priv->ds->index);
> +		 ds->index);
>   	priv->slave_mii_bus->dev.of_node = mdio_np;
>   	priv->slave_mii_bus->parent = priv->dev;
> -	priv->ds->slave_mii_bus = priv->slave_mii_bus;
> +	ds->slave_mii_bus = priv->slave_mii_bus;
>   
>   	ret = devm_of_mdiobus_register(priv->dev, priv->slave_mii_bus, mdio_np);
>   	if (ret) {
> @@ -413,6 +413,9 @@ static int realtek_smi_probe(struct platform_device *pdev)
>   	priv->cmd_write = var->cmd_write;
>   	priv->ops = var->ops;
>   
> +	priv->setup_interface=realtek_smi_setup_mdio;
> +	priv->write_reg_noack=realtek_smi_write_reg_noack;

Formatting: a = b, not a=b.

> +
>   	dev_set_drvdata(dev, priv);
>   	spin_lock_init(&priv->lock);
>   
> @@ -492,19 +495,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);
> diff --git a/drivers/net/dsa/realtek/rtl8365mb.c b/drivers/net/dsa/realtek/rtl8365mb.c
> index f562a6efb574..d6054f63f204 100644
> --- a/drivers/net/dsa/realtek/rtl8365mb.c
> +++ b/drivers/net/dsa/realtek/rtl8365mb.c
> @@ -1987,3 +1987,5 @@ const struct realtek_variant rtl8365mb_variant = {
>   	.chip_data_sz = sizeof(struct rtl8365mb),
>   };
>   EXPORT_SYMBOL_GPL(rtl8365mb_variant);
> +
> +MODULE_LICENSE("GPL");

You could also add MODULE_DESCRIPTION/MODULE_AUTHORs to these subdrivers 
now that they are free from the core.

> 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 b1635c20276b..31f1a949c8e7 100644
> --- a/drivers/net/dsa/realtek/rtl8366rb.c
> +++ b/drivers/net/dsa/realtek/rtl8366rb.c
> @@ -1812,3 +1812,5 @@ const struct realtek_variant rtl8366rb_variant = {
>   	.chip_data_sz = sizeof(struct rtl8366rb),
>   };
>   EXPORT_SYMBOL_GPL(rtl8366rb_variant);
> +
> +MODULE_LICENSE("GPL");
kernel test robot Dec. 17, 2021, 2:31 a.m. UTC | #2
Hi,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]

url:    https://github.com/0day-ci/linux/commits/luizluca-gmail-com/net-dsa-realtek-MDIO-interface-and-RTL8367S/20211217-041735
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 0f473bb6ed2d0b8533a079ee133f625f83de5315
config: arc-allyesconfig (https://download.01.org/0day-ci/archive/20211217/202112171017.KRgToQQ1-lkp@intel.com/config)
compiler: arceb-elf-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/4bbfd185490b3b2fcc4e90a63d3137a812f03057
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review luizluca-gmail-com/net-dsa-realtek-MDIO-interface-and-RTL8367S/20211217-041735
        git checkout 4bbfd185490b3b2fcc4e90a63d3137a812f03057
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arc SHELL=/bin/bash drivers/net/dsa/realtek/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/net/dsa/realtek/realtek-smi.c:295:5: warning: no previous prototype for 'realtek_smi_write_reg_noack' [-Wmissing-prototypes]
     295 | int realtek_smi_write_reg_noack(struct realtek_priv *priv, u32 addr,
         |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/net/dsa/realtek/realtek-smi.c:344:5: warning: no previous prototype for 'realtek_smi_setup_mdio' [-Wmissing-prototypes]
     344 | int realtek_smi_setup_mdio(struct dsa_switch *ds)
         |     ^~~~~~~~~~~~~~~~~~~~~~


vim +/realtek_smi_write_reg_noack +295 drivers/net/dsa/realtek/realtek-smi.c

d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  290  
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  291  /* There is one single case when we need to use this accessor and that
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  292   * is when issueing soft reset. Since the device reset as soon as we write
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  293   * that bit, no ACK will come back for natural reasons.
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  294   */
4b42215ee71c0f drivers/net/dsa/realtek/realtek-smi-core.c Luiz Angelo Daros de Luca 2021-12-16 @295  int realtek_smi_write_reg_noack(struct realtek_priv *priv, u32 addr,
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  296  				u32 data)
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  297  {
4b42215ee71c0f drivers/net/dsa/realtek/realtek-smi-core.c Luiz Angelo Daros de Luca 2021-12-16  298  	return realtek_smi_write_reg(priv, addr, data, false);
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  299  }
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  300  
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  301  /* Regmap accessors */
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  302  
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  303  static int realtek_smi_write(void *ctx, u32 reg, u32 val)
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  304  {
4b42215ee71c0f drivers/net/dsa/realtek/realtek-smi-core.c Luiz Angelo Daros de Luca 2021-12-16  305  	struct realtek_priv *priv = ctx;
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  306  
4b42215ee71c0f drivers/net/dsa/realtek/realtek-smi-core.c Luiz Angelo Daros de Luca 2021-12-16  307  	return realtek_smi_write_reg(priv, reg, val, true);
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  308  }
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  309  
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  310  static int realtek_smi_read(void *ctx, u32 reg, u32 *val)
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  311  {
4b42215ee71c0f drivers/net/dsa/realtek/realtek-smi-core.c Luiz Angelo Daros de Luca 2021-12-16  312  	struct realtek_priv *priv = ctx;
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  313  
4b42215ee71c0f drivers/net/dsa/realtek/realtek-smi-core.c Luiz Angelo Daros de Luca 2021-12-16  314  	return realtek_smi_read_reg(priv, reg, val);
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  315  }
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  316  
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  317  static const struct regmap_config realtek_smi_mdio_regmap_config = {
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  318  	.reg_bits = 10, /* A4..A0 R4..R0 */
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  319  	.val_bits = 16,
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  320  	.reg_stride = 1,
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  321  	/* PHY regs are at 0x8000 */
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  322  	.max_register = 0xffff,
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  323  	.reg_format_endian = REGMAP_ENDIAN_BIG,
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  324  	.reg_read = realtek_smi_read,
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  325  	.reg_write = realtek_smi_write,
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  326  	.cache_type = REGCACHE_NONE,
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  327  };
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  328  
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  329  static int realtek_smi_mdio_read(struct mii_bus *bus, int addr, int regnum)
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  330  {
4b42215ee71c0f drivers/net/dsa/realtek/realtek-smi-core.c Luiz Angelo Daros de Luca 2021-12-16  331  	struct realtek_priv *priv = bus->priv;
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  332  
4b42215ee71c0f drivers/net/dsa/realtek/realtek-smi-core.c Luiz Angelo Daros de Luca 2021-12-16  333  	return priv->ops->phy_read(priv, addr, regnum);
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  334  }
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  335  
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  336  static int realtek_smi_mdio_write(struct mii_bus *bus, int addr, int regnum,
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  337  				  u16 val)
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  338  {
4b42215ee71c0f drivers/net/dsa/realtek/realtek-smi-core.c Luiz Angelo Daros de Luca 2021-12-16  339  	struct realtek_priv *priv = bus->priv;
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  340  
4b42215ee71c0f drivers/net/dsa/realtek/realtek-smi-core.c Luiz Angelo Daros de Luca 2021-12-16  341  	return priv->ops->phy_write(priv, addr, regnum, val);
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  342  }
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  343  
4bbfd185490b3b drivers/net/dsa/realtek/realtek-smi.c      Luiz Angelo Daros de Luca 2021-12-16 @344  int realtek_smi_setup_mdio(struct dsa_switch *ds)
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  345  {
4bbfd185490b3b drivers/net/dsa/realtek/realtek-smi.c      Luiz Angelo Daros de Luca 2021-12-16  346  	struct realtek_priv *priv =  (struct realtek_priv *)ds->priv;
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  347  	struct device_node *mdio_np;
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  348  	int ret;
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  349  
4b42215ee71c0f drivers/net/dsa/realtek/realtek-smi-core.c Luiz Angelo Daros de Luca 2021-12-16  350  	mdio_np = of_get_compatible_child(priv->dev->of_node, "realtek,smi-mdio");
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  351  	if (!mdio_np) {
4b42215ee71c0f drivers/net/dsa/realtek/realtek-smi-core.c Luiz Angelo Daros de Luca 2021-12-16  352  		dev_err(priv->dev, "no MDIO bus node\n");
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  353  		return -ENODEV;
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  354  	}
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  355  
4b42215ee71c0f drivers/net/dsa/realtek/realtek-smi-core.c Luiz Angelo Daros de Luca 2021-12-16  356  	priv->slave_mii_bus = devm_mdiobus_alloc(priv->dev);
4b42215ee71c0f drivers/net/dsa/realtek/realtek-smi-core.c Luiz Angelo Daros de Luca 2021-12-16  357  	if (!priv->slave_mii_bus) {
3f1bb6abdf19cf drivers/net/dsa/realtek-smi.c              Johan Hovold              2019-01-16  358  		ret = -ENOMEM;
3f1bb6abdf19cf drivers/net/dsa/realtek-smi.c              Johan Hovold              2019-01-16  359  		goto err_put_node;
3f1bb6abdf19cf drivers/net/dsa/realtek-smi.c              Johan Hovold              2019-01-16  360  	}
4b42215ee71c0f drivers/net/dsa/realtek/realtek-smi-core.c Luiz Angelo Daros de Luca 2021-12-16  361  	priv->slave_mii_bus->priv = priv;
4b42215ee71c0f drivers/net/dsa/realtek/realtek-smi-core.c Luiz Angelo Daros de Luca 2021-12-16  362  	priv->slave_mii_bus->name = "SMI slave MII";
4b42215ee71c0f drivers/net/dsa/realtek/realtek-smi-core.c Luiz Angelo Daros de Luca 2021-12-16  363  	priv->slave_mii_bus->read = realtek_smi_mdio_read;
4b42215ee71c0f drivers/net/dsa/realtek/realtek-smi-core.c Luiz Angelo Daros de Luca 2021-12-16  364  	priv->slave_mii_bus->write = realtek_smi_mdio_write;
4b42215ee71c0f drivers/net/dsa/realtek/realtek-smi-core.c Luiz Angelo Daros de Luca 2021-12-16  365  	snprintf(priv->slave_mii_bus->id, MII_BUS_ID_SIZE, "SMI-%d",
4bbfd185490b3b drivers/net/dsa/realtek/realtek-smi.c      Luiz Angelo Daros de Luca 2021-12-16  366  		 ds->index);
4b42215ee71c0f drivers/net/dsa/realtek/realtek-smi-core.c Luiz Angelo Daros de Luca 2021-12-16  367  	priv->slave_mii_bus->dev.of_node = mdio_np;
4b42215ee71c0f drivers/net/dsa/realtek/realtek-smi-core.c Luiz Angelo Daros de Luca 2021-12-16  368  	priv->slave_mii_bus->parent = priv->dev;
4bbfd185490b3b drivers/net/dsa/realtek/realtek-smi.c      Luiz Angelo Daros de Luca 2021-12-16  369  	ds->slave_mii_bus = priv->slave_mii_bus;
4b42215ee71c0f drivers/net/dsa/realtek/realtek-smi-core.c Luiz Angelo Daros de Luca 2021-12-16  370  
4b42215ee71c0f drivers/net/dsa/realtek/realtek-smi-core.c Luiz Angelo Daros de Luca 2021-12-16  371  	ret = devm_of_mdiobus_register(priv->dev, priv->slave_mii_bus, mdio_np);
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  372  	if (ret) {
4b42215ee71c0f drivers/net/dsa/realtek/realtek-smi-core.c Luiz Angelo Daros de Luca 2021-12-16  373  		dev_err(priv->dev, "unable to register MDIO bus %s\n",
4b42215ee71c0f drivers/net/dsa/realtek/realtek-smi-core.c Luiz Angelo Daros de Luca 2021-12-16  374  			priv->slave_mii_bus->id);
3f1bb6abdf19cf drivers/net/dsa/realtek-smi.c              Johan Hovold              2019-01-16  375  		goto err_put_node;
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  376  	}
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  377  
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  378  	return 0;
3f1bb6abdf19cf drivers/net/dsa/realtek-smi.c              Johan Hovold              2019-01-16  379  
3f1bb6abdf19cf drivers/net/dsa/realtek-smi.c              Johan Hovold              2019-01-16  380  err_put_node:
3f1bb6abdf19cf drivers/net/dsa/realtek-smi.c              Johan Hovold              2019-01-16  381  	of_node_put(mdio_np);
3f1bb6abdf19cf drivers/net/dsa/realtek-smi.c              Johan Hovold              2019-01-16  382  
3f1bb6abdf19cf drivers/net/dsa/realtek-smi.c              Johan Hovold              2019-01-16  383  	return ret;
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  384  }
d8652956cf37c5 drivers/net/dsa/realtek-smi.c              Linus Walleij             2018-07-14  385  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Luiz Angelo Daros de Luca Dec. 17, 2021, 6:50 a.m. UTC | #3
Em qui., 16 de dez. de 2021 às 20:29, Alvin Šipraga
<ALSI@bang-olufsen.dk> escreveu:
>
> On 12/16/21 21:13, luizluca@gmail.com wrote:
> > From: Luiz Angelo Daros de Luca <luizluca@gmail.com>
> >
> > Preparing for multiple interfaces support, the drivers
> > must be independent of realtek-smi.
> >
> > Tested-by: Arınç ÜNAL <arinc.unal@arinc9.com>
> > Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
> > ---
> >   drivers/net/dsa/realtek/Kconfig               | 20 +++++++++++++++++--
> >   drivers/net/dsa/realtek/Makefile              |  4 +++-
> >   .../{realtek-smi-core.c => realtek-smi.c}     | 15 ++++++++++----
> >   drivers/net/dsa/realtek/rtl8365mb.c           |  2 ++
> >   .../dsa/realtek/{rtl8366.c => rtl8366-core.c} |  0
> >   drivers/net/dsa/realtek/rtl8366rb.c           |  2 ++
> >   6 files changed, 36 insertions(+), 7 deletions(-)
> >   rename drivers/net/dsa/realtek/{realtek-smi-core.c => realtek-smi.c} (96%)
> >   rename drivers/net/dsa/realtek/{rtl8366.c => rtl8366-core.c} (100%)
> >
> > diff --git a/drivers/net/dsa/realtek/Kconfig b/drivers/net/dsa/realtek/Kconfig
> > index bbc6e918baa6..c002a84a00f5 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
> > @@ -17,3 +15,21 @@ config NET_DSA_REALTEK_SMI
> >       default y
> >       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
>
> Maybe this should be CONFIG_NET_DSA_REALTEK_RTL8366 (no RB)? Not that I
> put my faith in Realtek's naming scheme...
>

Let's discuss this one in the rename patch. Unfortunately, I think
that there is no perfect name.

> > +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 96%
> > rename from drivers/net/dsa/realtek/realtek-smi-core.c
> > rename to drivers/net/dsa/realtek/realtek-smi.c
> > index 2c78eb5c0bdc..11447096c8dc 100644
> > --- a/drivers/net/dsa/realtek/realtek-smi-core.c
> > +++ b/drivers/net/dsa/realtek/realtek-smi.c
> > @@ -297,7 +297,6 @@ int realtek_smi_write_reg_noack(struct realtek_priv *priv, u32 addr,
> >   {
> >       return realtek_smi_write_reg(priv, addr, data, false);
> >   }
> > -EXPORT_SYMBOL_GPL(realtek_smi_write_reg_noack);
> >
> >   /* Regmap accessors */
> >
> > @@ -342,8 +341,9 @@ static int realtek_smi_mdio_write(struct mii_bus *bus, int addr, int regnum,
> >       return priv->ops->phy_write(priv, addr, regnum, val);
> >   }
> >
> > -int realtek_smi_setup_mdio(struct realtek_priv *priv)
> > +int realtek_smi_setup_mdio(struct dsa_switch *ds)
> >   {
> > +     struct realtek_priv *priv =  (struct realtek_priv *)ds->priv;
> >       struct device_node *mdio_np;
> >       int ret;
> >
> > @@ -363,10 +363,10 @@ int realtek_smi_setup_mdio(struct realtek_priv *priv)
> >       priv->slave_mii_bus->read = realtek_smi_mdio_read;
> >       priv->slave_mii_bus->write = realtek_smi_mdio_write;
> >       snprintf(priv->slave_mii_bus->id, MII_BUS_ID_SIZE, "SMI-%d",
> > -              priv->ds->index);
> > +              ds->index);
> >       priv->slave_mii_bus->dev.of_node = mdio_np;
> >       priv->slave_mii_bus->parent = priv->dev;
> > -     priv->ds->slave_mii_bus = priv->slave_mii_bus;
> > +     ds->slave_mii_bus = priv->slave_mii_bus;
> >
> >       ret = devm_of_mdiobus_register(priv->dev, priv->slave_mii_bus, mdio_np);
> >       if (ret) {
> > @@ -413,6 +413,9 @@ static int realtek_smi_probe(struct platform_device *pdev)
> >       priv->cmd_write = var->cmd_write;
> >       priv->ops = var->ops;
> >
> > +     priv->setup_interface=realtek_smi_setup_mdio;
> > +     priv->write_reg_noack=realtek_smi_write_reg_noack;
>
> Formatting: a = b, not a=b.
>

Check patch also got it. Thanks.

> > +
> >       dev_set_drvdata(dev, priv);
> >       spin_lock_init(&priv->lock);
> >
> > @@ -492,19 +495,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);
> > diff --git a/drivers/net/dsa/realtek/rtl8365mb.c b/drivers/net/dsa/realtek/rtl8365mb.c
> > index f562a6efb574..d6054f63f204 100644
> > --- a/drivers/net/dsa/realtek/rtl8365mb.c
> > +++ b/drivers/net/dsa/realtek/rtl8365mb.c
> > @@ -1987,3 +1987,5 @@ const struct realtek_variant rtl8365mb_variant = {
> >       .chip_data_sz = sizeof(struct rtl8365mb),
> >   };
> >   EXPORT_SYMBOL_GPL(rtl8365mb_variant);
> > +
> > +MODULE_LICENSE("GPL");
>
> You could also add MODULE_DESCRIPTION/MODULE_AUTHORs to these subdrivers
> now that they are free from the core.

realtek-smi also didn't have them. I'll add as well from the author of
the first commit in git log.
It might not be fair with other authors. If anyone sees a problem, I
can add/remove names.
Also, I'm not sure if I should name the authors without their ok

>
> > 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 b1635c20276b..31f1a949c8e7 100644
> > --- a/drivers/net/dsa/realtek/rtl8366rb.c
> > +++ b/drivers/net/dsa/realtek/rtl8366rb.c
> > @@ -1812,3 +1812,5 @@ const struct realtek_variant rtl8366rb_variant = {
> >       .chip_data_sz = sizeof(struct rtl8366rb),
> >   };
> >   EXPORT_SYMBOL_GPL(rtl8366rb_variant);
> > +
> > +MODULE_LICENSE("GPL");
>
diff mbox series

Patch

diff --git a/drivers/net/dsa/realtek/Kconfig b/drivers/net/dsa/realtek/Kconfig
index bbc6e918baa6..c002a84a00f5 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
@@ -17,3 +15,21 @@  config NET_DSA_REALTEK_SMI
 	default y
 	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 96%
rename from drivers/net/dsa/realtek/realtek-smi-core.c
rename to drivers/net/dsa/realtek/realtek-smi.c
index 2c78eb5c0bdc..11447096c8dc 100644
--- a/drivers/net/dsa/realtek/realtek-smi-core.c
+++ b/drivers/net/dsa/realtek/realtek-smi.c
@@ -297,7 +297,6 @@  int realtek_smi_write_reg_noack(struct realtek_priv *priv, u32 addr,
 {
 	return realtek_smi_write_reg(priv, addr, data, false);
 }
-EXPORT_SYMBOL_GPL(realtek_smi_write_reg_noack);
 
 /* Regmap accessors */
 
@@ -342,8 +341,9 @@  static int realtek_smi_mdio_write(struct mii_bus *bus, int addr, int regnum,
 	return priv->ops->phy_write(priv, addr, regnum, val);
 }
 
-int realtek_smi_setup_mdio(struct realtek_priv *priv)
+int realtek_smi_setup_mdio(struct dsa_switch *ds)
 {
+	struct realtek_priv *priv =  (struct realtek_priv *)ds->priv;
 	struct device_node *mdio_np;
 	int ret;
 
@@ -363,10 +363,10 @@  int realtek_smi_setup_mdio(struct realtek_priv *priv)
 	priv->slave_mii_bus->read = realtek_smi_mdio_read;
 	priv->slave_mii_bus->write = realtek_smi_mdio_write;
 	snprintf(priv->slave_mii_bus->id, MII_BUS_ID_SIZE, "SMI-%d",
-		 priv->ds->index);
+		 ds->index);
 	priv->slave_mii_bus->dev.of_node = mdio_np;
 	priv->slave_mii_bus->parent = priv->dev;
-	priv->ds->slave_mii_bus = priv->slave_mii_bus;
+	ds->slave_mii_bus = priv->slave_mii_bus;
 
 	ret = devm_of_mdiobus_register(priv->dev, priv->slave_mii_bus, mdio_np);
 	if (ret) {
@@ -413,6 +413,9 @@  static int realtek_smi_probe(struct platform_device *pdev)
 	priv->cmd_write = var->cmd_write;
 	priv->ops = var->ops;
 
+	priv->setup_interface=realtek_smi_setup_mdio;
+	priv->write_reg_noack=realtek_smi_write_reg_noack;
+
 	dev_set_drvdata(dev, priv);
 	spin_lock_init(&priv->lock);
 
@@ -492,19 +495,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);
diff --git a/drivers/net/dsa/realtek/rtl8365mb.c b/drivers/net/dsa/realtek/rtl8365mb.c
index f562a6efb574..d6054f63f204 100644
--- a/drivers/net/dsa/realtek/rtl8365mb.c
+++ b/drivers/net/dsa/realtek/rtl8365mb.c
@@ -1987,3 +1987,5 @@  const struct realtek_variant rtl8365mb_variant = {
 	.chip_data_sz = sizeof(struct rtl8365mb),
 };
 EXPORT_SYMBOL_GPL(rtl8365mb_variant);
+
+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 b1635c20276b..31f1a949c8e7 100644
--- a/drivers/net/dsa/realtek/rtl8366rb.c
+++ b/drivers/net/dsa/realtek/rtl8366rb.c
@@ -1812,3 +1812,5 @@  const struct realtek_variant rtl8366rb_variant = {
 	.chip_data_sz = sizeof(struct rtl8366rb),
 };
 EXPORT_SYMBOL_GPL(rtl8366rb_variant);
+
+MODULE_LICENSE("GPL");