From patchwork Sat Feb 3 07:58:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abhishek Sahu X-Patchwork-Id: 10198363 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DCAD5603ED for ; Sat, 3 Feb 2018 07:58:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D09A928F88 for ; Sat, 3 Feb 2018 07:58:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C564F28FCB; Sat, 3 Feb 2018 07:58:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 67B7F28F88 for ; Sat, 3 Feb 2018 07:58:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751980AbeBCH6y (ORCPT ); Sat, 3 Feb 2018 02:58:54 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:35336 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751624AbeBCH6h (ORCPT ); Sat, 3 Feb 2018 02:58:37 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id BC6366079C; Sat, 3 Feb 2018 07:58:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1517644716; bh=8Gz6GOXYmXqfVfibogAivXidi/JfMdDhuUkyIR7TRqo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=df6rJ8AULKs8ui8zhW3r+AXstxK7ruDqD2Z3LfqhQ3fDqIhYz91jZ41cwavgL0OCQ mQb0yR5YqiWCJhW5NN1Z3u/ALS8+YOV5Vt42H1l0F3RROZz2T8Ie8DAl4iAad9lF5R m154FjvaeVxW4eYg36Zhvw6iXnXjVvBvnkrJ9PUk= Received: from absahu-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: absahu@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 6A3B66079C; Sat, 3 Feb 2018 07:58:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1517644715; bh=8Gz6GOXYmXqfVfibogAivXidi/JfMdDhuUkyIR7TRqo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RgLwSmyTm3ogX+1cZqygHM4CGhwOl06fNgWyGv2rCb6Jtw9XIAmE72UIxqPNJuSt/ UPLcUEbeNnf1SvaLxTlLGj45Mzo8ufOTcK/A4xHN5mAY51FkPcDT4r7+FdTgUUUR+F 6wF0eLcPn/z5HqkZCJHZAlJXGXkza57lplVIieDU= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 6A3B66079C Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=absahu@codeaurora.org From: Abhishek Sahu To: Andy Gross , Wolfram Sang Cc: David Brown , Sricharan R , linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Abhishek Sahu Subject: [PATCH 02/12] i2c: qup: minor code reorganization for use_dma Date: Sat, 3 Feb 2018 13:28:07 +0530 Message-Id: <1517644697-30806-3-git-send-email-absahu@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1517644697-30806-1-git-send-email-absahu@codeaurora.org> References: <1517644697-30806-1-git-send-email-absahu@codeaurora.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 1. Assigns use_dma in qup_dev structure itself which will help in subsequent patches to determine the mode in IRQ handler. 2. Does minor code reorganization for loops to reduce the unnecessary comparison and assignment. Signed-off-by: Abhishek Sahu Reviewed-by: Austin Christ Reviewed-by: Andy Gross --- drivers/i2c/busses/i2c-qup.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/i2c/busses/i2c-qup.c b/drivers/i2c/busses/i2c-qup.c index 9faa26c41a..c68f433 100644 --- a/drivers/i2c/busses/i2c-qup.c +++ b/drivers/i2c/busses/i2c-qup.c @@ -190,6 +190,8 @@ struct qup_i2c_dev { /* dma parameters */ bool is_dma; + /* To check if the current transfer is using DMA */ + bool use_dma; struct dma_pool *dpool; struct qup_i2c_tag start_tag; struct qup_i2c_bam brx; @@ -1297,7 +1299,7 @@ static int qup_i2c_xfer_v2(struct i2c_adapter *adap, int num) { struct qup_i2c_dev *qup = i2c_get_adapdata(adap); - int ret, len, idx = 0, use_dma = 0; + int ret, len, idx = 0; qup->bus_err = 0; qup->qup_err = 0; @@ -1326,13 +1328,12 @@ static int qup_i2c_xfer_v2(struct i2c_adapter *adap, len = (msgs[idx].len > qup->out_fifo_sz) || (msgs[idx].len > qup->in_fifo_sz); - if ((!is_vmalloc_addr(msgs[idx].buf)) && len) { - use_dma = 1; - } else { - use_dma = 0; + if (is_vmalloc_addr(msgs[idx].buf) || !len) break; - } } + + if (idx == num) + qup->use_dma = true; } idx = 0; @@ -1356,15 +1357,17 @@ static int qup_i2c_xfer_v2(struct i2c_adapter *adap, reinit_completion(&qup->xfer); - if (use_dma) { + if (qup->use_dma) { ret = qup_i2c_bam_xfer(adap, &msgs[idx], num); + qup->use_dma = false; + break; } else { if (msgs[idx].flags & I2C_M_RD) ret = qup_i2c_read_one_v2(qup, &msgs[idx]); else ret = qup_i2c_write_one_v2(qup, &msgs[idx]); } - } while ((idx++ < (num - 1)) && !use_dma && !ret); + } while ((idx++ < (num - 1)) && !ret); if (!ret) ret = qup_i2c_change_state(qup, QUP_RESET_STATE);