Skip to contentSkip to conversation

iwlwifi: fix 64-bit division

PATCH In review Arnd Bergmann 4 participants 7 messages Mar 4, 2019 – Mar 7, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iwlwifi: fix 64-bit division

do_div() expects unsigned operands and otherwise triggers a warning like:

drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c:465:2: error: comparison of distinct pointer types ('typeof ((rtt_avg)) *' (aka 'long long *') and 'uint64_t *' (aka 'unsigned long long *')) [-Werror,-Wcompare-distinct-pointer-types]

        do_div(rtt_avg, 6666);
        ^~~~~~~~~~~~~~~~~~~~~
include/asm-generic/div64.h:222:28: note: expanded from macro 'do_div'
        (void)(((typeof((n)) *)0) == ((uint64_t *)0));  \
               ~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~

1 error generated.

Change the do_div() to the simpler div_s64() that can handle negative inputs correctly.

Fixes 937b10c0de68 ("iwlwifi: mvm: add debug prints for FTM")
---
 drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c +1 -3
index e9822a3ec373..94132cfd1f56 100644
@@ -460,9 +460,7 @@ static int iwl_mvm_ftm_range_resp_valid(struct iwl_mvm *mvm, u8 request_id,
 static void iwl_mvm_debug_range_resp(struct iwl_mvm *mvm, u8 index,
 				     struct cfg80211_pmsr_result *res)
 {
-	s64 rtt_avg = res->ftm.rtt_avg * 100;
-
-	do_div(rtt_avg, 6666);
+	s64 rtt_avg = div_s64(res->ftm.rtt_avg * 100, 6666);
 
 	IWL_DEBUG_INFO(mvm, "entry %d\n", index);
 	IWL_DEBUG_INFO(mvm, "\tstatus: %d\n", res->status);
Signature · 1 line
2.20.0
#1 lore raw

Hi Arnd,

Quoted 13 lines · Arnd Bergmann

do_div() expects unsigned operands and otherwise triggers a warning like:

drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c:465:2: error:
comparison of distinct pointer types ('typeof ((rtt_avg)) *' (aka 'long long *') and 'uint64_t *' (aka 'unsigned long long *')) [- Werror,-Wcompare-distinct-pointer-types]

        do_div(rtt_avg, 6666);
        ^~~~~~~~~~~~~~~~~~~~~
include/asm-generic/div64.h:222:28: note: expanded from macro
'do_div'
        (void)(((typeof((n)) *)0) == ((uint64_t *)0));  \
               ~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~
Quoted 8 lines

1 error generated.

Change the do_div() to the simpler div_s64() that can handle negative inputs correctly.

Fixes 937b10c0de68 ("iwlwifi: mvm: add debug prints for FTM")

---

This was already fixed with this patch:

https://patchwork.kernel.org/patch/10823267/

...but it hasn't reached the mainline yet.

I'm planning to send it to the v5.1-rc series as soon as the merge window closes. Is that quick enough for you?

--
Cheers,
Luca.

#2 lore raw
Quoted 9 lines · Luciano Coelho

On Mon, 2019-03-04 at 21:38 +0100, Arnd Bergmann wrote:
This was already fixed with this patch:

https://patchwork.kernel.org/patch/10823267/

...but it hasn't reached the mainline yet.

I'm planning to send it to the v5.1-rc series as soon as the merge window closes. Is that quick enough for you?

That's fine, I just want it to reach 5.1 so it does not regress against 5.0.

Sorry for the slightly bad timing of my submission. I had just restarted my randconfig tests the other day and wanted to get my 60 new patches out as quickly as possible.

Arnd

#3 lore raw
Quoted 7 lines · Arnd Bergmann
Quoted 5 lines · Luciano Coelho

On Mon, 2019-03-04 at 21:38 +0100, Arnd Bergmann wrote:
This was already fixed with this patch:

https://patchwork.kernel.org/patch/10823267/

Quoted 7 lines
Quoted 4 lines

...but it hasn't reached the mainline yet.

I'm planning to send it to the v5.1-rc series as soon as the merge window closes. Is that quick enough for you?

That's fine, I just want it to reach 5.1 so it does not regress against 5.0.

Okay, I'll push it to 5.1-rc series for sure.

Quoted 4 lines

Sorry for the slightly bad timing of my submission. I had just restarted
my randconfig tests the other day and wanted to get my 60 new patches out as quickly as possible.

No problem! I really appreciate your sending patches and reviews.

--
Cheers,
Luca.

#4 lore raw
In reply to Arnd Bergmann
Quoted 8 lines · Arnd Bergmann

do_div() expects unsigned operands and otherwise triggers a warning like:

drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c:465:2: error: comparison of distinct pointer types ('typeof ((rtt_avg)) *' (aka 'long long *') and 'uint64_t *' (aka 'unsigned long long *')) [-Werror,-Wcompare-distinct-pointer-types]

        do_div(rtt_avg, 6666);
        ^~~~~~~~~~~~~~~~~~~~~
include/asm-generic/div64.h:222:28: note: expanded from macro 'do_div'
        (void)(((typeof((n)) *)0) == ((uint64_t *)0));  \
               ~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~
Quoted 7 lines

1 error generated.

Change the do_div() to the simpler div_s64() that can handle negative inputs correctly.

Fixes 937b10c0de68 ("iwlwifi: mvm: add debug prints for FTM")

Luca, can I take this directly?

Signature · 1 line
Kalle Valo
#5 lore raw
Quoted 17 lines · Kalle Valo
Quoted 15 lines · Arnd Bergmann

do_div() expects unsigned operands and otherwise triggers a warning like:

drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c:465:2:
error: comparison of distinct pointer types ('typeof ((rtt_avg)) *' (aka 'long long *') and 'uint64_t *' (aka 'unsigned long long *')) [-Werror,-Wcompare-distinct-pointer-types]

        do_div(rtt_avg, 6666);
        ^~~~~~~~~~~~~~~~~~~~~
include/asm-generic/div64.h:222:28: note: expanded from macro
'do_div'
        (void)(((typeof((n)) *)0) == ((uint64_t *)0));  \
               ~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~

1 error generated.

Quoted 7 lines
Quoted 5 lines

Change the do_div() to the simpler div_s64() that can handle negative inputs correctly.

Fixes 937b10c0de68 ("iwlwifi: mvm: add debug prints for FTM")

Luca, can I take this directly?

Yeah, I guess to make things simpler, and since you're planning to send fixes to 5.1 already anyway, you can just take this one. I'll assign it to you in patchwork.

Arnd, this way you'll get it earlier. ;)

--
Cheers,
Luca.

#6 lore raw
In reply to Arnd Bergmann
Quoted 8 lines · Arnd Bergmann

do_div() expects unsigned operands and otherwise triggers a warning like:

drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c:465:2: error: comparison of distinct pointer types ('typeof ((rtt_avg)) *' (aka 'long long *') and 'uint64_t *' (aka 'unsigned long long *')) [-Werror,-Wcompare-distinct-pointer-types]

        do_div(rtt_avg, 6666);
        ^~~~~~~~~~~~~~~~~~~~~
include/asm-generic/div64.h:222:28: note: expanded from macro 'do_div'
        (void)(((typeof((n)) *)0) == ((uint64_t *)0));  \
               ~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~
Quoted 7 lines

1 error generated.

Change the do_div() to the simpler div_s64() that can handle negative inputs correctly.

Fixes 937b10c0de68 ("iwlwifi: mvm: add debug prints for FTM")

Patch applied to wireless-drivers.git, thanks.

688cd8bd2c0f iwlwifi: fix 64-bit division

Signature · 3 lines
https://patchwork.kernel.org/patch/10838587/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches