[PATCH] i2c-mpc: Wait for STOP to hit the bus

Joakim Tjernlund joakim.tjernlund at transmode.se
Tue Sep 11 20:13:22 EST 2012


Joakim Tjernlund/Transmode wrote on 2012/09/02 16:22:00:
>
> Tabi Timur-B04825 <B04825 at freescale.com> wrote on 2012/09/02 04:48:01:
> > On Thu, Aug 30, 2012 at 5:40 AM, Joakim Tjernlund
> > <Joakim.Tjernlund at transmode.se> wrote:
> >
> > > -       mpc_i2c_stop(i2c);
> > > +       mpc_i2c_stop(i2c); /* Initiate STOP */
> > > +       orig_jiffies = jiffies;
> > > +       /* Wait until STOP is seen, allow up to 1 s */
> > > +       while (readb(i2c->base + MPC_I2C_SR) & CSR_MBB) {
> > > +               if (time_after(jiffies, orig_jiffies + HZ)) {
> > > +                       u8 status = readb(i2c->base + MPC_I2C_SR);
> > > +
> > > +                       dev_dbg(i2c->dev, "timeout\n");
> > > +                       if ((status & (CSR_MCF | CSR_MBB | CSR_RXAK)) != 0) {
> > > +                               writeb(status & ~CSR_MAL,
> > > +                                      i2c->base + MPC_I2C_SR);
> > > +                               mpc_i2c_fixup(i2c);
> > > +                       }
> > > +                       return -EIO;
> > > +               }
> > > +               cond_resched();
> > > +       }
> >
> > Shouldn't the while-loop be inside mpc_i2c_stop() itself?
>
> Possibly but I choosed to do it this way as there is a similar loop in the beginning of mpc_xfer().
> I figured it has better visibility if it is in the same function.
>
>  Jocke

Ping? Anything holding this patch back?

 Jocke



More information about the Linuxppc-dev mailing list