1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _TPM_DEV_H 3 #define _TPM_DEV_H 4 5 #include <linux/poll.h> 6 #include "tpm.h" 7 8 struct file_priv { 9 struct tpm_chip *chip; 10 struct tpm_space *space; 11 12 /* Holds the amount of data passed or an error code from async op */ 13 ssize_t data_pending; 14 struct mutex buffer_mutex; 15 16 struct timer_list user_read_timer; /* user needs to claim result */ 17 struct work_struct timeout_work; 18 struct work_struct async_work; 19 wait_queue_head_t async_wait; 20 bool command_enqueued; 21 22 u8 data_buffer[TPM_BUFSIZE]; 23 }; 24 25 void tpm_common_open(struct file *file, struct tpm_chip *chip, 26 struct file_priv *priv, struct tpm_space *space); 27 ssize_t tpm_common_read(struct file *file, char __user *buf, 28 size_t size, loff_t *off); 29 ssize_t tpm_common_write(struct file *file, const char __user *buf, 30 size_t size, loff_t *off); 31 __poll_t tpm_common_poll(struct file *file, poll_table *wait); 32 33 void tpm_common_release(struct file *file, struct file_priv *priv); 34 #endif 35