1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2017 James.Bottomley@HansenPartnership.com
5 #include <linux/slab.h>
10 struct tpm_space space
;
13 static int tpmrm_open(struct inode
*inode
, struct file
*file
)
15 struct tpm_chip
*chip
;
16 struct tpmrm_priv
*priv
;
19 chip
= container_of(inode
->i_cdev
, struct tpm_chip
, cdevs
);
20 priv
= kzalloc(sizeof(*priv
), GFP_KERNEL
);
24 rc
= tpm2_init_space(&priv
->space
);
30 tpm_common_open(file
, chip
, &priv
->priv
, &priv
->space
);
35 static int tpmrm_release(struct inode
*inode
, struct file
*file
)
37 struct file_priv
*fpriv
= file
->private_data
;
38 struct tpmrm_priv
*priv
= container_of(fpriv
, struct tpmrm_priv
, priv
);
40 tpm_common_release(file
, fpriv
);
41 tpm2_del_space(fpriv
->chip
, &priv
->space
);
47 const struct file_operations tpmrm_fops
= {
51 .read
= tpm_common_read
,
52 .write
= tpm_common_write
,
53 .poll
= tpm_common_poll
,
54 .release
= tpmrm_release
,