Skip to contentSkip to conversation

net: phy: disregard "Clause 22 registers present" bit in get_phy_c45_devs_in_pkg

PATCH In review Heiner Kallweit 3 participants 12 messages Feb 8, 2019 – Feb 11, 2019

Subsystems (3)
lore
Share & tools
lore

Heiner Kallweit

author maintainer
#0 lore raw

v3 cover net: phy: disregard "Clause 22 registers present" bit in get_phy_c45_devs_in_pkg

Bit 0 in register 1.5 doesn't represent a device but is a flag that Clause 22 registers are present. Therefore disregard this bit when populating the device list. If code needs this information it should read register 1.5 directly instead of accessing the device list.
Because this bit doesn't represent a device don't define a MDIO_MMD_XYZ constant, just define a MDIO_DEVS_XYZ constant for the flag in the device list bitmap.

v2:
- make masking of bit 0 more explicit
- improve commit message

v3:
- replace single patch with a series
- add functionality of patch 1

Heiner Kallweit (3):
net: phy: remove unneeded masking of PHY register read results
net: phy: disregard "Clause 22 registers present" bit in

    get_phy_c45_devs_in_pkg

net: phy: add constant for "Clause 22 registers present" flags in
device list bitmap

 drivers/net/phy/phy_device.c | 15 +++++++++------
 include/uapi/linux/mdio.h    |  1 +
 2 files changed, 10 insertions(+), 6 deletions(-)
Signature · 1 line
2.20.1
author maintainer
#1 lore raw

PATCH v3 1/3 net: phy: remove unneeded masking of PHY register read results

PHY registers are only 16 bits wide, therefore, if the read was successful, there's no need to mask out the higher 16 bits.

---
 drivers/net/phy/phy_device.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/net/phy/phy_device.c +6 -6
index 9369e1323..82dd72954 100644
@@ -676,13 +676,13 @@ static int get_phy_c45_devs_in_pkg(struct mii_bus *bus, int addr, int dev_addr,
 	phy_reg = mdiobus_read(bus, addr, reg_addr);
 	if (phy_reg < 0)
 		return -EIO;
-	*devices_in_package = (phy_reg & 0xffff) << 16;
+	*devices_in_package = phy_reg << 16;
 
 	reg_addr = MII_ADDR_C45 | dev_addr << 16 | MDIO_DEVS1;
 	phy_reg = mdiobus_read(bus, addr, reg_addr);
 	if (phy_reg < 0)
 		return -EIO;
-	*devices_in_package |= (phy_reg & 0xffff);
+	*devices_in_package |= phy_reg;
 
 	return 0;
 }
@@ -743,13 +743,13 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr, u32 *phy_id,
 		phy_reg = mdiobus_read(bus, addr, reg_addr);
 		if (phy_reg < 0)
 			return -EIO;
-		c45_ids->device_ids[i] = (phy_reg & 0xffff) << 16;
+		c45_ids->device_ids[i] = phy_reg << 16;
 
 		reg_addr = MII_ADDR_C45 | i << 16 | MII_PHYSID2;
 		phy_reg = mdiobus_read(bus, addr, reg_addr);
 		if (phy_reg < 0)
 			return -EIO;
-		c45_ids->device_ids[i] |= (phy_reg & 0xffff);
+		c45_ids->device_ids[i] |= phy_reg;
 	}
 	*phy_id = 0;
 	return 0;
@@ -786,14 +786,14 @@ static int get_phy_id(struct mii_bus *bus, int addr, u32 *phy_id,
 		return (phy_reg == -EIO || phy_reg == -ENODEV) ? -ENODEV : -EIO;
 	}
 
-	*phy_id = (phy_reg & 0xffff) << 16;
+	*phy_id = phy_reg << 16;
 
 	/* Grab the bits from PHYIR2, and put them in the lower half */
 	phy_reg = mdiobus_read(bus, addr, MII_PHYSID2);
 	if (phy_reg < 0)
 		return -EIO;
 
-	*phy_id |= (phy_reg & 0xffff);
+	*phy_id |= phy_reg;
 
 	return 0;
 }
Signature · 1 line
2.20.1
author maintainer
#3 lore raw

