public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Oltean <olteanv@gmail.com>
To: Luiz Angelo Daros de Luca <luizluca@gmail.com>
Cc: "Linus Walleij" <linus.walleij@linaro.org>,
	"Alvin Šipraga" <alsi@bang-olufsen.dk>,
	"Andrew Lunn" <andrew@lunn.ch>,
	"Florian Fainelli" <f.fainelli@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Russell King" <linux@armlinux.org.uk>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v5 11/11] net: dsa: realtek: embed dsa_switch into realtek_priv
Date: Fri, 2 Feb 2024 00:58:24 +0200	[thread overview]
Message-ID: <20240201225824.hajwp2dbj7zcbkgp@skbuf> (raw)
In-Reply-To: <20240130-realtek_reverse-v5-11-ecafd9283a07@gmail.com> <20240130-realtek_reverse-v5-11-ecafd9283a07@gmail.com>

On Tue, Jan 30, 2024 at 08:13:30PM -0300, Luiz Angelo Daros de Luca wrote:
> To eliminate the need for a second memory allocation for dsa_switch, it
> has been embedded within realtek_priv.
> 
> Suggested-by: Alvin Šipraga <alsi@bang-olufsen.dk>
> Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
> ---

Reviewed-by: Vladimir Oltean <olteanv@gmail.com>

I don't think it would be bad if you could just define a local variable

	struct dsa_switch *ds = &priv->ds;

in all functions, including those which reference &priv->ds just once.

> diff --git a/drivers/net/dsa/realtek/realtek.h b/drivers/net/dsa/realtek/realtek.h
> index 864bb9a88f14..b80bfde1ad04 100644
> --- a/drivers/net/dsa/realtek/realtek.h
> +++ b/drivers/net/dsa/realtek/realtek.h
> @@ -61,7 +61,7 @@ struct realtek_priv {
>  	const struct realtek_variant *variant;
>  
>  	spinlock_t		lock; /* Locks around command writes */
> -	struct dsa_switch	*ds;
> +	struct dsa_switch	ds;
>  	struct irq_domain	*irqdomain;
>  	bool			leds_disabled;
>  
> diff --git a/drivers/net/dsa/realtek/rtl8365mb.c b/drivers/net/dsa/realtek/rtl8365mb.c
> index 778a962727ab..9066e34e9ace 100644
> --- a/drivers/net/dsa/realtek/rtl8365mb.c
> +++ b/drivers/net/dsa/realtek/rtl8365mb.c
> @@ -880,7 +880,7 @@ static int rtl8365mb_ext_config_rgmii(struct realtek_priv *priv, int port,
>  	if (!extint)
>  		return -ENODEV;
>  
> -	dp = dsa_to_port(priv->ds, port);
> +	dp = dsa_to_port(&priv->ds, port);

Nitpick: I don't think it would be bad if you could just define a local variable

	struct dsa_switch *ds = &priv->ds;

in all functions, including those which reference &priv->ds just once,
like this one.

>  	dn = dp->dn;
>  
>  	/* Set the RGMII TX/RX delay
> diff --git a/drivers/net/dsa/realtek/rtl83xx.c b/drivers/net/dsa/realtek/rtl83xx.c
> index aa998e15c42b..f65e47339d5b 100644
> --- a/drivers/net/dsa/realtek/rtl83xx.c
> +++ b/drivers/net/dsa/realtek/rtl83xx.c
> @@ -226,16 +226,12 @@ int rtl83xx_register_switch(struct realtek_priv *priv)
>  		return ret;
>  	}
>  
> -	priv->ds = devm_kzalloc(priv->dev, sizeof(*priv->ds), GFP_KERNEL);
> -	if (!priv->ds)
> -		return -ENOMEM;
> +	priv->ds.priv = priv;
> +	priv->ds.dev = priv->dev;
> +	priv->ds.ops = priv->variant->ds_ops;
> +	priv->ds.num_ports = priv->num_ports;

And here, I think it would actually look better to dereference just
through "ds".

Also, priv->dev is dereferenced 4 times in rtl83xx_register_switch(),
maybe you could add a local variable for it in the patch that introduces
rtl83xx_register_switch().

>  
> -	priv->ds->priv = priv;
> -	priv->ds->dev = priv->dev;
> -	priv->ds->ops = priv->variant->ds_ops;
> -	priv->ds->num_ports = priv->num_ports;
> -
> -	ret = dsa_register_switch(priv->ds);
> +	ret = dsa_register_switch(&priv->ds);
>  	if (ret) {
>  		dev_err_probe(priv->dev, ret, "unable to register switch\n");
>  		return ret;

  reply	other threads:[~2024-02-01 22:58 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-30 23:13 [PATCH net-next v5 00/11] net: dsa: realtek: variants to drivers, interfaces to a common module Luiz Angelo Daros de Luca
2024-01-30 23:13 ` [PATCH net-next v5 01/11] net: dsa: realtek: drop cleanup from realtek_ops Luiz Angelo Daros de Luca
2024-02-01  0:40   ` Vladimir Oltean
2024-01-30 23:13 ` [PATCH net-next v5 02/11] net: dsa: realtek: introduce REALTEK_DSA namespace Luiz Angelo Daros de Luca
2024-01-30 23:13 ` [PATCH net-next v5 03/11] net: dsa: realtek: convert variants into real drivers Luiz Angelo Daros de Luca
2024-02-01 11:30   ` Vladimir Oltean
2024-01-30 23:13 ` [PATCH net-next v5 04/11] net: dsa: realtek: keep variant reference in realtek_priv Luiz Angelo Daros de Luca
2024-01-30 23:13 ` [PATCH net-next v5 05/11] net: dsa: realtek: common rtl83xx module Luiz Angelo Daros de Luca
2024-02-01 18:23   ` Vladimir Oltean
2024-01-30 23:13 ` [PATCH net-next v5 06/11] net: dsa: realtek: merge rtl83xx and interface modules into realtek-dsa Luiz Angelo Daros de Luca
2024-01-30 23:13 ` [PATCH net-next v5 07/11] net: dsa: realtek: get internal MDIO node by name Luiz Angelo Daros de Luca
2024-01-30 23:13 ` [PATCH net-next v5 08/11] net: dsa: realtek: clean user_mii_bus setup Luiz Angelo Daros de Luca
2024-02-01 22:33   ` Vladimir Oltean
2024-01-30 23:13 ` [PATCH net-next v5 09/11] net: dsa: realtek: migrate user_mii_bus setup to realtek-dsa Luiz Angelo Daros de Luca
2024-02-01 22:45   ` Vladimir Oltean
2024-02-05 22:43     ` Luiz Angelo Daros de Luca
2024-01-30 23:13 ` [PATCH net-next v5 10/11] net: dsa: realtek: use the same mii bus driver for both interfaces Luiz Angelo Daros de Luca
2024-02-01 22:48   ` Vladimir Oltean
2024-01-30 23:13 ` [PATCH net-next v5 11/11] net: dsa: realtek: embed dsa_switch into realtek_priv Luiz Angelo Daros de Luca
2024-02-01 22:58   ` Vladimir Oltean [this message]
2024-02-05 21:49     ` 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=20240201225824.hajwp2dbj7zcbkgp@skbuf \
    --to=olteanv@gmail.com \
    --cc=alsi@bang-olufsen.dk \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --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