diff mbox

[03/12] tpm/st33zp24/spi: Remove useless use of memcpy.

Message ID 1455010021-21927-4-git-send-email-christophe-h.ricard@st.com (mailing list archive)
State New, archived
Headers show

Commit Message

Christophe Ricard Feb. 9, 2016, 9:26 a.m. UTC
An affectation is enough when copying 1 byte. Remove memcpy usage where
possible.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
---
 drivers/char/tpm/st33zp24/spi.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

Comments

Jarkko Sakkinen Feb. 11, 2016, 1:54 p.m. UTC | #1
On Tue, Feb 09, 2016 at 10:26:52AM +0100, Christophe Ricard wrote:
> An affectation is enough when copying 1 byte. Remove memcpy usage where
> possible.
> 
> Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>

Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>

/Jarkko

> ---
>  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);
> -- 
> 2.5.0
> 

------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
diff mbox

Patch

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);