From patchwork Tue Feb 23 21:25:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Ricard X-Patchwork-Id: 587092 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 ozlabs.org (Postfix) with ESMTPS id D4933140775 for ; Wed, 24 Feb 2016 08:26:17 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=sfs-ml-1.v29.ch3.sourceforge.com) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1aYKTE-0007OT-QF; Tue, 23 Feb 2016 21:26:12 +0000 Received: from sog-mx-2.v43.ch3.sourceforge.com ([172.29.43.192] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1aYKTD-0007OJ-OG for tpmdd-devel@lists.sourceforge.net; Tue, 23 Feb 2016 21:26:11 +0000 Received-SPF: pass (sog-mx-2.v43.ch3.sourceforge.com: domain of gmail.com designates 74.125.82.43 as permitted sender) client-ip=74.125.82.43; envelope-from=christophe.ricard@gmail.com; helo=mail-wm0-f43.google.com; Received: from mail-wm0-f43.google.com ([74.125.82.43]) by sog-mx-2.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1aYKTC-00051y-Ms for tpmdd-devel@lists.sourceforge.net; Tue, 23 Feb 2016 21:26:11 +0000 Received: by mail-wm0-f43.google.com with SMTP id g62so243165541wme.1 for ; Tue, 23 Feb 2016 13:26:10 -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=A4qcHewiEZKpqR1CxHG6W5rS8MLL4ek9fiWfL+Ihv9k=; b=YXPBR2CAf73qFItU/WrQg/hOrS7ZFVa3+d6MEYuJ4vMRzZqa4HsMKS72tauIKo9DcI OYtUlPVqXIcln4KsAThFPcQDz8OUhhDtXurxOJHe1AbDNoxhhL0pkW3J5YUiq3ZqHN8P TAi/u+Gi1jcmlIaNNSi7JlPGh6Vg8YfZn0OZBIgTTB5BvatxaAs8HNBlKIPAFpwoRi/z /wrv8N7I36G2JK6smYga28cLDCXUzwz606ljm0REOQ3Cw6Mj4/fbu57HfvIb3LpEoRZI ZA8nYd/QxNr7SwgOiIcxgPJBYMJnB9rm7wFFD+GFU+fTGjXk1HDGtewAAd1p2sBWC63a HxEA== X-Gm-Message-State: AG10YORTeMT/GLjwqOTFX1Iq+iYdW6cBMO+eR4Rc5EWtDJDR6cNlZCJJwyEN5xzFtoMBaQ== X-Received: by 10.194.94.40 with SMTP id cz8mr35681095wjb.17.1456262764715; Tue, 23 Feb 2016 13:26:04 -0800 (PST) Received: from localhost.localdomain (ax113-6-78-236-204-66.fbx.proxad.net. [78.236.204.66]) by smtp.gmail.com with ESMTPSA id v1sm31448264wjf.49.2016.02.23.13.26.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 23 Feb 2016 13:26:03 -0800 (PST) From: Christophe Ricard X-Google-Original-From: Christophe Ricard To: jarkko.sakkinen@linux.intel.com, peterhuewe@gmx.de Date: Tue, 23 Feb 2016 22:25:43 +0100 Message-Id: <1456262751-12096-5-git-send-email-christophe-h.ricard@st.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1456262751-12096-1-git-send-email-christophe-h.ricard@st.com> References: <1456262751-12096-1-git-send-email-christophe-h.ricard@st.com> X-Spam-Score: -1.6 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (christophe.ricard[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-Headers-End: 1aYKTC-00051y-Ms 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 v3 04/12] tpm/st33zp24/spi: Remove field spi_xfer from st33zp24_spi_phy structure 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 Remove spi_xfer from st33zp24_spi_phy structure and declare local spi_xfer when needed instead. Reviewed-by: Jarkko Sakkinen Signed-off-by: Christophe Ricard --- drivers/char/tpm/st33zp24/spi.c | 49 +++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/drivers/char/tpm/st33zp24/spi.c b/drivers/char/tpm/st33zp24/spi.c index 08ffbfe..f851053 100644 --- a/drivers/char/tpm/st33zp24/spi.c +++ b/drivers/char/tpm/st33zp24/spi.c @@ -66,7 +66,7 @@ struct st33zp24_spi_phy { struct spi_device *spi_device; - struct spi_transfer spi_xfer; + u8 tx_buf[ST33ZP24_SPI_BUFFER_SIZE]; u8 rx_buf[ST33ZP24_SPI_BUFFER_SIZE]; @@ -113,28 +113,30 @@ static int st33zp24_spi_send(void *phy_id, u8 tpm_register, u8 *tpm_data, 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; - u8 *rx_buf = phy->spi_xfer.rx_buf; + struct spi_transfer spi_xfer = { + .tx_buf = phy->tx_buf, + .rx_buf = phy->rx_buf, + }; /* Pre-Header */ - tx_buf[total_length++] = TPM_WRITE_DIRECTION | LOCALITY0; - tx_buf[total_length++] = tpm_register; + phy->tx_buf[total_length++] = TPM_WRITE_DIRECTION | LOCALITY0; + phy->tx_buf[total_length++] = tpm_register; if (tpm_size > 0 && tpm_register == TPM_DATA_FIFO) { - tx_buf[total_length++] = tpm_size >> 8; - tx_buf[total_length++] = tpm_size; + phy->tx_buf[total_length++] = tpm_size >> 8; + phy->tx_buf[total_length++] = tpm_size; } - memcpy(&tx_buf[total_length], tpm_data, tpm_size); + memcpy(&phy->tx_buf[total_length], tpm_data, tpm_size); total_length += tpm_size; - memset(&tx_buf[total_length], TPM_DUMMY_BYTE, phy->latency); + memset(&phy->tx_buf[total_length], TPM_DUMMY_BYTE, phy->latency); - phy->spi_xfer.len = total_length + phy->latency; + spi_xfer.len = total_length + phy->latency; - ret = spi_sync_transfer(dev, &phy->spi_xfer, 1); + ret = spi_sync_transfer(dev, &spi_xfer, 1); if (ret == 0) - ret = rx_buf[total_length + phy->latency - 1]; + ret = phy->rx_buf[total_length + phy->latency - 1]; return st33zp24_status_to_errno(ret); } /* st33zp24_spi_send() */ @@ -154,24 +156,26 @@ static int st33zp24_spi_read8_reg(void *phy_id, u8 tpm_register, u8 *tpm_data, 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; - u8 *rx_buf = phy->spi_xfer.rx_buf; + struct spi_transfer spi_xfer = { + .tx_buf = phy->tx_buf, + .rx_buf = phy->rx_buf, + }; /* Pre-Header */ - tx_buf[total_length++] = LOCALITY0; - tx_buf[total_length++] = tpm_register; + phy->tx_buf[total_length++] = LOCALITY0; + phy->tx_buf[total_length++] = tpm_register; - memset(&tx_buf[total_length], TPM_DUMMY_BYTE, + memset(&phy->tx_buf[total_length], TPM_DUMMY_BYTE, phy->latency + tpm_size); - phy->spi_xfer.len = total_length + phy->latency + tpm_size; + 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); + ret = spi_sync_transfer(dev, &spi_xfer, 1); if (tpm_size > 0 && ret == 0) { - ret = rx_buf[total_length + phy->latency - 1]; + ret = phy->rx_buf[total_length + phy->latency - 1]; - memcpy(tpm_data, rx_buf + total_length + phy->latency, + memcpy(tpm_data, phy->rx_buf + total_length + phy->latency, tpm_size); } @@ -328,9 +332,6 @@ static int st33zp24_spi_probe(struct spi_device *dev) return ret; } - phy->spi_xfer.tx_buf = phy->tx_buf; - phy->spi_xfer.rx_buf = phy->rx_buf; - phy->latency = st33zp24_spi_evaluate_latency(phy); if (phy->latency <= 0) return -ENODEV;