Re: [RFC PATCH v2 3/6] tpm: add send_recv() ops in tpm_class_ops

Stefano Garzarella
2025-03-03T16:22:03Z

On Sat, Mar 01, 2025 at 03:45:10AM +0200, Jarkko Sakkinen wrote:
>On Fri, Feb 28, 2025 at 06:07:17PM +0100, Stefano Garzarella wrote:
>> + int (*send_recv)(struct tpm_chip *chip, u8 *buf, size_t buf_len,
>> + size_t to_send);
>
>Please describe the meaning and purpose of to_send.

Sure, I'll add in the commit description.

Should I add documentation in the code as well?

The other callbacks don't have that, but if you think it's useful we can
start with that, I mean something like this:

/**
* send_recv() - send the command and receive the response on the same
* buffer in a single call.
*
* @chip: The TPM chip
* @buf: A buffer used to both send the command and receive the response
* @buf_len: The size of the buffer
* @to_send: Number of bytes in the buffer to send
*
* Return: number of received bytes on success, negative error code on
* failure.
*/
int (*send_recv)(struct tpm_chip *chip, u8 *buf, size_t buf_len,
size_t to_send);

Thanks,
Stefano