Re: [PATCH net-next v2 1/3] net: dsa: yt921x: Refactor port error message
From: Andrew Lunn
Date: Tue Feb 24 2026 - 08:41:59 EST
On Tue, Feb 24, 2026 at 07:24:05PM +0800, David Yang wrote:
> Sometimes we might get error from the underlying bus, but the return
> type of the function is void, so an error message is desired here. There
> are many instances of the same pattern, refactor it.
>
> +static void
> +print_port_err(const struct device *dev, int port, int res, const char *action)
Please use the prefix yt921x_.
> +{
> + dev_err(dev, "Failed to %s port %d: %i\n", action, port, res);
> +}
> +
> static int yt921x_reg_read(struct yt921x_priv *priv, u32 reg, u32 *valp)
> {
> WARN_ON(!mutex_is_locked(&priv->reg_lock));
> @@ -721,8 +727,7 @@ static int yt921x_read_mib(struct yt921x_priv *priv, int port)
> mib->tx_jumbo;
>
> if (res)
> - dev_err(dev, "Failed to %s port %d: %i\n", "read stats for",
> - port, res);
> + print_port_err(dev, port, res, "read stats for");
The thing about dev_err() is that everybody knows what it does. What
does print_port_err() do? yt921x_port_dev_err() would at least give a
better idea what it does, but being so long, do you actually save
anything?
So i don't know if this patch is actually useful.
Andrew