btrfs: Don't clear SGID when inheriting ACLs
[linux/fpc-iii.git] / drivers / char / tpm / tpmrm-dev.c
blobc636e7fdd1f5136e0eb50e7c8a72a6fbec2d8513
1 /*
2 * Copyright (C) 2017 James.Bottomley@HansenPartnership.com
4 * GPLv2
5 */
6 #include <linux/slab.h>
7 #include "tpm-dev.h"
9 struct tpmrm_priv {
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;
18 int rc;
20 chip = container_of(inode->i_cdev, struct tpm_chip, cdevs);
21 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
22 if (priv == NULL)
23 return -ENOMEM;
25 rc = tpm2_init_space(&priv->space);
26 if (rc) {
27 kfree(priv);
28 return -ENOMEM;
31 tpm_common_open(file, chip, &priv->priv);
33 return 0;
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);
43 kfree(priv);
45 return 0;
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 = {
58 .owner = THIS_MODULE,
59 .llseek = no_llseek,
60 .open = tpmrm_open,
61 .read = tpm_common_read,
62 .write = tpmrm_write,
63 .release = tpmrm_release,