mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Oleksij Rempel <o.rempel@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: Gerald Loacker <gerald.loacker@wolfvision.net>,
	barebox@lists.infradead.org
Subject: Re: [PATCH 3/4] net: ksz9477: propagate phy read error
Date: Fri, 8 Sep 2023 14:32:40 +0200	[thread overview]
Message-ID: <20230908123240.GA780075@pengutronix.de> (raw)
In-Reply-To: <23240e08-f109-36e4-8588-df64d8594f7a@pengutronix.de>

Hi,

On Fri, Sep 08, 2023 at 01:59:05PM +0200, Ahmad Fatoum wrote:
> On 08.09.23 12:16, Gerald Loacker wrote:
> > In case of an error we should not return an arbitrary value, propagate the
> > error code instead.
> > Fix return value in case of address error.
> > 
> > Signed-off-by: Gerald Loacker <gerald.loacker@wolfvision.net>
> > ---
> >  drivers/net/ksz9477.c | 9 +++++----
> >  1 file changed, 5 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/net/ksz9477.c b/drivers/net/ksz9477.c
> > index 9665e0f723..d664b7cf01 100644
> > --- a/drivers/net/ksz9477.c
> > +++ b/drivers/net/ksz9477.c
> > @@ -29,14 +29,15 @@ static int ksz9477_phy_read16(struct dsa_switch *ds, int addr, int reg)
> >  {
> >  	struct device *dev = ds->dev;
> >  	struct ksz_switch *priv = dev_get_priv(dev);
> > -	u16 val = 0xffff;
> > +	u16 val;
> > +	int ret;
> >  
> >  	if (addr >= priv->phy_port_cnt)
> > -		return val;
> > +		return -EINVAL;
> 
> Looks sensible IMO, but shouldn't we do the same in dsa_slave_phy_read
> if no callback is defined?
> 
> @Oleksij, why did you decide for 0xffff instead of a negative error code?

This code imitate real MDIO bus access. If you trying to read at not
existing PHY address, you will get 0xffff instead of negative error.
May be it is better to add a comment :)

Regards,
Oleksij
-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



  reply	other threads:[~2023-09-08 12:34 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-08 10:16 [PATCH 0/4] Fix rockchip I2C bus Gerald Loacker
2023-09-08 10:16 ` [PATCH 1/4] i2c: rockchip: fix i2c stop condition Gerald Loacker
2023-09-08 13:53   ` Sascha Hauer
2023-09-12  5:45     ` Gerald Loacker
2023-09-12  6:03       ` Sascha Hauer
2023-09-08 10:16 ` [PATCH 2/4] i2c: rockchip: ignore i2c transfers when another transfer is running Gerald Loacker
2023-09-08 11:51   ` Sascha Hauer
2023-09-08 11:55     ` Sascha Hauer
2023-09-08 13:13       ` Sascha Hauer
2023-09-11 11:46         ` Gerald Loacker
2023-09-08 10:16 ` [PATCH 3/4] net: ksz9477: propagate phy read error Gerald Loacker
2023-09-08 11:59   ` Ahmad Fatoum
2023-09-08 12:32     ` Oleksij Rempel [this message]
2023-09-08 10:16 ` [PATCH 4/4] net: ksz9477: propagate phy write error Gerald Loacker

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=20230908123240.GA780075@pengutronix.de \
    --to=o.rempel@pengutronix.de \
    --cc=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=gerald.loacker@wolfvision.net \
    /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