Yea I was able to do it with example.I will mention my observation if some once come here by chance should help them.
lets assume
Code:
loops_per_jiffy = 1011 0010
Code:
loopbit = loops_per_jiffy;
So loopbit = 1011 0010
Code:
/* Gradually work on the lower-order bits */
while (lps_precision-- && (loopbit >>= 1)) {
no idea of what lps_precision is may be some sort of check.
loopbit = loopbit/2 by above operation so new value of loopbit is
Code:
loopbit = 0101 1001
Code:
loops_per_jiffy |= loopbit;
Now due to above
Quote:
loops_per_jiffy = loops_per_jiffy | loopbit
|
so the result of an OR operation
Quote:
loops_per_jiffy = 1011 0010 OR 0101 1001 = 1111 1011
|
which is higher than the initial value of loops_per_jiffy
simple
Code:
while (ticks == jiffies); /* Wait until the start
is also simple if due to some calculation you are in mid of jiffy interval then
it will make sure that as
will come out of loop only
at the start of jiffy
Code:
of the next jiffy */
ticks = jiffies;
simple
Code:
/* Delay */
__delay(loops_per_jiffy);
Will delay for the value loops_per_jiffy
Code:
if (jiffies != ticks)
/* longer than 1 tick */
loops_per_jiffy &= ~loopbit;
here comes the magic if it is not satisfying the if condition then
will go back divide the loopbits by 2 as a result of >> (right shift)
and the OR operation will make sure that the value which is divided by
2 of loopbits gets added to loops_per_jiffy
will enter the delay loop and in this case if this time the "if"
condition is true then
the result of
Quote:
loops_per_jiffy &= ~loopbit
|
is
Quote:
loops_per_jiffy = loops_per_jiffy AND (~loopbit)
|
where taking complement of loopbit as above makes it negative (not
sure on this part)
and the result is the value is subtracted (as it was more than required value)
and then loopbit is again divided so added and this cycle will continue until
exact value of loops_per_jiffy is calculated.
but if there are more examples of such a calculation then let me know.
I just came across this one.