From: Piergiorgio Beruto <piergiorgio.beruto@gmail.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: Heiner Kallweit <hkallweit1@gmail.com>,
Russell King <linux@armlinux.org.uk>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
Oleksij Rempel <o.rempel@pengutronix.de>,
mailhol.vincent@wanadoo.fr, sudheer.mogilappagari@intel.com,
sbhatta@marvell.com, linux-doc@vger.kernel.org,
wangjie125@huawei.com, corbet@lwn.net, lkp@intel.com,
gal@nvidia.com, gustavoars@kernel.org
Subject: Re: [PATCH v2 net-next 4/5] drivers/net/phy: add helpers to get/set PLCA configuration
Date: Mon, 9 Jan 2023 00:50:23 +0100 [thread overview]
Message-ID: <Y7tWvws+5kLzDzX1@gvm01> (raw)
In-Reply-To: <Y7m0+MQggJrxfYju@lunn.ch>
On Sat, Jan 07, 2023 at 07:07:52PM +0100, Andrew Lunn wrote:
> > +/**
> > + * genphy_c45_plca_set_cfg - set PLCA configuration using standard registers
> > + * @phydev: target phy_device struct
> > + * @plca_cfg: structure containing the PLCA configuration. Fields set to -1 are
> > + * not to be changed.
> > + *
> > + * Description: if the PHY complies to the Open Alliance TC14 10BASE-T1S PLCA
> > + * Management Registers specifications, this function can be used to modify
> > + * the PLCA configuration using the standard registers in MMD 31.
> > + */
> > +int genphy_c45_plca_set_cfg(struct phy_device *phydev,
> > + const struct phy_plca_cfg *plca_cfg)
> > +{
> > + int ret;
> > + u16 val;
> > +
> > + // PLCA IDVER is read-only
> > + if (plca_cfg->version >= 0)
> > + return -EINVAL;
> > +
> > + // first of all, disable PLCA if required
> > + if (plca_cfg->enabled == 0) {
> > + ret = phy_clear_bits_mmd(phydev, MDIO_MMD_VEND2,
> > + MDIO_OATC14_PLCA_CTRL0,
> > + MDIO_OATC14_PLCA_EN);
> > +
> > + if (ret < 0)
> > + return ret;
> > + }
> > +
> > + if (plca_cfg->node_cnt >= 0 || plca_cfg->node_id >= 0) {
> > + if (plca_cfg->node_cnt < 0 || plca_cfg->node_id < 0) {
>
> I think it would be good to add some comments since this code is not
> immediately obvious to me. I had to think about it for a while.
Yes, I realize it is not very intuitive at furst glance :-)
I have added a comment explaining that we need to read back the register
to perform merge/pure of the configuration IFF we need to set one among
node ID / node count but not both.
>
> > + if (plca_cfg->burst_cnt >= 0 || plca_cfg->burst_tmr >= 0) {
> > + if (plca_cfg->burst_cnt < 0 || plca_cfg->burst_tmr < 0) {
> > + ret = phy_read_mmd(phydev, MDIO_MMD_VEND2,
> > + MDIO_OATC14_PLCA_BURST);
> > +
>
> This follows the same patterns, so maybe comments here as well?
Yup, added the same comment.
>
> With that, you can add my Reviewed-by.
Thanks!
>
> Andrew
next prev parent reply other threads:[~2023-01-08 23:50 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-06 18:43 [PATCH v2 net-next 0/5] add PLCA RS support and onsemi NCN26000 Piergiorgio Beruto
2023-01-06 18:44 ` [PATCH v2 net-next 1/5] net/ethtool: add netlink interface for the PLCA RS Piergiorgio Beruto
2023-01-07 17:29 ` Andrew Lunn
2023-01-06 18:44 ` [PATCH v2 net-next 2/5] drivers/net/phy: add the link modes for the 10BASE-T1S Ethernet PHY Piergiorgio Beruto
2023-01-07 17:31 ` Andrew Lunn
2023-01-06 18:45 ` [PATCH v2 net-next 3/5] drivers/net/phy: add connection between ethtool and phylib for PLCA Piergiorgio Beruto
2023-01-07 17:37 ` Andrew Lunn
2023-01-08 23:48 ` Piergiorgio Beruto
2023-01-06 18:45 ` [PATCH v2 net-next 4/5] drivers/net/phy: add helpers to get/set PLCA configuration Piergiorgio Beruto
2023-01-07 18:07 ` Andrew Lunn
2023-01-08 23:50 ` Piergiorgio Beruto [this message]
2023-01-06 18:45 ` [PATCH v2 net-next 5/5] drivers/net/phy: add driver for the onsemi NCN26000 10BASE-T1S PHY Piergiorgio Beruto
2023-01-07 18:23 ` Andrew Lunn
2023-01-08 23:57 ` Piergiorgio Beruto
2023-01-09 13:31 ` Andrew Lunn
2023-01-09 14:21 ` Piergiorgio Beruto
2023-01-09 14:24 ` Andrew Lunn
2023-01-09 17:12 ` Piergiorgio Beruto
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=Y7tWvws+5kLzDzX1@gvm01 \
--to=piergiorgio.beruto@gmail.com \
--cc=andrew@lunn.ch \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gal@nvidia.com \
--cc=gustavoars@kernel.org \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=lkp@intel.com \
--cc=mailhol.vincent@wanadoo.fr \
--cc=netdev@vger.kernel.org \
--cc=o.rempel@pengutronix.de \
--cc=pabeni@redhat.com \
--cc=sbhatta@marvell.com \
--cc=sudheer.mogilappagari@intel.com \
--cc=wangjie125@huawei.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).