From owner-svn-src-user@FreeBSD.ORG Fri Jan 23 19:20:31 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BEA15106566B; Fri, 23 Jan 2009 19:20:31 +0000 (UTC) (envelope-from sam@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id ACA618FC22; Fri, 23 Jan 2009 19:20:31 +0000 (UTC) (envelope-from sam@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n0NJKVBP051069; Fri, 23 Jan 2009 19:20:31 GMT (envelope-from sam@svn.freebsd.org) Received: (from sam@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n0NJKVAS051067; Fri, 23 Jan 2009 19:20:31 GMT (envelope-from sam@svn.freebsd.org) Message-Id: <200901231920.n0NJKVAS051067@svn.freebsd.org> From: Sam Leffler Date: Fri, 23 Jan 2009 19:20:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r187642 - user/sam/wifi/sys/dev/ath/ath_hal X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Jan 2009 19:20:32 -0000 Author: sam Date: Fri Jan 23 19:20:31 2009 New Revision: 187642 URL: http://svn.freebsd.org/changeset/base/187642 Log: Minor fixups to ath_hal_checkchannel: o move to an inline function unless building with AH_DEBUG o add assertions Modified: user/sam/wifi/sys/dev/ath/ath_hal/ah_internal.h user/sam/wifi/sys/dev/ath/ath_hal/ah_regdomain.c Modified: user/sam/wifi/sys/dev/ath/ath_hal/ah_internal.h ============================================================================== --- user/sam/wifi/sys/dev/ath/ath_hal/ah_internal.h Fri Jan 23 18:58:43 2009 (r187641) +++ user/sam/wifi/sys/dev/ath/ath_hal/ah_internal.h Fri Jan 23 19:20:31 2009 (r187642) @@ -437,32 +437,6 @@ isBigEndian(void) #define OS_REG_CLR_BIT(_a, _r, _f) \ OS_REG_WRITE(_a, _r, OS_REG_READ(_a, _r) &~ (_f)) -/* - * Regulatory domain support. - */ - -/* - * Return the max allowed antenna gain and apply any regulatory - * domain specific changes. - */ -u_int ath_hal_getantennareduction(struct ath_hal *ah, - const struct ieee80211_channel *chan, u_int twiceGain); - -/* - * Return the test group for the specific channel based on - * the current regulatory setup. - */ -u_int ath_hal_getctl(struct ath_hal *, const struct ieee80211_channel *); - -/* - * Map a public channel definition to the corresponding - * internal data structure. This implicitly specifies - * whether or not the specified channel is ok to use - * based on the current regulatory domain constraints. - */ -HAL_CHANNEL_INTERNAL *ath_hal_checkchannel(struct ath_hal *, - const struct ieee80211_channel *); - /* system-configurable parameters */ extern int ath_hal_dma_beacon_response_time; /* in TU's */ extern int ath_hal_sw_beacon_response_time; /* in TU's */ @@ -521,6 +495,46 @@ extern void ath_hal_assert_failed(const #define HALASSERT(_x) #endif /* AH_ASSERT */ +/* + * Regulatory domain support. + */ + +/* + * Return the max allowed antenna gain and apply any regulatory + * domain specific changes. + */ +u_int ath_hal_getantennareduction(struct ath_hal *ah, + const struct ieee80211_channel *chan, u_int twiceGain); + +/* + * Return the test group for the specific channel based on + * the current regulatory setup. + */ +u_int ath_hal_getctl(struct ath_hal *, const struct ieee80211_channel *); + +/* + * Map a public channel definition to the corresponding + * internal data structure. This implicitly specifies + * whether or not the specified channel is ok to use + * based on the current regulatory domain constraints. + */ +#ifndef AH_DEBUG +static OS_INLINE HAL_CHANNEL_INTERNAL * +ath_hal_checkchannel(struct ath_hal *ah, const struct ieee80211_channel *c) +{ + HAL_CHANNEL_INTERNAL *cc; + + HALASSERT(c->ic_devdata < AH_PRIVATE(ah)->ah_nchan); + cc = &AH_PRIVATE(ah)->ah_channels[c->ic_devdata]; + HALASSERT(c->ic_freq == cc->channel); + return cc; +} +#else +/* NB: non-inline version that checks state */ +HAL_CHANNEL_INTERNAL *ath_hal_checkchannel(struct ath_hal *, + const struct ieee80211_channel *); +#endif /* AH_DEBUG */ + /* * Convert between microseconds and core system clocks. */ Modified: user/sam/wifi/sys/dev/ath/ath_hal/ah_regdomain.c ============================================================================== --- user/sam/wifi/sys/dev/ath/ath_hal/ah_regdomain.c Fri Jan 23 18:58:43 2009 (r187641) +++ user/sam/wifi/sys/dev/ath/ath_hal/ah_regdomain.c Fri Jan 23 19:20:31 2009 (r187642) @@ -2272,31 +2272,34 @@ ath_hal_set_channels(struct ath_hal *ah, return status; } +#ifdef AH_DEBUG /* * Return the internal channel corresponding to a public channel. + * NB: normally this routine is inline'd (see ah_internal.h) */ HAL_CHANNEL_INTERNAL * ath_hal_checkchannel(struct ath_hal *ah, const struct ieee80211_channel *c) { - /* XXX should not happen */ - if (c->ic_devdata < AH_PRIVATE(ah)->ah_nchan) { - HAL_CHANNEL_INTERNAL *cc = - &AH_PRIVATE(ah)->ah_channels[c->ic_devdata]; - if (c->ic_freq == cc->channel) - return cc; - } + HAL_CHANNEL_INTERNAL *cc = &AH_PRIVATE(ah)->ah_channels[c->ic_devdata]; + + if (c->ic_devdata < AH_PRIVATE(ah)->ah_nchan && + c->ic_freq == cc->channel) + return cc; if (c->ic_devdata >= AH_PRIVATE(ah)->ah_nchan) { HALDEBUG(ah, HAL_DEBUG_ANY, "%s: bad mapping, devdata %u nchans %u\n", __func__, c->ic_devdata, AH_PRIVATE(ah)->ah_nchan); + HALASSERT(c->ic_devdata < AH_PRIVATE(ah)->ah_nchan); } else { HALDEBUG(ah, HAL_DEBUG_ANY, "%s: no match for %u/0x%x devdata %u channel %u\n", __func__, c->ic_freq, c->ic_flags, c->ic_devdata, AH_PRIVATE(ah)->ah_channels[c->ic_devdata].channel); + HALASSERT(c->ic_freq == cc->channel); } return AH_NULL; } +#endif /* AH_DEBUG */ #define isWwrSKU(_ah) \ ((getEepromRD((_ah)) & WORLD_SKU_MASK) == WORLD_SKU_PREFIX || \