PATCH v3 2/3 net: phy: disregard "Clause 22 registers present" bit in get_phy_c45_devs_in_pkg

In reply to Heiner Kallweit

Bit 0 in register 1.5 doesn't represent a device but is a flag that Clause 22 registers are present. Therefore disregard this bit when populating the device list. If code needs this information it should read register 1.5 directly instead of accessing the device list.

---
 drivers/net/phy/phy_device.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/phy/phy_device.c +3 -0
index 82dd72954..31f9e7c49 100644
@@ -684,6 +684,9 @@ static int get_phy_c45_devs_in_pkg(struct mii_bus *bus, int addr, int dev_addr,
 		return -EIO;
 	*devices_in_package |= phy_reg;
 
+	/* Bit 0 doesn't represent a device, it indicates c22 regs presence */
+	*devices_in_package &= ~BIT(0);
+
 	return 0;
 }
 
Signature · 1 line
2.20.1
maintainer Reviewed-by on v3 2/3
#4 lore raw
Quoted 7 lines · Heiner Kallweit

Bit 0 in register 1.5 doesn't represent a device but is a flag that Clause 22 registers are present. Therefore disregard this bit when populating the device list. If code needs this information it should read register 1.5 directly instead of accessing the device list.

Andrew

author maintainer
#5 lore raw

PATCH v3 3/3 net: phy: add constant for "Clause 22 registers present" flags in device list bitmap

In reply to Heiner Kallweit

Bit 0 ("Clause 22 registers present") is a flag and doesn't represent a device, therefore don't define a MDIO_MMD_XYZ constant, just define a MDIO_DEVS_XYZ constant for the flag in the device list bitmap.

---
 include/uapi/linux/mdio.h | 1 +
 1 file changed, 1 insertion(+)
include/uapi/linux/mdio.h +1 -0
index 2e6e309f0..0e012b168 100644
@@ -115,6 +115,7 @@
 
 /* Device present registers. */
 #define MDIO_DEVS_PRESENT(devad)	(1 << (devad))
+#define MDIO_DEVS_C22PRESENT		MDIO_DEVS_PRESENT(0)
 #define MDIO_DEVS_PMAPMD		MDIO_DEVS_PRESENT(MDIO_MMD_PMAPMD)
 #define MDIO_DEVS_WIS			MDIO_DEVS_PRESENT(MDIO_MMD_WIS)
 #define MDIO_DEVS_PCS			MDIO_DEVS_PRESENT(MDIO_MMD_PCS)
Signature · 1 line
2.20.1
maintainer Reviewed-by on v3 3/3
#6 lore raw

Re: [PATCH v3 3/3 net-next] net: phy: add constant for "Clause 22 registers present" flags in device list bitmap

Quoted 5 lines · Heiner Kallweit

Bit 0 ("Clause 22 registers present") is a flag and doesn't represent a device, therefore don't define a MDIO_MMD_XYZ constant, just define a MDIO_DEVS_XYZ constant for the flag in the device list bitmap.

Andrew

author maintainer
#7 lore raw

PATCH 1/1 net: phy: remove unneeded masking of PHY register read results

In reply to Heiner Kallweit

PHY registers are only 16 bits wide, therefore, if the read was successful, there's no need to mask out the higher 16 bits.

---
 drivers/net/phy/phy_device.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/net/phy/phy_device.c +6 -6
