summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorReyk Floeter <reyk@cvs.openbsd.org>2005-01-09 18:18:16 +0000
committerReyk Floeter <reyk@cvs.openbsd.org>2005-01-09 18:18:16 +0000
commita481f804c7ec1bdffe4f18f01db1bb3b1ef91e56 (patch)
tree89278270db330a7ad1884fedfd89824504ff7039 /sys/dev
parent4914b417371e3df3d9c7c97001ff0396141f1b15 (diff)
fix regulation domain handling
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/ic/ar5210.c8
-rw-r--r--sys/dev/ic/ar5xxx.c46
-rw-r--r--sys/dev/ic/ar5xxx.h8
3 files changed, 29 insertions, 33 deletions
diff --git a/sys/dev/ic/ar5210.c b/sys/dev/ic/ar5210.c
index 1a7cf2ebcda..e3bc067f928 100644
--- a/sys/dev/ic/ar5210.c
+++ b/sys/dev/ic/ar5210.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ar5210.c,v 1.8 2004/12/31 01:00:23 reyk Exp $ */
+/* $OpenBSD: ar5210.c,v 1.9 2005/01/09 18:18:15 reyk Exp $ */
/*
* Copyright (c) 2004 Reyk Floeter <reyk@vantronix.net>.
@@ -1552,7 +1552,7 @@ ar5k_ar5210_setRegulatoryDomain(hal, regdomain, status)
{
if (ar5k_eeprom_regulation_domain(hal, AH_TRUE,
- ar5k_regdomain_to_ieee((u_int8_t)regdomain)) == AH_TRUE) {
+ ar5k_regdomain_to_ieee(regdomain)) == AH_TRUE) {
*status = HAL_OK;
return (AH_TRUE);
}
@@ -1753,8 +1753,8 @@ ar5k_ar5210_getRegDomain(hal)
ieee80211_regdomain_t ieee_regdomain;
if (ar5k_eeprom_regulation_domain(hal,
- AH_FALSE, &ieee_regdomain) == AH_TRUE) {
- regdomain = ar5k_regdomain_from_ieee(&ieee_regdomain);
+ AH_FALSE, ieee_regdomain) == AH_TRUE) {
+ regdomain = ar5k_regdomain_from_ieee(ieee_regdomain);
return (regdomain > 0 ? regdomain : hal->ah_regdomain);
}
diff --git a/sys/dev/ic/ar5xxx.c b/sys/dev/ic/ar5xxx.c
index ba1cca8298c..fdefbda96a9 100644
--- a/sys/dev/ic/ar5xxx.c
+++ b/sys/dev/ic/ar5xxx.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ar5xxx.c,v 1.7 2004/12/31 03:39:01 espie Exp $ */
+/* $OpenBSD: ar5xxx.c,v 1.8 2005/01/09 18:18:15 reyk Exp $ */
/*
* Copyright (c) 2004 Reyk Floeter <reyk@vantronix.net>.
@@ -220,20 +220,18 @@ ath_hal_attach(device, sc, st, sh, status)
/* Set regulation domain */
if ((regdomain =
- (u_int16_t)hal->ah_capabilities.cap_eeprom.ee_regdomain) != 0) {
- ieee_regdomain = *ar5k_regdomain_to_ieee(regdomain);
- memcpy(&hal->ah_capabilities.cap_regdomain.reg_current,
- &ieee_regdomain, sizeof(ieee80211_regdomain_t));
+ hal->ah_capabilities.cap_eeprom.ee_regdomain) != 0) {
+ hal->ah_capabilities.cap_regdomain.reg_current =
+ ieee_regdomain = ar5k_regdomain_to_ieee(regdomain);
} else {
ieee_regdomain =
hal->ah_capabilities.cap_regdomain.reg_current;
/* Try to write default regulation domain to EEPROM */
- ar5k_eeprom_regulation_domain(hal, AH_TRUE, &ieee_regdomain);
+ ar5k_eeprom_regulation_domain(hal, AH_TRUE, ieee_regdomain);
}
- memcpy(&hal->ah_capabilities.cap_regdomain.reg_hw,
- &ieee_regdomain, sizeof(ieee80211_regdomain_t));
+ hal->ah_capabilities.cap_regdomain.reg_hw = ieee_regdomain;
/* Get misc capabilities */
if (hal->ah_get_capabilities(hal) != AH_TRUE) {
@@ -474,23 +472,24 @@ ar5k_radar_alert(hal)
}
u_int16_t
-ar5k_regdomain_from_ieee(regdomain)
- ieee80211_regdomain_t *regdomain;
+ar5k_regdomain_from_ieee(ieee)
+ ieee80211_regdomain_t ieee;
{
- /*
- * XXX Fix
- */
- return ((u_int16_t)*regdomain);
+ u_int32_t regdomain = (u_int32_t)ieee;
+
+ if (regdomain & 0xf0000000)
+ return ((u_int16_t)DMN_DEFAULT);
+
+ return (regdomain & 0xff);
}
-ieee80211_regdomain_t *
+ieee80211_regdomain_t
ar5k_regdomain_to_ieee(regdomain)
u_int16_t regdomain;
{
- /*
- * XXX Fix
- */
- return ((ieee80211_regdomain_t*)&regdomain);
+ ieee80211_regdomain_t ieee = (ieee80211_regdomain_t)regdomain & 0xff;
+
+ return (ieee);
}
u_int32_t
@@ -974,19 +973,16 @@ HAL_BOOL
ar5k_eeprom_regulation_domain(hal, write, regdomain)
struct ath_hal *hal;
HAL_BOOL write;
- ieee80211_regdomain_t *regdomain;
+ ieee80211_regdomain_t regdomain;
{
/* Read current value */
if (write != AH_TRUE) {
- memcpy(regdomain,
- &hal->ah_capabilities.cap_regdomain.reg_current,
- sizeof(ieee80211_regdomain_t));
+ regdomain = hal->ah_capabilities.cap_regdomain.reg_current;
return (AH_TRUE);
}
/* Try to write a new value */
- memcpy(&hal->ah_capabilities.cap_regdomain.reg_current, regdomain,
- sizeof(ieee80211_regdomain_t));
+ hal->ah_capabilities.cap_regdomain.reg_current = regdomain;
if (hal->ah_capabilities.cap_eeprom.ee_protect &
AR5K_EEPROM_PROTECT_WR_128_191)
diff --git a/sys/dev/ic/ar5xxx.h b/sys/dev/ic/ar5xxx.h
index 18a53abbaee..0d44b4e9b4f 100644
--- a/sys/dev/ic/ar5xxx.h
+++ b/sys/dev/ic/ar5xxx.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ar5xxx.h,v 1.7 2004/12/31 01:00:23 reyk Exp $ */
+/* $OpenBSD: ar5xxx.h,v 1.8 2005/01/09 18:18:15 reyk Exp $ */
/*
* Copyright (c) 2004 Reyk Floeter <reyk@vantronix.net>.
@@ -1408,8 +1408,8 @@ HAL_BOOL ath_hal_init_channels(struct ath_hal *, HAL_CHANNEL *,
u_int, u_int *, HAL_CTRY_CODE, u_int16_t, HAL_BOOL, HAL_BOOL);
void ar5k_radar_alert(struct ath_hal *);
-ieee80211_regdomain_t *ar5k_regdomain_to_ieee(u_int16_t);
-u_int16_t ar5k_regdomain_from_ieee(ieee80211_regdomain_t *);
+ieee80211_regdomain_t ar5k_regdomain_to_ieee(u_int16_t);
+u_int16_t ar5k_regdomain_from_ieee(ieee80211_regdomain_t);
u_int32_t ar5k_bitswap(u_int32_t, u_int);
u_int ar5k_clocktoh(u_int, HAL_BOOL);
u_int ar5k_htoclock(u_int, HAL_BOOL);
@@ -1421,7 +1421,7 @@ HAL_BOOL ar5k_register_timeout(struct ath_hal *, u_int32_t,
int ar5k_eeprom_init(struct ath_hal *);
int ar5k_eeprom_read_mac(struct ath_hal *, u_int8_t *);
HAL_BOOL ar5k_eeprom_regulation_domain(struct ath_hal *,
- HAL_BOOL, ieee80211_regdomain_t *);
+ HAL_BOOL, ieee80211_regdomain_t);
HAL_BOOL ar5k_channel(struct ath_hal *, HAL_CHANNEL *);
HAL_BOOL ar5k_rfregs(struct ath_hal *, HAL_CHANNEL *, u_int);