Received: by 10.213.65.68 with SMTP id h4csp47380imn; Mon, 12 Mar 2018 06:19:35 -0700 (PDT) X-Google-Smtp-Source: AG47ELt7FVfm7R17vcGWxq4D4u8UQ2RtEWiJ58zv089LXxwlqvvzMpqAh+cnTPEj7bToX6cJ2enw X-Received: by 10.98.82.144 with SMTP id g138mr7897597pfb.239.1520860775838; Mon, 12 Mar 2018 06:19:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520860775; cv=none; d=google.com; s=arc-20160816; b=E8D93wCZUINQU34DlkrDflD7jhgCWmoLReUqxnWlVrhNaYieN4DMjFst3BJqMs9qBV uIqpPuYCEW9Qjec6fwdjou8DFigcbtv9HNO2Xn+UY6sFoBcW/pqGwEX+3Mith3mwuHjE QBcXb3L+VClXjm4ymA6BfRazhuAx8EfwrvG8DxgTraOPQi6rbMAVm4IDDmgPVa5hW3rd XkBVLzcMjSVgUc0gcWXhS+rdUudeEUyHkpi8Z4vSBpTapvvzlAutNgc8iCvnPuoIDvn5 dsd5kehAiZrnsT+LLpTo04aHirJtOo3Eu4ARHXTR3zwu6Zz0q4emWTxe3IfDI95vPZfC jjPw== 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=YodcfzZ98LY+rjAAInR91ai9k+aF+W3PhDmKhv2WxK4=; b=LwOXm6HFdLIDEDjdCjFXxr/TPDYaRdUQF9LJSodBdOUlzPmeYkd2favN4Fo3oezPTm waujTsAoQR6B1IKPncRbTD8bjo4wJJ8H9vNRheQZR/tOZd/pA7IkH0lyApGzGTIObnd5 EO4aerYHh0ZjM0Ny+nIwDhNlXC3nQENKO/5U7dAZbKvoii//Cat5/PdkIfWZKlptBhpF JiPWurJfNZlmIe7AuMWwNbILDaPirzipWq0MJtqay0ZBBG3+9wWeThHCvD+h/gLh+sQd yvVRY8cdsQ6unJnsKPPAcABmFK9CV/57yIG/Ti1tT0GBGXy65pE3H/zxyD+G1TVS7Ciy Sk6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=Lg+NhF1k; dkim=pass header.i=@codeaurora.org header.s=default header.b=l0KPrlMg; 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 z14si4982360pge.393.2018.03.12.06.19.21; Mon, 12 Mar 2018 06:19:35 -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; dkim=pass header.i=@codeaurora.org header.s=default header.b=Lg+NhF1k; dkim=pass header.i=@codeaurora.org header.s=default header.b=l0KPrlMg; 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 S1751554AbeCLNPf (ORCPT + 99 others); Mon, 12 Mar 2018 09:15:35 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:41770 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751345AbeCLNPc (ORCPT ); Mon, 12 Mar 2018 09:15:32 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id C6CE0605FB; Mon, 12 Mar 2018 13:15:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1520860531; bh=2K04tnvNzNmU2PLgwGVp+wnxwqtGyoCBcXFe7VW/UHw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lg+NhF1k1Qae55l+GYxl+FD1J3aSHGQPCd5nsHXVHzwg7jKFIOWy9TcjCp7hRwByr fYEenGX9rDK0bcldRj7eOI0MhXvTYXqKJJ0zaJbnL+e75vOUhzgvzYJS6ZMxd+DiJJ ofp0dHOP6Bw+LgA1aOhKgbJ0jzyNaS08R/2kGEmg= 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 191E060807; Mon, 12 Mar 2018 13:15:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1520860530; bh=2K04tnvNzNmU2PLgwGVp+wnxwqtGyoCBcXFe7VW/UHw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l0KPrlMgH9gy/1/eE77UHq+LzXs0y+oDxu75RNbZ/yr+K5ocajPUcM9dNEngYN85f hKyp0qNqkQ6dL4+XEsGBZ8KpAXgPDWOemkiUJodoopUoCy7Qs70cYkI6nk85LOFp/V U6Vy2M8EMIDVNJm02aHaZOSyxW+Y5EhN2v3uAGBE= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 191E060807 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 , Austin Christ , 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 v2 04/13] i2c: qup: remove redundant variables for BAM SG count Date: Mon, 12 Mar 2018 18:44:53 +0530 Message-Id: <1520860502-14886-5-git-send-email-absahu@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1520860502-14886-1-git-send-email-absahu@codeaurora.org> References: <1520860502-14886-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 The rx_nents and tx_nents are redundant. rx_buf and tx_buf can be used for total number of SG entries. Since rx_buf and tx_buf give the impression that it is buffer instead of count so rename it to tx_cnt and rx_cnt for giving it more meaningful variable name. Signed-off-by: Abhishek Sahu Reviewed-by: Austin Christ Reviewed-by: Andy Gross --- * Changes from v1: 1. Changed rx_buf/tx_buf to tx_cnt/rx_cnt 2. Modified commit message for the same drivers/i2c/busses/i2c-qup.c | 42 ++++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/drivers/i2c/busses/i2c-qup.c b/drivers/i2c/busses/i2c-qup.c index f6ea074..d970458 100644 --- a/drivers/i2c/busses/i2c-qup.c +++ b/drivers/i2c/busses/i2c-qup.c @@ -683,8 +683,8 @@ static int qup_i2c_bam_do_xfer(struct qup_i2c_dev *qup, struct i2c_msg *msg, struct dma_async_tx_descriptor *txd, *rxd = NULL; int ret = 0, idx = 0, limit = QUP_READ_LIMIT; dma_cookie_t cookie_rx, cookie_tx; - u32 rx_nents = 0, tx_nents = 0, len, blocks, rem; - u32 i, tlen, tx_len, tx_buf = 0, rx_buf = 0, off = 0; + u32 len, blocks, rem; + u32 i, tlen, tx_len, tx_cnt = 0, rx_cnt = 0, off = 0; u8 *tags; while (idx < num) { @@ -698,9 +698,6 @@ static int qup_i2c_bam_do_xfer(struct qup_i2c_dev *qup, struct i2c_msg *msg, rem = msg->len - (blocks - 1) * limit; if (msg->flags & I2C_M_RD) { - rx_nents += (blocks * 2) + 1; - tx_nents += 1; - while (qup->blk.pos < blocks) { tlen = (i == (blocks - 1)) ? rem : limit; tags = &qup->start_tag.start[off + len]; @@ -708,14 +705,14 @@ static int qup_i2c_bam_do_xfer(struct qup_i2c_dev *qup, struct i2c_msg *msg, qup->blk.data_len -= tlen; /* scratch buf to read the start and len tags */ - ret = qup_sg_set_buf(&qup->brx.sg[rx_buf++], + ret = qup_sg_set_buf(&qup->brx.sg[rx_cnt++], &qup->brx.tag.start[0], 2, qup, DMA_FROM_DEVICE); if (ret) return ret; - ret = qup_sg_set_buf(&qup->brx.sg[rx_buf++], + ret = qup_sg_set_buf(&qup->brx.sg[rx_cnt++], &msg->buf[limit * i], tlen, qup, DMA_FROM_DEVICE); @@ -725,7 +722,7 @@ static int qup_i2c_bam_do_xfer(struct qup_i2c_dev *qup, struct i2c_msg *msg, i++; qup->blk.pos = i; } - ret = qup_sg_set_buf(&qup->btx.sg[tx_buf++], + ret = qup_sg_set_buf(&qup->btx.sg[tx_cnt++], &qup->start_tag.start[off], len, qup, DMA_TO_DEVICE); if (ret) @@ -733,28 +730,26 @@ static int qup_i2c_bam_do_xfer(struct qup_i2c_dev *qup, struct i2c_msg *msg, off += len; /* scratch buf to read the BAM EOT and FLUSH tags */ - ret = qup_sg_set_buf(&qup->brx.sg[rx_buf++], + ret = qup_sg_set_buf(&qup->brx.sg[rx_cnt++], &qup->brx.tag.start[0], 2, qup, DMA_FROM_DEVICE); if (ret) return ret; } else { - tx_nents += (blocks * 2); - while (qup->blk.pos < blocks) { tlen = (i == (blocks - 1)) ? rem : limit; tags = &qup->start_tag.start[off + tx_len]; len = qup_i2c_set_tags(tags, qup, msg, 1); qup->blk.data_len -= tlen; - ret = qup_sg_set_buf(&qup->btx.sg[tx_buf++], + ret = qup_sg_set_buf(&qup->btx.sg[tx_cnt++], tags, len, qup, DMA_TO_DEVICE); if (ret) return ret; tx_len += len; - ret = qup_sg_set_buf(&qup->btx.sg[tx_buf++], + ret = qup_sg_set_buf(&qup->btx.sg[tx_cnt++], &msg->buf[limit * i], tlen, qup, DMA_TO_DEVICE); if (ret) @@ -766,26 +761,25 @@ static int qup_i2c_bam_do_xfer(struct qup_i2c_dev *qup, struct i2c_msg *msg, if (idx == (num - 1)) { len = 1; - if (rx_nents) { + if (rx_cnt) { qup->btx.tag.start[0] = QUP_BAM_INPUT_EOT; len++; } qup->btx.tag.start[len - 1] = QUP_BAM_FLUSH_STOP; - ret = qup_sg_set_buf(&qup->btx.sg[tx_buf++], + ret = qup_sg_set_buf(&qup->btx.sg[tx_cnt++], &qup->btx.tag.start[0], len, qup, DMA_TO_DEVICE); if (ret) return ret; - tx_nents += 1; } } idx++; msg++; } - txd = dmaengine_prep_slave_sg(qup->btx.dma, qup->btx.sg, tx_nents, + txd = dmaengine_prep_slave_sg(qup->btx.dma, qup->btx.sg, tx_cnt, DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT | DMA_PREP_FENCE); if (!txd) { @@ -794,7 +788,7 @@ static int qup_i2c_bam_do_xfer(struct qup_i2c_dev *qup, struct i2c_msg *msg, goto desc_err; } - if (!rx_nents) { + if (!rx_cnt) { txd->callback = qup_i2c_bam_cb; txd->callback_param = qup; } @@ -807,9 +801,9 @@ static int qup_i2c_bam_do_xfer(struct qup_i2c_dev *qup, struct i2c_msg *msg, dma_async_issue_pending(qup->btx.dma); - if (rx_nents) { + if (rx_cnt) { rxd = dmaengine_prep_slave_sg(qup->brx.dma, qup->brx.sg, - rx_nents, DMA_DEV_TO_MEM, + rx_cnt, DMA_DEV_TO_MEM, DMA_PREP_INTERRUPT); if (!rxd) { dev_err(qup->dev, "failed to get rx desc\n"); @@ -844,7 +838,7 @@ static int qup_i2c_bam_do_xfer(struct qup_i2c_dev *qup, struct i2c_msg *msg, goto desc_err; } - if (rx_nents) + if (rx_cnt) writel(QUP_BAM_INPUT_EOT, qup->base + QUP_OUT_FIFO_BASE); @@ -862,10 +856,10 @@ static int qup_i2c_bam_do_xfer(struct qup_i2c_dev *qup, struct i2c_msg *msg, } desc_err: - dma_unmap_sg(qup->dev, qup->btx.sg, tx_nents, DMA_TO_DEVICE); + dma_unmap_sg(qup->dev, qup->btx.sg, tx_cnt, DMA_TO_DEVICE); - if (rx_nents) - dma_unmap_sg(qup->dev, qup->brx.sg, rx_nents, + if (rx_cnt) + dma_unmap_sg(qup->dev, qup->brx.sg, rx_cnt, DMA_FROM_DEVICE); return ret; -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation