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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Peter 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.
Sorry, my bad, will revise.

Thanks
Ajay
--nvpublic
> > 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





[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux