From patchwork Tue Feb 9 09:26:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Ricard X-Patchwork-Id: 8259051 Return-Path: X-Original-To: patchwork-tpmdd-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7F0B7BEEE5 for ; Tue, 9 Feb 2016 09:27:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 85EE620265 for ; Tue, 9 Feb 2016 09:27:22 +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 775E82022A for ; Tue, 9 Feb 2016 09:27:21 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-4.v29.ch3.sourceforge.com) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1aT4Zs-0004bA-0A; Tue, 09 Feb 2016 09:27:20 +0000 Received: from sog-mx-2.v43.ch3.sourceforge.com ([172.29.43.192] helo=mx.sourceforge.net) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1aT4Zq-0004az-M3 for tpmdd-devel@lists.sourceforge.net; Tue, 09 Feb 2016 09:27:18 +0000 Received-SPF: pass (sog-mx-2.v43.ch3.sourceforge.com: domain of gmail.com designates 74.125.82.66 as permitted sender) client-ip=74.125.82.66; envelope-from=christophe.ricard@gmail.com; helo=mail-wm0-f66.google.com; Received: from mail-wm0-f66.google.com ([74.125.82.66]) by sog-mx-2.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1aT4Zp-0003r0-TJ for tpmdd-devel@lists.sourceforge.net; Tue, 09 Feb 2016 09:27:18 +0000 Received: by mail-wm0-f66.google.com with SMTP id 128so2227418wmz.3 for ; Tue, 09 Feb 2016 01:27:17 -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=/cKjFaPoOBdqVbdZ9mwISZdlA/dZEL/VMXsDyWJsBa0=; b=YbaoOeVDR6XbKwBzoUdIHWYsazbzv4ePzTIPwu/GCG3TY+gqgX4lRBUQFOInhKgL2m pYiCFiasbC3gnQ4ycYAGYRe6l8jDhcx8hqksYdvOVnD99P3UqCbyTJu/1iIAFkDGkYF9 mE5NmhDDacmvTthVQC+DZ0IQqUKvPHOIYudNzq7Ngj6j25uFQNapfZpWiXWdnyjcm7oA IUadzRpWOvmpUGQi47lOZ+jYJDF88WmtQfZNcDhjBZ11YEnMTW5a1xHeVogkAY2xn1/3 XcFKgCFR4Jnh73ET1tb/30vhrIyL3pj27DB+IfmPk0KwKEuoA/tM2o/6yAJyvM6bG2g8 tORw== X-Gm-Message-State: AG10YOTmMbyp3uNMOgGdcpL5I+iQ/dQWXcudoWoD1Y/lpLiQ1fGrfenzPJOcYEzg0LLIMg== X-Received: by 10.194.240.66 with SMTP id vy2mr32740331wjc.28.1455010031902; Tue, 09 Feb 2016 01:27:11 -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 az10sm33793007wjc.28.2016.02.09.01.27.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 Feb 2016 01:27:10 -0800 (PST) From: Christophe Ricard X-Google-Original-From: Christophe Ricard To: jarkko.sakkinen@linux.intel.com, peterhuewe@gmx.de Date: Tue, 9 Feb 2016 10:26:52 +0100 Message-Id: <1455010021-21927-4-git-send-email-christophe-h.ricard@st.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1455010021-21927-1-git-send-email-christophe-h.ricard@st.com> References: <1455010021-21927-1-git-send-email-christophe-h.ricard@st.com> X-Spam-Score: -1.6 (-) X-Headers-End: 1aT4Zp-0003r0-TJ 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 03/12] tpm/st33zp24/spi: Remove useless use of memcpy. 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=-7.2 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 An affectation is enough when copying 1 byte. Remove memcpy usage where possible. Signed-off-by: Christophe Ricard Reviewed-by: Jarkko Sakkinen --- drivers/char/tpm/st33zp24/spi.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/drivers/char/tpm/st33zp24/spi.c b/drivers/char/tpm/st33zp24/spi.c index f42c443..08ffbfe 100644 --- a/drivers/char/tpm/st33zp24/spi.c +++ b/drivers/char/tpm/st33zp24/spi.c @@ -110,7 +110,6 @@ static int st33zp24_status_to_errno(u8 code) static int st33zp24_spi_send(void *phy_id, u8 tpm_register, u8 *tpm_data, int tpm_size) { - u8 data = 0; int total_length = 0, ret = 0; struct st33zp24_spi_phy *phy = phy_id; struct spi_device *dev = phy->spi_device; @@ -118,12 +117,8 @@ static int st33zp24_spi_send(void *phy_id, u8 tpm_register, u8 *tpm_data, u8 *rx_buf = phy->spi_xfer.rx_buf; /* Pre-Header */ - data = TPM_WRITE_DIRECTION | LOCALITY0; - memcpy(tx_buf + total_length, &data, sizeof(data)); - total_length++; - data = tpm_register; - memcpy(tx_buf + total_length, &data, sizeof(data)); - total_length++; + tx_buf[total_length++] = TPM_WRITE_DIRECTION | LOCALITY0; + tx_buf[total_length++] = tpm_register; if (tpm_size > 0 && tpm_register == TPM_DATA_FIFO) { tx_buf[total_length++] = tpm_size >> 8; @@ -156,7 +151,6 @@ static int st33zp24_spi_send(void *phy_id, u8 tpm_register, u8 *tpm_data, static int st33zp24_spi_read8_reg(void *phy_id, u8 tpm_register, u8 *tpm_data, int tpm_size) { - u8 data = 0; int total_length = 0, ret; struct st33zp24_spi_phy *phy = phy_id; struct spi_device *dev = phy->spi_device; @@ -164,12 +158,8 @@ static int st33zp24_spi_read8_reg(void *phy_id, u8 tpm_register, u8 *tpm_data, u8 *rx_buf = phy->spi_xfer.rx_buf; /* Pre-Header */ - data = LOCALITY0; - memcpy(tx_buf + total_length, &data, sizeof(data)); - total_length++; - data = tpm_register; - memcpy(tx_buf + total_length, &data, sizeof(data)); - total_length++; + tx_buf[total_length++] = LOCALITY0; + tx_buf[total_length++] = tpm_register; memset(&tx_buf[total_length], TPM_DUMMY_BYTE, phy->latency + tpm_size);