Skip to contentSkip to conversation

staging: rtl8188eu: Remove function rtw_modular64()

PATCH Ivan Safonov 3 participants 4 messages Apr 12, 2020 – Apr 14, 2020 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 1 line

Remove function rtw_modular64 as all it does is call do_div.

This is wrong. Macro do_div(x, y) change first argument x, but rtw_modular64(x, y) preserve it.

Review

Quoted 1 line
(quoted diff) +1 -0
+			tsf = pmlmeext->TSFValue - do_div(pmlmeext->TSFValue, (pmlmeinfo->bcn_interval*1024)) - 1024; /* us */

rounddown(pmlmeext->TSFValue, pmlmeinfo->bcn_interval * 1024) - 1024 is a better replacement for

Review

Quoted 1 line
(quoted diff) +0 -1
-			tsf = pmlmeext->TSFValue - rtw_modular64(pmlmeext->TSFValue, (pmlmeinfo->bcn_interval*1024)) - 1024; /* us */

Patch '[PATCH 01/10] staging: rtl8723bs: Remove function rtw_modular64()' have same bug.

Ivan Safonov.

#2 lore raw
Quoted 9 lines · Ivan Safonov
Quoted 1 line

Remove function rtw_modular64 as all it does is call do_div.

This is wrong. Macro do_div(x, y) change first argument x, but rtw_modular64(x, y) preserve it.

Review

Quoted 1 line
(quoted diff) +1 -0
+			tsf = pmlmeext->TSFValue - do_div(pmlmeext->TSFValue, (pmlmeinfo->bcn_interval*1024)) - 1024; /* us */

rounddown(pmlmeext->TSFValue, pmlmeinfo->bcn_interval * 1024) - 1024 is a better replacement for

You're absolutely correct that the patch is buggy, but I'm not sure that rounddown() is what we want.

rtw_modular64() took the MOD of x. So it should be something like:

	tsf = pmlmeext->TSFValue - (pmlmeext->TSFValue % (pmlmeinfo->bcn_interval * 1024)) - 1024; /* us */

But what the heck is that even??? If pmlmeinfo->bcn_interval is zero or one then the subtraction ends up giving us a negative.

regards,
dan carpenter

#3 lore raw
Quoted 16 lines · Dan Carpenter
Quoted 9 lines · Ivan Safonov
Quoted 1 line

Remove function rtw_modular64 as all it does is call do_div.

This is wrong. Macro do_div(x, y) change first argument x, but rtw_modular64(x, y) preserve it.

Review

Quoted 1 line
(quoted diff) +1 -0
+			tsf = pmlmeext->TSFValue - do_div(pmlmeext->TSFValue, (pmlmeinfo->bcn_interval*1024)) - 1024; /* us */

rounddown(pmlmeext->TSFValue, pmlmeinfo->bcn_interval * 1024) - 1024 is a better replacement for

You're absolutely correct that the patch is buggy, but I'm not sure that rounddown() is what we want.

rtw_modular64() took the MOD of x. So it should be something like:

Quoted 8 lines
	tsf = pmlmeext->TSFValue - (pmlmeext->TSFValue % (pmlmeinfo->bcn_interval * 1024)) - 1024; /* us */

But what the heck is that even??? If pmlmeinfo->bcn_interval is zero or one then the subtraction ends up giving us a negative.

regards,
dan carpenter

1. pmlmeext->TSFValue can not be negative, because it is uint64_t;
2. pmlmeext->TSFValue is cyclic value:

    https://en.wikipedia.org/wiki/Timing_synchronization_function ;

3. (rounddown(a, b)) is equal to (a - a % b) by definition.

Ivan Safonov.

#4 lore raw
Quoted 22 lines · Ivan Safonov
Quoted 21 lines · Dan Carpenter
Quoted 9 lines · Ivan Safonov
Quoted 1 line

Remove function rtw_modular64 as all it does is call do_div.

This is wrong. Macro do_div(x, y) change first argument x, but rtw_modular64(x, y) preserve it.

Review

Quoted 1 line
(quoted diff) +1 -0
+			tsf = pmlmeext->TSFValue - do_div(pmlmeext->TSFValue, (pmlmeinfo->bcn_interval*1024)) - 1024; /* us */

rounddown(pmlmeext->TSFValue, pmlmeinfo->bcn_interval * 1024) - 1024 is a better replacement for

You're absolutely correct that the patch is buggy, but I'm not sure that rounddown() is what we want.

rtw_modular64() took the MOD of x. So it should be something like:

	tsf = pmlmeext->TSFValue - (pmlmeext->TSFValue % (pmlmeinfo->bcn_interval * 1024)) - 1024; /* us */

But what the heck is that even??? If pmlmeinfo->bcn_interval is zero or one then the subtraction ends up giving us a negative.

Quoted 8 lines
Quoted 3 lines

regards,
dan carpenter

1. pmlmeext->TSFValue can not be negative, because it is uint64_t;
2. pmlmeext->TSFValue is cyclic value:

    https://en.wikipedia.org/wiki/Timing_synchronization_function ;

3. (rounddown(a, b)) is equal to (a - a % b) by definition.

Yeah. You're right. I got mixed up and I misread what you were suggesting.

	tsf = rounddown(pmlmeext->TSFValue, pmlmeinfo->bcn_interval * 1024) - 1024;

regards,
dan carpenter