Re: [PATCH 3/3] i2c: cadence: Add atomic transfer support for controller version 1.4

From: Andi Shyti
Date: Wed Sep 11 2024 - 04:24:51 EST


Hi Manikanta,

> > > if (msg_timeout < adap->timeout)
> > > msg_timeout = adap->timeout;
> > >
> > > - /* Wait for the signal of completion */
> > > - time_left = wait_for_completion_timeout(&id->xfer_done, msg_timeout);
> > > + if (!id->atomic) {
> > > + /* Wait for the signal of completion */
> > > + time_left = wait_for_completion_timeout(&id->xfer_done,
> > msg_timeout);
> > > + } else {
> > > + /* 0 is success, -ETIMEDOUT is error */
> > > + time_left = !readl_poll_timeout_atomic(id->membase +
> > CDNS_I2C_ISR_OFFSET,
> > > + reg, (reg & CDNS_I2C_IXR_COMP),
> > > + CDNS_I2C_POLL_US_ATOMIC,
> > msg_timeout);
> > > + }
> >
> > You can merge this if/else with the one above, to save some code.
> Thank you for your suggestion to merge the if/else blocks to streamline the code. We have considered this approach; however, merging them would necessitate duplicating the following lines in both the if and else blocks:
> if (msg_timeout < adap->timeout)
> msg_timeout = adap->timeout;

OK, makes sense, I didn't see it.

Thanks,
Andi