lkml.org 
[lkml]   [2020]   [Apr]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 5/8] staging: rtl8188eu: Remove function rtw_modular64()
From
Date
On 4/14/20 2:56 PM, Dan Carpenter wrote:
> On Sun, Apr 12, 2020 at 04:34:08PM +0300, Ivan Safonov wrote:
>>> 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.
>>
>>> + 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
>

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.

\
 
 \ /
  Last update: 2020-04-14 14:19    [W:0.100 / U:0.320 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site