index d4fc1fd8a..31f9e7c49 100644
@@ -676,13 +676,13 @@ static int get_phy_c45_devs_in_pkg(struct mii_bus *bus, int addr, int dev_addr,
 	phy_reg = mdiobus_read(bus, addr, reg_addr);
 	if (phy_reg < 0)
 		return -EIO;
-	*devices_in_package = (phy_reg & 0xffff) << 16;
+	*devices_in_package = phy_reg << 16;
 
 	reg_addr = MII_ADDR_C45 | dev_addr << 16 | MDIO_DEVS1;
 	phy_reg = mdiobus_read(bus, addr, reg_addr);
 	if (phy_reg < 0)
 		return -EIO;
-	*devices_in_package |= (phy_reg & 0xffff);
+	*devices_in_package |= phy_reg;
 
 	/* Bit 0 doesn't represent a device, it indicates c22 regs presence */
 	*devices_in_package &= ~BIT(0);
@@ -746,13 +746,13 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr, u32 *phy_id,
 		phy_reg = mdiobus_read(bus, addr, reg_addr);
 		if (phy_reg < 0)
 			return -EIO;
-		c45_ids->device_ids[i] = (phy_reg & 0xffff) << 16;
+		c45_ids->device_ids[i] = phy_reg << 16;
 
 		reg_addr = MII_ADDR_C45 | i << 16 | MII_PHYSID2;
 		phy_reg = mdiobus_read(bus, addr, reg_addr);
 		if (phy_reg < 0)
 			return -EIO;
-		c45_ids->device_ids[i] |= (phy_reg & 0xffff);
+		c45_ids->device_ids[i] |= phy_reg;
 	}
 	*phy_id = 0;
 	return 0;
@@ -789,14 +789,14 @@ static int get_phy_id(struct mii_bus *bus, int addr, u32 *phy_id,
 		return (phy_reg == -EIO || phy_reg == -ENODEV) ? -ENODEV : -EIO;
 	}
 
-	*phy_id = (phy_reg & 0xffff) << 16;
+	*phy_id = phy_reg << 16;
 
 	/* Grab the bits from PHYIR2, and put them in the lower half */
 	phy_reg = mdiobus_read(bus, addr, MII_PHYSID2);
 	if (phy_reg < 0)
 		return -EIO;
 
-	*phy_id |= (phy_reg & 0xffff);
+	*phy_id |= phy_reg;
 
 	return 0;
 }
Signature · 1 line
2.20.1
maintainer
#9 lore raw
In reply to Heiner Kallweit

From: Heiner Kallweit <[email protected]>
Date: Fri, 8 Feb 2019 20:19:17 +0100

Quoted 8 lines

Bit 0 in register 1.5 doesn't represent a device but is a flag that Clause 22 registers are present. Therefore disregard this bit when populating the device list. If code needs this information it should read register 1.5 directly instead of accessing the device list.
Because this bit doesn't represent a device don't define a MDIO_MMD_XYZ constant, just define a MDIO_DEVS_XYZ constant for the flag in the device list bitmap.

...

This doesn't apply cleanly to net-next, please respin.

Thanks.

author maintainer
#10 lore raw
Quoted 11 lines · David Miller

From: Heiner Kallweit <[email protected]>
Date: Fri, 8 Feb 2019 20:19:17 +0100

Quoted 8 lines

Bit 0 in register 1.5 doesn't represent a device but is a flag that Clause 22 registers are present. Therefore disregard this bit when populating the device list. If code needs this information it should read register 1.5 directly instead of accessing the device list.
Because this bit doesn't represent a device don't define a MDIO_MMD_XYZ constant, just define a MDIO_DEVS_XYZ constant for the flag in the device list bitmap.

Quoted 4 lines

...

This doesn't apply cleanly to net-next, please respin.

You applied v2 already, and with a follow-up patch I "upgraded" it to v3. So you can disregard this series.

Quoted 2 lines

Thanks.

maintainer
#11 lore raw

From: Heiner Kallweit <[email protected]>
Date: Mon, 11 Feb 2019 22:34:34 +0100

Quoted 12 lines · David Miller
Quoted 11 lines

From: Heiner Kallweit <[email protected]>
Date: Fri, 8 Feb 2019 20:19:17 +0100

Quoted 8 lines

Bit 0 in register 1.5 doesn't represent a device but is a flag that Clause 22 registers are present. Therefore disregard this bit when populating the device list. If code needs this information it should read register 1.5 directly instead of accessing the device list.
Because this bit doesn't represent a device don't define a MDIO_MMD_XYZ constant, just define a MDIO_DEVS_XYZ constant for the flag in the device list bitmap.

Quoted 6 lines
Quoted 4 lines

...

This doesn't apply cleanly to net-next, please respin.

You applied v2 already, and with a follow-up patch I "upgraded" it to v3. So you can disregard this series.

Oh that's right, thanks.