From: Michael Walle <mwalle@kernel.org>
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>,
"Yisen Zhuang" <yisen.zhuang@huawei.com>,
"Salil Mehta" <salil.mehta@huawei.com>,
"Florian Fainelli" <florian.fainelli@broadcom.com>,
"Broadcom internal kernel review list"
<bcm-kernel-feedback-list@broadcom.com>,
"Marek Behún" <kabel@kernel.org>, "Xu Liang" <lxu@maxlinear.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v2 07/10] net: phy: add support for C45-over-C22 transfers
Date: Mon, 26 Jun 2023 09:14:46 +0200 [thread overview]
Message-ID: <6288946d020417d9c87236235d5c664f@kernel.org> (raw)
In-Reply-To: <52859948-9812-4b0b-ae5f-7e174926d5c4@lunn.ch>
Am 2023-06-24 22:15, schrieb Andrew Lunn:
>> int __phy_read_mmd(struct phy_device *phydev, int devad, u32 regnum)
>> {
>> - int val;
>> + struct mii_bus *bus = phydev->mdio.bus;
>> + int phy_addr = phydev->mdio.addr;
>> + bool check_rc = true;
>> + int ret;
>
> Although __phy_read_mmd() is exported as a GPL symbol, it is not in
> fact used outside of this file. I think we can easily change it
> signature.
>
>> + switch (phydev->access_mode) {
>
> Have access_mode passed in as a parameter. It then becomes a generic
> low level helper.
Are you sure? Why is it a generic helper then? You still need the phydev
parameter. E.g. for the bus, the address and more importantly, for the
phydev->drv->read_mmd op. And in this case, you can't use it for my new
phy_probe_mmd_read() because there is no phydev structure at that time.
Also __phy_read_mmd() is just one of a whole block of (unlocked)
functions
to access the MMDs of a PHY. So, to be consistent you'd have to change
all
the other ones, too. No?
That being said, what about a true generic helper, without the phydev
parameter, which is then called in __phy_{read,write}_mmd()? Where
would that helper belong to? Without the C45-over-C22 I'd have suggested
to put it into mdio_bus.c but C45-over-C22 being a PHY thing, I guess
it should be in phy-core.c.
> The function which is really exported and expected to by used by PHY
> drivers is:
>
> int phy_read_mmd(struct phy_device *phydev, int devad, u32 regnum)
> {
> int ret;
>
> phy_lock_mdio_bus(phydev);
> ret = __phy_read_mmd(phydev, devad, regnum);
> phy_unlock_mdio_bus(phydev);
>
> return ret;
> }
> EXPORT_SYMBOL(phy_read_mmd);
>
> This can easily pass phydev->access_mode as a parameter.
>
>> +static int phy_probe_mmd_read(struct mii_bus *bus, int prtad, int
>> devad,
>> + u16 regnum, bool c45_over_c22)
>> +{
>
> What i don't like is this bool c45_over_c22. Why have both the enum
> for the three access modes, and this bool. Pass an access mode.
Ok, but just to be sure, access mode c22 is then a "return -EINVAL".
>> + int ret;
>> +
>> + if (!c45_over_c22)
>> + return mdiobus_c45_read(bus, prtad, devad, regnum);
>> +
>> + mutex_lock(&bus->mdio_lock);
>> +
>> + ret = __phy_mmd_indirect(bus, prtad, devad, regnum);
>> + if (ret)
>> + goto out;
>> +
>> + ret = __mdiobus_read(bus, prtad, MII_MMD_DATA);
>
> And then this just uses the generic low level __phy_read_mmd().
See above, no there is no *phydev.
-michael
next prev parent reply other threads:[~2023-06-26 7:15 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-23 10:29 [PATCH net-next v2 00/10] net: phy: C45-over-C22 access Michael Walle
2023-06-23 10:29 ` [PATCH net-next v2 01/10] net: phy: add error checks in mmd_phy_indirect() and export it Michael Walle
2023-06-23 10:29 ` [PATCH net-next v2 02/10] net: phy: get rid of redundant is_c45 information Michael Walle
2023-06-23 10:29 ` [PATCH net-next v2 03/10] net: phy: introduce phy_is_c45() Michael Walle
2023-06-23 17:15 ` Andrew Lunn
2023-06-23 10:29 ` [PATCH net-next v2 04/10] net: phy: replace is_c45 with phy_accces_mode Michael Walle
2023-06-23 17:34 ` Andrew Lunn
2023-06-23 19:54 ` Andrew Lunn
2023-06-26 6:31 ` Michael Walle
2023-06-23 10:29 ` [PATCH net-next v2 05/10] net: phy: make the "prevent_c45_scan" a property of the MII bus Michael Walle
2023-06-23 10:29 ` [PATCH net-next v2 06/10] net: phy: print an info if a broken C45 bus is found Michael Walle
2023-06-23 17:42 ` Andrew Lunn
2023-06-23 20:35 ` Simon Horman
2023-06-26 6:50 ` Michael Walle
2023-06-23 10:29 ` [PATCH net-next v2 07/10] net: phy: add support for C45-over-C22 transfers Michael Walle
2023-06-23 20:43 ` Simon Horman
2023-06-24 20:15 ` Andrew Lunn
2023-06-26 7:14 ` Michael Walle [this message]
2023-06-23 10:29 ` [PATCH net-next v2 08/10] net: phy: introduce phy_promote_to_c45() Michael Walle
2023-06-23 10:29 ` [PATCH net-next v2 09/10] net: mdio: add C45-over-C22 fallback to fwnode_mdiobus_register_phy() Michael Walle
2023-06-23 10:29 ` [PATCH net-next v2 10/10] net: mdio: support C45-over-C22 when probed via OF Michael Walle
2023-06-23 20:48 ` Simon Horman
2023-06-26 7:37 ` Michael Walle
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=6288946d020417d9c87236235d5c664f@kernel.org \
--to=mwalle@kernel.org \
--cc=andrew@lunn.ch \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=florian.fainelli@broadcom.com \
--cc=hkallweit1@gmail.com \
--cc=kabel@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=lxu@maxlinear.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=salil.mehta@huawei.com \
--cc=yisen.zhuang@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