netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vladimir Oltean <olteanv@gmail.com>
To: Colin King <colin.king@canonical.com>
Cc: Andrew Lunn <andrew@lunn.ch>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	Russell King <linux@armlinux.org.uk>,
	"David S . Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	netdev@vger.kernel.org, kernel-janitors@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH][next] net: pcs: xpcs: Fix a less than zero u16 comparision error
Date: Tue, 15 Jun 2021 16:42:06 +0300	[thread overview]
Message-ID: <20210615134206.ayjpjk2sqv7umjah@skbuf> (raw)
In-Reply-To: <20210615131601.57900-1-colin.king@canonical.com>

Some nitpicks, fix them if you'd like, ignore them if not:

s/comparision/comparison/

On Tue, Jun 15, 2021 at 02:16:01PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Currently the check for the u16 variable val being less than zero is
> always false because val is unsigned. Fix this by using the int
> variable for the assignment and less than zero check.
> 
> Addresses-Coverity: ("Unsigned compared against 0")
> Fixes: f7380bba42fd ("net: pcs: xpcs: add support for NXP SJA1110")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/net/pcs/pcs-xpcs-nxp.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/pcs/pcs-xpcs-nxp.c b/drivers/net/pcs/pcs-xpcs-nxp.c
> index de99c37cf2ae..80430ca94fbf 100644
> --- a/drivers/net/pcs/pcs-xpcs-nxp.c
> +++ b/drivers/net/pcs/pcs-xpcs-nxp.c
> @@ -152,11 +152,11 @@ static int nxp_sja1110_pma_config(struct dw_xpcs *xpcs,
>  	/* Enable TX and RX PLLs and circuits.
>  	 * Release reset of PMA to enable data flow to/from PCS.
>  	 */
> -	val = xpcs_read(xpcs, MDIO_MMD_VEND2, SJA1110_POWERDOWN_ENABLE);
> -	if (val < 0)
> -		return val;
> +	ret = xpcs_read(xpcs, MDIO_MMD_VEND2, SJA1110_POWERDOWN_ENABLE);
> +	if (ret < 0)
> +		return ret;
>  
> -	val &= ~(SJA1110_TXPLL_PD | SJA1110_TXPD | SJA1110_RXCH_PD |
> +	val = ret & ~(SJA1110_TXPLL_PD | SJA1110_TXPD | SJA1110_RXCH_PD |

You could have realigned the following 2 lines as well with the new
position of SJA1110_TXPLL_PD.

>  		 SJA1110_RXBIAS_PD | SJA1110_RESET_SER_EN |
>  		 SJA1110_RESET_SER | SJA1110_RESET_DES);
>  	val |= SJA1110_RXPKDETEN | SJA1110_RCVEN;
> -- 
> 2.31.1
> 

Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>

      reply	other threads:[~2021-06-15 13:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-15 13:16 [PATCH][next] net: pcs: xpcs: Fix a less than zero u16 comparision error Colin King
2021-06-15 13:42 ` Vladimir Oltean [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=20210615134206.ayjpjk2sqv7umjah@skbuf \
    --to=olteanv@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=colin.king@canonical.com \
    --cc=davem@davemloft.net \
    --cc=hkallweit1@gmail.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).