From owner-svn-src-head@freebsd.org Mon Jun 11 19:34:48 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2BBB7100E002; Mon, 11 Jun 2018 19:34:48 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D549879072; Mon, 11 Jun 2018 19:34:47 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B6D591FCF5; Mon, 11 Jun 2018 19:34:47 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5BJYlTZ046245; Mon, 11 Jun 2018 19:34:47 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5BJYlnb046244; Mon, 11 Jun 2018 19:34:47 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201806111934.w5BJYlnb046244@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Mon, 11 Jun 2018 19:34:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334973 - head/sys/dev/usb/net X-SVN-Group: head X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: head/sys/dev/usb/net X-SVN-Commit-Revision: 334973 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jun 2018 19:34:48 -0000 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)) {