[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180504171927.GB13899@kwain>
Date: Fri, 4 May 2018 19:19:27 +0200
From: Antoine Tenart <antoine.tenart@...tlin.com>
To: Florian Fainelli <f.fainelli@...il.com>
Cc: Antoine Tenart <antoine.tenart@...tlin.com>, davem@...emloft.net,
kishon@...com, linux@...linux.org.uk, gregory.clement@...tlin.com,
andrew@...n.ch, jason@...edaemon.net,
sebastian.hesselbarth@...il.com, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org, thomas.petazzoni@...tlin.com,
maxime.chevallier@...tlin.com, miquel.raynal@...tlin.com,
nadavh@...vell.com, stefanc@...vell.com, ymarkman@...vell.com,
mw@...ihalf.com, linux-arm-kernel@...ts.infradead.org
Subject: Re: [PATCH net-next v2 01/13] net: phy: sfp: make the i2c-bus
property really optional
Hi Florian,
On Fri, May 04, 2018 at 10:03:16AM -0700, Florian Fainelli wrote:
> On 05/04/2018 06:56 AM, Antoine Tenart wrote:
> >
> > static int sfp_read(struct sfp *sfp, bool a2, u8 addr, void *buf, size_t len)
> > {
> > + if (!sfp->read)
> > + return -EOPNOTSUPP;
>
> -ENODEV would be closer to the intended meaning IMHO, those this could
> be argue that this is yet another color to paint the bikeshed with.
I thought about -ENODEV as well, but ended up choosing -EOPNOTSUPP for
some reason. But I'm really fine with both solutions, it really depends
on if we want to return a callback isn't available from a s/w point of
view (-EOPNOTSUPP) or a h/w point of view (-ENODEV).
> > ret = sfp_read(sfp, false, 0, &id, sizeof(id));
> > + if (ret == -EOPNOTSUPP)
> > + return ret;
>
> Can you find a way such that only sfp_sm_mod_probe() needs to check
> whether the sfp read/write operations returned failure and then we just
> make sure the SFP state machine does not make any more progress? Having
> to check the sfp_read()/sfp_write() operations all over the place sounds
> error prone and won't scale in the future.
I tried doing this in this way (only having logic in the probe
function), but that wasn't as simple as this solution and it seemed
quite invasive as these read/write calls can be called from a few
functions but many code paths (as it's a state machine). So I choose the
easiest solution to maintain in the long run, as each future state
machine update could impact this.
Thanks!
Antoine
--
Antoine Ténart, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
Powered by blists - more mailing lists