Netdev List
 help / color / mirror / Atom feed
From: Vivien Didelot <vivien.didelot@gmail.com>
To: "Marek Behún" <marek.behun@nic.cz>
Cc: netdev@vger.kernel.org, "Andrew Lunn" <andrew@lunn.ch>,
	"Florian Fainelli" <f.fainelli@gmail.com>,
	"Vladimir Oltean" <olteanv@gmail.com>,
	"Marek Behún" <marek.behun@nic.cz>
Subject: Re: [PATCH net-next v3 3/6] net: dsa: mv88e6xxx: create serdes_get_lane chip operation
Date: Sun, 25 Aug 2019 11:48:25 -0400	[thread overview]
Message-ID: <20190825114825.GD6729@t480s.localdomain> (raw)
In-Reply-To: <20190825035915.13112-4-marek.behun@nic.cz>

Hi Marek,

On Sun, 25 Aug 2019 05:59:12 +0200, Marek Behún <marek.behun@nic.cz> wrote:
>  void mv88e6390x_serdes_irq_free(struct mv88e6xxx_chip *chip, int port)
>  {
> -	int lane = mv88e6390x_serdes_get_lane(chip, port);
> +	int err;
> +	s8 lane;
>  
> -	if (lane == -ENODEV)
> +	err = mv88e6xxx_serdes_get_lane(chip, port, &lane);
> +	if (err) {
> +		dev_err(chip->dev, "Unable to free SERDES irq: %d\n", err);
>  		return;
> -
> +	}
>  	if (lane < 0)
>  		return;

[...]

> -int mv88e6390x_serdes_get_lane(struct mv88e6xxx_chip *chip, int port);
> +/* Put the SERDES lane address a port is using into *lane. If a port has
> + * multiple lanes, should put the first lane the port is using. If a port does
> + * not have a lane, put -1 into *lane.
> + */
> +static inline int mv88e6xxx_serdes_get_lane(struct mv88e6xxx_chip *chip,
> +					    int port, s8 *lane)
> +{
> +	if (!chip->info->ops->serdes_get_lane)
> +		return -EOPNOTSUPP;
> +
> +	return chip->info->ops->serdes_get_lane(chip, port, lane);
> +}

Using an invalid value is only useful if it can be interpreted by the other
functions of the API. So I would've make lane an u8, assuming it gets modified
only on success, which would result in calls like this one:

    u8 lane;
    int err;

    err = mv88e6xxx_serdes_get_lane(chip, port, &lane);
    if (err) {
        if (err == -ENODEV)
            err = 0;
        return err;
    }

But at least it is well documented, so we can eventually fine tuned later:

Reviewed-by: Vivien Didelot <vivien.didelot@gmail.com>


Thank you!

	Vivien

  reply	other threads:[~2019-08-25 15:48 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-25  3:59 [PATCH net-next v3 0/6] net: dsa: mv88e6xxx: Peridot/Topaz SERDES changes Marek Behún
2019-08-25  3:59 ` [PATCH net-next v3 1/6] net: dsa: mv88e6xxx: support 2500base-x in SGMII IRQ handler Marek Behún
2019-08-25  3:59 ` [PATCH net-next v3 2/6] net: dsa: mv88e6xxx: update code operating on hidden registers Marek Behún
2019-08-25 15:07   ` Vivien Didelot
2019-08-25  3:59 ` [PATCH net-next v3 3/6] net: dsa: mv88e6xxx: create serdes_get_lane chip operation Marek Behún
2019-08-25 15:48   ` Vivien Didelot [this message]
2019-08-25 16:12   ` Vivien Didelot
2019-08-26 12:21     ` Marek Behun
2019-08-25  3:59 ` [PATCH net-next v3 4/6] net: dsa: mv88e6xxx: simplify SERDES code for Topaz and Peridot Marek Behún
2019-08-25 16:02   ` Vivien Didelot
2019-08-25 16:36     ` Marek Behun
2019-08-26 16:08       ` Vivien Didelot
2019-08-25  3:59 ` [PATCH net-next v3 5/6] net: dsa: mv88e6xxx: rename port cmode macro Marek Behún
2019-08-25  3:59 ` [PATCH net-next v3 6/6] net: dsa: mv88e6xxx: fully support SERDES on Topaz family Marek Behún

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=20190825114825.GD6729@t480s.localdomain \
    --to=vivien.didelot@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=f.fainelli@gmail.com \
    --cc=marek.behun@nic.cz \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    /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