From: Vivien Didelot <vivien.didelot@gmail.com>
To: Marek Behun <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>
Subject: Re: [PATCH net-next v3 4/6] net: dsa: mv88e6xxx: simplify SERDES code for Topaz and Peridot
Date: Mon, 26 Aug 2019 12:08:34 -0400 [thread overview]
Message-ID: <20190826120834.GB1341@t480s.localdomain> (raw)
In-Reply-To: <20190825183609.4a9cc0d7@nic.cz>
Hi Marek,
On Sun, 25 Aug 2019 18:36:09 +0200, Marek Behun <marek.behun@nic.cz> wrote:
> > Aren't you relying on -ENODEV as well?
>
> Vivien, I am not relying o -ENODEV. I changed the serdes_get_lane
> semantics:
> - previously:
> - if port has a lane for current cmode, return given lane number
> - otherwise return -ENODEV
> - if other error occured during serdes_get_lane, return that error
> (this never happened, because all implementations only need port
> number and cmode, and cmode is cached, so no function was called
> that could err)
> - after this commit:
> - if port has a lane for current cmode, return 0 and put lane number
> into *lane
> - otherwise return 0 and put -1 into *lane
> - if error occured, return that error number
>
> I removed the -ENODEV semantics for "no lane on port" event.
> There are two reasons for this:
> 1. once you requested lane number to be put into a place pointed to
> by a pointer, rather than the return value, the code seemed better
> to me (you may of course disagree, this is a personal opinion) when
> I did:
> if (err)
> return err;
> if (lane < 0)
> return 0;
> rather than
> if (err == -ENODEV)
> return 0;
> if (err)
> return err;
A single return path for invalid queries, eventually checking a specific
error, is always more idiomatic and better than checking two places which
could lead in mistakes as your previous patch did. So this is more readable:
if (err)
return err;
or:
if (err && err != -ENODEV)
return err;
or:
if (err) {
if (err = -ENODEV)
err = 0;
return err;
}
> 2. some future implementation may actually need to call some MDIO
> read/write functions, which may or may not return -ENODEV. That
> could conflict with the -ENODEV returned when there is no lane.
The current code is already using -ENODEV to inform about "no lane for port",
even if it can be used by lower level functions, same as -EINVAL. That is fine.
So if you have to respin the series again, I would really prefer to see an
unsigned lane parameter, otherwise, fine...
Thanks,
Vivien
next prev parent reply other threads:[~2019-08-26 16:08 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
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 [this message]
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=20190826120834.GB1341@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;
as well as URLs for NNTP newsgroup(s).