mbox series

[-next,0/2] net: dsa: qca8k: check return value of read functions correctly

Message ID 20210528082240.3863991-1-yangyingliang@huawei.com
Headers show
Series net: dsa: qca8k: check return value of read functions correctly | expand

Message

Yang Yingliang May 28, 2021, 8:22 a.m. UTC
patch #1 - Change return type and add output parameter to make check
return value of read  functions correctly.

patch #2 - Add missing check return value in qca8k_phylink_mac_config().

Yang Yingliang (2):
  net: dsa: qca8k: check return value of read functions correctly
  net: dsa: qca8k: add missing check return value in
    qca8k_phylink_mac_config()

 drivers/net/dsa/qca8k.c | 135 +++++++++++++++++++---------------------
 1 file changed, 65 insertions(+), 70 deletions(-)

Comments

Jakub Kicinski May 28, 2021, 9:15 p.m. UTC | #1
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@huawei.com>

> @@ -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;
      |      ^~~
Jakub Kicinski May 28, 2021, 9:19 p.m. UTC | #2
On Fri, 28 May 2021 16:22:39 +0800 Yang Yingliang wrote:
> @@ -1793,14 +1783,15 @@ static int qca8k_read_switch_id(struct qca8k_priv *priv)
>  	const struct qca8k_match_data *data;
>  	u32 val;
>  	u8 id;
> +	int ret;

ret before id to keep the reverse xmas tree ordering