blob: 1089fc0bb290cb59098321fbf6605872167f7a15 [file] [log] [blame]
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00001/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _TPM_DEV_H
3#define _TPM_DEV_H
4
David Brazdil0f672f62019-12-10 10:32:29 +00005#include <linux/poll.h>
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00006#include "tpm.h"
7
8struct file_priv {
9 struct tpm_chip *chip;
David Brazdil0f672f62019-12-10 10:32:29 +000010 struct tpm_space *space;
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000011
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000012 struct mutex buffer_mutex;
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000013 struct timer_list user_read_timer; /* user needs to claim result */
David Brazdil0f672f62019-12-10 10:32:29 +000014 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 Scullb4b6d4a2019-01-02 15:54:55 +000020
21 u8 data_buffer[TPM_BUFSIZE];
22};
23
24void tpm_common_open(struct file *file, struct tpm_chip *chip,
David Brazdil0f672f62019-12-10 10:32:29 +000025 struct file_priv *priv, struct tpm_space *space);
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000026ssize_t tpm_common_read(struct file *file, char __user *buf,
27 size_t size, loff_t *off);
28ssize_t tpm_common_write(struct file *file, const char __user *buf,
David Brazdil0f672f62019-12-10 10:32:29 +000029 size_t size, loff_t *off);
30__poll_t tpm_common_poll(struct file *file, poll_table *wait);
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000031
David Brazdil0f672f62019-12-10 10:32:29 +000032void tpm_common_release(struct file *file, struct file_priv *priv);
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000033#endif