[v13,2/2] usb: typec: ucsi: add support for Cypress CCGx

From: Ajay Gupta <ajayg@nvidia.com>
Date: 2018-10-26 16:25:40

Hi Peter and Andy,
quoted
quoted
quoted
quoted
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));
quoted
quoted
quoted
                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.
quoted
quoted
quoted
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.
Sorry, my bad, will revise.

Thanks
Ajay
--nvpublic
quoted
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help