Thread (10 messages) 10 messages, 5 authors, 2019-02-22

Re: [PATCH] iwlwifi: mvm: Use div64_s64 instead of do_div in iwl_mvm_debug_range_resp

From: Luciano Coelho <hidden>
Date: 2019-02-21 07:33:40
Also in: linux-wireless, lkml

On Wed, 2019-02-20 at 10:56 -0700, Nathan Chancellor wrote:
On Wed, Feb 20, 2019 at 11:51:34AM +0100, Arnd Bergmann wrote:
quoted
On Tue, Feb 19, 2019 at 7:22 PM Nathan Chancellor
[off-list ref] wrote:
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?
Sure, please do! I already applied this internally, but I can just fix
it with your new patch and that will be squashed before being sent
upstream, so it will look like your second patch.

--
Cheers,
Luca.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help