2 * Copyright (C) 2017 James.Bottomley@HansenPartnership.com
6 #include <linux/slab.h>
10 struct file_priv priv
;
11 struct tpm_space space
;
14 static int tpmrm_open(struct inode
*inode
, struct file
*file
)
16 struct tpm_chip
*chip
;
17 struct tpmrm_priv
*priv
;
20 chip
= container_of(inode
->i_cdev
, struct tpm_chip
, cdevs
);
21 priv
= kzalloc(sizeof(*priv
), GFP_KERNEL
);
25 rc
= tpm2_init_space(&priv
->space
);
31 tpm_common_open(file
, chip
, &priv
->priv
);
36 static int tpmrm_release(struct inode
*inode
, struct file
*file
)
38 struct file_priv
*fpriv
= file
->private_data
;
39 struct tpmrm_priv
*priv
= container_of(fpriv
, struct tpmrm_priv
, priv
);
41 tpm_common_release(file
, fpriv
);
42 tpm2_del_space(fpriv
->chip
, &priv
->space
);
48 ssize_t
tpmrm_write(struct file
*file
, const char __user
*buf
,
49 size_t size
, loff_t
*off
)
51 struct file_priv
*fpriv
= file
->private_data
;
52 struct tpmrm_priv
*priv
= container_of(fpriv
, struct tpmrm_priv
, priv
);
54 return tpm_common_write(file
, buf
, size
, off
, &priv
->space
);
57 const struct file_operations tpmrm_fops
= {
61 .read
= tpm_common_read
,
63 .release
= tpmrm_release
,