public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn•ch>
To: Vladimir Oltean <olteanv@gmail•com>
Cc: f.fainelli@gmail•com, vivien.didelot@gmail•com,
	davem@davemloft•net, netdev@vger•kernel.org
Subject: Re: [PATCH net 1/2] net: dsa: sja1105: Force a negative value for enum sja1105_speed_t
Date: Sat, 1 Jun 2019 18:03:56 +0200	[thread overview]
Message-ID: <20190601160356.GB19081@lunn.ch> (raw)
In-Reply-To: <20190601103735.27506-2-olteanv@gmail.com>

On Sat, Jun 01, 2019 at 01:37:34PM +0300, Vladimir Oltean wrote:
> The code in sja1105_adjust_port_config relies on the fact that an
> invalid link speed is detected by sja1105_get_speed_cfg and returned as
> -EINVAL.  However storing this into an enum that only has positive
> members will cast it into an unsigned value, and it will miss the
> negative check.
> 
> So make the -EINVAL value part of the enum, so that it is stored as a
> signed number and passes the negative check.
> 
> Fixes: 8aa9ebccae87 ("net: dsa: Introduce driver for NXP SJA1105 5-port L2 switch")
> Signed-off-by: Vladimir Oltean <olteanv@gmail•com>

Hi Vladimir

It seems like just using a switch statement would be simpler, and more
likely to be correct. And it would avoid adding SJA1105_SPEED_INVALID
= -EINVAL which feels hackish.

  Andrew

  reply	other threads:[~2019-06-01 16:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-01 10:37 [PATCH net 0/2] Fix link speed handling for SJA1105 DSA driver Vladimir Oltean
2019-06-01 10:37 ` [PATCH net 1/2] net: dsa: sja1105: Force a negative value for enum sja1105_speed_t Vladimir Oltean
2019-06-01 16:03   ` Andrew Lunn [this message]
2019-06-01 20:30     ` Vladimir Oltean
2019-06-01 21:36       ` Andrew Lunn
2019-06-01 10:37 ` [PATCH net 2/2] net: dsa: sja1105: Fix link speed not working at 100 Mbps and below Vladimir Oltean

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=20190601160356.GB19081@lunn.ch \
    --to=andrew@lunn$(echo .)ch \
    --cc=davem@davemloft$(echo .)net \
    --cc=f.fainelli@gmail$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=olteanv@gmail$(echo .)com \
    --cc=vivien.didelot@gmail$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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