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