Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | #ifndef _TPM_DEV_H |
| 3 | #define _TPM_DEV_H |
| 4 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 5 | #include <linux/poll.h> |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 6 | #include "tpm.h" |
| 7 | |
| 8 | struct file_priv { |
| 9 | struct tpm_chip *chip; |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 10 | struct tpm_space *space; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 11 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 12 | struct mutex buffer_mutex; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 13 | struct timer_list user_read_timer; /* user needs to claim result */ |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 14 | struct work_struct timeout_work; |
| 15 | struct work_struct async_work; |
| 16 | wait_queue_head_t async_wait; |
| 17 | size_t response_length; |
| 18 | bool response_read; |
| 19 | bool command_enqueued; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 20 | |
| 21 | u8 data_buffer[TPM_BUFSIZE]; |
| 22 | }; |
| 23 | |
| 24 | void tpm_common_open(struct file *file, struct tpm_chip *chip, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 25 | struct file_priv *priv, struct tpm_space *space); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 26 | ssize_t tpm_common_read(struct file *file, char __user *buf, |
| 27 | size_t size, loff_t *off); |
| 28 | ssize_t tpm_common_write(struct file *file, const char __user *buf, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 29 | size_t size, loff_t *off); |
| 30 | __poll_t tpm_common_poll(struct file *file, poll_table *wait); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 31 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 32 | void tpm_common_release(struct file *file, struct file_priv *priv); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 33 | #endif |