diff options
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/ic/ar5210.c | 8 | ||||
-rw-r--r-- | sys/dev/ic/ar5211.c | 12 | ||||
-rw-r--r-- | sys/dev/ic/ar5212.c | 24 | ||||
-rw-r--r-- | sys/dev/ic/ar5xxx.c | 34 | ||||
-rw-r--r-- | sys/dev/ic/ar5xxx.h | 3 |
5 files changed, 40 insertions, 41 deletions
diff --git a/sys/dev/ic/ar5210.c b/sys/dev/ic/ar5210.c index b44a33a2454..2889b784d95 100644 --- a/sys/dev/ic/ar5210.c +++ b/sys/dev/ic/ar5210.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ar5210.c,v 1.44 2009/01/15 07:55:22 grange Exp $ */ +/* $OpenBSD: ar5210.c,v 1.45 2009/06/02 12:39:02 reyk Exp $ */ /* * Copyright (c) 2004, 2005, 2006, 2007 Reyk Floeter <reyk@openbsd.org> @@ -387,7 +387,7 @@ ar5k_ar5210_reset(struct ath_hal *hal, HAL_OPMODE op_mode, HAL_CHANNEL *channel, /* * Write initial mode register settings */ - for (i = 0; i < AR5K_ELEMENTS(ar5210_ini); i++) { + for (i = 0; i < nitems(ar5210_ini); i++) { if (change_channel == AH_TRUE && ar5210_ini[i].ini_register >= AR5K_AR5210_PCU_MIN && ar5210_ini[i].ini_register <= AR5K_AR5210_PCU_MAX) @@ -808,7 +808,7 @@ ar5k_ar5210_init_tx_queue(struct ath_hal *hal, u_int aifs, HAL_BOOL turbo) /* * Write initial mode register settings */ - for (i = 0; i < AR5K_ELEMENTS(initial); i++) + for (i = 0; i < nitems(initial); i++) AR5K_REG_WRITE((u_int32_t)initial[i].mode_register, turbo == AH_TRUE ? initial[i].mode_turbo : initial[i].mode_base); @@ -1886,7 +1886,7 @@ ar5k_ar5210_set_key(struct ath_hal *hal, u_int16_t entry, return (AH_FALSE); } - for (i = 0; i < AR5K_ELEMENTS(key_v); i++) + for (i = 0; i < nitems(key_v); i++) AR5K_REG_WRITE(AR5K_AR5210_KEYTABLE_OFF(entry, i), key_v[i]); return (ar5k_ar5210_set_key_lladdr(hal, entry, mac)); diff --git a/sys/dev/ic/ar5211.c b/sys/dev/ic/ar5211.c index ffeb024e000..e4293692863 100644 --- a/sys/dev/ic/ar5211.c +++ b/sys/dev/ic/ar5211.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ar5211.c,v 1.43 2009/06/02 12:09:26 guenther Exp $ */ +/* $OpenBSD: ar5211.c,v 1.44 2009/06/02 12:39:02 reyk Exp $ */ /* * Copyright (c) 2004, 2005, 2006, 2007 Reyk Floeter <reyk@openbsd.org> @@ -486,7 +486,7 @@ ar5k_ar5211_reset(struct ath_hal *hal, HAL_OPMODE op_mode, HAL_CHANNEL *channel, /* * Write initial mode settings */ - for (i = 0; i < AR5K_ELEMENTS(ar5211_mode); i++) { + for (i = 0; i < nitems(ar5211_mode); i++) { AR5K_REG_WAIT(i); AR5K_REG_WRITE((u_int32_t)ar5211_mode[i].mode_register, ar5211_mode[i].mode_value[mode]); @@ -495,7 +495,7 @@ ar5k_ar5211_reset(struct ath_hal *hal, HAL_OPMODE op_mode, HAL_CHANNEL *channel, /* * Write initial register settings */ - for (i = 0; i < AR5K_ELEMENTS(ar5211_ini); i++) { + for (i = 0; i < nitems(ar5211_ini); i++) { if (change_channel == AH_TRUE && ar5211_ini[i].ini_register >= AR5K_AR5211_PCU_MIN && ar5211_ini[i].ini_register <= AR5K_AR5211_PCU_MAX) @@ -1992,7 +1992,7 @@ ar5k_ar5211_set_key(struct ath_hal *hal, u_int16_t entry, return (AH_FALSE); } - for (i = 0; i < AR5K_ELEMENTS(key_v); i++) + for (i = 0; i < nitems(key_v); i++) AR5K_REG_WRITE(AR5K_AR5211_KEYTABLE_OFF(entry, i), key_v[i]); return (ar5k_ar5211_set_key_lladdr(hal, entry, mac)); @@ -2562,7 +2562,7 @@ ar5k_ar5211_rfregs(struct ath_hal *hal, HAL_CHANNEL *channel, u_int freq, u_int ee_mode) { struct ar5k_eeprom_info *ee = &hal->ah_capabilities.cap_eeprom; - struct ar5k_ar5211_ini_rf rf[AR5K_ELEMENTS(ar5211_rf)]; + struct ar5k_ar5211_ini_rf rf[nitems(ar5211_rf)]; u_int32_t ob, db, obdb, xpds, xpdp, x_gain; u_int i; @@ -2611,7 +2611,7 @@ ar5k_ar5211_rfregs(struct ath_hal *hal, HAL_CHANNEL *channel, u_int freq, rf[17].rf_value[freq] = (rf[17].rf_value[freq] & ~0x8) | ((xpds << 3) & 0x8); - for (i = 0; i < AR5K_ELEMENTS(rf); i++) { + for (i = 0; i < nitems(rf); i++) { AR5K_REG_WAIT(i); AR5K_REG_WRITE((u_int32_t)rf[i].rf_register, rf[i].rf_value[freq]); diff --git a/sys/dev/ic/ar5212.c b/sys/dev/ic/ar5212.c index 6821e0b3cf1..6ede05807c9 100644 --- a/sys/dev/ic/ar5212.c +++ b/sys/dev/ic/ar5212.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ar5212.c,v 1.50 2009/02/06 17:06:45 grange Exp $ */ +/* $OpenBSD: ar5212.c,v 1.51 2009/06/02 12:39:02 reyk Exp $ */ /* * Copyright (c) 2004, 2005, 2006, 2007 Reyk Floeter <reyk@openbsd.org> @@ -264,7 +264,7 @@ ar5k_ar5212_attach(u_int16_t device, void *sc, bus_space_tag_t st, if (hal->ah_pci_express == AH_TRUE) { /* PCI-Express based devices need some extra initialization */ - ar5k_write_ini(hal, ar5212_pcie, AR5K_ELEMENTS(ar5212_pcie), 0); + ar5k_write_ini(hal, ar5212_pcie, nitems(ar5212_pcie), 0); } bcopy(etherbroadcastaddr, mac, IEEE80211_ADDR_LEN); @@ -550,33 +550,33 @@ ar5k_ar5212_reset(struct ath_hal *hal, HAL_OPMODE op_mode, HAL_CHANNEL *channel, /* * Write initial mode and register settings */ - ar5k_write_mode(hal, ar5212_mode, AR5K_ELEMENTS(ar5212_mode), mode); - ar5k_write_ini(hal, ar5212_ini, AR5K_ELEMENTS(ar5212_ini), chanchange); + ar5k_write_mode(hal, ar5212_mode, nitems(ar5212_mode), mode); + ar5k_write_ini(hal, ar5212_ini, nitems(ar5212_ini), chanchange); switch (hal->ah_radio) { case AR5K_AR5111: ar5k_write_mode(hal, ar5212_ar5111_mode, - AR5K_ELEMENTS(ar5212_ar5111_mode), mode); + nitems(ar5212_ar5111_mode), mode); break; case AR5K_AR5112: ar5k_write_mode(hal, ar5212_ar5112_mode, - AR5K_ELEMENTS(ar5212_ar5112_mode), mode); + nitems(ar5212_ar5112_mode), mode); break; case AR5K_AR5413: ar5k_write_mode(hal, ar5413_mode, - AR5K_ELEMENTS(ar5413_mode), mode); + nitems(ar5413_mode), mode); break; case AR5K_AR2413: AR5K_REG_WRITE(AR5K_AR5212_PHY(648), 0x018830c6); ar5k_write_mode(hal, ar2413_mode, - AR5K_ELEMENTS(ar2413_mode), mode); + nitems(ar2413_mode), mode); break; case AR5K_AR2425: AR5K_REG_WRITE(AR5K_AR5212_PHY(648), 0x018830c6); if (mode == AR5K_INI_VAL_11B) mode = AR5K_INI_VAL_11G; ar5k_write_mode(hal, ar2425_mode, - AR5K_ELEMENTS(ar2425_mode), mode); + nitems(ar2425_mode), mode); break; default: AR5K_PRINTF("invalid radio: %d\n", hal->ah_radio); @@ -585,10 +585,10 @@ ar5k_ar5212_reset(struct ath_hal *hal, HAL_OPMODE op_mode, HAL_CHANNEL *channel, if (hal->ah_radio == AR5K_AR5111) ar5k_write_ini(hal, ar5111_bbgain, - AR5K_ELEMENTS(ar5111_bbgain), chanchange); + nitems(ar5111_bbgain), chanchange); else ar5k_write_ini(hal, ar5112_bbgain, - AR5K_ELEMENTS(ar5112_bbgain), chanchange); + nitems(ar5112_bbgain), chanchange); /* * Write initial RF gain settings @@ -2368,7 +2368,7 @@ ar5k_ar5212_set_key(struct ath_hal *hal, u_int16_t entry, return (AH_FALSE); } - for (i = 0; i < AR5K_ELEMENTS(key_v); i++) + for (i = 0; i < nitems(key_v); i++) AR5K_REG_WRITE(AR5K_AR5212_KEYTABLE_OFF(entry, i), key_v[i]); return (ar5k_ar5212_set_key_lladdr(hal, entry, mac)); diff --git a/sys/dev/ic/ar5xxx.c b/sys/dev/ic/ar5xxx.c index e1e75da938c..126cc029588 100644 --- a/sys/dev/ic/ar5xxx.c +++ b/sys/dev/ic/ar5xxx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ar5xxx.c,v 1.53 2009/06/02 12:09:26 guenther Exp $ */ +/* $OpenBSD: ar5xxx.c,v 1.54 2009/06/02 12:39:02 reyk Exp $ */ /* * Copyright (c) 2004, 2005, 2006, 2007 Reyk Floeter <reyk@openbsd.org> @@ -145,7 +145,7 @@ ath_hal_probe(u_int16_t vendor, u_int16_t device) /* * Perform a linear search on the table of supported devices */ - for (i = 0; i < AR5K_ELEMENTS(ar5k_known_products); i++) { + for (i = 0; i < nitems(ar5k_known_products); i++) { if (vendor == ar5k_known_products[i].vendor && device == ar5k_known_products[i].device) return (""); @@ -172,7 +172,7 @@ ath_hal_attach(u_int16_t device, void *arg, bus_space_tag_t st, /* * Call the chipset-dependent attach routine by device id */ - for (i = 0; i < AR5K_ELEMENTS(ar5k_known_products); i++) { + for (i = 0; i < nitems(ar5k_known_products); i++) { if (device == ar5k_known_products[i].device && ar5k_known_products[i].attach != NULL) attach = ar5k_known_products[i].attach; @@ -445,7 +445,7 @@ ath_hal_init_channels(struct ath_hal *hal, HAL_CHANNEL *channels, * and mode. 5GHz... */ for (i = 0; (hal->ah_capabilities.cap_range.range_5ghz_max > 0) && - (i < AR5K_ELEMENTS(ar5k_5ghz_channels)) && + (i < nitems(ar5k_5ghz_channels)) && (c < max_channels); i++) { /* Check if channel is supported by the chipset */ if (ar5k_check_channel(hal, @@ -475,7 +475,7 @@ ath_hal_init_channels(struct ath_hal *hal, HAL_CHANNEL *channels, * ...and 2GHz. */ for (i = 0; (hal->ah_capabilities.cap_range.range_2ghz_max > 0) && - (i < AR5K_ELEMENTS(ar5k_2ghz_channels)) && + (i < nitems(ar5k_2ghz_channels)) && (c < max_channels); i++) { /* Check if channel is supported by the chipset */ if (ar5k_check_channel(hal, @@ -525,7 +525,7 @@ ar5k_printver(enum ar5k_srev_type type, u_int32_t val) const char *name = "xxxx"; int i; - for (i = 0; i < AR5K_ELEMENTS(names); i++) { + for (i = 0; i < nitems(names); i++) { if (type == AR5K_VERSION_DEV) { if (names[i].sr_type == type && names[i].sr_val == val) { @@ -1528,7 +1528,7 @@ HAL_BOOL ar5k_ar5111_rfregs(struct ath_hal *hal, HAL_CHANNEL *channel, u_int mode) { struct ar5k_eeprom_info *ee = &hal->ah_capabilities.cap_eeprom; - const u_int rf_size = AR5K_ELEMENTS(ar5111_rf); + const u_int rf_size = nitems(ar5111_rf); u_int32_t *rf; int i, obdb = -1, bank = -1; u_int32_t ee_mode; @@ -1636,10 +1636,10 @@ ar5k_ar5112_rfregs(struct ath_hal *hal, HAL_CHANNEL *channel, u_int mode) if (hal->ah_radio_5ghz_revision >= AR5K_SREV_RAD_5112A) { rf_ini = ar5112a_rf; - rf_size = AR5K_ELEMENTS(ar5112a_rf); + rf_size = nitems(ar5112a_rf); } else { rf_ini = ar5112_rf; - rf_size = AR5K_ELEMENTS(ar5112_rf); + rf_size = nitems(ar5112_rf); } /* Copy values to modify them */ @@ -1731,17 +1731,17 @@ ar5k_arxxxx_rfregs(struct ath_hal *hal, HAL_CHANNEL *channel, u_int mode) switch (hal->ah_radio) { case AR5K_AR5413: rf_ini = ar5413_rf; - rf_size = AR5K_ELEMENTS(ar5413_rf); + rf_size = nitems(ar5413_rf); break; case AR5K_AR2413: rf_ini = ar2413_rf; - rf_size = AR5K_ELEMENTS(ar2413_rf); + rf_size = nitems(ar2413_rf); break; case AR5K_AR2425: if (mode == AR5K_INI_VAL_11B) mode = AR5K_INI_VAL_11G; rf_ini = ar2425_rf; - rf_size = AR5K_ELEMENTS(ar2425_rf); + rf_size = nitems(ar2425_rf); break; default: return (AH_FALSE); @@ -1779,22 +1779,22 @@ ar5k_rfgain(struct ath_hal *hal, u_int freq) switch (hal->ah_radio) { case AR5K_AR5111: rfg = ar5111_rfg; - rfg_size = AR5K_ELEMENTS(ar5111_rfg); + rfg_size = nitems(ar5111_rfg); break; case AR5K_AR5112: rfg = ar5112_rfg; - rfg_size = AR5K_ELEMENTS(ar5112_rfg); + rfg_size = nitems(ar5112_rfg); break; case AR5K_AR5413: rfg = ar5413_rfg; - rfg_size = AR5K_ELEMENTS(ar5413_rfg); + rfg_size = nitems(ar5413_rfg); break; case AR5K_AR2413: case AR5K_AR2425: if (freq == AR5K_INI_RFGAIN_5GHZ) return (AH_FALSE); rfg = ar2413_rfg; - rfg_size = AR5K_ELEMENTS(ar2413_rfg); + rfg_size = nitems(ar2413_rfg); break; default: return (AH_FALSE); @@ -1844,7 +1844,7 @@ ar5k_txpower_table(struct ath_hal *hal, HAL_CHANNEL *channel, int16_t max_power) hal->ah_txpower.txp_ofdm = rates[0]; /* Calculate the power table */ - n = AR5K_ELEMENTS(hal->ah_txpower.txp_pcdac); + n = nitems(hal->ah_txpower.txp_pcdac); min = AR5K_EEPROM_PCDAC_START; max = AR5K_EEPROM_PCDAC_STOP; for (i = 0; i < n; i += AR5K_EEPROM_PCDAC_STEP) diff --git a/sys/dev/ic/ar5xxx.h b/sys/dev/ic/ar5xxx.h index 348d64a7f05..96d37069d09 100644 --- a/sys/dev/ic/ar5xxx.h +++ b/sys/dev/ic/ar5xxx.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ar5xxx.h,v 1.45 2008/08/29 10:05:00 reyk Exp $ */ +/* $OpenBSD: ar5xxx.h,v 1.46 2009/06/02 12:39:02 reyk Exp $ */ /* * Copyright (c) 2004, 2005, 2006, 2007 Reyk Floeter <reyk@openbsd.org> @@ -1295,7 +1295,6 @@ struct ar5k_srev_name { #define AR5K_TRACE #endif #define AR5K_DELAY(_n) delay(_n) -#define AR5K_ELEMENTS(_array) (sizeof(_array) / sizeof(_array[0])) typedef struct ath_hal * (ar5k_attach_t) (u_int16_t, void *, bus_space_tag_t, bus_space_handle_t, HAL_STATUS *); |