Re: [PATCH v4 1/4] tpm: add buf_size parameter in the .send callback
From: Stefano Garzarella <sgarzare@redhat.com>
Date: 2025-05-13 14:03:13
Also in:
linux-arm-kernel, linux-integrity, lkml
On Sat, May 10, 2025 at 10:44:38AM +0300, Jarkko Sakkinen wrote:
On Fri, May 09, 2025 at 10:57:10AM +0200, Stefano Garzarella wrote:quoted
From: Stefano Garzarella <sgarzare@redhat.com> Add a new `buf_size` 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 `buf_now` 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 cmd_len, Suggested-by: Jarkko Sakkinen <jarkko@kernel.org> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com> --- v4: - rework the commit description [Jarkko] --- include/linux/tpm.h | 3 ++- drivers/char/tpm/st33zp24/st33zp24.c | 2 +- drivers/char/tpm/tpm-interface.c | 2 +- drivers/char/tpm/tpm_atmel.c | 3 ++- drivers/char/tpm/tpm_crb.c | 2 +- drivers/char/tpm/tpm_ftpm_tee.c | 4 +++- drivers/char/tpm/tpm_i2c_atmel.c | 3 ++- drivers/char/tpm/tpm_i2c_infineon.c | 3 ++- drivers/char/tpm/tpm_i2c_nuvoton.c | 3 ++- drivers/char/tpm/tpm_ibmvtpm.c | 6 ++++-- drivers/char/tpm/tpm_infineon.c | 3 ++- drivers/char/tpm/tpm_nsc.c | 3 ++- drivers/char/tpm/tpm_svsm.c | 3 ++- drivers/char/tpm/tpm_tis_core.c | 3 ++- drivers/char/tpm/tpm_tis_i2c_cr50.c | 6 ++++-- drivers/char/tpm/tpm_vtpm_proxy.c | 4 +++- drivers/char/tpm/xen-tpmfront.c | 3 ++- 17 files changed, 37 insertions(+), 19 deletions(-)diff --git a/include/linux/tpm.h b/include/linux/tpm.h index 9ac9768cc8f7..7ac390ec89ce 100644 --- a/include/linux/tpm.h +++ b/include/linux/tpm.h@@ -87,7 +87,8 @@ struct tpm_class_ops { const u8 req_complete_val; bool (*req_canceled)(struct tpm_chip *chip, u8 status); int (*recv) (struct tpm_chip *chip, u8 *buf, size_t len); - int (*send) (struct tpm_chip *chip, u8 *buf, size_t len); + int (*send)(struct tpm_chip *chip, u8 *buf, size_t cmd_len, + size_t buf_size);I'm sorry but now that I look at this, just for the sake of consistency: int (*send)(struct tpm_chip *chip, u8 *buf, size_t bufsiz, size_t cmd_len); I.e. match the order and parameter names from tpm_try_transmit().
Ah, I see, makes sense, I'll update and send v5. Thanks, Stefano