Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4292952pxk; Tue, 22 Sep 2020 15:56:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJ5jKGtUL5H+Y8Ek+AzU4SKKx0RZEP0/OpTtre4CC62XLZ99TNgA54Phr0VMfJmzUJ8jYV X-Received: by 2002:a50:fc08:: with SMTP id i8mr6636643edr.257.1600815364167; Tue, 22 Sep 2020 15:56:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600815364; cv=none; d=google.com; s=arc-20160816; b=qayJL5AFBZJtZdNvCqwb9/ugdDLfTyd30XjCT4RLsjmoxqHO7VZ7k7ULLBTW9Pg++A HSEh88YO4twCYP4AL2NohTvptT2GN7JhC0PAJCGojc/5gfuoV+ZC6pIWFA4uEzB3lILu 6wrE8dnj8QxQd1lHZjcfuamZxFw8H8m6NBwFOLd6tQhtHzsWg9vTRxlt46bEl0zM3COC 3/0bK6CFdox2Lbv6hUU5zbHZgzmIYDUcD5+auoOz3yFHKpUcRkNCRzyFz4IZfd2AbjXQ AGIGXRue4L7zfso03XjErYL2L1T1cR9K1W9N7vV/F4bVO5tQfivTPJDBvnKjetkGEDuf unYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9jKPC4Y8PGr72JzqJj/t+lHzExw3qoHFHLOgMaNhKTU=; b=iNFLdN53BV1lSUGM7rkQ5VCP7IDub/N3sC2MraVN7PJ4rIVT4501lVGa70kNs3azmE ESGc+LEA16Rjh9xU/ntuyu9evo3zhVoVHbuGQqYpIVsQpkPdJXFTc4ieCg30JdVz2BgD nt0QNinX7a7lUyN6rPXZZihga2mFHvqZtV/4Fa+yDGDE12ZVNEpZHHoJLNeGwyg7vyYR 9LklFe7ErSml3b+o2ZrTsWjl/wBTyEqRJQSFusCBIMMykz9y5/SY096LQZuDPuHx9xfx 61VYuyvUD1YkfQ4FE2DsAcLWPDr3YNi+ohtJH61f06tNWdf/LtzboZBi8bWBNQgRmQC9 OFWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=PwOBAhSP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f2si11125147ejc.542.2020.09.22.15.55.40; Tue, 22 Sep 2020 15:56:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=PwOBAhSP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727171AbgIVWxs (ORCPT + 99 others); Tue, 22 Sep 2020 18:53:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727012AbgIVWwv (ORCPT ); Tue, 22 Sep 2020 18:52:51 -0400 Received: from mail-lf1-x144.google.com (mail-lf1-x144.google.com [IPv6:2a00:1450:4864:20::144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29C84C0613D3; Tue, 22 Sep 2020 15:52:51 -0700 (PDT) Received: by mail-lf1-x144.google.com with SMTP id 77so12538265lfj.0; Tue, 22 Sep 2020 15:52:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9jKPC4Y8PGr72JzqJj/t+lHzExw3qoHFHLOgMaNhKTU=; b=PwOBAhSPQSxjvqbB94InL4uRztLMaVf7i7mJKEZ5U2wELq/W6eRIYHIZYUJashdwqs XONqwevjUAmTxABh6Ly9OR4147gQRKfitSIM5+SqzYH4KLiS5OWsqANUnbujnyGdglfM 4pwE50EornF+hOmEP63Qq7N3+lrc9p3+I6cCXiYPVbFEGRuaJCpNn69IkIDl0gRGxxbe B4ANWAGXDKkge/V6EElo5bfvmxMxXPqjASwh1zGZzywc4pT+e6J3f71BVoxw8sea5RD+ TVZY75QIb49nYqnVJzhiiDcsNkRlX9IJi7yLXAgAPiWSFOQ5Nj0tyqReFist/aPg1OQ8 dQpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9jKPC4Y8PGr72JzqJj/t+lHzExw3qoHFHLOgMaNhKTU=; b=ZxtIkQ5Ia835PdcIjYsu2lSHVGxDEpQ7eaduWKhb6Rvhkf3Coup89SLXSymFcYv8j7 oAZQq6sUfWD3yoAmmvIdWCM4tsXbkWkBuut8DYmVM7vIC5ayeCCOiZsSH+ttxKY0dFMl 6uw/N8tCT9zkIPtFE/ZlOHYKiFa7qxgY5MO2K6KGoh6tB65R/9vxUlS3YRckv679+Ss3 v7CtGqmnM9h0/rUurJmYZcyX/Ij9nyLuaF/JkD2arHHAfcQ8ugcBkfCJGDfjutjmDofq WoULHN/MrwHLrCLGnw5ec9hCjG7CKNG1SVkSzVNTh/4Us+h0qBrywF7Av9pMHFbNvHRb 6a1Q== X-Gm-Message-State: AOAM531X3cxtf0g3aovQA5ggII0D8RPsJL/DX9xZWbGrD/CNJC9sSAxN yWfx6Erf/C7U+UW8YBNNzSs= X-Received: by 2002:a19:546:: with SMTP id 67mr2155553lff.99.1600815169578; Tue, 22 Sep 2020 15:52:49 -0700 (PDT) Received: from localhost.localdomain (109-252-170-211.dynamic.spd-mgts.ru. [109.252.170.211]) by smtp.gmail.com with ESMTPSA id l15sm3977588lfk.71.2020.09.22.15.52.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Sep 2020 15:52:49 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Laxman Dewangan , Wolfram Sang , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Andy Shevchenko Cc: linux-i2c@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v8 20/32] i2c: tegra: Remove "dma" variable from tegra_i2c_xfer_msg() Date: Wed, 23 Sep 2020 01:51:43 +0300 Message-Id: <20200922225155.10798-21-digetx@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200922225155.10798-1-digetx@gmail.com> References: <20200922225155.10798-1-digetx@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The "dma" variable of tegra_i2c_xfer_msg() function doesn't bring much in regards to readability and generation of the code. Besides readability, it's also not very nice that the is_curr_dma_xfer is initialized in tegra_i2c_xfer_msg() and then could be overridden by tegra_i2c_config_fifo_trig(). In a result, the "dma" variable creates slight confusion since it's not instantly obvious why it's set after tegra_i2c_config_fifo_trig(). Hence should be better to have the variable removed. This makes code more consistent. Acked-by: Thierry Reding Tested-by: Thierry Reding Signed-off-by: Dmitry Osipenko --- drivers/i2c/busses/i2c-tegra.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index 79fa98423cae..eb62284e2293 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -1120,7 +1120,6 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev, size_t xfer_size; u32 *buffer = NULL; int err = 0; - bool dma; u16 xfer_time = 100; err = tegra_i2c_flush_fifos(i2c_dev); @@ -1143,7 +1142,7 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev, i2c_dev->dma_buf && !i2c_dev->is_curr_atomic_xfer; tegra_i2c_config_fifo_trig(i2c_dev, xfer_size); - dma = i2c_dev->is_curr_dma_xfer; + /* * Transfer time in mSec = Total bits / transfer rate * Total bits = 9 bits per byte (including ACK bit) + Start & stop bits @@ -1153,7 +1152,7 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev, int_mask = I2C_INT_NO_ACK | I2C_INT_ARBITRATION_LOST; tegra_i2c_unmask_irq(i2c_dev, int_mask); - if (dma) { + if (i2c_dev->is_curr_dma_xfer) { if (i2c_dev->msg_read) { dma_sync_single_for_device(i2c_dev->dev, i2c_dev->dma_phys, @@ -1181,13 +1180,13 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev, PACKET_HEADER0_PROTOCOL_I2C) | FIELD_PREP(PACKET_HEADER0_CONT_ID, i2c_dev->cont_id) | FIELD_PREP(PACKET_HEADER0_PACKET_ID, 1); - if (dma && !i2c_dev->msg_read) + if (i2c_dev->is_curr_dma_xfer && !i2c_dev->msg_read) *buffer++ = packet_header; else i2c_writel(i2c_dev, packet_header, I2C_TX_FIFO); packet_header = msg->len - 1; - if (dma && !i2c_dev->msg_read) + if (i2c_dev->is_curr_dma_xfer && !i2c_dev->msg_read) *buffer++ = packet_header; else i2c_writel(i2c_dev, packet_header, I2C_TX_FIFO); @@ -1207,13 +1206,13 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev, packet_header |= I2C_HEADER_CONT_ON_NAK; if (msg->flags & I2C_M_RD) packet_header |= I2C_HEADER_READ; - if (dma && !i2c_dev->msg_read) + if (i2c_dev->is_curr_dma_xfer && !i2c_dev->msg_read) *buffer++ = packet_header; else i2c_writel(i2c_dev, packet_header, I2C_TX_FIFO); if (!i2c_dev->msg_read) { - if (dma) { + if (i2c_dev->is_curr_dma_xfer) { memcpy(buffer, msg->buf, msg->len); dma_sync_single_for_device(i2c_dev->dev, i2c_dev->dma_phys, @@ -1233,7 +1232,7 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev, if (i2c_dev->hw->has_per_pkt_xfer_complete_irq) int_mask |= I2C_INT_PACKET_XFER_COMPLETE; - if (!dma) { + if (!i2c_dev->is_curr_dma_xfer) { if (msg->flags & I2C_M_RD) int_mask |= I2C_INT_RX_FIFO_DATA_REQ; else if (i2c_dev->msg_buf_remaining) @@ -1244,7 +1243,7 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev, dev_dbg(i2c_dev->dev, "unmasked irq: %02x\n", i2c_readl(i2c_dev, I2C_INT_MASK)); - if (dma) { + if (i2c_dev->is_curr_dma_xfer) { time_left = tegra_i2c_wait_completion_timeout( i2c_dev, &i2c_dev->dma_complete, xfer_time); -- 2.27.0