diff options
Diffstat (limited to 'drivers/char/tpm/xen-tpmfront.c')
-rw-r--r-- | drivers/char/tpm/xen-tpmfront.c | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/drivers/char/tpm/xen-tpmfront.c b/drivers/char/tpm/xen-tpmfront.c index 3111f2778079..62028f483bba 100644 --- a/drivers/char/tpm/xen-tpmfront.c +++ b/drivers/char/tpm/xen-tpmfront.c | |||
@@ -28,6 +28,8 @@ struct tpm_private { | |||
28 | unsigned int evtchn; | 28 | unsigned int evtchn; |
29 | int ring_ref; | 29 | int ring_ref; |
30 | domid_t backend_id; | 30 | domid_t backend_id; |
31 | int irq; | ||
32 | wait_queue_head_t read_queue; | ||
31 | }; | 33 | }; |
32 | 34 | ||
33 | enum status_bits { | 35 | enum status_bits { |
@@ -39,7 +41,7 @@ enum status_bits { | |||
39 | 41 | ||
40 | static u8 vtpm_status(struct tpm_chip *chip) | 42 | static u8 vtpm_status(struct tpm_chip *chip) |
41 | { | 43 | { |
42 | struct tpm_private *priv = TPM_VPRIV(chip); | 44 | struct tpm_private *priv = dev_get_drvdata(&chip->dev); |
43 | switch (priv->shr->state) { | 45 | switch (priv->shr->state) { |
44 | case VTPM_STATE_IDLE: | 46 | case VTPM_STATE_IDLE: |
45 | return VTPM_STATUS_IDLE | VTPM_STATUS_CANCELED; | 47 | return VTPM_STATUS_IDLE | VTPM_STATUS_CANCELED; |
@@ -60,7 +62,7 @@ static bool vtpm_req_canceled(struct tpm_chip *chip, u8 status) | |||
60 | 62 | ||
61 | static void vtpm_cancel(struct tpm_chip *chip) | 63 | static void vtpm_cancel(struct tpm_chip *chip) |
62 | { | 64 | { |
63 | struct tpm_private *priv = TPM_VPRIV(chip); | 65 | struct tpm_private *priv = dev_get_drvdata(&chip->dev); |
64 | priv->shr->state = VTPM_STATE_CANCEL; | 66 | priv->shr->state = VTPM_STATE_CANCEL; |
65 | wmb(); | 67 | wmb(); |
66 | notify_remote_via_evtchn(priv->evtchn); | 68 | notify_remote_via_evtchn(priv->evtchn); |
@@ -73,7 +75,7 @@ static unsigned int shr_data_offset(struct vtpm_shared_page *shr) | |||
73 | 75 | ||
74 | static int vtpm_send(struct tpm_chip *chip, u8 *buf, size_t count) | 76 | static int vtpm_send(struct tpm_chip *chip, u8 *buf, size_t count) |
75 | { | 77 | { |
76 | struct tpm_private *priv = TPM_VPRIV(chip); | 78 | struct tpm_private *priv = dev_get_drvdata(&chip->dev); |
77 | struct vtpm_shared_page *shr = priv->shr; | 79 | struct vtpm_shared_page *shr = priv->shr; |
78 | unsigned int offset = shr_data_offset(shr); | 80 | unsigned int offset = shr_data_offset(shr); |
79 | 81 | ||
@@ -87,8 +89,8 @@ static int vtpm_send(struct tpm_chip *chip, u8 *buf, size_t count) | |||
87 | return -EINVAL; | 89 | return -EINVAL; |
88 | 90 | ||
89 | /* Wait for completion of any existing command or cancellation */ | 91 | /* Wait for completion of any existing command or cancellation */ |
90 | if (wait_for_tpm_stat(chip, VTPM_STATUS_IDLE, chip->vendor.timeout_c, | 92 | if (wait_for_tpm_stat(chip, VTPM_STATUS_IDLE, chip->timeout_c, |
91 | &chip->vendor.read_queue, true) < 0) { | 93 | &priv->read_queue, true) < 0) { |
92 | vtpm_cancel(chip); | 94 | vtpm_cancel(chip); |
93 | return -ETIME; | 95 | return -ETIME; |
94 | } | 96 | } |
@@ -104,7 +106,7 @@ static int vtpm_send(struct tpm_chip *chip, u8 *buf, size_t count) | |||
104 | duration = tpm_calc_ordinal_duration(chip, ordinal); | 106 | duration = tpm_calc_ordinal_duration(chip, ordinal); |
105 | 107 | ||
106 | if (wait_for_tpm_stat(chip, VTPM_STATUS_IDLE, duration, | 108 | if (wait_for_tpm_stat(chip, VTPM_STATUS_IDLE, duration, |
107 | &chip->vendor.read_queue, true) < 0) { | 109 | &priv->read_queue, true) < 0) { |
108 | /* got a signal or timeout, try to cancel */ | 110 | /* got a signal or timeout, try to cancel */ |
109 | vtpm_cancel(chip); | 111 | vtpm_cancel(chip); |
110 | return -ETIME; | 112 | return -ETIME; |
@@ -115,7 +117,7 @@ static int vtpm_send(struct tpm_chip *chip, u8 *buf, size_t count) | |||
115 | 117 | ||
116 | static int vtpm_recv(struct tpm_chip *chip, u8 *buf, size_t count) | 118 | static int vtpm_recv(struct tpm_chip *chip, u8 *buf, size_t count) |
117 | { | 119 | { |
118 | struct tpm_private *priv = TPM_VPRIV(chip); | 120 | struct tpm_private *priv = dev_get_drvdata(&chip->dev); |
119 | struct vtpm_shared_page *shr = priv->shr; | 121 | struct vtpm_shared_page *shr = priv->shr; |
120 | unsigned int offset = shr_data_offset(shr); | 122 | unsigned int offset = shr_data_offset(shr); |
121 | size_t length = shr->length; | 123 | size_t length = shr->length; |
@@ -124,8 +126,8 @@ static int vtpm_recv(struct tpm_chip *chip, u8 *buf, size_t count) | |||
124 | return -ECANCELED; | 126 | return -ECANCELED; |
125 | 127 | ||
126 | /* In theory the wait at the end of _send makes this one unnecessary */ | 128 | /* In theory the wait at the end of _send makes this one unnecessary */ |
127 | if (wait_for_tpm_stat(chip, VTPM_STATUS_RESULT, chip->vendor.timeout_c, | 129 | if (wait_for_tpm_stat(chip, VTPM_STATUS_RESULT, chip->timeout_c, |
128 | &chip->vendor.read_queue, true) < 0) { | 130 | &priv->read_queue, true) < 0) { |
129 | vtpm_cancel(chip); | 131 | vtpm_cancel(chip); |
130 | return -ETIME; | 132 | return -ETIME; |
131 | } | 133 | } |
@@ -161,7 +163,7 @@ static irqreturn_t tpmif_interrupt(int dummy, void *dev_id) | |||
161 | switch (priv->shr->state) { | 163 | switch (priv->shr->state) { |
162 | case VTPM_STATE_IDLE: | 164 | case VTPM_STATE_IDLE: |
163 | case VTPM_STATE_FINISH: | 165 | case VTPM_STATE_FINISH: |
164 | wake_up_interruptible(&priv->chip->vendor.read_queue); | 166 | wake_up_interruptible(&priv->read_queue); |
165 | break; | 167 | break; |
166 | case VTPM_STATE_SUBMIT: | 168 | case VTPM_STATE_SUBMIT: |
167 | case VTPM_STATE_CANCEL: | 169 | case VTPM_STATE_CANCEL: |
@@ -179,10 +181,10 @@ static int setup_chip(struct device *dev, struct tpm_private *priv) | |||
179 | if (IS_ERR(chip)) | 181 | if (IS_ERR(chip)) |
180 | return PTR_ERR(chip); | 182 | return PTR_ERR(chip); |
181 | 183 | ||
182 | init_waitqueue_head(&chip->vendor.read_queue); | 184 | init_waitqueue_head(&priv->read_queue); |
183 | 185 | ||
184 | priv->chip = chip; | 186 | priv->chip = chip; |
185 | TPM_VPRIV(chip) = priv; | 187 | dev_set_drvdata(&chip->dev, priv); |
186 | 188 | ||
187 | return 0; | 189 | return 0; |
188 | } | 190 | } |
@@ -217,7 +219,7 @@ static int setup_ring(struct xenbus_device *dev, struct tpm_private *priv) | |||
217 | xenbus_dev_fatal(dev, rv, "allocating TPM irq"); | 219 | xenbus_dev_fatal(dev, rv, "allocating TPM irq"); |
218 | return rv; | 220 | return rv; |
219 | } | 221 | } |
220 | priv->chip->vendor.irq = rv; | 222 | priv->irq = rv; |
221 | 223 | ||
222 | again: | 224 | again: |
223 | rv = xenbus_transaction_start(&xbt); | 225 | rv = xenbus_transaction_start(&xbt); |
@@ -277,8 +279,8 @@ static void ring_free(struct tpm_private *priv) | |||
277 | else | 279 | else |
278 | free_page((unsigned long)priv->shr); | 280 | free_page((unsigned long)priv->shr); |
279 | 281 | ||
280 | if (priv->chip && priv->chip->vendor.irq) | 282 | if (priv->irq) |
281 | unbind_from_irqhandler(priv->chip->vendor.irq, priv); | 283 | unbind_from_irqhandler(priv->irq, priv); |
282 | 284 | ||
283 | kfree(priv); | 285 | kfree(priv); |
284 | } | 286 | } |
@@ -318,10 +320,10 @@ static int tpmfront_probe(struct xenbus_device *dev, | |||
318 | static int tpmfront_remove(struct xenbus_device *dev) | 320 | static int tpmfront_remove(struct xenbus_device *dev) |
319 | { | 321 | { |
320 | struct tpm_chip *chip = dev_get_drvdata(&dev->dev); | 322 | struct tpm_chip *chip = dev_get_drvdata(&dev->dev); |
321 | struct tpm_private *priv = TPM_VPRIV(chip); | 323 | struct tpm_private *priv = dev_get_drvdata(&chip->dev); |
322 | tpm_chip_unregister(chip); | 324 | tpm_chip_unregister(chip); |
323 | ring_free(priv); | 325 | ring_free(priv); |
324 | TPM_VPRIV(chip) = NULL; | 326 | dev_set_drvdata(&chip->dev, NULL); |
325 | return 0; | 327 | return 0; |
326 | } | 328 | } |
327 | 329 | ||