From: Buday Csaba <buday.csaba@prolan.hu>
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>,
Philipp Zabel <p.zabel@pengutronix.de>, <netdev@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH net-next v5 3/4] net: mdio: reset PHY before attempting to access registers in fwnode_mdiobus_register_phy
Date: Wed, 29 Oct 2025 15:15:27 +0100 [thread overview]
Message-ID: <aQIhf3dXOxS4vd2W@debianbuilder> (raw)
In-Reply-To: <e61e1c1c-083b-472f-8edd-b16832ca578e@lunn.ch>
On Wed, Oct 29, 2025 at 02:20:14PM +0100, Andrew Lunn wrote:
> > +/* Hard-reset a PHY before registration */
> > +static int fwnode_reset_phy(struct mii_bus *bus, u32 addr,
> > + struct fwnode_handle *phy_node)
> > +{
> > + struct mdio_device *tmpdev;
> > + int rc;
> > +
> > + tmpdev = mdio_device_create(bus, addr);
> > + if (IS_ERR(tmpdev))
> > + return PTR_ERR(tmpdev);
> > +
> > + fwnode_handle_get(phy_node);
>
> You add a _get() here. Where is the corresponding _put()?
When mdio_device_free() is called, it eventually invokes
mdio_device_release(). There is the corresponding _put(), that will
release the reference. I also verified this with a stack trace.
>
> Also, fwnode_handle_get() returns a handle. Why do you throw it away?
> What is the point of this get?
>
I copied this initialization stub from of_mdiobus_register_device()
in of_mdio.c. The same pattern is used there:
fwnode_handle_get(fwnode);
device_set_node(&mdiodev->dev, fwnode);
It is kind of awkward that we need to half-establish a device, just
to assert the reset, but I could not think of any better solution, that
does not lead to a large amount of code duplication.
> > + device_set_node(&tmpdev->dev, phy_node);
> > + rc = mdio_device_register_reset(tmpdev);
> > + if (rc) {
> > + mdio_device_free(tmpdev);
> > + return rc;
> > + }
> > +
> > + mdio_device_reset(tmpdev, 1);
> > + mdio_device_reset(tmpdev, 0);
> > +
> > + mdio_device_unregister_reset(tmpdev);
> > + mdio_device_free(tmpdev);
> > +
> > + return 0;
> > +}
> > +
>
> Andrew
>
Csaba
next prev parent reply other threads:[~2025-10-29 14:15 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-29 10:23 [PATCH net-next v5 0/4] net: mdio: implement optional PHY reset before MDIO access Buday Csaba
2025-10-29 10:23 ` [PATCH net-next v5 1/4] net: mdio: common handling of phy reset properties Buday Csaba
2025-10-29 13:03 ` Andrew Lunn
2025-10-29 13:59 ` Buday Csaba
2025-10-29 10:23 ` [PATCH net-next v5 2/4] net: mdio: change property read from fwnode_property_read_u32() to device_property_read_u32() Buday Csaba
2025-10-29 13:09 ` Andrew Lunn
2025-10-29 10:23 ` [PATCH net-next v5 3/4] net: mdio: reset PHY before attempting to access registers in fwnode_mdiobus_register_phy Buday Csaba
2025-10-29 13:20 ` Andrew Lunn
2025-10-29 14:15 ` Buday Csaba [this message]
2025-10-29 15:15 ` Andrew Lunn
2025-10-30 6:33 ` Buday Csaba
2025-10-29 10:23 ` [PATCH net-next v5 4/4] net: mdio: add message when resetting a PHY before registration Buday Csaba
2025-10-29 13:21 ` Andrew Lunn
2025-10-29 12:43 ` [PATCH net-next v5 0/4] net: mdio: implement optional PHY reset before MDIO access Andrew Lunn
2025-10-29 13:42 ` Buday Csaba
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=aQIhf3dXOxS4vd2W@debianbuilder \
--to=buday.csaba@prolan.hu \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=pabeni@redhat.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).