Re: [PATCH -next 1/2] net: dsa: qca8k: check return value of read functions correctly

From: Jakub Kicinski
Date: Fri May 28 2021 - 17:15:16 EST


On Fri, 28 May 2021 16:22:39 +0800 Yang Yingliang wrote:
> Current return type of qca8k_mii_read32() and qca8k_read() are
> unsigned, it can't be negative, so the return value check is
> unuseful. For check the return value correctly, change return
> type of the read functions and add a output parameter to store
> the read value.
>
> Signed-off-by: Yang Yingliang <yangyingliang@xxxxxxxxxx>

> @@ -1141,6 +1128,7 @@ qca8k_phylink_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
> {
> struct qca8k_priv *priv = ds->priv;
> u32 reg, val;
> + int ret;
>
> switch (port) {
> case 0: /* 1st CPU port */
> @@ -1211,7 +1199,7 @@ qca8k_phylink_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
> qca8k_write(priv, reg, QCA8K_PORT_PAD_SGMII_EN);
>
> /* Enable/disable SerDes auto-negotiation as necessary */
> - val = qca8k_read(priv, QCA8K_REG_PWS);
> + ret = qca8k_read(priv, QCA8K_REG_PWS, &val);
> if (phylink_autoneg_inband(mode))
> val &= ~QCA8K_PWS_SERDES_AEN_DIS;
> else
> @@ -1219,7 +1207,7 @@ qca8k_phylink_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
> qca8k_write(priv, QCA8K_REG_PWS, val);
>
> /* Configure the SGMII parameters */
> - val = qca8k_read(priv, QCA8K_REG_SGMII_CTRL);
> + ret = qca8k_read(priv, QCA8K_REG_SGMII_CTRL, &val);
>
> val |= QCA8K_SGMII_EN_PLL | QCA8K_SGMII_EN_RX |
> QCA8K_SGMII_EN_TX | QCA8K_SGMII_EN_SD;

drivers/net/dsa/qca8k.c: In function ‘qca8k_phylink_mac_config’:
drivers/net/dsa/qca8k.c:1131:6: warning: variable ‘ret’ set but not used [-Wunused-but-set-variable]
1131 | int ret;
| ^~~