diff options
author | Christophe RICARD <christophe.ricard@gmail.com> | 2016-02-13 10:15:24 -0500 |
---|---|---|
committer | Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> | 2016-06-25 10:21:42 -0400 |
commit | 9feaab5dd27c5caf13368055ced9d58a8302ff21 (patch) | |
tree | 24debf28740ef637d99fafe0f143d8b24e1d3338 /drivers/char | |
parent | 26703c636c1f3272b39bd0f6d04d2e970984f1b6 (diff) |
tpm/st33zp24/spi: Remove nbr_dummy_bytes variable usage
nbr_dummy_bytes variable could be easily replaced by phy->latency in
st33zp24_spi_send and st33zp24_spi_recv.
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/tpm/st33zp24/spi.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/drivers/char/tpm/st33zp24/spi.c b/drivers/char/tpm/st33zp24/spi.c index f974c945c97a..74c5fcc5c397 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, | |||
111 | int tpm_size) | 111 | int tpm_size) |
112 | { | 112 | { |
113 | u8 data = 0; | 113 | u8 data = 0; |
114 | int total_length = 0, nbr_dummy_bytes = 0, ret = 0; | 114 | int total_length = 0, ret = 0; |
115 | struct st33zp24_spi_phy *phy = phy_id; | 115 | struct st33zp24_spi_phy *phy = phy_id; |
116 | struct spi_device *dev = phy->spi_device; | 116 | struct spi_device *dev = phy->spi_device; |
117 | u8 *tx_buf = (u8 *)phy->spi_xfer.tx_buf; | 117 | 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, | |||
133 | memcpy(&tx_buf[total_length], tpm_data, tpm_size); | 133 | memcpy(&tx_buf[total_length], tpm_data, tpm_size); |
134 | total_length += tpm_size; | 134 | total_length += tpm_size; |
135 | 135 | ||
136 | nbr_dummy_bytes = phy->latency; | 136 | memset(&tx_buf[total_length], TPM_DUMMY_BYTE, phy->latency); |
137 | memset(&tx_buf[total_length], TPM_DUMMY_BYTE, nbr_dummy_bytes); | ||
138 | 137 | ||
139 | phy->spi_xfer.len = total_length + nbr_dummy_bytes; | 138 | phy->spi_xfer.len = total_length + phy->latency; |
140 | 139 | ||
141 | ret = spi_sync_transfer(dev, &phy->spi_xfer, 1); | 140 | ret = spi_sync_transfer(dev, &phy->spi_xfer, 1); |
142 | if (ret == 0) | 141 | if (ret == 0) |
143 | ret = rx_buf[total_length + nbr_dummy_bytes - 1]; | 142 | ret = rx_buf[total_length + phy->latency - 1]; |
144 | 143 | ||
145 | return st33zp24_status_to_errno(ret); | 144 | return st33zp24_status_to_errno(ret); |
146 | } /* st33zp24_spi_send() */ | 145 | } /* st33zp24_spi_send() */ |
@@ -157,7 +156,7 @@ static int st33zp24_spi_send(void *phy_id, u8 tpm_register, u8 *tpm_data, | |||
157 | static int read8_reg(void *phy_id, u8 tpm_register, u8 *tpm_data, int tpm_size) | 156 | static int read8_reg(void *phy_id, u8 tpm_register, u8 *tpm_data, int tpm_size) |
158 | { | 157 | { |
159 | u8 data = 0; | 158 | u8 data = 0; |
160 | int total_length = 0, nbr_dummy_bytes, ret; | 159 | int total_length = 0, ret; |
161 | struct st33zp24_spi_phy *phy = phy_id; | 160 | struct st33zp24_spi_phy *phy = phy_id; |
162 | struct spi_device *dev = phy->spi_device; | 161 | struct spi_device *dev = phy->spi_device; |
163 | u8 *tx_buf = (u8 *)phy->spi_xfer.tx_buf; | 162 | 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) | |||
171 | memcpy(tx_buf + total_length, &data, sizeof(data)); | 170 | memcpy(tx_buf + total_length, &data, sizeof(data)); |
172 | total_length++; | 171 | total_length++; |
173 | 172 | ||
174 | nbr_dummy_bytes = phy->latency; | ||
175 | memset(&tx_buf[total_length], TPM_DUMMY_BYTE, | 173 | memset(&tx_buf[total_length], TPM_DUMMY_BYTE, |
176 | nbr_dummy_bytes + tpm_size); | 174 | phy->latency + tpm_size); |
177 | 175 | ||
178 | phy->spi_xfer.len = total_length + nbr_dummy_bytes + tpm_size; | 176 | phy->spi_xfer.len = total_length + phy->latency + tpm_size; |
179 | 177 | ||
180 | /* header + status byte + size of the data + status byte */ | 178 | /* header + status byte + size of the data + status byte */ |
181 | ret = spi_sync_transfer(dev, &phy->spi_xfer, 1); | 179 | ret = spi_sync_transfer(dev, &phy->spi_xfer, 1); |
182 | if (tpm_size > 0 && ret == 0) { | 180 | if (tpm_size > 0 && ret == 0) { |
183 | ret = rx_buf[total_length + nbr_dummy_bytes - 1]; | 181 | ret = rx_buf[total_length + phy->latency - 1]; |
184 | 182 | ||
185 | memcpy(tpm_data, rx_buf + total_length + nbr_dummy_bytes, | 183 | memcpy(tpm_data, rx_buf + total_length + phy->latency, |
186 | tpm_size); | 184 | tpm_size); |
187 | } | 185 | } |
188 | 186 | ||