From: Peter Rosin <peda@axentia.se>
To: Ajay Gupta <ajayg@nvidia.com>,
Heikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: "wsa@the-dreams.de" <wsa@the-dreams.de>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"linux-i2c@vger.kernel.org" <linux-i2c@vger.kernel.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [v13,2/2] usb: typec: ucsi: add support for Cypress CCGx
Date: Fri, 26 Oct 2018 06:49:51 +0000 [thread overview]
Message-ID: <f2f69497-a0c1-2b11-ce5e-524b1634432c@axentia.se> (raw)
On 2018-10-25 23:55, Ajay Gupta wrote:
> Hi Heikki and Andy
> [...]
>>>> Shouldn't you return -ETIMEDOUT if count == 0?
>>> Yes. Good catch. Does the below fix looks ok?
>>>
>>> do {
>>> status = ccg_write(uc, CCGX_RAB_INTR_REG, &data, sizeof(data));
>>> if (status < 0)
>>> return status;
>>>
>>> usleep_range(10000, 11000);
>>>
>>> status = ccg_read(uc, CCGX_RAB_INTR_REG, &data, sizeof(data));
>>> if (status < 0)
>>> return status;
>>>
>>> if (!data)
>>> return 0;
>>> } while (data && count--);
>>
>> Doesn't that condition break out of the loop immediately?
> How? I didn't get your point? We want to break out when data is
> zero (interrupt status cleared).
The statement
if (!data)
return 0;
ensures that 'data' is non-zero when the loop continues, so checking
that 'data' is non-zero in the while loop test is pointless.
>>> Ah, I see, but why you not reorganize it to put this into do-while loop?
> We actually need to check data after reading it so will reorganize accordingly.
> do {
> read
> check for data and break out if (!data)
> write
> sleep
> } while (--count);
Here, you have fixed the "issue" (but it doesn't match v14).
Cheers,
Peter
next reply other threads:[~2018-10-26 6:49 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-26 6:49 Peter Rosin [this message]
-- strict thread matches above, loose matches on Subject: below --
2018-10-26 16:25 [v13,2/2] usb: typec: ucsi: add support for Cypress CCGx Ajay Gupta
2018-10-26 7:27 Heikki Krogerus
2018-10-25 21:55 Ajay Gupta
2018-10-25 21:30 Ajay Gupta
2018-10-25 21:29 Ajay Gupta
2018-10-25 9:26 Andy Shevchenko
2018-10-25 9:26 Heikki Krogerus
2018-10-25 9:07 Peter Rosin
2018-10-25 8:17 Heikki Krogerus
2018-10-24 17:43 Ajay Gupta
2018-10-24 9:25 Andy Shevchenko
2018-10-23 18:56 Ajay Gupta
2018-10-23 9:35 Heikki Krogerus
2018-10-03 18:27 Ajay Gupta
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f2f69497-a0c1-2b11-ce5e-524b1634432c@axentia.se \
--to=peda@axentia.se \
--cc=ajayg@nvidia.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=heikki.krogerus@linux.intel.com \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=wsa@the-dreams.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.