Date: Mon, 11 Jun 2018 19:34:47 +0000 (UTC) From: Ed Maste <emaste@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334973 - head/sys/dev/usb/net Message-ID: <201806111934.w5BJYlnb046244@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: emaste Date: Mon Jun 11 19:34:47 2018 New Revision: 334973 URL: https://svnweb.freebsd.org/changeset/base/334973 Log: if_muge: retire lan78xx_eeprom_read lan78xx_eeprom_read just checked for EEPROM presence then called lan78xx_eeprom_read_raw if present, and had only one caller. Introduce lan78xx_eeprom_present to check for EEPROM presence, and use it in the one place it is needed. This is used by r334964, which was accidentally committed out-of-order from my work tree. Reported by: markj Sponsored by: The FreeBSD Foundation 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 Jun 11 19:32:49 2018 (r334972) +++ head/sys/dev/usb/net/if_muge.c Mon Jun 11 19:34:47 2018 (r334973) @@ -445,32 +445,14 @@ done: return (err); } -/** - * lan78xx_eeprom_read - Read EEPROM and confirm it is programmed - * @sc: soft context - * @off: the eeprom address offset - * @buf: stores the bytes - * @buflen: the number of bytes to read - * - * RETURNS: - * 0 on success, or a USB_ERR_?? error code on failure. - */ -static int -lan78xx_eeprom_read(struct muge_softc *sc, uint16_t off, uint8_t *buf, - uint16_t buflen) +static bool +lan78xx_eeprom_present(struct muge_softc *sc) { - uint8_t sig; int ret; + uint8_t sig; ret = lan78xx_eeprom_read_raw(sc, ETH_E2P_INDICATOR_OFFSET, &sig, 1); - if ((ret == 0) && (sig == ETH_E2P_INDICATOR)) { - ret = lan78xx_eeprom_read_raw(sc, off, buf, buflen); - muge_dbg_printf(sc, "EEPROM present\n"); - } else { - ret = -EINVAL; - muge_dbg_printf(sc, "EEPROM not present\n"); - } - return (ret); + return (ret == 0 && sig == ETH_E2P_INDICATOR); } /** @@ -1487,7 +1469,8 @@ muge_attach_post(struct usb_ether *ue) /* If RX_ADDRx did not provide a valid MAC address, try EEPROM. */ if (!ETHER_IS_VALID(sc->sc_ue.ue_eaddr)) { - if ((lan78xx_eeprom_read(sc, ETH_E2P_MAC_OFFSET, + if ((lan78xx_eeprom_present(sc) && + lan78xx_eeprom_read_raw(sc, ETH_E2P_MAC_OFFSET, sc->sc_ue.ue_eaddr, ETHER_ADDR_LEN) == 0) || (lan78xx_otp_read(sc, OTP_MAC_OFFSET, sc->sc_ue.ue_eaddr, ETHER_ADDR_LEN) == 0)) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201806111934.w5BJYlnb046244>