From patchwork Sat Feb 13 15:15:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Ricard X-Patchwork-Id: 8300041 Return-Path: X-Original-To: patchwork-tpmdd-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1A3729F6E4 for ; Sat, 13 Feb 2016 15:15:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 17DD82025B for ; Sat, 13 Feb 2016 15:15:52 +0000 (UTC) Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CC1E6203C4 for ; Sat, 13 Feb 2016 15:15:50 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-2.v29.ch3.sourceforge.com) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1aUbvJ-0000SC-BC; Sat, 13 Feb 2016 15:15:49 +0000 Received: from sog-mx-2.v43.ch3.sourceforge.com ([172.29.43.192] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1aUbvI-0000S0-8n for tpmdd-devel@lists.sourceforge.net; Sat, 13 Feb 2016 15:15:48 +0000 Received-SPF: pass (sog-mx-2.v43.ch3.sourceforge.com: domain of gmail.com designates 74.125.82.65 as permitted sender) client-ip=74.125.82.65; envelope-from=christophe.ricard@gmail.com; helo=mail-wm0-f65.google.com; Received: from mail-wm0-f65.google.com ([74.125.82.65]) by sog-mx-2.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1aUbvH-0006B0-AZ for tpmdd-devel@lists.sourceforge.net; Sat, 13 Feb 2016 15:15:48 +0000 Received: by mail-wm0-f65.google.com with SMTP id b205so467232wmb.1 for ; Sat, 13 Feb 2016 07:15:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8R3upXo96sonok8De36KLi45orw9o4C6co789uJx/q4=; b=UZzojwPxttzuAoRUYplC6agM2woqxsMSg3blrqF9rp8VfMTyXm7HLGeCGYl7og1y6E c+gYIUcUmYyhKbkoFEhLPtZSBH5q09jNT4RgKfQ3UW88i+66vnOs0Lrc6z8eo0WWrAND NJmAI1RMhN2SdmayQ2do62YjJ8PrwVWsiAYpdLrMQnl5yo0Im6yKVzLa9py3GQsqhyQj pP17b3NPx0DrwYuCk85eJlZhu2P8VEvHyyNjhwcGjkFbj/P8HEM7dQCyMcI1xVpubNYc eH+wv3TSi9O1yx3OOgvLcJgbkwcbXXZH9AEeOSgQRi2yjDY4uQJ64lN+B9bfPYjCeS0j jvGw== X-Gm-Message-State: AG10YOTwbjmfFiPncGRHEEmjH7Jgck8AsISpbA4KTD07JzCKXoh3O/3UO4WsTbpyBym7Rw== X-Received: by 10.28.21.19 with SMTP id 19mr3283211wmv.43.1455376541325; Sat, 13 Feb 2016 07:15:41 -0800 (PST) Received: from localhost.localdomain (AMarseille-654-1-450-135.w92-150.abo.wanadoo.fr. [92.150.10.135]) by smtp.gmail.com with ESMTPSA id v66sm7129466wmb.18.2016.02.13.07.15.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 13 Feb 2016 07:15:39 -0800 (PST) From: Christophe Ricard X-Google-Original-From: Christophe Ricard To: jarkko.sakkinen@linux.intel.com, peterhuewe@gmx.de Date: Sat, 13 Feb 2016 16:15:24 +0100 Message-Id: <1455376535-9549-2-git-send-email-christophe-h.ricard@st.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1455376535-9549-1-git-send-email-christophe-h.ricard@st.com> References: <1455376535-9549-1-git-send-email-christophe-h.ricard@st.com> X-Spam-Score: -1.6 (-) X-Headers-End: 1aUbvH-0006B0-AZ Cc: jean-luc.blanc@st.com, ashley@ashleylai.com, christophe.ricard@gmail.com, tpmdd-devel@lists.sourceforge.net, christophe-h.ricard@st.com, benoit.houyere@st.com Subject: [tpmdd-devel] [PATCH v2 01/12] tpm/st33zp24/spi: Remove nbr_dummy_bytes variable usage X-BeenThere: tpmdd-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Tpm Device Driver maintainance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: tpmdd-devel-bounces@lists.sourceforge.net X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,HK_RANDOM_ENVFROM,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP nbr_dummy_bytes variable could be easily replaced by phy->latency in st33zp24_spi_send and st33zp24_spi_recv. Reviewed-by: Jarkko Sakkinen Signed-off-by: Christophe Ricard --- drivers/char/tpm/st33zp24/spi.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/char/tpm/st33zp24/spi.c b/drivers/char/tpm/st33zp24/spi.c index f974c94..74c5fcc 100644 --- a/drivers/char/tpm/st33zp24/spi.c +++ b/drivers/char/tpm/st33zp24/spi.c @@ -111,7 +111,7 @@ static int st33zp24_spi_send(void *phy_id, u8 tpm_register, u8 *tpm_data, int tpm_size) { u8 data = 0; - int total_length = 0, nbr_dummy_bytes = 0, ret = 0; + int total_length = 0, ret = 0; struct st33zp24_spi_phy *phy = phy_id; struct spi_device *dev = phy->spi_device; u8 *tx_buf = (u8 *)phy->spi_xfer.tx_buf; @@ -133,14 +133,13 @@ static int st33zp24_spi_send(void *phy_id, u8 tpm_register, u8 *tpm_data, memcpy(&tx_buf[total_length], tpm_data, tpm_size); total_length += tpm_size; - nbr_dummy_bytes = phy->latency; - memset(&tx_buf[total_length], TPM_DUMMY_BYTE, nbr_dummy_bytes); + memset(&tx_buf[total_length], TPM_DUMMY_BYTE, phy->latency); - phy->spi_xfer.len = total_length + nbr_dummy_bytes; + phy->spi_xfer.len = total_length + phy->latency; ret = spi_sync_transfer(dev, &phy->spi_xfer, 1); if (ret == 0) - ret = rx_buf[total_length + nbr_dummy_bytes - 1]; + ret = rx_buf[total_length + phy->latency - 1]; return st33zp24_status_to_errno(ret); } /* st33zp24_spi_send() */ @@ -157,7 +156,7 @@ static int st33zp24_spi_send(void *phy_id, u8 tpm_register, u8 *tpm_data, static int read8_reg(void *phy_id, u8 tpm_register, u8 *tpm_data, int tpm_size) { u8 data = 0; - int total_length = 0, nbr_dummy_bytes, ret; + int total_length = 0, ret; struct st33zp24_spi_phy *phy = phy_id; struct spi_device *dev = phy->spi_device; u8 *tx_buf = (u8 *)phy->spi_xfer.tx_buf; @@ -171,18 +170,17 @@ static int read8_reg(void *phy_id, u8 tpm_register, u8 *tpm_data, int tpm_size) memcpy(tx_buf + total_length, &data, sizeof(data)); total_length++; - nbr_dummy_bytes = phy->latency; memset(&tx_buf[total_length], TPM_DUMMY_BYTE, - nbr_dummy_bytes + tpm_size); + phy->latency + tpm_size); - phy->spi_xfer.len = total_length + nbr_dummy_bytes + tpm_size; + phy->spi_xfer.len = total_length + phy->latency + tpm_size; /* header + status byte + size of the data + status byte */ ret = spi_sync_transfer(dev, &phy->spi_xfer, 1); if (tpm_size > 0 && ret == 0) { - ret = rx_buf[total_length + nbr_dummy_bytes - 1]; + ret = rx_buf[total_length + phy->latency - 1]; - memcpy(tpm_data, rx_buf + total_length + nbr_dummy_bytes, + memcpy(tpm_data, rx_buf + total_length + phy->latency, tpm_size); }