Received: by 10.192.165.156 with SMTP id m28csp1193316imm; Wed, 18 Apr 2018 05:51:49 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+F13tWy1c+8lxfZPeUVf/MxVMjammqhvqxYyBL92naTOZihED9+IWFgxsbQjEmMfJ5xDXn X-Received: by 2002:a17:902:60cd:: with SMTP id k13-v6mr1958353pln.44.1524055909238; Wed, 18 Apr 2018 05:51:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524055909; cv=none; d=google.com; s=arc-20160816; b=ry6Z/WUCshfxVAkiheB9gtw8ViFgBRJbp5TB16ixAfVcVpmCQzeb2OkM114YYgcMO5 9lDXXLnnnVi5dcMDavh4PiyLUc8uIzjFOxd8lqKMFZmKDHeAsVaGXMmRY1eir7qzEPy4 EXmjTaj2rExe+zTx6z7in3betZ4WMwkpHeuRjuootk5P3rC6Od3Oaf7mGOKBGx2h1WQg QHg1iymK/+Mjp2b4d6MPDqvQqvdtdvID2bFdzHW5gWlhKuPDIwhUdgnA3IqqUwYgkdjp nSjwusnR2EeOGBfgwm2CtDR0wAQfVd9CboOLnlZ2gd0tgjuXJ9IDavnBkpmw3NAieTSe ig2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=yfmwco3ptdIHDI3SeR2gzzveR+WJSFLskJluUZ0NRs0=; b=lLJIXjiM7gWWrOePMMwNqWeeLpcSJ5/Ma1un3o5f+qvmgGTcUpACcG0IlhijGVov/Y CeKvCTRzqBkKAS6DwpgHI3VwefZByVLjZyxycBBfa7fKWrrDvQvJbvC6D8PWIcxqwBut B2fgimr8JBlG1xgV6kTrYQ/Ndq2K+h3wcxyH/ofRej1g46sN0h+YlDAJikxy7MhfPO5d cci0/bv7EVRbndHmD6bM++YTRhCtOmbzeNNxHMdhP+VA4UCmMm32QywR6Nzik2Qcg2s1 uK1HVodm85+Bx4KHBC35l3Y/jq3nO1JtrVzh16Cy4nO/oKZWRFchj+NQ1ME3cC+/k1G5 EaFg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d8si1045560pgt.630.2018.04.18.05.51.35; Wed, 18 Apr 2018 05:51:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753943AbeDRMu0 (ORCPT + 99 others); Wed, 18 Apr 2018 08:50:26 -0400 Received: from mail.sysgo.com ([176.9.12.79]:50860 "EHLO mail.sysgo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753902AbeDRMuY (ORCPT ); Wed, 18 Apr 2018 08:50:24 -0400 X-Greylist: delayed 520 seconds by postgrey-1.27 at vger.kernel.org; Wed, 18 Apr 2018 08:50:23 EDT From: David Engraf To: ludovic.desroches@microchip.com, nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com Cc: linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, David Engraf Subject: [PATCH] i2c: at91: Read all available bytes at once Date: Wed, 18 Apr 2018 14:40:55 +0200 Message-Id: <20180418124055.21333-1-david.engraf@sysgo.com> X-Mailer: git-send-email 2.14.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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); + } /* * When a NACK condition is detected, the I2C controller sets the NACK, -- 2.14.1