From: Johan Hovold <johan@kernel.org>
To: FUJITA Tomonori <fujita.tomonori@gmail.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org, Johan Hovold <johan@kernel.org>,
Hans-Frieder Vogt <hfdevel@gmx.net>
Subject: [PATCH net-next v2 2/2] net: tn40xx: switch to primary software node
Date: Mon, 16 Nov 2026 10:11:49 +0100 [thread overview]
Message-ID: <20261116091149.730586-3-johan@kernel.org> (raw)
In-Reply-To: <20261116091149.730586-1-johan@kernel.org>
Some cards use a secondary software node which is removed from the
device by device_remove_software_node() on probe failure and on driver
unbind.
Removing a secondary software node this way involves clearing the
mdiobus device firmware node pointer, which in turn means that the
driver must drop any reference taken by __mdiobus_register() during
registration instead of letting mdiobus_release() do it as it would for
a primary firmware node.
Fix the asymmetry and layering violation and clean up the software node
handling by making the software node a primary node which is released
when freeing the mdiobus.
Cc: Hans-Frieder Vogt <hfdevel@gmx.net>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/net/ethernet/tehuti/tn40_mdio.c | 23 ++++-------------------
1 file changed, 4 insertions(+), 19 deletions(-)
diff --git a/drivers/net/ethernet/tehuti/tn40_mdio.c b/drivers/net/ethernet/tehuti/tn40_mdio.c
index 438f0d86c2a1..4130d75fbcaf 100644
--- a/drivers/net/ethernet/tehuti/tn40_mdio.c
+++ b/drivers/net/ethernet/tehuti/tn40_mdio.c
@@ -156,21 +156,14 @@ static int tn40_swnodes_register(struct tn40_priv *priv)
void tn40_swnodes_cleanup(struct tn40_priv *priv)
{
/* cleanup of swnodes is only needed for AQR105-based cards */
- if (priv->pdev->device == PCI_DEVICE_ID_TEHUTI_TN9510) {
- /*
- * drop any reference taken by __mdiobus_register() before
- * device_remove_software_node() clears the fwnode pointer
- */
- if (priv->mdio->state != MDIOBUS_ALLOCATED)
- fwnode_handle_put(dev_fwnode(&priv->mdio->dev));
- device_remove_software_node(&priv->mdio->dev);
+ if (priv->pdev->device == PCI_DEVICE_ID_TEHUTI_TN9510)
software_node_unregister_node_group(priv->nodes.group);
- }
}
int tn40_mdiobus_init(struct tn40_priv *priv)
{
struct pci_dev *pdev = priv->pdev;
+ struct fwnode_handle *fwnode;
struct mii_bus *bus;
int ret;
@@ -196,13 +189,8 @@ int tn40_mdiobus_init(struct tn40_priv *priv)
return ret;
}
- ret = device_add_software_node(&bus->dev,
- priv->nodes.group[SWNODE_MDIO]);
- if (ret) {
- dev_err(&pdev->dev,
- "device_add_software_node failed: %d\n", ret);
- goto err_swnodes_unregister;
- }
+ fwnode = software_node_fwnode(priv->nodes.group[SWNODE_MDIO]);
+ bus->dev.fwnode = fwnode;
}
tn40_mdio_set_speed(priv, TN40_MDIO_SPEED_6MHZ);
@@ -214,9 +202,6 @@ int tn40_mdiobus_init(struct tn40_priv *priv)
}
return 0;
-err_swnodes_unregister:
- software_node_unregister_node_group(priv->nodes.group);
- return ret;
err_swnodes_cleanup:
tn40_swnodes_cleanup(priv);
return ret;
--
2.56.1
prev parent reply other threads:[~2026-11-16 9:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 9:11 [PATCH net-next v2 0/2] net: tn40xx: avoid early firmware node release Johan Hovold
2026-11-16 9:11 ` [PATCH net-next v2 1/2] " Johan Hovold
2026-11-16 9:11 ` Johan Hovold [this message]
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=20261116091149.730586-3-johan@kernel.org \
--to=johan@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=fujita.tomonori@gmail.com \
--cc=hfdevel@gmx.net \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--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