Received: by 10.223.176.5 with SMTP id f5csp337609wra; Sat, 3 Feb 2018 00:20:18 -0800 (PST) X-Google-Smtp-Source: AH8x227Y/8VLv4uCuTpCyimnS52HnHMxAe2tWLebENhTNAlYzGZ+AYP4omC0hAHRYyuMoandG2jo X-Received: by 10.98.194.212 with SMTP id w81mr41714257pfk.232.1517646017991; Sat, 03 Feb 2018 00:20:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517646017; cv=none; d=google.com; s=arc-20160816; b=zF9onwr0NiyTH1Pq7Z7P5VcxlMW8grx885qpFr9yqM4iWgNHt1oPtlZ8UBacB+0ztK n0fZL2fhAmBPxEQi9VnVQmJVMlOI/8K6CbJyDlG3X5fihtSUtFd3n+6X3jUcsHx33zWt fxycgZc0prej7RQ91Whu+/+w04NReSwo9N6h2pmvOZN/ST8lA4uD7kphP7nngq6IpPbw zHvgjVJXfTGJ3r6Sc4Ya1QIK+sdZZ7TrGeI8W3XFZsD2UNkxn/SA8U3NEyTIqwEX2BRz nLiQyS2fixopV6urqiFdpjt6Pe8JdpDj3SB4APK243vZNelf1295JpWmqQ0B4mIQuCSE OzSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=T7lb43el0u2nR4In7RYqQl55r+J6GkcbgdVJB9w9zgo=; b=pR2a51JL5T/L8OjevJWvkVv+sqgUhy/g8YyjXaZkmN9OqZFDFMgO9arqFaCh2sUkyK CpgeUMp2xsUivZbJFIM6cZH7yG3RxuophnkrPIFVlxBoE4+R6cTt9K2ofuOHZxf1LwdN vPIoXF+kOdc2uy7JEz9BZfo0NjQBjEhCt9QvyQqeZcZbhSZo6nBm2dJiLbKsJUmSoua/ zrEsCPFsYeaXo5OqJuTjYHw4nXP7es99GKxc+521X8t+lTiOfPjRQc515yN847H3o2Gf FtBYliilJ06M1OQlETWsHIi2wue2xkRGTVA1sxJ/WIE5Winc1SikViuAlNRq1BQWxAaS alJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=df6rJ8AU; dkim=pass header.i=@codeaurora.org header.s=default header.b=RgLwSmyT; 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 f3si2664601pgu.546.2018.02.03.00.20.03; Sat, 03 Feb 2018 00:20:17 -0800 (PST) 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; dkim=pass header.i=@codeaurora.org header.s=default header.b=df6rJ8AU; dkim=pass header.i=@codeaurora.org header.s=default header.b=RgLwSmyT; 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 S1752059AbeBCH7D (ORCPT + 99 others); Sat, 3 Feb 2018 02:59:03 -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= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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); -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation