From: Vladimir Oltean <olteanv@gmail.com>
To: Luiz Angelo Daros de Luca <luizluca@gmail.com>
Cc: netdev@vger.kernel.org, linus.walleij@linaro.org,
alsi@bang-olufsen.dk, andrew@lunn.ch, f.fainelli@gmail.com,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, arinc.unal@arinc9.com, ansuelsmth@gmail.com
Subject: Re: [PATCH net-next v4 08/11] net: dsa: realtek: clean user_mii_bus setup
Date: Thu, 25 Jan 2024 13:17:18 +0200 [thread overview]
Message-ID: <20240125111718.armzsazgcjnicc2h@skbuf> (raw)
In-Reply-To: <20240123215606.26716-9-luizluca@gmail.com> <20240123215606.26716-9-luizluca@gmail.com>
On Tue, Jan 23, 2024 at 06:56:00PM -0300, Luiz Angelo Daros de Luca wrote:
> The line assigning dev.of_node in mdio_bus has been removed since the
> subsequent of_mdiobus_register will always overwrite it.
Please use present tense and imperative mood. "Remove the line assigning
dev.of_node, because ...".
>
> ds->user_mii_bus is not assigned anymore[1].
"As discussed in [1], allow the DSA core to be simplified, by not
assigning ds->user_mii_bus when the MDIO bus is described in OF, as it
is unnecessary."
> It should work as before as long as the switch ports have a valid
> phy-handle property.
>
> Since commit 3b73a7b8ec38 ("net: mdio_bus: add refcounting for fwnodes
> to mdiobus"), we can put the "mdio" node just after the MDIO bus
> registration.
> The switch unregistration was moved into realtek_common_remove() as
> both interfaces now use the same code path.
Hopefully you can sort this part out in a separate patch that's
unrelated to the user_mii_bus cleanup, ideally in "net: dsa: realtek:
common rtl83xx module".
>
> [1] https://lkml.kernel.org/netdev/20231213120656.x46fyad6ls7sqyzv@skbuf/T/#u
>
> Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
> ---
> drivers/net/dsa/realtek/realtek-mdio.c | 5 -----
> drivers/net/dsa/realtek/realtek-smi.c | 15 ++-------------
> drivers/net/dsa/realtek/rtl83xx.c | 2 ++
> 3 files changed, 4 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/net/dsa/realtek/realtek-mdio.c b/drivers/net/dsa/realtek/realtek-mdio.c
> index 0171185ec665..c75b4550802c 100644
> --- a/drivers/net/dsa/realtek/realtek-mdio.c
> +++ b/drivers/net/dsa/realtek/realtek-mdio.c
> @@ -158,11 +158,6 @@ void realtek_mdio_remove(struct mdio_device *mdiodev)
> {
> struct realtek_priv *priv = dev_get_drvdata(&mdiodev->dev);
>
> - if (!priv)
> - return;
> -
The way I would structure these guards is I would keep them here, and
not in rtl83xx_remove() and rtl83xx_shutdown(). Then I would make sure
that rtl83xx_remove() is the exact opposite of just rtl83xx_probe(), and
rtl83xx_unregister_switch() is the exact opposite of just rtl83xx_register_switch().
And I would fix the error handling path of realtek_smi_probe() and
realtek_mdio_probe() to call rtl83xx_remove() when rtl83xx_register_switch()
fails.
> - dsa_unregister_switch(priv->ds);
> -
> rtl83xx_remove(priv);
> }
> EXPORT_SYMBOL_NS_GPL(realtek_mdio_remove, REALTEK_DSA);
> diff --git a/drivers/net/dsa/realtek/realtek-smi.c b/drivers/net/dsa/realtek/realtek-smi.c
> index 0ccb2a6059a6..a89813e527d2 100644
> --- a/drivers/net/dsa/realtek/realtek-smi.c
> +++ b/drivers/net/dsa/realtek/realtek-smi.c
> @@ -331,7 +331,7 @@ static int realtek_smi_setup_mdio(struct dsa_switch *ds)
> {
> struct realtek_priv *priv = ds->priv;
> struct device_node *mdio_np;
> - int ret;
> + int ret = 0;
>
> mdio_np = of_get_child_by_name(priv->dev->of_node, "mdio");
> if (!mdio_np) {
> @@ -344,15 +344,14 @@ static int realtek_smi_setup_mdio(struct dsa_switch *ds)
> ret = -ENOMEM;
> goto err_put_node;
> }
> +
> priv->user_mii_bus->priv = priv;
> priv->user_mii_bus->name = "SMI user MII";
> priv->user_mii_bus->read = realtek_smi_mdio_read;
> priv->user_mii_bus->write = realtek_smi_mdio_write;
> snprintf(priv->user_mii_bus->id, MII_BUS_ID_SIZE, "SMI-%d",
> ds->index);
> - priv->user_mii_bus->dev.of_node = mdio_np;
> priv->user_mii_bus->parent = priv->dev;
> - ds->user_mii_bus = priv->user_mii_bus;
>
> ret = devm_of_mdiobus_register(priv->dev, priv->user_mii_bus, mdio_np);
> if (ret) {
> @@ -361,8 +360,6 @@ static int realtek_smi_setup_mdio(struct dsa_switch *ds)
> goto err_put_node;
> }
>
> - return 0;
> -
> err_put_node:
> of_node_put(mdio_np);
>
> @@ -434,14 +431,6 @@ void realtek_smi_remove(struct platform_device *pdev)
> {
> struct realtek_priv *priv = platform_get_drvdata(pdev);
>
> - if (!priv)
> - return;
> -
> - dsa_unregister_switch(priv->ds);
> -
> - if (priv->user_mii_bus)
> - of_node_put(priv->user_mii_bus->dev.of_node);
> -
> rtl83xx_remove(priv);
> }
> EXPORT_SYMBOL_NS_GPL(realtek_smi_remove, REALTEK_DSA);
> diff --git a/drivers/net/dsa/realtek/rtl83xx.c b/drivers/net/dsa/realtek/rtl83xx.c
> index 3d07c5662fa4..53bacbacc82e 100644
> --- a/drivers/net/dsa/realtek/rtl83xx.c
> +++ b/drivers/net/dsa/realtek/rtl83xx.c
> @@ -190,6 +190,8 @@ void rtl83xx_remove(struct realtek_priv *priv)
> if (!priv)
> return;
>
> + dsa_unregister_switch(priv->ds);
> +
> /* leave the device reset asserted */
> if (priv->reset)
> gpiod_set_value(priv->reset, 1);
> --
> 2.43.0
>
next prev parent reply other threads:[~2024-01-25 11:17 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-23 21:55 [PATCH net-next v4 00/11] net: dsa: realtek: variants to drivers, interfaces to a common module Luiz Angelo Daros de Luca
2024-01-23 21:55 ` [PATCH net-next v4 01/11] net: dsa: realtek: drop cleanup from realtek_ops Luiz Angelo Daros de Luca
2024-01-23 21:55 ` [PATCH net-next v4 02/11] net: dsa: realtek: introduce REALTEK_DSA namespace Luiz Angelo Daros de Luca
2024-01-25 10:02 ` Vladimir Oltean
2024-01-29 16:09 ` Florian Fainelli
2024-01-23 21:55 ` [PATCH net-next v4 03/11] net: dsa: realtek: convert variants into real drivers Luiz Angelo Daros de Luca
2024-01-24 19:19 ` Jakub Kicinski
2024-01-25 10:25 ` Vladimir Oltean
2024-01-28 23:34 ` Luiz Angelo Daros de Luca
2024-01-29 16:21 ` Vladimir Oltean
2024-01-23 21:55 ` [PATCH net-next v4 04/11] net: dsa: realtek: keep variant reference in realtek_priv Luiz Angelo Daros de Luca
2024-01-25 10:26 ` Vladimir Oltean
2024-01-29 16:10 ` Florian Fainelli
2024-01-29 17:36 ` Luiz Angelo Daros de Luca
2024-01-23 21:55 ` [PATCH net-next v4 05/11] net: dsa: realtek: common rtl83xx module Luiz Angelo Daros de Luca
2024-01-25 10:45 ` Vladimir Oltean
2024-01-29 0:09 ` Luiz Angelo Daros de Luca
2024-01-29 16:18 ` Vladimir Oltean
2024-01-26 23:19 ` kernel test robot
2024-01-23 21:55 ` [PATCH net-next v4 06/11] net: dsa: realtek: merge rtl83xx and interface modules into realtek-dsa Luiz Angelo Daros de Luca
2024-01-25 11:00 ` Vladimir Oltean
2024-01-29 16:13 ` Florian Fainelli
2024-01-23 21:55 ` [PATCH net-next v4 07/11] net: dsa: realtek: get internal MDIO node by name Luiz Angelo Daros de Luca
2024-01-29 16:11 ` Florian Fainelli
2024-01-23 21:56 ` [PATCH net-next v4 08/11] net: dsa: realtek: clean user_mii_bus setup Luiz Angelo Daros de Luca
2024-01-25 11:17 ` Vladimir Oltean [this message]
2024-01-29 2:12 ` Luiz Angelo Daros de Luca
2024-01-29 16:15 ` Vladimir Oltean
2024-01-29 16:22 ` Florian Fainelli
2024-01-29 16:43 ` Vladimir Oltean
2024-01-29 16:54 ` Florian Fainelli
2024-01-30 14:40 ` Arınç ÜNAL
2024-01-30 15:02 ` Andrew Lunn
2024-01-30 18:17 ` Luiz Angelo Daros de Luca
2024-01-23 21:56 ` [PATCH net-next v4 09/11] net: dsa: realtek: migrate user_mii_bus setup to realtek-dsa Luiz Angelo Daros de Luca
2024-01-25 16:05 ` Vladimir Oltean
2024-01-29 2:49 ` Luiz Angelo Daros de Luca
2024-01-29 15:19 ` Vladimir Oltean
2024-01-23 21:56 ` [PATCH net-next v4 10/11] net: dsa: realtek: use the same mii bus driver for both interfaces Luiz Angelo Daros de Luca
2024-01-23 21:56 ` [PATCH net-next v4 11/11] net: dsa: realtek: embed dsa_switch into realtek_priv Luiz Angelo Daros de Luca
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240125111718.armzsazgcjnicc2h@skbuf \
--to=olteanv@gmail.com \
--cc=alsi@bang-olufsen.dk \
--cc=andrew@lunn.ch \
--cc=ansuelsmth@gmail.com \
--cc=arinc.unal@arinc9.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=kuba@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=luizluca@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox