From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Peter Geis <pgwipeout@gmail.com>
Cc: Andrew Lunn <andrew@lunn.ch>,
Heiner Kallweit <hkallweit1@gmail.com>,
"David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
linux-rockchip@lists.infradead.org
Subject: Re: [PATCH v3] net: phy: add driver for Motorcomm yt8511 phy
Date: Fri, 14 May 2021 14:09:08 +0100 [thread overview]
Message-ID: <20210514130908.GD12395@shell.armlinux.org.uk> (raw)
In-Reply-To: <20210514115826.3025223-1-pgwipeout@gmail.com>
Hi!
On Fri, May 14, 2021 at 07:58:26AM -0400, Peter Geis wrote:
> + /* set rgmii delay mode */
> + val = __phy_read(phydev, YT8511_PAGE);
> +
> + switch (phydev->interface) {
> + case PHY_INTERFACE_MODE_RGMII:
> + val &= ~(YT8511_DELAY_RX | YT8511_DELAY_TX);
> + break;
> + case PHY_INTERFACE_MODE_RGMII_ID:
> + val |= YT8511_DELAY_RX | YT8511_DELAY_TX;
> + break;
> + case PHY_INTERFACE_MODE_RGMII_RXID:
> + val &= ~(YT8511_DELAY_TX);
> + val |= YT8511_DELAY_RX;
> + break;
> + case PHY_INTERFACE_MODE_RGMII_TXID:
> + val &= ~(YT8511_DELAY_RX);
> + val |= YT8511_DELAY_TX;
> + break;
> + default: /* leave everything alone in other modes */
> + break;
> + }
> +
> + ret = __phy_write(phydev, YT8511_PAGE, val);
> + if (ret < 0)
> + goto err_restore_page;
Another way of writing the above is to set "val" to be the value of the
YT8511_DELAY_RX and YT8511_DELAY_TX bits, and then do:
ret = __phy_modify(phydev, YT8511_PAGE,
(YT8511_DELAY_RX | YT8511_DELAY_TX), val);
if (ret < 0)
goto err_restore_page;
which moves the read-modify-write out of the driver into core code and
makes the driver code smaller. It also handles your missing error check
on __phy_read() above - would you want the above code to attempt to
write a -ve error number back to this register? I suspect not!
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
next prev parent reply other threads:[~2021-05-14 13:09 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-14 11:58 [PATCH v3] net: phy: add driver for Motorcomm yt8511 phy Peter Geis
2021-05-14 13:09 ` Heiner Kallweit
2021-05-14 14:04 ` Peter Geis
2021-05-14 13:09 ` Russell King (Oracle) [this message]
2021-05-14 14:09 ` Peter Geis
2021-05-14 13:24 ` Andrew Lunn
2021-05-14 14:14 ` Peter Geis
2021-05-14 14:52 ` Andrew Lunn
2021-05-14 15:25 ` Peter Geis
2021-05-14 15:41 ` Andrew Lunn
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=20210514130908.GD12395@shell.armlinux.org.uk \
--to=linux@armlinux.org.uk \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=netdev@vger.kernel.org \
--cc=pgwipeout@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).