From: Russell King - ARM Linux <linux@armlinux.org.uk>
To: Andrew Lunn <andrew@lunn.ch>
Cc: Florian Fainelli <f.fainelli@gmail.com>, netdev@vger.kernel.org
Subject: Re: [PATCH net-next 4/7] net: phy: add paged phy register accessors
Date: Sun, 31 Dec 2017 10:07:15 +0000 [thread overview]
Message-ID: <20171231100714.GD10595@n2100.armlinux.org.uk> (raw)
In-Reply-To: <20171231081039.GA14485@lunn.ch>
On Sun, Dec 31, 2017 at 09:10:39AM +0100, Andrew Lunn wrote:
> > +/**
> > + * phy_save_page() - take the bus lock and save the current page
> > + * @phydev: a pointer to a &struct phy_device
> > + *
> > + * Take the MDIO bus lock, and return the current page number. On error,
> > + * returns a negative errno. phy_restore_page() must be called after this
> > + * to release the lock even on failure.
> > + */
> > +int phy_save_page(struct phy_device *phydev)
> > +{
> > + mutex_lock(&phydev->mdio.bus->mdio_lock);
> > + return __phy_read_page(phydev);
> > +}
> > +EXPORT_SYMBOL_GPL(phy_save_page);
> > +
> > +/**
> > + * phy_select_page() - take the bus lock, save the current page, and set a page
> > + * @phydev: a pointer to a &struct phy_device
> > + * @page: desired page
> > + *
> > + * Take the MDIO bus lock to protect against concurrent access, save the
> > + * current PHY page, and set the current page. On error, returns a
> > + * negative errno, otherwise returns the previous page number.
> > + * phy_restore_page() must be called after this to restore the page
> > + * number (if this call was successful) and release the lock.
>
> Hi Russell
>
> This comment seems wrong. It looks like you need to call
> phy_restore_page() on error as well. I think the text in () should be
> removed, and add the "even on failure" which the previous function
> states.
It's one of those slightly confusing bits of English, and I doubt
there's a way to express it better.
phy_restore_page() must be called after this to [restore the page
number (if this call was successful) and] release the lock.
I could use:
phy_restore_page() must always be called to release the lock,
and restore the page number if this call was successful.
but that can still be read in an ambiguous manner.
--
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 8.8Mbps down 630kbps up
According to speedtest.net: 8.21Mbps down 510kbps up
next prev parent reply other threads:[~2017-12-31 10:07 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-29 12:30 [PATCH net-next 0/7] Resolve races in phy accessors Russell King - ARM Linux
2017-12-29 12:30 ` [PATCH net-next 1/7] net: mdiobus: add unlocked accessors Russell King
2017-12-29 12:30 ` [PATCH net-next 2/7] net: phy: use unlocked accessors for indirect MMD accesses Russell King
2017-12-29 12:30 ` [PATCH net-next 3/7] net: phy: add unlocked accessors Russell King
2017-12-29 12:31 ` [PATCH net-next 4/7] net: phy: add paged phy register accessors Russell King
2017-12-31 8:10 ` Andrew Lunn
2017-12-31 10:07 ` Russell King - ARM Linux [this message]
2018-01-02 10:50 ` Russell King - ARM Linux
2018-01-02 13:14 ` Andrew Lunn
2017-12-29 12:31 ` [PATCH net-next 5/7] net: phy: marvell: fix paged access races Russell King
2017-12-29 12:31 ` [PATCH net-next 6/7] net: phy: add phy_modify() accessor Russell King
2017-12-29 12:31 ` [PATCH net-next 7/7] net: phy: convert read-modify-write to phy_modify() Russell King
2017-12-30 16:18 ` Russell King - ARM Linux
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=20171231100714.GD10595@n2100.armlinux.org.uk \
--to=linux@armlinux.org.uk \
--cc=andrew@lunn.ch \
--cc=f.fainelli@gmail.com \
--cc=netdev@vger.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).