git: 10ceddaa94d5 - main - smsc: Use read-modify-write to configure LEDs

From: Ed Maste <emaste_at_FreeBSD.org>
Date: Fri, 23 Oct 2026 22:02:08 UTC
The branch main has been updated by emaste:

URL: https://cgit.FreeBSD.org/src/commit/?id=10ceddaa94d5b234dde897a3eb90ca57700636d8

commit 10ceddaa94d5b234dde897a3eb90ca57700636d8
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2026-10-16 17:52:04 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2026-10-23 22:01:59 +0000

    smsc: Use read-modify-write to configure LEDs
    
    After reset the driver enables three LED outputs by writing 1s to
    the appropriate GPIO/LED configuration bits in the LED & GPIO
    configuration register LED_GPIO_CFG.
    
    The LED Select (LED_SEL) bit in LED_GPIO_CFG chooses between two LED
    modes:
    
    0: Speed, Link+Activity, Full Duplex
    1: Speed, Link, Activity
    
    If an EEPROM is present LED_SEL is initialized from bit 1 in the
    EEPROM's configuration flags value.  If no EEPROM is present this bit
    defaults to zero.
    
    Previously we wrote to all bits in the register, clearing LED_SEL.  A
    device with LED_SEL set by the EEPROM would thus not have correct LEDs.
    
    Now we read the current value of LED_GPIO_CFG and just set the three
    LED configuration bits, as Linux does in commit 52a2f0608366 ("net: usb:
    smsc95xx: fix changing LED_SEL bit value updated from EEPROM").
    
    Sponsored by:   The FreeBSD Foundation
    Differential Revision: https://reviews.freebsd.org/D60828
---
 sys/dev/usb/net/if_smsc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sys/dev/usb/net/if_smsc.c b/sys/dev/usb/net/if_smsc.c
index 3144eb7e8917..f1e1c0d58961 100644
--- a/sys/dev/usb/net/if_smsc.c
+++ b/sys/dev/usb/net/if_smsc.c
@@ -1429,7 +1429,9 @@ smsc_chip_init(struct smsc_softc *sc)
 	    (sc->sc_rev_id & SMSC_ID_REV_CHIP_REV_MASK));
 
 	/* GPIO/LED setup */
-	reg_val = SMSC_LED_GPIO_CFG_SPD_LED | SMSC_LED_GPIO_CFG_LNK_LED | 
+	if (smsc_read_reg(sc, SMSC_LED_GPIO_CFG, &reg_val) < 0)
+		reg_val = 0;
+	reg_val |= SMSC_LED_GPIO_CFG_SPD_LED | SMSC_LED_GPIO_CFG_LNK_LED |
 	          SMSC_LED_GPIO_CFG_FDX_LED;
 	smsc_write_reg(sc, SMSC_LED_GPIO_CFG, reg_val);