aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/char/tpm/tpm-dev-common.c8
-rw-r--r--drivers/char/tpm/tpm-dev.c10
-rw-r--r--drivers/char/tpm/tpm-dev.h5
-rw-r--r--drivers/char/tpm/tpmrm-dev.c14
4 files changed, 12 insertions, 25 deletions
diff --git a/drivers/char/tpm/tpm-dev-common.c b/drivers/char/tpm/tpm-dev-common.c
index e4a04b2d3c32..f0c033b69b62 100644
--- a/drivers/char/tpm/tpm-dev-common.c
+++ b/drivers/char/tpm/tpm-dev-common.c
@@ -43,9 +43,11 @@ static void timeout_work(struct work_struct *work)
43} 43}
44 44
45void tpm_common_open(struct file *file, struct tpm_chip *chip, 45void tpm_common_open(struct file *file, struct tpm_chip *chip,
46 struct file_priv *priv) 46 struct file_priv *priv, struct tpm_space *space)
47{ 47{
48 priv->chip = chip; 48 priv->chip = chip;
49 priv->space = space;
50
49 mutex_init(&priv->buffer_mutex); 51 mutex_init(&priv->buffer_mutex);
50 timer_setup(&priv->user_read_timer, user_reader_timeout, 0); 52 timer_setup(&priv->user_read_timer, user_reader_timeout, 0);
51 INIT_WORK(&priv->work, timeout_work); 53 INIT_WORK(&priv->work, timeout_work);
@@ -79,7 +81,7 @@ ssize_t tpm_common_read(struct file *file, char __user *buf,
79} 81}
80 82
81ssize_t tpm_common_write(struct file *file, const char __user *buf, 83ssize_t tpm_common_write(struct file *file, const char __user *buf,
82 size_t size, loff_t *off, struct tpm_space *space) 84 size_t size, loff_t *off)
83{ 85{
84 struct file_priv *priv = file->private_data; 86 struct file_priv *priv = file->private_data;
85 size_t in_size = size; 87 size_t in_size = size;
@@ -119,7 +121,7 @@ ssize_t tpm_common_write(struct file *file, const char __user *buf,
119 mutex_unlock(&priv->buffer_mutex); 121 mutex_unlock(&priv->buffer_mutex);
120 return -EPIPE; 122 return -EPIPE;
121 } 123 }
122 out_size = tpm_transmit(priv->chip, space, priv->data_buffer, 124 out_size = tpm_transmit(priv->chip, priv->space, priv->data_buffer,
123 sizeof(priv->data_buffer), 0); 125 sizeof(priv->data_buffer), 0);
124 126
125 tpm_put_ops(priv->chip); 127 tpm_put_ops(priv->chip);
diff --git a/drivers/char/tpm/tpm-dev.c b/drivers/char/tpm/tpm-dev.c
index ebd74ab5abef..98b9630c3a36 100644
--- a/drivers/char/tpm/tpm-dev.c
+++ b/drivers/char/tpm/tpm-dev.c
@@ -39,7 +39,7 @@ static int tpm_open(struct inode *inode, struct file *file)
39 if (priv == NULL) 39 if (priv == NULL)
40 goto out; 40 goto out;
41 41
42 tpm_common_open(file, chip, priv); 42 tpm_common_open(file, chip, priv, NULL);
43 43
44 return 0; 44 return 0;
45 45
@@ -48,12 +48,6 @@ static int tpm_open(struct inode *inode, struct file *file)
48 return -ENOMEM; 48 return -ENOMEM;
49} 49}
50 50
51static ssize_t tpm_write(struct file *file, const char __user *buf,
52 size_t size, loff_t *off)
53{
54 return tpm_common_write(file, buf, size, off, NULL);
55}
56
57/* 51/*
58 * Called on file close 52 * Called on file close
59 */ 53 */
@@ -73,6 +67,6 @@ const struct file_operations tpm_fops = {
73 .llseek = no_llseek, 67 .llseek = no_llseek,
74 .open = tpm_open, 68 .open = tpm_open,
75 .read = tpm_common_read, 69 .read = tpm_common_read,
76 .write = tpm_write, 70 .write = tpm_common_write,
77 .release = tpm_release, 71 .release = tpm_release,
78}; 72};
diff --git a/drivers/char/tpm/tpm-dev.h b/drivers/char/tpm/tpm-dev.h
index b24cfb4d3ee1..4048677bbd78 100644
--- a/drivers/char/tpm/tpm-dev.h
+++ b/drivers/char/tpm/tpm-dev.h
@@ -6,6 +6,7 @@
6 6
7struct file_priv { 7struct file_priv {
8 struct tpm_chip *chip; 8 struct tpm_chip *chip;
9 struct tpm_space *space;
9 10
10 /* Data passed to and from the tpm via the read/write calls */ 11 /* Data passed to and from the tpm via the read/write calls */
11 size_t data_pending; 12 size_t data_pending;
@@ -18,11 +19,11 @@ struct file_priv {
18}; 19};
19 20
20void tpm_common_open(struct file *file, struct tpm_chip *chip, 21void tpm_common_open(struct file *file, struct tpm_chip *chip,
21 struct file_priv *priv); 22 struct file_priv *priv, struct tpm_space *space);
22ssize_t tpm_common_read(struct file *file, char __user *buf, 23ssize_t tpm_common_read(struct file *file, char __user *buf,
23 size_t size, loff_t *off); 24 size_t size, loff_t *off);
24ssize_t tpm_common_write(struct file *file, const char __user *buf, 25ssize_t tpm_common_write(struct file *file, const char __user *buf,
25 size_t size, loff_t *off, struct tpm_space *space); 26 size_t size, loff_t *off);
26void tpm_common_release(struct file *file, struct file_priv *priv); 27void tpm_common_release(struct file *file, struct file_priv *priv);
27 28
28#endif 29#endif
diff --git a/drivers/char/tpm/tpmrm-dev.c b/drivers/char/tpm/tpmrm-dev.c
index 1a0e97a5da5a..96006c6b9696 100644
--- a/drivers/char/tpm/tpmrm-dev.c
+++ b/drivers/char/tpm/tpmrm-dev.c
@@ -28,7 +28,7 @@ static int tpmrm_open(struct inode *inode, struct file *file)
28 return -ENOMEM; 28 return -ENOMEM;
29 } 29 }
30 30
31 tpm_common_open(file, chip, &priv->priv); 31 tpm_common_open(file, chip, &priv->priv, &priv->space);
32 32
33 return 0; 33 return 0;
34} 34}
@@ -45,21 +45,11 @@ static int tpmrm_release(struct inode *inode, struct file *file)
45 return 0; 45 return 0;
46} 46}
47 47
48static ssize_t tpmrm_write(struct file *file, const char __user *buf,
49 size_t size, loff_t *off)
50{
51 struct file_priv *fpriv = file->private_data;
52 struct tpmrm_priv *priv = container_of(fpriv, struct tpmrm_priv, priv);
53
54 return tpm_common_write(file, buf, size, off, &priv->space);
55}
56
57const struct file_operations tpmrm_fops = { 48const struct file_operations tpmrm_fops = {
58 .owner = THIS_MODULE, 49 .owner = THIS_MODULE,
59 .llseek = no_llseek, 50 .llseek = no_llseek,
60 .open = tpmrm_open, 51 .open = tpmrm_open,
61 .read = tpm_common_read, 52 .read = tpm_common_read,
62 .write = tpmrm_write, 53 .write = tpm_common_write,
63 .release = tpmrm_release, 54 .release = tpmrm_release,
64}; 55};
65