|
27 | 27 | static struct workqueue_struct *tpm_dev_wq;
|
28 | 28 | static DEFINE_MUTEX(tpm_dev_wq_lock);
|
29 | 29 |
|
30 |
| -static void tpm_async_work(struct work_struct *work) |
| 30 | +static ssize_t tpm_dev_transmit(struct tpm_chip *chip, struct tpm_space *space, |
| 31 | + u8 *buf, size_t bufsiz) |
| 32 | +{ |
| 33 | + ssize_t ret; |
| 34 | + |
| 35 | + mutex_lock(&chip->tpm_mutex); |
| 36 | + ret = tpm_transmit(chip, space, buf, bufsiz, TPM_TRANSMIT_UNLOCKED); |
| 37 | + mutex_unlock(&chip->tpm_mutex); |
| 38 | + |
| 39 | + return ret; |
| 40 | +} |
| 41 | + |
| 42 | +static void tpm_dev_async_work(struct work_struct *work) |
31 | 43 | {
|
32 | 44 | struct file_priv *priv =
|
33 | 45 | container_of(work, struct file_priv, async_work);
|
34 | 46 | ssize_t ret;
|
35 | 47 |
|
36 | 48 | mutex_lock(&priv->buffer_mutex);
|
37 | 49 | priv->command_enqueued = false;
|
38 |
| - ret = tpm_transmit(priv->chip, priv->space, priv->data_buffer, |
39 |
| - sizeof(priv->data_buffer), 0); |
40 |
| - |
| 50 | + ret = tpm_dev_transmit(priv->chip, priv->space, priv->data_buffer, |
| 51 | + sizeof(priv->data_buffer)); |
41 | 52 | tpm_put_ops(priv->chip);
|
42 | 53 | if (ret > 0) {
|
43 | 54 | priv->response_length = ret;
|
@@ -80,7 +91,7 @@ void tpm_common_open(struct file *file, struct tpm_chip *chip,
|
80 | 91 | mutex_init(&priv->buffer_mutex);
|
81 | 92 | timer_setup(&priv->user_read_timer, user_reader_timeout, 0);
|
82 | 93 | INIT_WORK(&priv->timeout_work, tpm_timeout_work);
|
83 |
| - INIT_WORK(&priv->async_work, tpm_async_work); |
| 94 | + INIT_WORK(&priv->async_work, tpm_dev_async_work); |
84 | 95 | init_waitqueue_head(&priv->async_wait);
|
85 | 96 | file->private_data = priv;
|
86 | 97 | }
|
@@ -183,8 +194,8 @@ ssize_t tpm_common_write(struct file *file, const char __user *buf,
|
183 | 194 | return size;
|
184 | 195 | }
|
185 | 196 |
|
186 |
| - ret = tpm_transmit(priv->chip, priv->space, priv->data_buffer, |
187 |
| - sizeof(priv->data_buffer), 0); |
| 197 | + ret = tpm_dev_transmit(priv->chip, priv->space, priv->data_buffer, |
| 198 | + sizeof(priv->data_buffer)); |
188 | 199 | tpm_put_ops(priv->chip);
|
189 | 200 |
|
190 | 201 | if (ret > 0) {
|
|
0 commit comments