lkml.org 
[lkml]   [2018]   [Apr]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] i2c: at91: Read all available bytes at once
From
Date
Hi Ludovic,

Am 25.04.2018 um 17:08 schrieb Ludovic Desroches:
> Hi David,
>
> On Wed, Apr 18, 2018 at 02:40:55PM +0200, David Engraf wrote:
>> With FIFO enabled it is possible to read multiple bytes
>> at once in the interrupt handler as long as RXRDY is
>> set. This may also reduce the number of interrupts.
>>
>> Signed-off-by: David Engraf <david.engraf@sysgo.com>
>> ---
>> drivers/i2c/busses/i2c-at91.c | 8 ++++++--
>> 1 file changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
>> index bfd1fdff64a9..d01c2b2384bd 100644
>> --- a/drivers/i2c/busses/i2c-at91.c
>> +++ b/drivers/i2c/busses/i2c-at91.c
>> @@ -518,8 +518,12 @@ static irqreturn_t atmel_twi_interrupt(int irq, void *dev_id)
>> * the RXRDY interrupt first in order to not keep garbage data in the
>> * Receive Holding Register for the next transfer.
>> */
>> - if (irqstatus & AT91_TWI_RXRDY)
>> - at91_twi_read_next_byte(dev);
>> + if (irqstatus & AT91_TWI_RXRDY) {
>> + /* read all available bytes at once when FIFO is used */
>> + do {
>> + at91_twi_read_next_byte(dev);
>> + } while (at91_twi_read(dev, AT91_TWI_SR) & AT91_TWI_RXRDY);
>
> You can avoid this check by using the RXFL field to know the number of
> data you can read. Did you try to use it? If yes, did you notice some issues?

I did a quick test by reading RXFL and it worked as well but I decided
to use the more readable solution by polling RXRDY. Also I don't need to
check if the FIFO has been enabled.

If you prefer using RXFL I can create a new patch.

Best regards
- David


> Regards
>
> Ludovic
>
>> + }
>>
>> /*
>> * When a NACK condition is detected, the I2C controller sets the NACK,
>> --
>> 2.14.1
>>

\
 
 \ /
  Last update: 2018-04-25 17:43    [W:0.076 / U:4.316 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site