From owner-svn-src-head@freebsd.org Sat Oct 3 16:37:39 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9B29CA0EDD7; Sat, 3 Oct 2015 16:37:39 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 71A9D1DB2; Sat, 3 Oct 2015 16:37:39 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t93GbdYm095271; Sat, 3 Oct 2015 16:37:39 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t93GbdZn095270; Sat, 3 Oct 2015 16:37:39 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <201510031637.t93GbdZn095270@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Sat, 3 Oct 2015 16:37:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r288616 - head/sys/dev/usb/wlan X-SVN-Group: head 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.20 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: Sat, 03 Oct 2015 16:37:39 -0000 Author: adrian Date: Sat Oct 3 16:37:38 2015 New Revision: 288616 URL: https://svnweb.freebsd.org/changeset/base/288616 Log: rum(4): move some code from rum_init() into separate function. Tested: * rum0: MAC/BBP RT2573 (rev 0x2573a), RF RT2528, STA mode Submitted by: Differential Revision: https://reviews.freebsd.org/D3623 Modified: head/sys/dev/usb/wlan/if_rum.c Modified: head/sys/dev/usb/wlan/if_rum.c ============================================================================== --- head/sys/dev/usb/wlan/if_rum.c Sat Oct 3 16:34:21 2015 (r288615) +++ head/sys/dev/usb/wlan/if_rum.c Sat Oct 3 16:37:38 2015 (r288616) @@ -215,6 +215,7 @@ static void rum_update_promisc(struct i static void rum_setpromisc(struct rum_softc *); static const char *rum_get_rf(int); static void rum_read_eeprom(struct rum_softc *); +static int rum_bbp_wakeup(struct rum_softc *); static int rum_bbp_init(struct rum_softc *); static int rum_init(struct rum_softc *); static void rum_stop(struct rum_softc *); @@ -2010,6 +2011,27 @@ rum_read_eeprom(struct rum_softc *sc) } static int +rum_bbp_wakeup(struct rum_softc *sc) +{ + unsigned int ntries; + + for (ntries = 0; ntries < 100; ntries++) { + if (rum_read(sc, RT2573_MAC_CSR12) & 8) + break; + rum_write(sc, RT2573_MAC_CSR12, 4); /* force wakeup */ + if (rum_pause(sc, hz / 100)) + break; + } + if (ntries == 100) { + device_printf(sc->sc_dev, + "timeout waiting for BBP/RF to wakeup\n"); + return (ETIMEDOUT); + } + + return (0); +} + +static int rum_bbp_init(struct rum_softc *sc) { int i, ntries; @@ -2047,7 +2069,7 @@ rum_init(struct rum_softc *sc) struct ieee80211com *ic = &sc->sc_ic; struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); uint32_t tmp; - int i, ntries, ret; + int i, ret; RUM_LOCK(sc); if (sc->sc_running) { @@ -2064,19 +2086,8 @@ rum_init(struct rum_softc *sc) rum_write(sc, RT2573_MAC_CSR1, 0); /* wait for BBP/RF to wakeup */ - for (ntries = 0; ntries < 100; ntries++) { - if (rum_read(sc, RT2573_MAC_CSR12) & 8) - break; - rum_write(sc, RT2573_MAC_CSR12, 4); /* force wakeup */ - if (rum_pause(sc, hz / 100)) - break; - } - if (ntries == 100) { - device_printf(sc->sc_dev, - "timeout waiting for BBP/RF to wakeup\n"); - ret = ETIMEDOUT; + if ((ret = rum_bbp_wakeup(sc)) != 0) goto end; - } if ((ret = rum_bbp_init(sc)) != 0) goto end;