diff mbox series

[net-next,1/1] net: phy: Add additional logics on probing C45 PHY devices

Message ID 20201112150351.12662-1-vee.khee.wong@intel.com (mailing list archive)
State Deferred
Delegated to: Netdev Maintainers
Headers show
Series [net-next,1/1] net: phy: Add additional logics on probing C45 PHY devices | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net-next
netdev/subject_prefix success Link
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 28 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link
netdev/stable success Stable not CCed

Commit Message

Wong, Vee Khee Nov. 12, 2020, 3:03 p.m. UTC
For clause 45 PHY, introduce additional logics in get_phy_c45_ids() to
check if there is at least one valid device ID, return 0 on true, and
-ENODEV otherwise.

Signed-off-by: Wong Vee Khee <vee.khee.wong@intel.com>
---
 drivers/net/phy/phy_device.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Andrew Lunn Nov. 12, 2020, 3:21 p.m. UTC | #1
On Thu, Nov 12, 2020 at 11:03:51PM +0800, Wong Vee Khee wrote:
> For clause 45 PHY, introduce additional logics in get_phy_c45_ids() to
> check if there is at least one valid device ID, return 0 on true, and
> -ENODEV otherwise.

So does this mean you have a device which uses c45 and does not have
any valid IDs? What device is it? Can it be used via c22?

I would like to know more about why this is needed, since it sounds
like a workaround for a broken device.

     Andrew
Jakub Kicinski Nov. 17, 2020, 7:56 p.m. UTC | #2
On Thu, 12 Nov 2020 23:03:51 +0800 Wong Vee Khee wrote:
> For clause 45 PHY, introduce additional logics in get_phy_c45_ids() to
> check if there is at least one valid device ID, return 0 on true, and
> -ENODEV otherwise.
> 
> Signed-off-by: Wong Vee Khee <vee.khee.wong@intel.com>

I don't see any response to Andrew's questions, so I'm dropping this
from patchwork.
diff mbox series

Patch

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index e13a46c25437..c9ddcd7a63d4 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -730,6 +730,7 @@  static int get_phy_c45_ids(struct mii_bus *bus, int addr,
 	const int num_ids = ARRAY_SIZE(c45_ids->device_ids);
 	u32 devs_in_pkg = 0;
 	int i, ret, phy_reg;
+	u32 valid_did = 0;
 
 	/* Find first non-zero Devices In package. Device zero is reserved
 	 * for 802.3 c45 complied PHYs, so don't probe it at first.
@@ -796,12 +797,21 @@  static int get_phy_c45_ids(struct mii_bus *bus, int addr,
 		if (phy_reg < 0)
 			return -EIO;
 		c45_ids->device_ids[i] |= phy_reg;
+
+		/* Check if there is at least one valid device ID */
+		if (c45_ids->device_ids[i] &&
+		    (c45_ids->device_ids[i] & 0x1fffffff) != 0x1fffffff)
+			valid_did |= (1 << i);
 	}
 
 	c45_ids->devices_in_package = devs_in_pkg;
 	/* Bit 0 doesn't represent a device, it indicates c22 regs presence */
 	c45_ids->mmds_present = devs_in_pkg & ~BIT(0);
 
+	/* There is no valid device ID */
+	if (!valid_did)
+		return -ENODEV;
+
 	return 0;
 }