On 04/10/2018 19:19, Rafael J. Wysocki wrote:
> On Thu, Oct 4, 2018 at 4:51 PM Daniel Lezcano <[email protected]> 
> wrote:
>>
>> On Tue, Oct 02, 2018 at 11:44:06PM +0200, Rafael J. Wysocki wrote:
>>> From: Rafael J. Wysocki <[email protected]>
>>>
>>> Rearrange the code in menu_select() so that the loop over idle states
>>> always starts from 0 and get rid of the first_idx variable.
>>>
>>> While at it, add two empty lines to separate conditional statements
>>> one another.
>>>
>>> No intentional behavior changes.
>>>
>>> Signed-off-by: Rafael J. Wysocki <[email protected]>
>>> ---
>>
>> This code is becoming a bit complex to follow :/
>>
>> May be I missed something, but it is not possible to enter the condition 
>> without
>> idx != 0, no ? (I meant the condition if ((drv->states[idx].flags &
>> FLAG_POLLING))
> 
> Not sure what you mean.

Yes, sorry let me clarify.

I meant the flag polling is always on state[0], so if the flag is set
then idx == 0.

We have the conditions:

  drv->states[idx].flags & CPUIDLE_FLAG_POLLING

If it is true then idx is zero.


Then comes the second condition:

  i == idx + 1

because of the above, idx is zero, then it can become i == 1.

Then the variable assignation:

 idx = i can be replaced by idx = 1





> We start with idx = -1, i = 0.  If state[0] is enabled, idx becomes 0.
> 
> If the target residency or exit latency of state[0] are already beyond
> the limits, we just bail out and state[0] will be returned.
> 
> If not, we go to i = 1, but idx is still 0.  If the target residency
> of state[1] is beyond predicted_us (which is the interesting case), we
> check (drv->states[0].flags & FLAG_POLLING) and so on.
> 
> Currently, the polling state must be state[0] (if used at all) anyway.
> 
>> Reviewed-by: Daniel Lezcano <[email protected]>
>>
> 
> Thanks!
> 


-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

Reply via email to