[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6809357f-b826-445b-9aac-5dd951bd5d83@lunn.ch>
Date: Sun, 24 Aug 2025 17:34:24 +0200
From: Andrew Lunn <andrew@...n.ch>
To: David Yang <mmyangfl@...il.com>
Cc: netdev@...r.kernel.org, Vladimir Oltean <olteanv@...il.com>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>, Simon Horman <horms@...nel.org>,
Russell King <linux@...linux.org.uk>, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next v6 3/3] net: dsa: yt921x: Add support for
Motorcomm YT921x
> +static void yt921x_smi_acquire(struct yt921x_priv *priv)
> +{
> + if (priv->smi_ops->acquire)
> + priv->smi_ops->acquire(priv->smi_ctx);
> +}
> +
> +static void yt921x_smi_release(struct yt921x_priv *priv)
> +{
> + if (priv->smi_ops->release)
> + priv->smi_ops->release(priv->smi_ctx);
> +}
What happens if priv->smi_ops->acquire and priv->smi_ops->release are
not implemented? Very likely, it will mostly work, but have subtle bug
which are going to be hard to observe and find.
You want bugs to be obvious, so they are quick and easy to find. The
best way to make the bug of missing locking obvious is to jump through
a NULL pointer and get an Opps. The stack trace will make it obvious
what has happened.
> +
> +static int yt921x_smi_read(struct yt921x_priv *priv, u32 reg, u32 *valp)
> +{
> + return priv->smi_ops->read(priv->smi_ctx, reg, valp);
> +}
> +
> +static int yt921x_smi_read_burst(struct yt921x_priv *priv, u32 reg, u32 *valp)
> +{
> + int res;
> +
> + yt921x_smi_acquire(priv);
> + res = yt921x_smi_read(priv, reg, valp);
> + yt921x_smi_release(priv);
I don't understand the name _burst here? Why is it called
that. Looking at other drivers, _u32 would be more common, especially
if you have functions to read a _u16, _u8 etc.
Andrew
Powered by blists - more mailing lists