netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Russell King - ARM Linux admin <linux@armlinux.org.uk>
To: Andrew Lunn <andrew@lunn.ch>
Cc: "Marek Behún" <kabel@kernel.org>,
	netdev@vger.kernel.org, "Jakub Kicinski" <kuba@kernel.org>,
	davem@davemloft.net, pali@kernel.org
Subject: Re: [PATCH net-next v4 1/4] net: phy: mdio-i2c: support I2C MDIO protocol for RollBall SFP modules
Date: Tue, 12 Jan 2021 21:22:58 +0000	[thread overview]
Message-ID: <20210112212258.GF1551@shell.armlinux.org.uk> (raw)
In-Reply-To: <X/4MgF+n+jQZ11Gd@lunn.ch>

On Tue, Jan 12, 2021 at 09:54:24PM +0100, Andrew Lunn wrote:
> > +static int i2c_transfer_rollball(struct i2c_adapter *i2c,
> > +				 struct i2c_msg *msgs, int num)
> > +{
> > +	u8 saved_page;
> > +	int ret;
> > +
> > +	i2c_lock_bus(i2c, I2C_LOCK_SEGMENT);
> > +
> > +	/* save original page */
> > +	ret = __i2c_rollball_get_page(i2c, msgs->addr, &saved_page);
> > +	if (ret)
> > +		goto unlock;
> > +
> > +	/* change to RollBall MDIO page */
> > +	ret = __i2c_rollball_set_page(i2c, msgs->addr, SFP_PAGE_ROLLBALL_MDIO);
> > +	if (ret)
> > +		goto unlock;
> > +
> > +	/* do the transfer */
> > +	ret = __i2c_transfer_err(i2c, msgs, num);
> > +	if (ret)
> > +		goto unlock;
> 
> If get page and set page worked, and you get an error in during the
> actual data transfer, i wonder if you should try restoring the page
> before returning with the error?

That's what we do with paged PHYs - if the access encounters an error,
we still attempt to restore the page and propagate the _original_ error.
We would only propagate the error from the page restore if it was the
only error.  See the logic and comments for phy_restore_page().

Note that phy_(save|select)_page()..phy_restore_page() deal with the
locking, which is why they always have to be paired (also means that
the user doesn't have to think too hard about error handling.)

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

  parent reply	other threads:[~2021-01-12 21:38 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-11  5:00 [PATCH net-next v4 0/4] Support for RollBall 10G copper SFP modules Marek Behún
2021-01-11  5:00 ` [PATCH net-next v4 1/4] net: phy: mdio-i2c: support I2C MDIO protocol for RollBall " Marek Behún
2021-01-12  8:42   ` Heiner Kallweit
2021-01-12 14:02     ` Andrew Lunn
2021-01-12 14:40       ` Heiner Kallweit
2021-01-12 17:49       ` Marek Behún
2021-01-12 19:22     ` Russell King - ARM Linux admin
2021-01-18 12:13       ` Pali Rohár
2021-01-18 15:45         ` Russell King - ARM Linux admin
2021-01-12 20:20   ` Andrew Lunn
2021-01-12 20:43   ` Andrew Lunn
2021-01-12 20:53     ` Marek Behún
2021-01-12 20:55       ` Andrew Lunn
2021-01-12 20:54   ` Andrew Lunn
2021-01-12 21:01     ` Marek Behún
2021-01-13 10:51       ` Pali Rohár
2021-01-12 21:22     ` Russell King - ARM Linux admin [this message]
2021-01-13 11:22   ` Pali Rohár
2021-01-13 13:56     ` Andrew Lunn
2021-01-13 13:58       ` Pali Rohár
2021-01-13 16:14       ` Russell King - ARM Linux admin
2021-01-11  5:00 ` [PATCH net-next v4 2/4] net: phylink: allow attaching phy for SFP modules on 802.3z mode Marek Behún
2021-01-13 10:38   ` Pali Rohár
2021-01-11  5:00 ` [PATCH net-next v4 3/4] net: sfp: create/destroy I2C mdiobus before PHY probe/after PHY release Marek Behún
2021-01-13 10:41   ` Pali Rohár
2021-01-11  5:00 ` [PATCH net-next v4 4/4] net: sfp: add support for multigig RollBall transceivers Marek Behún
2021-01-13 10:49   ` Pali Rohár
2021-01-13 11:08     ` Russell King - ARM Linux admin
2021-01-13 11:26       ` Pali Rohár

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=20210112212258.GF1551@shell.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=kabel@kernel.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pali@kernel.org \
    /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).