git: 13a747009656 - main - e1000: Avoid signed shifts while assembling PHY IDs

From: Kevin Bowling <kbowling_at_FreeBSD.org>
Date: Tue, 11 Aug 2026 21:00:12 UTC
The branch main has been updated by kbowling:

URL: https://cgit.FreeBSD.org/src/commit/?id=13a7470096567480676e24545b3c1d6404f3f2ec

commit 13a7470096567480676e24545b3c1d6404f3f2ec
Author:     Kevin Bowling <kbowling@FreeBSD.org>
AuthorDate: 2026-08-11 19:40:48 +0000
Commit:     Kevin Bowling <kbowling@FreeBSD.org>
CommitDate: 2026-08-11 20:59:33 +0000

    e1000: Avoid signed shifts while assembling PHY IDs
    
    PHY identifier words are promoted to signed int when the cast is applied
    after the shift.  Cast each 16-bit register value first so identifiers
    with their high bit set are assembled as unsigned data.
    
    MFC after:      2 weeks
---
 sys/dev/e1000/e1000_82571.c   | 2 +-
 sys/dev/e1000/e1000_ich8lan.c | 2 +-
 sys/dev/e1000/e1000_phy.c     | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/sys/dev/e1000/e1000_82571.c b/sys/dev/e1000/e1000_82571.c
index fa010075f367..d02efd08a163 100644
--- a/sys/dev/e1000/e1000_82571.c
+++ b/sys/dev/e1000/e1000_82571.c
@@ -485,7 +485,7 @@ static s32 e1000_get_phy_id_82571(struct e1000_hw *hw)
 		if (ret_val)
 			return ret_val;
 
-		phy->id = (u32)(phy_id << 16);
+		phy->id = (u32)phy_id << 16;
 		usec_delay(20);
 		ret_val = phy->ops.read_reg(hw, PHY_ID2, &phy_id);
 		if (ret_val)
diff --git a/sys/dev/e1000/e1000_ich8lan.c b/sys/dev/e1000/e1000_ich8lan.c
index 1fbdc35e74df..eb6971b0e530 100644
--- a/sys/dev/e1000/e1000_ich8lan.c
+++ b/sys/dev/e1000/e1000_ich8lan.c
@@ -211,7 +211,7 @@ static bool e1000_phy_is_accessible_pchlan(struct e1000_hw *hw)
 		ret_val = hw->phy.ops.read_reg_locked(hw, PHY_ID1, &phy_reg);
 		if (ret_val || (phy_reg == 0xFFFF))
 			continue;
-		phy_id = (u32)(phy_reg << 16);
+		phy_id = (u32)phy_reg << 16;
 
 		ret_val = hw->phy.ops.read_reg_locked(hw, PHY_ID2, &phy_reg);
 		if (ret_val || (phy_reg == 0xFFFF)) {
diff --git a/sys/dev/e1000/e1000_phy.c b/sys/dev/e1000/e1000_phy.c
index 8b00a80337a1..7d12d98bffd8 100644
--- a/sys/dev/e1000/e1000_phy.c
+++ b/sys/dev/e1000/e1000_phy.c
@@ -238,7 +238,7 @@ s32 e1000_get_phy_id(struct e1000_hw *hw)
 		if (ret_val)
 			return ret_val;
 
-		phy->id = (u32)(phy_id << 16);
+		phy->id = (u32)phy_id << 16;
 		usec_delay(20);
 		ret_val = phy->ops.read_reg(hw, PHY_ID2, &phy_id);
 		if (ret_val)