commit 65a3c32acf5d5fcf5177de9d8f552fe0705f0d1e Author: Jiri Slaby Date: Fri Jul 13 08:18:45 2007 +0200 cleanup hal's key functions diff --git a/openhal/ath5k.h b/openhal/ath5k.h index e0cc2c4..3ca9468 100644 --- a/openhal/ath5k.h +++ b/openhal/ath5k.h @@ -1057,11 +1057,10 @@ unsigned int ath5k_hw_get_ack_timeout(struct ath_hw *hal); bool ath5k_hw_set_cts_timeout(struct ath_hw *hal, unsigned int timeout); unsigned int ath5k_hw_get_cts_timeout(struct ath_hw *hal); /* Key table (WEP) functions */ -bool ath5k_hw_is_cipher_supported(struct ath_hw *hal, enum ath5k_cipher cipher); -bool ath5k_hw_reset_key(struct ath_hw *hal, u16 entry); -bool ath5k_hw_is_key_valid(struct ath_hw *hal, u16 entry); -bool ath5k_hw_set_key(struct ath_hw *hal, u16 entry, const struct ath5k_keyval *keyval, const u8 *mac, int xor_notused); -bool ath5k_hw_set_key_lladdr(struct ath_hw *hal, u16 entry, const u8 *mac); +int ath5k_hw_reset_key(struct ath_hw *hal, u16 entry); +int ath5k_hw_is_key_valid(struct ath_hw *hal, u16 entry); +int ath5k_hw_set_key(struct ath_hw *hal, u16 entry, const struct ath5k_keyval *keyval, const u8 *mac); +int ath5k_hw_set_key_lladdr(struct ath_hw *hal, u16 entry, const u8 *mac); /* Queue Control Unit, DFS Control Unit Functions */ int ath5k_hw_setup_tx_queue(struct ath_hw *hal, enum ath5k_tx_queue queue_type, struct ath5k_txq_info *queue_info); int ath5k_hw_setup_tx_queueprops(struct ath_hw *hal, int queue, const struct ath5k_txq_info *queue_info); diff --git a/openhal/ath5k_hw.c b/openhal/ath5k_hw.c index 7d246e0..dbee59a 100644 --- a/openhal/ath5k_hw.c +++ b/openhal/ath5k_hw.c @@ -3157,29 +3157,9 @@ ath5k_hw_get_cts_timeout(struct ath_hw *hal) * Key table (WEP) functions */ -/* - * Return which ciphers are supported by hw - */ -bool -ath5k_hw_is_cipher_supported(struct ath_hw *hal, enum ath5k_cipher cipher) +int ath5k_hw_reset_key(struct ath_hw *hal, u16 entry) { - AR5K_TRACE; - /* - * Only WEP for now - */ - if (cipher == AR5K_CIPHER_WEP) - return true; - - return false; -} - -/* - * Reset encryption key - */ -bool -ath5k_hw_reset_key(struct ath_hw *hal, u16 entry) -{ - int i; + unsigned int i; AR5K_TRACE; AR5K_ASSERT_ENTRY(entry, AR5K_KEYTABLE_SIZE); @@ -3192,43 +3172,28 @@ ath5k_hw_reset_key(struct ath_hw *hal, u16 entry) ath5k_hw_reg_write(hal, AR5K_KEYTABLE_TYPE_NULL, AR5K_KEYTABLE_TYPE(entry)); - return false; /*????*/ + return 0; } -/* - * Check if a key entry is valid - */ -bool -ath5k_hw_is_key_valid(struct ath_hw *hal, u16 entry) +int ath5k_hw_is_key_valid(struct ath_hw *hal, u16 entry) { AR5K_TRACE; AR5K_ASSERT_ENTRY(entry, AR5K_KEYTABLE_SIZE); - /* - * Check the validation flag at the end of the entry - */ - if (ath5k_hw_reg_read(hal, AR5K_KEYTABLE_MAC1(entry)) & - AR5K_KEYTABLE_VALID) - return true; - - return false; + /* Check the validation flag at the end of the entry */ + return ath5k_hw_reg_read(hal, AR5K_KEYTABLE_MAC1(entry)) & + AR5K_KEYTABLE_VALID; } -/* - * Set encryption key - */ -bool -ath5k_hw_set_key(struct ath_hw *hal, u16 entry, - const struct ath5k_keyval *keyval, const u8 *mac, int xor_notused) +int ath5k_hw_set_key(struct ath_hw *hal, u16 entry, + const struct ath5k_keyval *keyval, const u8 *mac) { - int i; - u32 key_v[AR5K_KEYCACHE_SIZE - 2]; + unsigned int i; + u32 key_v[AR5K_KEYCACHE_SIZE - 2] = {}; AR5K_TRACE; AR5K_ASSERT_ENTRY(entry, AR5K_KEYTABLE_SIZE); - memset(&key_v, 0, sizeof(key_v)); - switch (keyval->wk_len) { case AR5K_KEYVAL_LENGTH_40: memcpy(&key_v[0], keyval->wk_key, 4); @@ -3255,8 +3220,7 @@ ath5k_hw_set_key(struct ath_hw *hal, u16 entry, break; default: - /* Unsupported key length (not WEP40/104/128) */ - return false; + return -EINVAL; } for (i = 0; i < ARRAY_SIZE(key_v); i++) @@ -3265,9 +3229,7 @@ ath5k_hw_set_key(struct ath_hw *hal, u16 entry, return ath5k_hw_set_key_lladdr(hal, entry, mac); } -bool -ath5k_hw_set_key_lladdr(struct ath_hw *hal, u16 entry, - const u8 *mac) +int ath5k_hw_set_key_lladdr(struct ath_hw *hal, u16 entry, const u8 *mac) { u32 low_id, high_id; @@ -3277,11 +3239,10 @@ ath5k_hw_set_key_lladdr(struct ath_hw *hal, u16 entry, /* MAC may be NULL if it's a broadcast key. In this case no need to * to compute AR5K_LOW_ID and AR5K_HIGH_ID as we already know it. */ - if(unlikely(mac == NULL)) { + if (unlikely(mac == NULL)) { low_id = 0xffffffff; high_id = 0xffff | AR5K_KEYTABLE_VALID; - } - else { + } else { low_id = AR5K_LOW_ID(mac); high_id = AR5K_HIGH_ID(mac) | AR5K_KEYTABLE_VALID; } @@ -3289,12 +3250,10 @@ ath5k_hw_set_key_lladdr(struct ath_hw *hal, u16 entry, ath5k_hw_reg_write(hal, low_id, AR5K_KEYTABLE_MAC0(entry)); ath5k_hw_reg_write(hal, high_id, AR5K_KEYTABLE_MAC1(entry)); - return true; + return 0; } - - /********************************************\ Queue Control Unit, DFS Control Unit Functions \********************************************/