mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mieczyslaw Nalewaj <namiltd@yahoo.com>
To: "Luiz Angelo Daros de Luca" <luizluca@gmail.com>,
	"Linus Walleij" <linusw@kernel.org>,
	"Alvin Šipraga" <alsi@bang-olufsen.dk>,
	"Andrew Lunn" <andrew@lunn.ch>,
	"Vladimir Oltean" <olteanv@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next] net: dsa: realtek: rtl8365mb: use devm_mutex_init
Date: Sun, 26 Jul 2026 21:18:44 +0200	[thread overview]
Message-ID: <2263dec9-67fe-4f0c-ad0a-82ab2a2661c1@yahoo.com> (raw)
In-Reply-To: <20260718-realtek_mutext-v1-1-1cd7beb20ae6@gmail.com>

On 7/18/2026 7:59 AM, Luiz Angelo Daros de Luca wrote:
> mutex_destroy() is needed while debugging mutex. Instead of calling it
> directly on driver .remove(), just use devm.
> 
> Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
> ---
>  drivers/net/dsa/realtek/rtl8365mb_main.c | 15 ++++++++++++---
>  drivers/net/dsa/realtek/rtl83xx.c        | 14 +++++++++++---
>  2 files changed, 23 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/dsa/realtek/rtl8365mb_main.c b/drivers/net/dsa/realtek/rtl8365mb_main.c
> index 5ac091bf93c9..c787fdb75413 100644
> --- a/drivers/net/dsa/realtek/rtl8365mb_main.c
> +++ b/drivers/net/dsa/realtek/rtl8365mb_main.c
> @@ -1988,16 +1988,19 @@ static void rtl8365mb_get_stats64(struct dsa_switch *ds, int port,
>  	spin_unlock(&p->stats_lock);
>  }
>  
> -static void rtl8365mb_stats_setup(struct realtek_priv *priv)
> +static int rtl8365mb_stats_setup(struct realtek_priv *priv)
>  {
>  	struct rtl8365mb *mb = priv->chip_data;
>  	struct dsa_switch *ds = &priv->ds;
>  	struct dsa_port *dp;
> +	int ret;
>  
>  	/* Per-chip global mutex to protect MIB counter access, since doing
>  	 * so requires accessing a series of registers in a particular order.
>  	 */
> -	mutex_init(&mb->mib_lock);
> +	ret = devm_mutex_init(priv->dev, &mb->mib_lock);
> +	if (ret)
> +		return ret;
>  
>  	dsa_switch_for_each_available_port(dp, ds) {
>  		struct rtl8365mb_port *p = &mb->ports[dp->index];
> @@ -2010,6 +2013,8 @@ static void rtl8365mb_stats_setup(struct realtek_priv *priv)
>  		 */
>  		INIT_DELAYED_WORK(&p->mib_work, rtl8365mb_stats_poll);
>  	}
> +
> +	return 0;
>  }
>  
>  static void rtl8365mb_stats_teardown(struct realtek_priv *priv)
> @@ -2567,7 +2572,11 @@ static int rtl8365mb_setup(struct dsa_switch *ds)
>  	}
>  
>  	/* Start statistics counter polling */
> -	rtl8365mb_stats_setup(priv);
> +	ret = rtl8365mb_stats_setup(priv);
> +	if (ret) {
> +		dev_err(priv->dev, "failed to setup stats\n");
> +		goto out_teardown_irq;
> +	}
>  
>  	return 0;
>  
> diff --git a/drivers/net/dsa/realtek/rtl83xx.c b/drivers/net/dsa/realtek/rtl83xx.c
> index 90843d52c5a8..35df809a5951 100644
> --- a/drivers/net/dsa/realtek/rtl83xx.c
> +++ b/drivers/net/dsa/realtek/rtl83xx.c
> @@ -156,9 +156,17 @@ rtl83xx_probe(struct device *dev,
>  	if (!priv)
>  		return ERR_PTR(-ENOMEM);
>  
> -	mutex_init(&priv->map_lock);
> -	mutex_init(&priv->vlan_lock);
> -	mutex_init(&priv->l2_lock);
> +	ret = devm_mutex_init(dev, &priv->map_lock);
> +	if (ret)
> +		return ERR_PTR(ret);
> +
> +	ret = devm_mutex_init(dev, &priv->vlan_lock);
> +	if (ret)
> +		return ERR_PTR(ret);
> +
> +	ret = devm_mutex_init(dev, &priv->l2_lock);
> +	if (ret)
> +		return ERR_PTR(ret);
>  
>  	rc.lock_arg = priv;
>  	priv->map = devm_regmap_init(dev, NULL, priv, &rc);
> 
> ---
> base-commit: ce6b4d3216b63f902bb8e9695ee6c10c83415f65
> change-id: 20260718-realtek_mutext-41a072e5cd24
> 
> Best regards,
> --  
> Luiz Angelo Daros de Luca <luizluca@gmail.com>
> 
> 

Reviewed-by: Mieczyslaw Nalewaj <namiltd@yahoo.com>

      parent reply	other threads:[~2026-07-26 19:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-18  5:59 Luiz Angelo Daros de Luca
2026-07-19  2:41 ` Qingfang Deng
2026-07-27  1:57   ` Luiz Angelo Daros de Luca
2026-07-26 19:18 ` Mieczyslaw Nalewaj [this message]

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=2263dec9-67fe-4f0c-ad0a-82ab2a2661c1@yahoo.com \
    --to=namiltd@yahoo.com \
    --cc=alsi@bang-olufsen.dk \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linusw@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luizluca@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --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

all inboxes | Powered by JetHome®