Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp138332yba; Wed, 8 May 2019 17:56:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqxRgvaT0FxvFPxGNC5OM9R0jKzzg2czhhYtFhSDz2CCfvaDH4fT7oQ3fgs5joumI0rvwnDN X-Received: by 2002:a17:902:567:: with SMTP id 94mr1194816plf.120.1557363375554; Wed, 08 May 2019 17:56:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557363375; cv=none; d=google.com; s=arc-20160816; b=Y4lepmp8pEW1Ki2TRl0hwNun1jKkHgUQwiKEfdoPomW554Gifc7j+Y2D7WdTQiM3rb /R3e70K3jIS38qBrqRbYETH3AXYsFAvWD/ibDJwY3Jk6ISxl1YDNDanxRsfQEgMUZ9JX aiUkPbYKPVhdxlJAeMLi1BCKJNpy6DzgCxYn3m0jvcLk8rmI5TvElh08UwQem/gTtPmd Si7KTM/LpzYptycfkO+7dNOlsQcg8Vd1b9SgOlvY/nEEKce0ePqxAoKuyY9C2lkuC//9 FqIXN3moRL8Giz1qtclYSltgsMcNvSKS1vAiQXuBYtrKAwJLaMGJztbvqG0wMBfP6zW/ hpsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=D0UuoBi8V/iTgwNbtAhTSNVY+GRsu9g8Yk9Ddb7ICyY=; b=QcXE5RHcXeFxALIkfv+UT3IW7wyFHpVQ+f6dIUEu/Z5UWGlz+1QahwbhMwW4NIdmHh Jwf82J26DazPnEKSSQlOnsE5vPJSWX/oTWpjQFPx9mlNZPVcSGnOqGoOcJfy7Srg9u0A Jv5n4TLEL3dqnvQdOXOpjPHbcvlabqEAI/L9V1ScJOBNuVYhySAi7K1L25Zk5uL5mpW4 IiswQgZ17/vFGObT4rTjbV+mreZLgU6deSIh84tr3AUTGcTQtTGp1+52/IwKUHJuBj2x WWvI3hlWxTe/Q9JcqdKQt0nAui1x4nd5P8qsFmqPoQXZxp/fiG7eWhDAdobpIDtm2Da8 RhQA== ARC-Authentication-Results: i=1; mx.google.com; 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 e25si533863pfi.123.2019.05.08.17.55.59; Wed, 08 May 2019 17:56:15 -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; 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 S1726251AbfEIAzJ (ORCPT + 99 others); Wed, 8 May 2019 20:55:09 -0400 Received: from www.osadl.org ([62.245.132.105]:59629 "EHLO www.osadl.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725778AbfEIAzJ (ORCPT ); Wed, 8 May 2019 20:55:09 -0400 Received: from debian01.hofrr.at (178.115.242.59.static.drei.at [178.115.242.59]) by www.osadl.org (8.13.8/8.13.8/OSADL-2007092901) with ESMTP id x490sgfS028444; Thu, 9 May 2019 02:54:43 +0200 From: Nicholas Mc Guire To: Laxman Dewangan Cc: Thierry Reding , Jonathan Hunter , linux-i2c@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, Nicholas Mc Guire Subject: [PATCH] i2c: tegra: use busendiannes variable Date: Thu, 9 May 2019 02:48:57 +0200 Message-Id: <1557362937-6591-1-git-send-email-hofrat@osadl.org> X-Mailer: git-send-email 2.1.4 X-Spam-Status: No, score=-4.2 required=6.0 tests=BAYES_00,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on www.osadl.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Converting from bus to host endiannes was done using the same variable which makes sparse unhappy as it can not verify the endiannes handling properly. To allow sparse to verify endiannes handling a __le32 is introduced. This patch does not actually change the code logic while the binary does change due to limit on instruction re-ordering induced by the additional constraint. Signed-off-by: Nicholas Mc Guire --- Problem located by an experimental coccinelle script to locate patters that make sparse unhappy (false positives): sparse was complaining about: drivers/i2c/busses/i2c-tegra.c:596:23: warning: cast to restricted __le32 Note that the binary does change in this case - from inspection of the .lst files it seems that the introduction of the __le32 limits the re-ordering options for the compiler so one instruction position changed (ldr r1, [sp, #4]) but from my understanding that does not change the program logic here. Patch was compile-tested with: tegra_defconfig (implies I2C_TEGRA=y) Patch is against 5.1 (localversion-next is next-20190508) drivers/i2c/busses/i2c-tegra.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index ebaa78d..cbaddcc 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c @@ -543,18 +543,19 @@ static int tegra_i2c_empty_rx_fifo(struct tegra_i2c_dev *i2c_dev) static int tegra_i2c_fill_tx_fifo(struct tegra_i2c_dev *i2c_dev) { u32 val; + __le32 busval; int tx_fifo_avail; u8 *buf = i2c_dev->msg_buf; size_t buf_remaining = i2c_dev->msg_buf_remaining; int words_to_transfer; if (i2c_dev->hw->has_mst_fifo) { - val = i2c_readl(i2c_dev, I2C_MST_FIFO_STATUS); - tx_fifo_avail = (val & I2C_MST_FIFO_STATUS_TX_MASK) >> + busval = i2c_readl(i2c_dev, I2C_MST_FIFO_STATUS); + tx_fifo_avail = (busval & I2C_MST_FIFO_STATUS_TX_MASK) >> I2C_MST_FIFO_STATUS_TX_SHIFT; } else { - val = i2c_readl(i2c_dev, I2C_FIFO_STATUS); - tx_fifo_avail = (val & I2C_FIFO_STATUS_TX_MASK) >> + busval = i2c_readl(i2c_dev, I2C_FIFO_STATUS); + tx_fifo_avail = (busval & I2C_FIFO_STATUS_TX_MASK) >> I2C_FIFO_STATUS_TX_SHIFT; } @@ -592,8 +593,8 @@ static int tegra_i2c_fill_tx_fifo(struct tegra_i2c_dev *i2c_dev) */ if (tx_fifo_avail > 0 && buf_remaining > 0) { BUG_ON(buf_remaining > 3); - memcpy(&val, buf, buf_remaining); - val = le32_to_cpu(val); + memcpy(&busval, buf, buf_remaining); + val = le32_to_cpu(busval); /* Again update before writing to FIFO to make sure isr sees. */ i2c_dev->msg_buf_remaining = 0; -- 2.1.4