@@ -47,8 +47,8 @@ struct tpm_tis_spi_phy {
struct tpm_tis_data priv;
struct spi_device *spi_device;
- u8 tx_buf[4];
- u8 rx_buf[4];
+ u8 *tx_buf;
+ u8 *rx_buf;
};
static inline struct tpm_tis_spi_phy *to_tpm_tis_spi_phy(struct tpm_tis_data *data)
@@ -115,10 +115,9 @@ static int tpm_tis_spi_transfer(struct tpm_tis_data *data, u32 addr, u16 len,
if (direction) {
spi_xfer.tx_buf = NULL;
- spi_xfer.rx_buf = buffer;
} else {
- spi_xfer.tx_buf = buffer;
spi_xfer.rx_buf = NULL;
+ memcpy(phy->tx_buf, buffer, transfer_len);
}
spi_message_init(&m);
@@ -127,6 +126,9 @@ static int tpm_tis_spi_transfer(struct tpm_tis_data *data, u32 addr, u16 len,
if (ret < 0)
goto exit;
+ if (direction)
+ memcpy(buffer, phy->rx_buf, transfer_len);
+
len -= transfer_len;
buffer += transfer_len;
}
@@ -194,6 +196,14 @@ static int tpm_tis_spi_probe(struct spi_device *dev)
phy->spi_device = dev;
+ phy->tx_buf = devm_kmalloc(&dev->dev, MAX_SPI_FRAMESIZE, GFP_KERNEL);
+ if (!phy->tx_buf)
+ return -ENOMEM;
+
+ phy->rx_buf = devm_kmalloc(&dev->dev, MAX_SPI_FRAMESIZE, GFP_KERNEL);
+ if (!phy->rx_buf)
+ return -ENOMEM;
+
return tpm_tis_core_init(&dev->dev, &phy->priv, -1, &tpm_spi_phy_ops,
NULL);
}