From: Emmanuel Grumbach Date: Sun, 14 Apr 2013 11:41:03 +0000 (+0300) Subject: iwlwifi: mvm: fix first_antenna X-Git-Tag: v3.10-rc1~132^2~18^2^2~8^2~7 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=d7dad550e6ddb96db9d3e4d322f7d1dd8a6a9c8d;p=karo-tx-linux.git iwlwifi: mvm: fix first_antenna first_antenna is supposed to return the first antenna as a 0-based bitmap: ANT_A is BIT(0), ANT_B is BIT(1), etc... Since ffs is 1 based (ffs(BIT(0)) = 1), then we had an off-by-one bug: BIT(ffs(ANT_A)) = BIT(ffs(BIT(0))) = BIT(1) = ANT_B. So what we really want is: BIT(ffs(ANT_A) - 1) = BIT(ffs(BIT(0)) - 1) = BIT(0) = ANT_A. Signed-off-by: Emmanuel Grumbach Signed-off-by: Johannes Berg --- diff --git a/drivers/net/wireless/iwlwifi/mvm/utils.c b/drivers/net/wireless/iwlwifi/mvm/utils.c index 0cc8d8c0d393..687b34e387ac 100644 --- a/drivers/net/wireless/iwlwifi/mvm/utils.c +++ b/drivers/net/wireless/iwlwifi/mvm/utils.c @@ -253,8 +253,9 @@ int iwl_mvm_rx_fw_error(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb, u8 first_antenna(u8 mask) { BUILD_BUG_ON(ANT_A != BIT(0)); /* using ffs is wrong if not */ - WARN_ON_ONCE(!mask); /* ffs will return 0 if mask is zeroed */ - return (u8)(BIT(ffs(mask))); + if (WARN_ON_ONCE(!mask)) /* ffs will return 0 if mask is zeroed */ + return BIT(0); + return BIT(ffs(mask) - 1); } /*