aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/tpm/tpm.c
diff options
context:
space:
mode:
authorKylene Hall <kjhall@us.ibm.com>2005-06-24 01:02:02 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-24 03:05:26 -0400
commitd9e5b6bf9cf19e6e9f2825228136ea17bc9a051a (patch)
tree4261c5ec342c9cdd56b214a9f1eb4c4b83465733 /drivers/char/tpm/tpm.c
parent6659ca2ab6730c3bbb9fa495f2327b95b955decd (diff)
[PATCH] tpm: add cancel function
This patch provides the logic to check if an operation has been canceled while waiting for the response to arrive. Signed-off-by: Kylene Hall <kjhall@us.ibm.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/char/tpm/tpm.c')
-rw-r--r--drivers/char/tpm/tpm.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index b72050c851d2..e7c1dedfe448 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -141,7 +141,7 @@ EXPORT_SYMBOL_GPL(tpm_lpc_bus_init);
141static ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf, 141static ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
142 size_t bufsiz) 142 size_t bufsiz)
143{ 143{
144 ssize_t len; 144 ssize_t rc;
145 u32 count; 145 u32 count;
146 unsigned long stop; 146 unsigned long stop;
147 147
@@ -157,10 +157,10 @@ static ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
157 157
158 down(&chip->tpm_mutex); 158 down(&chip->tpm_mutex);
159 159
160 if ((len = chip->vendor->send(chip, (u8 *) buf, count)) < 0) { 160 if ((rc = chip->vendor->send(chip, (u8 *) buf, count)) < 0) {
161 dev_err(&chip->pci_dev->dev, 161 dev_err(&chip->pci_dev->dev,
162 "tpm_transmit: tpm_send: error %zd\n", len); 162 "tpm_transmit: tpm_send: error %zd\n", rc);
163 return len; 163 goto out;
164 } 164 }
165 165
166 stop = jiffies + 2 * 60 * HZ; 166 stop = jiffies + 2 * 60 * HZ;
@@ -170,23 +170,31 @@ static ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
170 chip->vendor->req_complete_val) { 170 chip->vendor->req_complete_val) {
171 goto out_recv; 171 goto out_recv;
172 } 172 }
173 msleep(TPM_TIMEOUT); /* CHECK */ 173
174 if ((status == chip->vendor->req_canceled)) {
175 dev_err(&chip->pci_dev->dev, "Operation Canceled\n");
176 rc = -ECANCELED;
177 goto out;
178 }
179
180 msleep(TPM_TIMEOUT); /* CHECK */
174 rmb(); 181 rmb();
175 } while (time_before(jiffies, stop)); 182 } while (time_before(jiffies, stop));
176 183
177 184
178 chip->vendor->cancel(chip); 185 chip->vendor->cancel(chip);
179 dev_err(&chip->pci_dev->dev, "Time expired\n"); 186 dev_err(&chip->pci_dev->dev, "Operation Timed out\n");
180 up(&chip->tpm_mutex); 187 rc = -ETIME;
181 return -EIO; 188 goto out;
182 189
183out_recv: 190out_recv:
184 len = chip->vendor->recv(chip, (u8 *) buf, bufsiz); 191 rc = chip->vendor->recv(chip, (u8 *) buf, bufsiz);
185 if (len < 0) 192 if (rc < 0)
186 dev_err(&chip->pci_dev->dev, 193 dev_err(&chip->pci_dev->dev,
187 "tpm_transmit: tpm_recv: error %zd\n", len); 194 "tpm_transmit: tpm_recv: error %zd\n", rc);
195out:
188 up(&chip->tpm_mutex); 196 up(&chip->tpm_mutex);
189 return len; 197 return rc;
190} 198}
191 199
192#define TPM_DIGEST_SIZE 20 200#define TPM_DIGEST_SIZE 20