aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/char/tpm/tpm.c32
-rw-r--r--drivers/char/tpm/tpm.h1
-rw-r--r--drivers/char/tpm/tpm_atmel.c1
-rw-r--r--drivers/char/tpm/tpm_nsc.c1
4 files changed, 23 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
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index a3ff4dc5bdb3..714cb16b32cb 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -49,6 +49,7 @@ struct tpm_chip;
49struct tpm_vendor_specific { 49struct tpm_vendor_specific {
50 u8 req_complete_mask; 50 u8 req_complete_mask;
51 u8 req_complete_val; 51 u8 req_complete_val;
52 u8 req_canceled;
52 u16 base; /* TPM base address */ 53 u16 base; /* TPM base address */
53 54
54 int (*recv) (struct tpm_chip *, u8 *, size_t); 55 int (*recv) (struct tpm_chip *, u8 *, size_t);
diff --git a/drivers/char/tpm/tpm_atmel.c b/drivers/char/tpm/tpm_atmel.c
index 07abfb7143b1..68974577a6a6 100644
--- a/drivers/char/tpm/tpm_atmel.c
+++ b/drivers/char/tpm/tpm_atmel.c
@@ -147,6 +147,7 @@ static struct tpm_vendor_specific tpm_atmel = {
147 .cancel = tpm_atml_cancel, 147 .cancel = tpm_atml_cancel,
148 .req_complete_mask = ATML_STATUS_BUSY | ATML_STATUS_DATA_AVAIL, 148 .req_complete_mask = ATML_STATUS_BUSY | ATML_STATUS_DATA_AVAIL,
149 .req_complete_val = ATML_STATUS_DATA_AVAIL, 149 .req_complete_val = ATML_STATUS_DATA_AVAIL,
150 .req_canceled = ATML_STATUS_READY,
150 .base = TPM_ATML_BASE, 151 .base = TPM_ATML_BASE,
151 .attr_group = &atmel_attr_grp, 152 .attr_group = &atmel_attr_grp,
152 .miscdev = { .fops = &atmel_ops, }, 153 .miscdev = { .fops = &atmel_ops, },
diff --git a/drivers/char/tpm/tpm_nsc.c b/drivers/char/tpm/tpm_nsc.c
index 675290169508..37bea14f9310 100644
--- a/drivers/char/tpm/tpm_nsc.c
+++ b/drivers/char/tpm/tpm_nsc.c
@@ -245,6 +245,7 @@ static struct tpm_vendor_specific tpm_nsc = {
245 .cancel = tpm_nsc_cancel, 245 .cancel = tpm_nsc_cancel,
246 .req_complete_mask = NSC_STATUS_OBF, 246 .req_complete_mask = NSC_STATUS_OBF,
247 .req_complete_val = NSC_STATUS_OBF, 247 .req_complete_val = NSC_STATUS_OBF,
248 .req_canceled = NSC_STATUS_RDY,
248 .base = TPM_NSC_BASE, 249 .base = TPM_NSC_BASE,
249 .attr_group = &nsc_attr_grp, 250 .attr_group = &nsc_attr_grp,
250 .miscdev = { .fops = &nsc_ops, }, 251 .miscdev = { .fops = &nsc_ops, },