diff mbox

[4/7] i2c: img-scb: mark transaction as complete when no more data to write

Message ID 1437998162-32724-5-git-send-email-sifan.naeem@imgtec.com
State Changes Requested
Headers show

Commit Message

Sifan Naeem July 27, 2015, 11:55 a.m. UTC
We can mark the transfer as complete without waiting for the stop
bit. This is important when handling repeated start transfers as
we have to start the next transfer without the stop bit being issued.

This doesn't affect the older versions of the IP.

Signed-off-by: Sifan Naeem <sifan.naeem@imgtec.com>
---
 drivers/i2c/busses/i2c-img-scb.c |   15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

Comments

James Hogan July 29, 2015, 2:22 p.m. UTC | #1
On 27/07/15 12:55, Sifan Naeem wrote:
> We can mark the transfer as complete without waiting for the stop
> bit. This is important when handling repeated start transfers as
> we have to start the next transfer without the stop bit being issued.
> 
> This doesn't affect the older versions of the IP.
> 
> Signed-off-by: Sifan Naeem <sifan.naeem@imgtec.com>
> ---
>  drivers/i2c/busses/i2c-img-scb.c |   15 +++++----------
>  1 file changed, 5 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-img-scb.c b/drivers/i2c/busses/i2c-img-scb.c
> index e27c3e0..efad4d7 100644
> --- a/drivers/i2c/busses/i2c-img-scb.c
> +++ b/drivers/i2c/busses/i2c-img-scb.c
> @@ -911,16 +911,11 @@ static unsigned int img_i2c_auto(struct img_i2c *i2c,
>  		}
>  	} else {
>  		if (int_status & INT_FIFO_EMPTY_EMPTYING) {
> -			/*
> -			 * The write fifo empty indicates that we're in the
> -			 * last byte so it's safe to start a new write
> -			 * transaction without losing any bytes from the
> -			 * previous one.
> -			 * see 2.3.7 Repeated Start Transactions.
> -			 */
> -			if ((int_status & INT_FIFO_EMPTY) &&
> -			    i2c->msg.len == 0)
> -				return ISR_WAITSTOP;
> +			if (i2c->msg.len == 0) {
> +				if (i2c->last_msg)
> +					return ISR_WAITSTOP;
> +				return ISR_COMPLETE(0);
> +			}

Again, already happens in img_i2c_isr().

Cheers
James

>  			img_i2c_write_fifo(i2c);
>  		}
>  	}
>
Sifan Naeem July 29, 2015, 2:38 p.m. UTC | #2
Hi James,

> On 27/07/15 12:55, Sifan Naeem wrote:
> > We can mark the transfer as complete without waiting for the stop bit.
> > This is important when handling repeated start transfers as we have to
> > start the next transfer without the stop bit being issued.
> >
> > This doesn't affect the older versions of the IP.
> >
> > Signed-off-by: Sifan Naeem <sifan.naeem@imgtec.com>
> > ---
> >  drivers/i2c/busses/i2c-img-scb.c |   15 +++++----------
> >  1 file changed, 5 insertions(+), 10 deletions(-)
> >
> > diff --git a/drivers/i2c/busses/i2c-img-scb.c
> > b/drivers/i2c/busses/i2c-img-scb.c
> > index e27c3e0..efad4d7 100644
> > --- a/drivers/i2c/busses/i2c-img-scb.c
> > +++ b/drivers/i2c/busses/i2c-img-scb.c
> > @@ -911,16 +911,11 @@ static unsigned int img_i2c_auto(struct img_i2c
> *i2c,
> >  		}
> >  	} else {
> >  		if (int_status & INT_FIFO_EMPTY_EMPTYING) {
> > -			/*
> > -			 * The write fifo empty indicates that we're in the
> > -			 * last byte so it's safe to start a new write
> > -			 * transaction without losing any bytes from the
> > -			 * previous one.
> > -			 * see 2.3.7 Repeated Start Transactions.
> > -			 */
> > -			if ((int_status & INT_FIFO_EMPTY) &&
> > -			    i2c->msg.len == 0)
> > -				return ISR_WAITSTOP;
> > +			if (i2c->msg.len == 0) {
> > +				if (i2c->last_msg)
> > +					return ISR_WAITSTOP;
> > +				return ISR_COMPLETE(0);
> > +			}
> 
> Again, already happens in img_i2c_isr().
> 
Will drop this patch from v2.

Sifan
> Cheers
> James
> 
> >  			img_i2c_write_fifo(i2c);
> >  		}
> >  	}
> >

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/i2c/busses/i2c-img-scb.c b/drivers/i2c/busses/i2c-img-scb.c
index e27c3e0..efad4d7 100644
--- a/drivers/i2c/busses/i2c-img-scb.c
+++ b/drivers/i2c/busses/i2c-img-scb.c
@@ -911,16 +911,11 @@  static unsigned int img_i2c_auto(struct img_i2c *i2c,
 		}
 	} else {
 		if (int_status & INT_FIFO_EMPTY_EMPTYING) {
-			/*
-			 * The write fifo empty indicates that we're in the
-			 * last byte so it's safe to start a new write
-			 * transaction without losing any bytes from the
-			 * previous one.
-			 * see 2.3.7 Repeated Start Transactions.
-			 */
-			if ((int_status & INT_FIFO_EMPTY) &&
-			    i2c->msg.len == 0)
-				return ISR_WAITSTOP;
+			if (i2c->msg.len == 0) {
+				if (i2c->last_msg)
+					return ISR_WAITSTOP;
+				return ISR_COMPLETE(0);
+			}
 			img_i2c_write_fifo(i2c);
 		}
 	}