Skip to content

Commit 8ab547a

Browse files
author
Jarkko Sakkinen
committed
tpm: Fix some name collisions with drivers/char/tpm.h
* Rename TPM_BUFSIZE defined in drivers/char/tpm/st33zp24/st33zp24.h to ST33ZP24_BUFSIZE. * Rename TPM_BUFSIZE defined in drivers/char/tpm/tpm_i2c_infineon.c to TPM_I2C_INFINEON_BUFSIZE. * Rename TPM_RETRY in tpm_i2c_nuvoton to TPM_I2C_RETRIES. * Remove TPM_HEADER_SIZE from tpm_i2c_nuvoton. Cc: stable@vger.kernel.org Fixes: bf38b87 ("tpm/tpm_i2c_stm_st33: Split tpm_i2c_tpm_st33 in 2 layers (core + phy)") Fixes: aad628c ("char/tpm: Add new driver for Infineon I2C TIS TPM") Fixes: 32d33b2 ("TPM: Retry SaveState command in suspend path") Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
1 parent 3d7a850 commit 8ab547a

File tree

5 files changed

+19
-20
lines changed

5 files changed

+19
-20
lines changed

drivers/char/tpm/st33zp24/i2c.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
struct st33zp24_i2c_phy {
3535
struct i2c_client *client;
36-
u8 buf[TPM_BUFSIZE + 1];
36+
u8 buf[ST33ZP24_BUFSIZE + 1];
3737
int io_lpcpd;
3838
};
3939

drivers/char/tpm/st33zp24/spi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
* some latency byte before the answer is available (max 15).
6464
* We have 2048 + 1024 + 15.
6565
*/
66-
#define ST33ZP24_SPI_BUFFER_SIZE (TPM_BUFSIZE + (TPM_BUFSIZE / 2) +\
66+
#define ST33ZP24_SPI_BUFFER_SIZE (ST33ZP24_BUFSIZE + (ST33ZP24_BUFSIZE / 2) +\
6767
MAX_SPI_LATENCY)
6868

6969

drivers/char/tpm/st33zp24/st33zp24.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
#ifndef __LOCAL_ST33ZP24_H__
1919
#define __LOCAL_ST33ZP24_H__
2020

21-
#define TPM_WRITE_DIRECTION 0x80
22-
#define TPM_BUFSIZE 2048
21+
#define TPM_WRITE_DIRECTION 0x80
22+
#define ST33ZP24_BUFSIZE 2048
2323

2424
struct st33zp24_dev {
2525
struct tpm_chip *chip;

drivers/char/tpm/tpm_i2c_infineon.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626
#include <linux/wait.h>
2727
#include "tpm.h"
2828

29-
/* max. buffer size supported by our TPM */
30-
#define TPM_BUFSIZE 1260
29+
#define TPM_I2C_INFINEON_BUFSIZE 1260
3130

3231
/* max. number of iterations after I2C NAK */
3332
#define MAX_COUNT 3
@@ -63,11 +62,13 @@ enum i2c_chip_type {
6362
UNKNOWN,
6463
};
6564

66-
/* Structure to store I2C TPM specific stuff */
6765
struct tpm_inf_dev {
6866
struct i2c_client *client;
6967
int locality;
70-
u8 buf[TPM_BUFSIZE + sizeof(u8)]; /* max. buffer size + addr */
68+
/* In addition to the data itself, the buffer must fit the 7-bit I2C
69+
* address and the direction bit.
70+
*/
71+
u8 buf[TPM_I2C_INFINEON_BUFSIZE + 1];
7172
struct tpm_chip *chip;
7273
enum i2c_chip_type chip_type;
7374
unsigned int adapterlimit;
@@ -219,7 +220,7 @@ static int iic_tpm_write_generic(u8 addr, u8 *buffer, size_t len,
219220
.buf = tpm_dev.buf
220221
};
221222

222-
if (len > TPM_BUFSIZE)
223+
if (len > TPM_I2C_INFINEON_BUFSIZE)
223224
return -EINVAL;
224225

225226
if (!tpm_dev.client->adapter->algo->master_xfer)
@@ -527,8 +528,8 @@ static int tpm_tis_i2c_send(struct tpm_chip *chip, u8 *buf, size_t len)
527528
u8 retries = 0;
528529
u8 sts = TPM_STS_GO;
529530

530-
if (len > TPM_BUFSIZE)
531-
return -E2BIG; /* command is too long for our tpm, sorry */
531+
if (len > TPM_I2C_INFINEON_BUFSIZE)
532+
return -E2BIG;
532533

533534
if (request_locality(chip, 0) < 0)
534535
return -EBUSY;

drivers/char/tpm/tpm_i2c_nuvoton.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,12 @@
3535
#include "tpm.h"
3636

3737
/* I2C interface offsets */
38-
#define TPM_STS 0x00
39-
#define TPM_BURST_COUNT 0x01
40-
#define TPM_DATA_FIFO_W 0x20
41-
#define TPM_DATA_FIFO_R 0x40
42-
#define TPM_VID_DID_RID 0x60
43-
/* TPM command header size */
44-
#define TPM_HEADER_SIZE 10
45-
#define TPM_RETRY 5
38+
#define TPM_STS 0x00
39+
#define TPM_BURST_COUNT 0x01
40+
#define TPM_DATA_FIFO_W 0x20
41+
#define TPM_DATA_FIFO_R 0x40
42+
#define TPM_VID_DID_RID 0x60
43+
#define TPM_I2C_RETRIES 5
4644
/*
4745
* I2C bus device maximum buffer size w/o counting I2C address or command
4846
* i.e. max size required for I2C write is 34 = addr, command, 32 bytes data
@@ -292,7 +290,7 @@ static int i2c_nuvoton_recv(struct tpm_chip *chip, u8 *buf, size_t count)
292290
dev_err(dev, "%s() count < header size\n", __func__);
293291
return -EIO;
294292
}
295-
for (retries = 0; retries < TPM_RETRY; retries++) {
293+
for (retries = 0; retries < TPM_I2C_RETRIES; retries++) {
296294
if (retries > 0) {
297295
/* if this is not the first trial, set responseRetry */
298296
i2c_nuvoton_write_status(client,

0 commit comments

Comments
 (0)