Skip to content

Commit 07d8004

Browse files
stefano-garzarellajarkkojs
authored andcommitted
tpm: add bufsiz parameter in the .send callback
Add a new `bufsiz` parameter to the `.send` callback in `tpm_class_ops`. This parameter will allow drivers to differentiate between the actual command length to send and the total buffer size. Currently `bufsiz` is not used, but it will be used to implement devices with synchronous send() to send the command and receive the response on the same buffer. Also rename the previous parameter `len` to `cmd_len` in the declaration to make it clear that it contains the length in bytes of the command stored in the buffer. The semantics don't change and it can be used as before by drivers. This is an optimization since the drivers could get it from the header, but let's avoid duplicating code. While we are here, resolve a checkpatch warning: WARNING: Unnecessary space before function pointer arguments #66: FILE: include/linux/tpm.h:90: + int (*send) (struct tpm_chip *chip, u8 *buf, size_t bufsiz, Signed-off-by: Stefano Garzarella <[email protected]> Suggested-by: Jarkko Sakkinen <[email protected]> Reviewed-by: Jarkko Sakkinen <[email protected]> Signed-off-by: Jarkko Sakkinen <[email protected]>
1 parent 89be9a8 commit 07d8004

17 files changed

+37
-19
lines changed

drivers/char/tpm/st33zp24/st33zp24.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ static irqreturn_t tpm_ioserirq_handler(int irq, void *dev_id)
300300
* send TPM commands through the I2C bus.
301301
*/
302302
static int st33zp24_send(struct tpm_chip *chip, unsigned char *buf,
303-
size_t len)
303+
size_t bufsiz, size_t len)
304304
{
305305
struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev);
306306
u32 status, i, size, ordinal;

drivers/char/tpm/tpm-interface.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ static ssize_t tpm_try_transmit(struct tpm_chip *chip, void *buf, size_t bufsiz)
106106
return -E2BIG;
107107
}
108108

109-
rc = chip->ops->send(chip, buf, count);
109+
rc = chip->ops->send(chip, buf, bufsiz, count);
110110
if (rc < 0) {
111111
if (rc != -EPIPE)
112112
dev_err(&chip->dev,

drivers/char/tpm/tpm_atmel.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ static int tpm_atml_recv(struct tpm_chip *chip, u8 *buf, size_t count)
148148
return size;
149149
}
150150

151-
static int tpm_atml_send(struct tpm_chip *chip, u8 *buf, size_t count)
151+
static int tpm_atml_send(struct tpm_chip *chip, u8 *buf, size_t bufsiz,
152+
size_t count)
152153
{
153154
struct tpm_atmel_priv *priv = dev_get_drvdata(&chip->dev);
154155
int i;

drivers/char/tpm/tpm_crb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ static int tpm_crb_smc_start(struct device *dev, unsigned long func_id)
426426
}
427427
#endif
428428

429-
static int crb_send(struct tpm_chip *chip, u8 *buf, size_t len)
429+
static int crb_send(struct tpm_chip *chip, u8 *buf, size_t bufsiz, size_t len)
430430
{
431431
struct crb_priv *priv = dev_get_drvdata(&chip->dev);
432432
int rc = 0;

drivers/char/tpm/tpm_ftpm_tee.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,15 @@ static int ftpm_tee_tpm_op_recv(struct tpm_chip *chip, u8 *buf, size_t count)
6363
* ftpm_tee_tpm_op_send() - send TPM commands through the TEE shared memory.
6464
* @chip: the tpm_chip description as specified in driver/char/tpm/tpm.h
6565
* @buf: the buffer to send.
66+
* @bufsiz: the size of the buffer.
6667
* @len: the number of bytes to send.
6768
*
6869
* Return:
6970
* In case of success, returns 0.
7071
* On failure, -errno
7172
*/
72-
static int ftpm_tee_tpm_op_send(struct tpm_chip *chip, u8 *buf, size_t len)
73+
static int ftpm_tee_tpm_op_send(struct tpm_chip *chip, u8 *buf, size_t bufsiz,
74+
size_t len)
7375
{
7476
struct ftpm_tee_private *pvt_data = dev_get_drvdata(chip->dev.parent);
7577
size_t resp_len;

drivers/char/tpm/tpm_i2c_atmel.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ struct priv_data {
3737
u8 buffer[sizeof(struct tpm_header) + 25];
3838
};
3939

40-
static int i2c_atmel_send(struct tpm_chip *chip, u8 *buf, size_t len)
40+
static int i2c_atmel_send(struct tpm_chip *chip, u8 *buf, size_t bufsiz,
41+
size_t len)
4142
{
4243
struct priv_data *priv = dev_get_drvdata(&chip->dev);
4344
struct i2c_client *client = to_i2c_client(chip->dev.parent);

drivers/char/tpm/tpm_i2c_infineon.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,8 @@ static int tpm_tis_i2c_recv(struct tpm_chip *chip, u8 *buf, size_t count)
514514
return size;
515515
}
516516

517-
static int tpm_tis_i2c_send(struct tpm_chip *chip, u8 *buf, size_t len)
517+
static int tpm_tis_i2c_send(struct tpm_chip *chip, u8 *buf, size_t bufsiz,
518+
size_t len)
518519
{
519520
int rc, status;
520521
ssize_t burstcnt;

drivers/char/tpm/tpm_i2c_nuvoton.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,8 @@ static int i2c_nuvoton_recv(struct tpm_chip *chip, u8 *buf, size_t count)
350350
* tpm.c can skip polling for the data to be available as the interrupt is
351351
* waited for here
352352
*/
353-
static int i2c_nuvoton_send(struct tpm_chip *chip, u8 *buf, size_t len)
353+
static int i2c_nuvoton_send(struct tpm_chip *chip, u8 *buf, size_t bufsiz,
354+
size_t len)
354355
{
355356
struct priv_data *priv = dev_get_drvdata(&chip->dev);
356357
struct device *dev = chip->dev.parent;

drivers/char/tpm/tpm_ibmvtpm.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,15 @@ static int tpm_ibmvtpm_resume(struct device *dev)
191191
* tpm_ibmvtpm_send() - Send a TPM command
192192
* @chip: tpm chip struct
193193
* @buf: buffer contains data to send
194-
* @count: size of buffer
194+
* @bufsiz: size of the buffer
195+
* @count: length of the command
195196
*
196197
* Return:
197198
* 0 on success,
198199
* -errno on error
199200
*/
200-
static int tpm_ibmvtpm_send(struct tpm_chip *chip, u8 *buf, size_t count)
201+
static int tpm_ibmvtpm_send(struct tpm_chip *chip, u8 *buf, size_t bufsiz,
202+
size_t count)
201203
{
202204
struct ibmvtpm_dev *ibmvtpm = dev_get_drvdata(&chip->dev);
203205
bool retry = true;

drivers/char/tpm/tpm_infineon.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,8 @@ static int tpm_inf_recv(struct tpm_chip *chip, u8 * buf, size_t count)
312312
return -EIO;
313313
}
314314

315-
static int tpm_inf_send(struct tpm_chip *chip, u8 * buf, size_t count)
315+
static int tpm_inf_send(struct tpm_chip *chip, u8 *buf, size_t bufsiz,
316+
size_t count)
316317
{
317318
int i;
318319
int ret;

0 commit comments

Comments
 (0)