From: Sean Anderson <sean.anderson@seco.com>
To: "David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Madalin Bucur <madalin.bucur@nxp.com>,
netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
Paolo Abeni <pabeni@redhat.com>,
Russell King <linux@armlinux.org.uk>,
Eric Dumazet <edumazet@google.com>,
Sean Anderson <sean.anderson@seco.com>
Subject: [PATCH net-next 11/28] net: fman: Configure fixed link in memac_initialization
Date: Fri, 17 Jun 2022 16:32:55 -0400 [thread overview]
Message-ID: <20220617203312.3799646-12-sean.anderson@seco.com> (raw)
In-Reply-To: <20220617203312.3799646-1-sean.anderson@seco.com>
memac is the only mac which parses fixed links. Move the
parsing/configuring to its initialization function.
Signed-off-by: Sean Anderson <sean.anderson@seco.com>
---
drivers/net/ethernet/freescale/fman/mac.c | 93 +++++++++++------------
1 file changed, 46 insertions(+), 47 deletions(-)
diff --git a/drivers/net/ethernet/freescale/fman/mac.c b/drivers/net/ethernet/freescale/fman/mac.c
index 5d6159c0e1f0..248108b15cb0 100644
--- a/drivers/net/ethernet/freescale/fman/mac.c
+++ b/drivers/net/ethernet/freescale/fman/mac.c
@@ -34,7 +34,6 @@ struct mac_priv_s {
/* List of multicast addresses */
struct list_head mc_addr_list;
struct platform_device *eth_dev;
- struct fixed_phy_status *fixed_link;
u16 speed;
u16 max_speed;
};
@@ -399,6 +398,7 @@ static int memac_initialization(struct mac_device *mac_dev,
int err;
struct mac_priv_s *priv;
struct fman_mac_params params;
+ struct fixed_phy_status *fixed_link;
priv = mac_dev->priv;
mac_dev->set_promisc = memac_set_promiscuous;
@@ -437,21 +437,52 @@ static int memac_initialization(struct mac_device *mac_dev,
if (err < 0)
goto _return_fm_mac_free;
- err = memac_cfg_fixed_link(mac_dev->fman_mac, priv->fixed_link);
- if (err < 0)
- goto _return_fm_mac_free;
+ if (!mac_dev->phy_node && of_phy_is_fixed_link(mac_node)) {
+ struct phy_device *phy;
+
+ err = of_phy_register_fixed_link(mac_node);
+ if (err)
+ goto _return_fm_mac_free;
+
+ fixed_link = kzalloc(sizeof(*fixed_link), GFP_KERNEL);
+ if (!fixed_link) {
+ err = -ENOMEM;
+ goto _return_fm_mac_free;
+ }
+
+ mac_dev->phy_node = of_node_get(mac_node);
+ phy = of_phy_find_device(mac_dev->phy_node);
+ if (!phy) {
+ err = -EINVAL;
+ of_node_put(mac_dev->phy_node);
+ goto _return_fixed_link_free;
+ }
+
+ fixed_link->link = phy->link;
+ fixed_link->speed = phy->speed;
+ fixed_link->duplex = phy->duplex;
+ fixed_link->pause = phy->pause;
+ fixed_link->asym_pause = phy->asym_pause;
+
+ put_device(&phy->mdio.dev);
+
+ err = memac_cfg_fixed_link(mac_dev->fman_mac, fixed_link);
+ if (err < 0)
+ goto _return_fixed_link_free;
+ }
err = memac_init(mac_dev->fman_mac);
if (err < 0)
- goto _return_fm_mac_free;
+ goto _return_fixed_link_free;
dev_info(mac_dev->dev, "FMan MEMAC\n");
goto _return;
+_return_fixed_link_free:
+ kfree(fixed_link);
_return_fm_mac_free:
memac_free(mac_dev->fman_mac);
-
_return:
return err;
}
@@ -578,7 +609,7 @@ static int mac_probe(struct platform_device *_of_dev)
dev_err(dev, "of_get_parent(%pOF) failed\n",
mac_node);
err = -EINVAL;
- goto _return_of_get_parent;
+ goto _return_of_node_put;
}
of_dev = of_find_device_by_node(dev_node);
@@ -612,7 +643,7 @@ static int mac_probe(struct platform_device *_of_dev)
if (err < 0) {
dev_err(dev, "of_address_to_resource(%pOF) = %d\n",
mac_node, err);
- goto _return_of_get_parent;
+ goto _return_of_node_put;
}
mac_dev->res = __devm_request_region(dev,
@@ -622,7 +653,7 @@ static int mac_probe(struct platform_device *_of_dev)
if (!mac_dev->res) {
dev_err(dev, "__devm_request_mem_region(mac) failed\n");
err = -EBUSY;
- goto _return_of_get_parent;
+ goto _return_of_node_put;
}
priv->vaddr = devm_ioremap(dev, mac_dev->res->start,
@@ -630,12 +661,12 @@ static int mac_probe(struct platform_device *_of_dev)
if (!priv->vaddr) {
dev_err(dev, "devm_ioremap() failed\n");
err = -EIO;
- goto _return_of_get_parent;
+ goto _return_of_node_put;
}
if (!of_device_is_available(mac_node)) {
err = -ENODEV;
- goto _return_of_get_parent;
+ goto _return_of_node_put;
}
/* Get the cell-index */
@@ -643,7 +674,7 @@ static int mac_probe(struct platform_device *_of_dev)
if (err) {
dev_err(dev, "failed to read cell-index for %pOF\n", mac_node);
err = -EINVAL;
- goto _return_of_get_parent;
+ goto _return_of_node_put;
}
priv->cell_index = (u8)val;
@@ -658,14 +689,14 @@ static int mac_probe(struct platform_device *_of_dev)
dev_err(dev, "of_count_phandle_with_args(%pOF, fsl,fman-ports) failed\n",
mac_node);
err = nph;
- goto _return_of_get_parent;
+ goto _return_of_node_put;
}
if (nph != ARRAY_SIZE(mac_dev->port)) {
dev_err(dev, "Not supported number of fman-ports handles of mac node %pOF from device tree\n",
mac_node);
err = -EINVAL;
- goto _return_of_get_parent;
+ goto _return_of_node_put;
}
for (i = 0; i < ARRAY_SIZE(mac_dev->port); i++) {
@@ -724,42 +755,12 @@ static int mac_probe(struct platform_device *_of_dev)
/* Get the rest of the PHY information */
mac_dev->phy_node = of_parse_phandle(mac_node, "phy-handle", 0);
- if (!mac_dev->phy_node && of_phy_is_fixed_link(mac_node)) {
- struct phy_device *phy;
-
- err = of_phy_register_fixed_link(mac_node);
- if (err)
- goto _return_of_get_parent;
-
- priv->fixed_link = kzalloc(sizeof(*priv->fixed_link),
- GFP_KERNEL);
- if (!priv->fixed_link) {
- err = -ENOMEM;
- goto _return_of_get_parent;
- }
-
- mac_dev->phy_node = of_node_get(mac_node);
- phy = of_phy_find_device(mac_dev->phy_node);
- if (!phy) {
- err = -EINVAL;
- of_node_put(mac_dev->phy_node);
- goto _return_of_get_parent;
- }
-
- priv->fixed_link->link = phy->link;
- priv->fixed_link->speed = phy->speed;
- priv->fixed_link->duplex = phy->duplex;
- priv->fixed_link->pause = phy->pause;
- priv->fixed_link->asym_pause = phy->asym_pause;
-
- put_device(&phy->mdio.dev);
- }
err = init(mac_dev, mac_node);
if (err < 0) {
dev_err(dev, "mac_dev->init() = %d\n", err);
of_node_put(mac_dev->phy_node);
- goto _return_of_get_parent;
+ goto _return_of_node_put;
}
/* pause frame autonegotiation enabled */
@@ -790,8 +791,6 @@ static int mac_probe(struct platform_device *_of_dev)
_return_of_node_put:
of_node_put(dev_node);
-_return_of_get_parent:
- kfree(priv->fixed_link);
_return:
return err;
}
--
2.35.1.1320.gc452695387.dirty
next prev parent reply other threads:[~2022-06-17 20:35 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-17 20:32 [PATCH net-next 00/28] [RFC] net: dpaa: Convert to phylink Sean Anderson
2022-06-17 20:32 ` [PATCH net-next 01/28] dt-bindings: phy: Add QorIQ SerDes binding Sean Anderson
2022-06-17 23:27 ` Rob Herring
2022-06-18 1:15 ` Krzysztof Kozlowski
2022-06-18 3:38 ` Sean Anderson
2022-06-19 11:24 ` Krzysztof Kozlowski
2022-06-19 15:53 ` Sean Anderson
2022-06-20 10:54 ` Krzysztof Kozlowski
2022-06-20 17:19 ` Sean Anderson
2022-06-20 18:21 ` Krzysztof Kozlowski
2022-06-20 18:51 ` Sean Anderson
2022-06-21 7:12 ` Krzysztof Kozlowski
2022-06-17 20:32 ` [PATCH net-next 02/28] dt-bindings: net: fman: Add additional interface properties Sean Anderson
2022-06-18 1:16 ` Krzysztof Kozlowski
2022-06-18 15:55 ` Sean Anderson
2022-06-19 10:33 ` Krzysztof Kozlowski
2022-06-27 23:05 ` Rob Herring
2022-06-17 20:32 ` [PATCH net-next 03/28] phy: fsl: Add QorIQ SerDes driver Sean Anderson
2022-06-18 3:02 ` kernel test robot
[not found] ` <GV1PR04MB905598703F5E9A0989662EFDE0AE9@GV1PR04MB9055.eurprd04.prod.outlook.com>
2022-06-18 12:39 ` Ioana Ciornei
2022-06-18 15:52 ` Sean Anderson
2022-06-20 18:53 ` Sean Anderson
2022-06-17 20:32 ` [PATCH net-next 04/28] net: fman: Convert to SPDX identifiers Sean Anderson
2022-06-17 20:32 ` [PATCH net-next 05/28] net: fman: Don't pass comm_mode to enable/disable Sean Anderson
2022-06-17 20:32 ` [PATCH net-next 06/28] net: fman: Store en/disable in mac_device instead of mac_priv_s Sean Anderson
2022-06-17 20:32 ` [PATCH net-next 07/28] net: fman: dtsec: Always gracefully stop/start Sean Anderson
2022-06-17 20:32 ` [PATCH net-next 08/28] net: fman: Get PCS node in per-mac init Sean Anderson
2022-06-17 20:32 ` [PATCH net-next 09/28] net: fman: Store initialization function in match data Sean Anderson
2022-06-17 20:32 ` [PATCH net-next 10/28] net: fman: Move struct dev to mac_device Sean Anderson
2022-06-18 3:57 ` kernel test robot
2022-06-17 20:32 ` Sean Anderson [this message]
2022-06-17 20:32 ` [PATCH net-next 12/28] net: fman: Export/rename some common functions Sean Anderson
2022-06-17 20:32 ` [PATCH net-next 13/28] net: fman: memac: Use params instead of priv for max_speed Sean Anderson
2022-06-17 20:32 ` [PATCH net-next 14/28] net: fman: Move initialization to mac-specific files Sean Anderson
2022-06-17 20:32 ` [PATCH net-next 15/28] net: fman: Mark mac methods static Sean Anderson
2022-06-17 20:33 ` [PATCH net-next 16/28] net: fman: Inline several functions into initialization Sean Anderson
2022-06-17 20:33 ` [PATCH net-next 17/28] net: fman: Remove internal_phy_node from params Sean Anderson
2022-06-17 20:33 ` [PATCH net-next 18/28] net: fman: Map the base address once Sean Anderson
2022-06-18 2:01 ` kernel test robot
2022-06-17 20:33 ` [PATCH net-next 19/28] net: fman: Pass params directly to mac init Sean Anderson
2022-06-17 20:33 ` [PATCH net-next 20/28] net: fman: Use mac_dev for some params Sean Anderson
2022-06-17 20:33 ` [PATCH net-next 21/28] net: fman: Clean up error handling Sean Anderson
2022-06-17 20:33 ` [PATCH net-next 22/28] net: fman: memac: Add serdes support Sean Anderson
2022-06-17 20:33 ` [PATCH net-next 23/28] net: fman: memac: Use lynx pcs driver Sean Anderson
2022-06-17 20:33 ` [PATCH net-next 24/28] net: dpaa: Use mac_dev variable in dpaa_netdev_init Sean Anderson
2022-06-17 20:33 ` [PATCH net-next 25/28] [RFC] net: dpaa: Convert to phylink Sean Anderson
2022-06-17 22:01 ` Russell King (Oracle)
2022-06-18 0:45 ` Sean Anderson
2022-06-18 8:22 ` Russell King (Oracle)
2022-06-18 15:58 ` Sean Anderson
2022-06-23 22:39 ` Sean Anderson
2022-06-24 0:24 ` Russell King (Oracle)
2022-06-27 15:17 ` Sean Anderson
2022-06-17 20:33 ` [PATCH net-next 26/28] arm64: dts: ls1046ardb: Add serdes bindings Sean Anderson
2022-06-17 20:33 ` [PATCH net-next 27/28] arm64: dts: ls1046a: Add SerDes bindings Sean Anderson
2022-06-17 20:33 ` [PATCH net-next 28/28] arm64: dts: ls1046a: Specify which MACs support RGMII Sean Anderson
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=20220617203312.3799646-12-sean.anderson@seco.com \
--to=sean.anderson@seco.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=madalin.bucur@nxp.com \
--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;
as well as URLs for NNTP newsgroup(s).