From: Rosen Penev <rosenp@gmail.com>
To: netdev@vger.kernel.org
Cc: Horatiu Vultur <horatiu.vultur@microchip.com>,
UNGLinuxDriver@microchip.com (maintainer:MICROCHIP LAN966X
ETHERNET DRIVER), Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Russell King <linux@armlinux.org.uk> (maintainer:SFF/SFP/SFP+
MODULE SUPPORT:Keyword:phylink\.h|struct\s+phylink|\.phylink|>,
linux-kernel@vger.kernel.org (open list)
Subject: [PATCHv2 net-next 2/2] net: lan966x: convert fwnode to of
Date: Mon, 1 Sep 2025 13:20:01 -0700 [thread overview]
Message-ID: <20250901202001.27024-3-rosenp@gmail.com> (raw)
In-Reply-To: <20250901202001.27024-1-rosenp@gmail.com>
This is a purely OF driver. There's no need for fwnode to handle any of
this, with the exception being phylik_create. Use of_fwnode_handle for
that.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
.../ethernet/microchip/lan966x/lan966x_main.c | 34 ++++++++++---------
.../ethernet/microchip/lan966x/lan966x_main.h | 2 +-
2 files changed, 19 insertions(+), 17 deletions(-)
diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
index 8bf28915c030..98937830e74b 100644
--- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
+++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
@@ -183,7 +183,7 @@ static int lan966x_port_open(struct net_device *dev)
ANA_PORT_CFG_PORTID_VAL,
lan966x, ANA_PORT_CFG(port->chip_port));
- err = phylink_fwnode_phy_connect(port->phylink, port->fwnode, 0);
+ err = phylink_of_phy_connect(port->phylink, port->dnode, 0);
if (err) {
netdev_err(dev, "Could not attach to PHY\n");
return err;
@@ -767,8 +767,8 @@ static void lan966x_cleanup_ports(struct lan966x *lan966x)
port->phylink = NULL;
}
- if (port->fwnode)
- fwnode_handle_put(port->fwnode);
+ if (port->dnode)
+ of_node_put(port->dnode);
}
disable_irq(lan966x->xtr_irq);
@@ -791,7 +791,7 @@ static void lan966x_cleanup_ports(struct lan966x *lan966x)
static int lan966x_probe_port(struct lan966x *lan966x, u32 p,
phy_interface_t phy_mode,
- struct fwnode_handle *portnp)
+ struct device_node *portnp)
{
struct lan966x_port *port;
struct phylink *phylink;
@@ -855,7 +855,7 @@ static int lan966x_probe_port(struct lan966x *lan966x, u32 p,
port->phylink_config.supported_interfaces);
phylink = phylink_create(&port->phylink_config,
- portnp,
+ of_fwnode_handle(portnp),
phy_mode,
&lan966x_phylink_mac_ops);
if (IS_ERR(phylink)) {
@@ -1081,7 +1081,7 @@ static int lan966x_reset_switch(struct lan966x *lan966x)
static int lan966x_probe(struct platform_device *pdev)
{
- struct fwnode_handle *ports, *portnp;
+ struct device_node *ports, *portnp;
struct lan966x *lan966x;
int err;
@@ -1179,7 +1179,7 @@ static int lan966x_probe(struct platform_device *pdev)
}
}
- ports = device_get_named_child_node(&pdev->dev, "ethernet-ports");
+ ports = of_get_child_by_name(pdev->dev.of_node, "ethernet-ports");
if (!ports)
return dev_err_probe(&pdev->dev, -ENODEV,
"no ethernet-ports child found\n");
@@ -1191,25 +1191,27 @@ static int lan966x_probe(struct platform_device *pdev)
lan966x_stats_init(lan966x);
/* go over the child nodes */
- fwnode_for_each_available_child_node(ports, portnp) {
+ for_each_available_child_of_node(ports, portnp) {
phy_interface_t phy_mode;
struct phy *serdes;
u32 p;
- if (fwnode_property_read_u32(portnp, "reg", &p))
+ if (of_property_read_u32(portnp, "reg", &p))
continue;
- phy_mode = fwnode_get_phy_mode(portnp);
+ err = of_get_phy_mode(portnp, &phy_mode);
+ if (err)
+ goto cleanup_ports;
+
err = lan966x_probe_port(lan966x, p, phy_mode, portnp);
if (err)
goto cleanup_ports;
/* Read needed configuration */
lan966x->ports[p]->config.portmode = phy_mode;
- lan966x->ports[p]->fwnode = fwnode_handle_get(portnp);
+ lan966x->ports[p]->dnode = of_node_get(portnp);
- serdes = devm_of_phy_optional_get(lan966x->dev,
- to_of_node(portnp), NULL);
+ serdes = devm_of_phy_optional_get(lan966x->dev, portnp, NULL);
if (IS_ERR(serdes)) {
err = PTR_ERR(serdes);
goto cleanup_ports;
@@ -1222,7 +1224,7 @@ static int lan966x_probe(struct platform_device *pdev)
goto cleanup_ports;
}
- fwnode_handle_put(ports);
+ of_node_put(ports);
lan966x_mdb_init(lan966x);
err = lan966x_fdb_init(lan966x);
@@ -1255,8 +1257,8 @@ static int lan966x_probe(struct platform_device *pdev)
lan966x_fdb_deinit(lan966x);
cleanup_ports:
- fwnode_handle_put(ports);
- fwnode_handle_put(portnp);
+ of_node_put(ports);
+ of_node_put(portnp);
lan966x_cleanup_ports(lan966x);
diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.h b/drivers/net/ethernet/microchip/lan966x/lan966x_main.h
index 4f75f0688369..bafb8f5ee64d 100644
--- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.h
+++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.h
@@ -407,7 +407,7 @@ struct lan966x_port {
struct lan966x_port_config config;
struct phylink *phylink;
struct phy *serdes;
- struct fwnode_handle *fwnode;
+ struct device_node *dnode;
u8 ptp_tx_cmd;
bool ptp_rx_cmd;
--
2.51.0
next prev parent reply other threads:[~2025-09-01 20:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-01 20:19 [PATCHv2 net-next 0/2] net: lan966x: some OF cleanups Rosen Penev
2025-09-01 20:20 ` [PATCHv2 net-next 1/2] net: lan966x: use of_get_mac_address Rosen Penev
2025-09-01 20:20 ` Rosen Penev [this message]
2025-09-03 23:55 ` [PATCHv2 net-next 2/2] net: lan966x: convert fwnode to of Jakub Kicinski
2025-09-04 1:04 ` Rosen Penev
2025-09-04 9:00 ` Daniel Machon
2025-09-04 20:30 ` Rosen Penev
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=20250901202001.27024-3-rosenp@gmail.com \
--to=rosenp@gmail.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horatiu.vultur@microchip.com \
--cc=kuba@kernel.org \
--cc=linux@armlinux.org.uk \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.