[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230405-net-next-topic-net-phy-reset-v1-2-7e5329f08002@pengutronix.de>
Date: Wed, 05 Apr 2023 11:26:53 +0200
From: Marco Felsch <m.felsch@...gutronix.de>
To: Andrew Lunn <andrew@...n.ch>,
Heiner Kallweit <hkallweit1@...il.com>,
Russell King <linux@...linux.org.uk>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Florian Fainelli <f.fainelli@...il.com>,
Broadcom internal kernel review list
<bcm-kernel-feedback-list@...adcom.com>,
Richard Cochran <richardcochran@...il.com>,
Radu Pirea <radu-nicolae.pirea@....nxp.com>,
Shyam Sundar S K <Shyam-sundar.S-k@....com>,
Yisen Zhuang <yisen.zhuang@...wei.com>,
Salil Mehta <salil.mehta@...wei.com>,
Jassi Brar <jaswinder.singh@...aro.org>,
Ilias Apalodimas <ilias.apalodimas@...aro.org>,
Iyappan Subramanian <iyappan@...amperecomputing.com>,
Keyur Chudgar <keyur@...amperecomputing.com>,
Quan Nguyen <quan@...amperecomputing.com>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Len Brown <lenb@...nel.org>, Rob Herring <robh+dt@...nel.org>,
Frank Rowand <frowand.list@...il.com>
Cc: netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-acpi@...r.kernel.org, devicetree@...r.kernel.org,
kernel@...gutronix.de
Subject: [PATCH 02/12] net: phy: refactor get_phy_device function
Split get_phy_device() into local helper function. This commit is in
preparation of fixing the phy reset handling. No functional changes for
the public API users.
Signed-off-by: Marco Felsch <m.felsch@...gutronix.de>
---
drivers/net/phy/phy_device.c | 44 +++++++++++++++++++++++++++-----------------
1 file changed, 27 insertions(+), 17 deletions(-)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index dd0aaa866d17..64292e47e3fc 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -938,6 +938,32 @@ int fwnode_get_phy_id(struct fwnode_handle *fwnode, u32 *phy_id)
}
EXPORT_SYMBOL(fwnode_get_phy_id);
+static int phy_device_detect(struct mii_bus *bus, int addr, bool *is_c45,
+ u32 *phy_id, struct phy_c45_device_ids *c45_ids)
+{
+ int r;
+
+ if (*is_c45)
+ r = get_phy_c45_ids(bus, addr, c45_ids);
+ else
+ r = get_phy_c22_id(bus, addr, phy_id);
+
+ if (r)
+ return r;
+
+ /* PHY device such as the Marvell Alaska 88E2110 will return a PHY ID
+ * of 0 when probed using get_phy_c22_id() with no error. Proceed to
+ * probe with C45 to see if we're able to get a valid PHY ID in the C45
+ * space, if successful, create the C45 PHY device.
+ */
+ if (!*is_c45 && *phy_id == 0 && bus->read_c45) {
+ *is_c45 = true;
+ return get_phy_c45_ids(bus, addr, c45_ids);
+ }
+
+ return 0;
+}
+
/**
* get_phy_device - reads the specified PHY device and returns its @phy_device
* struct
@@ -967,26 +993,10 @@ struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45)
c45_ids.mmds_present = 0;
memset(c45_ids.device_ids, 0xff, sizeof(c45_ids.device_ids));
- if (is_c45)
- r = get_phy_c45_ids(bus, addr, &c45_ids);
- else
- r = get_phy_c22_id(bus, addr, &phy_id);
-
+ r = phy_device_detect(bus, addr, &is_c45, &phy_id, &c45_ids);
if (r)
return ERR_PTR(r);
- /* PHY device such as the Marvell Alaska 88E2110 will return a PHY ID
- * of 0 when probed using get_phy_c22_id() with no error. Proceed to
- * probe with C45 to see if we're able to get a valid PHY ID in the C45
- * space, if successful, create the C45 PHY device.
- */
- if (!is_c45 && phy_id == 0 && bus->read_c45) {
- r = get_phy_c45_ids(bus, addr, &c45_ids);
- if (!r)
- return phy_device_create(bus, addr, phy_id,
- true, &c45_ids);
- }
-
return phy_device_create(bus, addr, phy_id, is_c45, &c45_ids);
}
EXPORT_SYMBOL(get_phy_device);
--
2.39.2
Powered by blists - more mailing lists