From owner-p4-projects@FreeBSD.ORG Tue Oct 2 02:58:08 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id A7B7D16A469; Tue, 2 Oct 2007 02:58:08 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4CC2016A418 for ; Tue, 2 Oct 2007 02:58:08 +0000 (UTC) (envelope-from thompsa@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 47BC313C458 for ; Tue, 2 Oct 2007 02:58:08 +0000 (UTC) (envelope-from thompsa@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id l922w84O076711 for ; Tue, 2 Oct 2007 02:58:08 GMT (envelope-from thompsa@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id l922w8IZ076708 for perforce@freebsd.org; Tue, 2 Oct 2007 02:58:08 GMT (envelope-from thompsa@freebsd.org) Date: Tue, 2 Oct 2007 02:58:08 GMT Message-Id: <200710020258.l922w8IZ076708@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to thompsa@freebsd.org using -f From: Andrew Thompson To: Perforce Change Reviews Cc: Subject: PERFORCE change 127083 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Oct 2007 02:58:08 -0000 http://perforce.freebsd.org/chv.cgi?CH=127083 Change 127083 by thompsa@thompsa_heff on 2007/10/02 02:57:19 Simplify ipw_media_status() rate conversion. Obtained from: sam Affected files ... .. //depot/projects/wifi/sys/dev/ipw/if_ipw.c#31 edit Differences ... ==== //depot/projects/wifi/sys/dev/ipw/if_ipw.c#31 (text+ko) ==== @@ -779,6 +779,18 @@ return (error); } +static int +ipw_cvtrate(int ipwrate) +{ + switch (ipwrate) { + case IPW_RATE_DS1: return 2; + case IPW_RATE_DS2: return 4; + case IPW_RATE_DS5: return 11; + case IPW_RATE_DS11: return 22; + } + return 0; +} + /* * The firmware automatically adapts the transmit speed. We report its current * value here. @@ -786,20 +798,9 @@ static void ipw_media_status(struct ifnet *ifp, struct ifmediareq *imr) { -#define N(a) (sizeof (a) / sizeof (a[0])) struct ipw_softc *sc = ifp->if_softc; struct ieee80211com *ic = &sc->sc_ic; - static const struct { - uint32_t val; - int rate; - } rates[] = { - { IPW_RATE_DS1, 2 }, - { IPW_RATE_DS2, 4 }, - { IPW_RATE_DS5, 11 }, - { IPW_RATE_DS11, 22 }, - }; - uint32_t val; - int rate, i; + int rate; imr->ifm_status = IFM_AVALID; imr->ifm_active = IFM_IEEE80211; @@ -807,14 +808,9 @@ imr->ifm_status |= IFM_ACTIVE; /* read current transmission rate from adapter */ - val = ipw_read_table1(sc, IPW_INFO_CURRENT_TX_RATE) & 0xf; - - /* convert ipw rate to 802.11 rate */ - for (i = 0; i < N(rates) && rates[i].val != val; i++); - rate = (i < N(rates)) ? rates[i].rate : 0; + rate = ipw_cvtrate(ipw_read_table1(sc, IPW_INFO_CURRENT_TX_RATE) & 0xf); + imr->ifm_active |= ieee80211_rate2media(ic, rate, IEEE80211_MODE_11B); - imr->ifm_active |= IFM_IEEE80211_11B; - imr->ifm_active |= ieee80211_rate2media(ic, rate, IEEE80211_MODE_11B); switch (ic->ic_opmode) { case IEEE80211_M_STA: break; @@ -833,7 +829,6 @@ /* should not get there */ break; } -#undef N } static int