[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1f5c1533-5c9f-4cc2-b40b-6e9b22374640@ti.com>
Date: Wed, 28 Feb 2024 09:38:39 -0600
From: Judith Mendez <jm@...com>
To: Adrian Hunter <adrian.hunter@...el.com>
CC: <linux-mmc@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
Ulf Hansson
<ulf.hansson@...aro.org>
Subject: Re: [PATCH v2 1/7] mmc: sdhci_am654: Add tuning algorithm for delay
chain
Hello Adrian,
On 2/28/24 7:21 AM, Adrian Hunter wrote:
> On 20/02/24 22:10, Judith Mendez wrote:
>> On 2/16/24 11:09 AM, Adrian Hunter wrote:
>>> On 7/02/24 03:15, Judith Mendez wrote:
>>>> +
>>>> + if (!num_fails)
>>>> + return ITAPDLY_LAST_INDEX >> 1;
>>>> +
>>>> + if (fail_window->length == ITAPDLY_LENGTH) {
>>>> + dev_err(dev, "No passing ITAPDLY, return 0\n");
>>>> + return 0;
>>>> + }
>>>> +
>>>> + first_fail_start = fail_window->start;
>>>> + last_fail_end = fail_window[num_fails - 1].end;
>>>> +
>>>> + for (i = 0; i < num_fails; i++) {
>>>> + start_fail = fail_window[i].start;
>>>> + end_fail = fail_window[i].end;
>>>> + pass_length = start_fail - (prev_fail_end + 1);
>>>> +
>>>> + if (pass_length > pass_window.length) {
>>>> + pass_window.start = prev_fail_end + 1;
>>>> + pass_window.length = pass_length;
>>>> + }
>>>> + prev_fail_end = end_fail;
>>>> + }
>>>> +
>>>> + if (!circular_buffer)
>>>> + pass_length = ITAPDLY_LAST_INDEX - last_fail_end;
>>>> + else
>>>> + pass_length = ITAPDLY_LAST_INDEX - last_fail_end + first_fail_start;
>>>> +
>>>> + if (pass_length > pass_window.length) {
>>>> + pass_window.start = last_fail_end + 1;
>>>> + pass_window.length = pass_length;
>>>> + }
>>>> +
>>>> + if (!circular_buffer)
>>>> + itap = pass_window.start + (pass_window.length >> 1);
>>>> + else
>>>> + itap = (pass_window.start + (pass_window.length >> 1)) % ITAPDLY_LENGTH;
>>>> +
>>>> + return (itap < 0 || itap > ITAPDLY_LAST_INDEX ? 0 : itap);
>>>
>>> Parentheses are not needed where they are but putting
>>> them around the condition would make it more readable e.g.
>>>
>>> return (itap < 0 || itap > ITAPDLY_LAST_INDEX) ? 0 : itap;
>>>
>>> However (itap < 0) is not possible because itap is an unsigned type
>>> and if (itap > ITAPDLY_LAST_INDEX) then maybe it would be better
>>> to return ITAPDLY_LAST_INDEX
>>
>> You are right about itap < 0, thanks will fix.
>>
>> About itap > ITAPDLY_LAST_INDEX, this is an error. Why
>> return ITAPDLY_LAST_INDEX instead of 0?
>
> It doesn't matter. Just if a value has a better chance to work
> if the calculation fails, like maybe ITAPDLY_LAST_INDEX / 2, but
> presumably it should not fail.
Ok, ITAPDLY_LAST_INDEX / sounds good to me, I will add this instead.
Thanks,
~ Judith
Powered by blists - more mailing lists