Re: [PATCH] iwlwifi: mvm: Use div64_s64 instead of do_div in iwl_mvm_debug_range_resp
From: Nathan Chancellor <hidden>
Date: 2019-02-20 17:56:22
Also in:
lkml, netdev
From: Nathan Chancellor <hidden>
Date: 2019-02-20 17:56:22
Also in:
lkml, netdev
On Wed, Feb 20, 2019 at 11:51:34AM +0100, Arnd Bergmann wrote:
On Tue, Feb 19, 2019 at 7:22 PM Nathan Chancellor [off-list ref] wrote:quoted
quoted
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c b/drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c index e9822a3ec373..92b22250eb7d 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c@@ -462,7 +462,7 @@ static void iwl_mvm_debug_range_resp(struct iwl_mvm *mvm, u8 index, { s64 rtt_avg = res->ftm.rtt_avg * 100; - do_div(rtt_avg, 6666); + div64_s64(rtt_avg, 6666);This is wrong: div64_s64 does not modify its argument like do_div(), but it returns the result instead. You also don't want to divide by a 64-bit value when the second argument is a small constant. I think the correct way should be s64 rtt_avg = div_s64(res->ftm.rtt_avg * 100, 6666); If you know that the value is positive, using unsigned types and div_u64() would be slightly faster. Arnd
Thanks for the review and explanation, Arnd. Luca, could you drop this version so I can resend it? Nathan