From patchwork Fri Jun 29 11:05:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shubhrajyoti Datta X-Patchwork-Id: 1131521 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 55AC7DFF34 for ; Fri, 29 Jun 2012 11:06:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754188Ab2F2LGI (ORCPT ); Fri, 29 Jun 2012 07:06:08 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:51101 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752393Ab2F2LGH (ORCPT ); Fri, 29 Jun 2012 07:06:07 -0400 Received: from dbdp20.itg.ti.com ([172.24.170.38]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id q5TB5aTD000392; Fri, 29 Jun 2012 06:05:37 -0500 Received: from DBDE70.ent.ti.com (localhost [127.0.0.1]) by dbdp20.itg.ti.com (8.13.8/8.13.8) with ESMTP id q5TB5YZB009769; Fri, 29 Jun 2012 16:35:36 +0530 (IST) Received: from dbdp33.itg.ti.com (172.24.170.252) by dbde70.ent.ti.com (172.24.170.148) with Microsoft SMTP Server id 14.1.323.3; Fri, 29 Jun 2012 16:35:34 +0530 Received: from ula0393217.india.ti.com (smtpvbd.itg.ti.com [172.24.170.250]) by dbdp33.itg.ti.com (8.13.8/8.13.8) with ESMTP id q5TB5VHP001275; Fri, 29 Jun 2012 16:35:34 +0530 From: Shubhrajyoti D To: CC: , , , , , Felipe Balbi , Shubhrajyoti D Subject: [RFC PATCH 2/3] i2c: omap: implement handling for 'actual' bytes transferred Date: Fri, 29 Jun 2012 16:35:26 +0530 Message-ID: <1340967927-27354-3-git-send-email-shubhrajyoti@ti.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1340967927-27354-1-git-send-email-shubhrajyoti@ti.com> References: <1340967927-27354-1-git-send-email-shubhrajyoti@ti.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org From: Felipe Balbi this is important in cases where client driver wants to know how many bytes were actually transferred. Signed-off-by: Felipe Balbi Signed-off-by: Shubhrajyoti D --- drivers/i2c/busses/i2c-omap.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c index 266bba7..fc726a6 100644 --- a/drivers/i2c/busses/i2c-omap.c +++ b/drivers/i2c/busses/i2c-omap.c @@ -189,6 +189,7 @@ struct omap_i2c_dev { u8 *buf; u8 *regs; size_t buf_len; + u16 actual; struct i2c_adapter adapter; u8 threshold; u8 fifo_size; /* use as flag and value @@ -601,6 +602,7 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap, omap_i2c_init(dev); return -ETIMEDOUT; } + msg->actual = dev->actual; if (likely(!dev->cmd_err)) return 0; @@ -828,6 +830,7 @@ static void omap_i2c_receive_data(struct omap_i2c_dev *dev, u8 num_bytes, w = omap_i2c_read_reg(dev, OMAP_I2C_DATA_REG); *dev->buf++ = w; dev->buf_len--; + dev->actual++; /* * Data reg in 2430, omap3 and @@ -848,6 +851,7 @@ static int omap_i2c_transmit_data(struct omap_i2c_dev *dev, u8 num_bytes, while (num_bytes--) { w = *dev->buf++; dev->buf_len--; + dev->actual++; /* * Data reg in 2430, omap3 and @@ -908,6 +912,7 @@ omap_i2c_isr(int this_irq, void *dev_id) if (stat & OMAP_I2C_STAT_NACK) { err |= OMAP_I2C_STAT_NACK; + dev->actual--; omap_i2c_ack_stat(dev, OMAP_I2C_STAT_NACK); goto out; }