svn commit: r348020 - head/sys/dev/usb/net
Ian Lepore
ian at FreeBSD.org
Mon May 20 22:32:33 UTC 2019
Author: ian
Date: Mon May 20 22:32:31 2019
New Revision: 348020
URL: https://svnweb.freebsd.org/changeset/base/348020
Log:
Reverse the bit logic of sc_led_modes_mask. Instead of initializing it to
all-ones then carving out blocks of zeroes where specified values go, init
it to all-zeroes, put in ones where values need to be masked, then use it
as value &= ~sc_led_modes_mask. In addition to being more idiomatic, this
means everything related to FDT data is initialized to zero along with the
rest of the softc, and that allows removing some #ifdef FDT sections and
wrapping the whole muge_set_leds() function in a single ifdef block.
This also deletes the early-out from muge_set_leds() when an eeprom exists.
Even if there is an eeprom with led config in it, the fdt data (if present)
should override that, because the user is in control of the fdt data.
Modified:
head/sys/dev/usb/net/if_muge.c
Modified: head/sys/dev/usb/net/if_muge.c
==============================================================================
--- head/sys/dev/usb/net/if_muge.c Mon May 20 22:32:26 2019 (r348019)
+++ head/sys/dev/usb/net/if_muge.c Mon May 20 22:32:31 2019 (r348020)
@@ -938,10 +938,10 @@ lan78xx_phy_init(struct muge_softc *sc)
bmcr = lan78xx_miibus_readreg(sc->sc_ue.ue_dev, sc->sc_phyno, MII_BMCR);
/* Configure LED Modes. */
- if (sc->sc_led_modes_mask != 0xffff) {
+ if (sc->sc_led_modes_mask != 0) {
lmsr = lan78xx_miibus_readreg(sc->sc_ue.ue_dev, sc->sc_phyno,
MUGE_PHY_LED_MODE);
- lmsr &= sc->sc_led_modes_mask;
+ lmsr &= ~sc->sc_led_modes_mask;
lmsr |= sc->sc_led_modes;
lan78xx_miibus_writereg(sc->sc_ue.ue_dev, sc->sc_phyno,
MUGE_PHY_LED_MODE, lmsr);
@@ -1526,20 +1526,13 @@ muge_set_mac_addr(struct usb_ether *ue)
static void
muge_set_leds(struct usb_ether *ue)
{
- struct muge_softc *sc = uether_getsc(ue);
#ifdef FDT
+ struct muge_softc *sc = uether_getsc(ue);
phandle_t node;
pcell_t modes[4]; /* 4 LEDs are possible */
ssize_t proplen;
uint32_t count;
-#endif
- sc->sc_leds = 0; /* no LED mode is set */
- sc->sc_led_modes = 0;
- sc->sc_led_modes_mask = 0xffff;
- if (lan78xx_eeprom_present(sc))
- return;
-#ifdef FDT
if ((node = usb_fdt_get_node(ue->ue_dev, ue->ue_udev)) != -1 &&
(proplen = OF_getencprop(node, "microchip,led-modes", modes,
sizeof(modes))) > 0) {
@@ -1550,7 +1543,7 @@ muge_set_leds(struct usb_ether *ue)
(count > 3) * ETH_HW_CFG_LED3_EN_;
while (count-- > 0) {
sc->sc_led_modes |= (modes[count] & 0xf) << (4 * count);
- sc->sc_led_modes_mask <<= 4;
+ sc->sc_led_modes_mask |= 0xf << (4 * count);
}
muge_dbg_printf(sc, "LED modes set from FDT data\n");
}
More information about the svn-src-head
mailing list