diff options
author | Christophe RICARD <christophe.ricard@gmail.com> | 2016-02-13 10:15:27 -0500 |
---|---|---|
committer | Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> | 2016-06-25 10:26:11 -0400 |
commit | a5392e912031dff0b74a5d923c49c9839cea5bb3 (patch) | |
tree | 8e3a1ce264880389ffa7f6ddf01f2becaca28442 /drivers/char/tpm | |
parent | d34306e28891257e3c4e8c172af19d70f84fa272 (diff) |
tpm/st33zp24/spi: Remove field spi_xfer from st33zp24_spi_phy structure
Remove spi_xfer from st33zp24_spi_phy structure and declare local spi_xfer
when needed instead.
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/tpm')
-rw-r--r-- | drivers/char/tpm/st33zp24/spi.c | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/drivers/char/tpm/st33zp24/spi.c b/drivers/char/tpm/st33zp24/spi.c index 08ffbfe7588c..f85105303de9 100644 --- a/drivers/char/tpm/st33zp24/spi.c +++ b/drivers/char/tpm/st33zp24/spi.c | |||
@@ -66,7 +66,7 @@ | |||
66 | 66 | ||
67 | struct st33zp24_spi_phy { | 67 | struct st33zp24_spi_phy { |
68 | struct spi_device *spi_device; | 68 | struct spi_device *spi_device; |
69 | struct spi_transfer spi_xfer; | 69 | |
70 | u8 tx_buf[ST33ZP24_SPI_BUFFER_SIZE]; | 70 | u8 tx_buf[ST33ZP24_SPI_BUFFER_SIZE]; |
71 | u8 rx_buf[ST33ZP24_SPI_BUFFER_SIZE]; | 71 | u8 rx_buf[ST33ZP24_SPI_BUFFER_SIZE]; |
72 | 72 | ||
@@ -113,28 +113,30 @@ static int st33zp24_spi_send(void *phy_id, u8 tpm_register, u8 *tpm_data, | |||
113 | int total_length = 0, ret = 0; | 113 | int total_length = 0, ret = 0; |
114 | struct st33zp24_spi_phy *phy = phy_id; | 114 | struct st33zp24_spi_phy *phy = phy_id; |
115 | struct spi_device *dev = phy->spi_device; | 115 | struct spi_device *dev = phy->spi_device; |
116 | u8 *tx_buf = (u8 *)phy->spi_xfer.tx_buf; | 116 | struct spi_transfer spi_xfer = { |
117 | u8 *rx_buf = phy->spi_xfer.rx_buf; | 117 | .tx_buf = phy->tx_buf, |
118 | .rx_buf = phy->rx_buf, | ||
119 | }; | ||
118 | 120 | ||
119 | /* Pre-Header */ | 121 | /* Pre-Header */ |
120 | tx_buf[total_length++] = TPM_WRITE_DIRECTION | LOCALITY0; | 122 | phy->tx_buf[total_length++] = TPM_WRITE_DIRECTION | LOCALITY0; |
121 | tx_buf[total_length++] = tpm_register; | 123 | phy->tx_buf[total_length++] = tpm_register; |
122 | 124 | ||
123 | if (tpm_size > 0 && tpm_register == TPM_DATA_FIFO) { | 125 | if (tpm_size > 0 && tpm_register == TPM_DATA_FIFO) { |
124 | tx_buf[total_length++] = tpm_size >> 8; | 126 | phy->tx_buf[total_length++] = tpm_size >> 8; |
125 | tx_buf[total_length++] = tpm_size; | 127 | phy->tx_buf[total_length++] = tpm_size; |
126 | } | 128 | } |
127 | 129 | ||
128 | memcpy(&tx_buf[total_length], tpm_data, tpm_size); | 130 | memcpy(&phy->tx_buf[total_length], tpm_data, tpm_size); |
129 | total_length += tpm_size; | 131 | total_length += tpm_size; |
130 | 132 | ||
131 | memset(&tx_buf[total_length], TPM_DUMMY_BYTE, phy->latency); | 133 | memset(&phy->tx_buf[total_length], TPM_DUMMY_BYTE, phy->latency); |
132 | 134 | ||
133 | phy->spi_xfer.len = total_length + phy->latency; | 135 | spi_xfer.len = total_length + phy->latency; |
134 | 136 | ||
135 | ret = spi_sync_transfer(dev, &phy->spi_xfer, 1); | 137 | ret = spi_sync_transfer(dev, &spi_xfer, 1); |
136 | if (ret == 0) | 138 | if (ret == 0) |
137 | ret = rx_buf[total_length + phy->latency - 1]; | 139 | ret = phy->rx_buf[total_length + phy->latency - 1]; |
138 | 140 | ||
139 | return st33zp24_status_to_errno(ret); | 141 | return st33zp24_status_to_errno(ret); |
140 | } /* st33zp24_spi_send() */ | 142 | } /* st33zp24_spi_send() */ |
@@ -154,24 +156,26 @@ static int st33zp24_spi_read8_reg(void *phy_id, u8 tpm_register, u8 *tpm_data, | |||
154 | int total_length = 0, ret; | 156 | int total_length = 0, ret; |
155 | struct st33zp24_spi_phy *phy = phy_id; | 157 | struct st33zp24_spi_phy *phy = phy_id; |
156 | struct spi_device *dev = phy->spi_device; | 158 | struct spi_device *dev = phy->spi_device; |
157 | u8 *tx_buf = (u8 *)phy->spi_xfer.tx_buf; | 159 | struct spi_transfer spi_xfer = { |
158 | u8 *rx_buf = phy->spi_xfer.rx_buf; | 160 | .tx_buf = phy->tx_buf, |
161 | .rx_buf = phy->rx_buf, | ||
162 | }; | ||
159 | 163 | ||
160 | /* Pre-Header */ | 164 | /* Pre-Header */ |
161 | tx_buf[total_length++] = LOCALITY0; | 165 | phy->tx_buf[total_length++] = LOCALITY0; |
162 | tx_buf[total_length++] = tpm_register; | 166 | phy->tx_buf[total_length++] = tpm_register; |
163 | 167 | ||
164 | memset(&tx_buf[total_length], TPM_DUMMY_BYTE, | 168 | memset(&phy->tx_buf[total_length], TPM_DUMMY_BYTE, |
165 | phy->latency + tpm_size); | 169 | phy->latency + tpm_size); |
166 | 170 | ||
167 | phy->spi_xfer.len = total_length + phy->latency + tpm_size; | 171 | spi_xfer.len = total_length + phy->latency + tpm_size; |
168 | 172 | ||
169 | /* header + status byte + size of the data + status byte */ | 173 | /* header + status byte + size of the data + status byte */ |
170 | ret = spi_sync_transfer(dev, &phy->spi_xfer, 1); | 174 | ret = spi_sync_transfer(dev, &spi_xfer, 1); |
171 | if (tpm_size > 0 && ret == 0) { | 175 | if (tpm_size > 0 && ret == 0) { |
172 | ret = rx_buf[total_length + phy->latency - 1]; | 176 | ret = phy->rx_buf[total_length + phy->latency - 1]; |
173 | 177 | ||
174 | memcpy(tpm_data, rx_buf + total_length + phy->latency, | 178 | memcpy(tpm_data, phy->rx_buf + total_length + phy->latency, |
175 | tpm_size); | 179 | tpm_size); |
176 | } | 180 | } |
177 | 181 | ||
@@ -328,9 +332,6 @@ static int st33zp24_spi_probe(struct spi_device *dev) | |||
328 | return ret; | 332 | return ret; |
329 | } | 333 | } |
330 | 334 | ||
331 | phy->spi_xfer.tx_buf = phy->tx_buf; | ||
332 | phy->spi_xfer.rx_buf = phy->rx_buf; | ||
333 | |||
334 | phy->latency = st33zp24_spi_evaluate_latency(phy); | 335 | phy->latency = st33zp24_spi_evaluate_latency(phy); |
335 | if (phy->latency <= 0) | 336 | if (phy->latency <= 0) |
336 | return -ENODEV; | 337 | return -ENODEV; |