aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKylene Jo Hall <kjhall@us.ibm.com>2005-10-30 18:03:23 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2005-10-30 20:37:28 -0500
commitb4ed3e3cbb312869929cf4528d71e52629a6cacb (patch)
treed514dfb584eebf74f7d89d3cdd57618e55aaaeca
parent162a88f7b8539a097a088c0321ea1997cacccaea (diff)
[PATCH] tpm: add status function to allow non-lpc bus chips
This patch is in preparation of supporting chips that are not necessarily on the lpc bus and thus are not accessed with inb's and outb's. The patch replaces the call to get the chip's status in the tpm.c file with a vendor specific status function. The patch also defines the function for each of the current supported devices. 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>
-rw-r--r--drivers/char/tpm/tpm.c2
-rw-r--r--drivers/char/tpm/tpm.h1
-rw-r--r--drivers/char/tpm/tpm_atmel.c6
-rw-r--r--drivers/char/tpm/tpm_infineon.c6
-rw-r--r--drivers/char/tpm/tpm_nsc.c6
5 files changed, 20 insertions, 1 deletions
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index 049d128ae7f0..328f2a97916e 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -79,7 +79,7 @@ static ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
79 79
80 stop = jiffies + 2 * 60 * HZ; 80 stop = jiffies + 2 * 60 * HZ;
81 do { 81 do {
82 u8 status = inb(chip->vendor->base + 1); 82 u8 status = chip->vendor->status(chip);
83 if ((status & chip->vendor->req_complete_mask) == 83 if ((status & chip->vendor->req_complete_mask) ==
84 chip->vendor->req_complete_val) { 84 chip->vendor->req_complete_val) {
85 goto out_recv; 85 goto out_recv;
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index 373b41f6b460..ba70bf519fc9 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -55,6 +55,7 @@ struct tpm_vendor_specific {
55 int (*recv) (struct tpm_chip *, u8 *, size_t); 55 int (*recv) (struct tpm_chip *, u8 *, size_t);
56 int (*send) (struct tpm_chip *, u8 *, size_t); 56 int (*send) (struct tpm_chip *, u8 *, size_t);
57 void (*cancel) (struct tpm_chip *); 57 void (*cancel) (struct tpm_chip *);
58 u8 (*status) (struct tpm_chip *);
58 struct miscdevice miscdev; 59 struct miscdevice miscdev;
59 struct attribute_group *attr_group; 60 struct attribute_group *attr_group;
60}; 61};
diff --git a/drivers/char/tpm/tpm_atmel.c b/drivers/char/tpm/tpm_atmel.c
index c0d64914595f..96ab9003047c 100644
--- a/drivers/char/tpm/tpm_atmel.c
+++ b/drivers/char/tpm/tpm_atmel.c
@@ -118,6 +118,11 @@ static void tpm_atml_cancel(struct tpm_chip *chip)
118 outb(ATML_STATUS_ABORT, chip->vendor->base + 1); 118 outb(ATML_STATUS_ABORT, chip->vendor->base + 1);
119} 119}
120 120
121static u8 tpm_atml_status(struct tpm_chip *chip)
122{
123 return inb(chip->vendor->base + 1);
124}
125
121static struct file_operations atmel_ops = { 126static struct file_operations atmel_ops = {
122 .owner = THIS_MODULE, 127 .owner = THIS_MODULE,
123 .llseek = no_llseek, 128 .llseek = no_llseek,
@@ -146,6 +151,7 @@ static struct tpm_vendor_specific tpm_atmel = {
146 .recv = tpm_atml_recv, 151 .recv = tpm_atml_recv,
147 .send = tpm_atml_send, 152 .send = tpm_atml_send,
148 .cancel = tpm_atml_cancel, 153 .cancel = tpm_atml_cancel,
154 .status = tpm_atml_status,
149 .req_complete_mask = ATML_STATUS_BUSY | ATML_STATUS_DATA_AVAIL, 155 .req_complete_mask = ATML_STATUS_BUSY | ATML_STATUS_DATA_AVAIL,
150 .req_complete_val = ATML_STATUS_DATA_AVAIL, 156 .req_complete_val = ATML_STATUS_DATA_AVAIL,
151 .req_canceled = ATML_STATUS_READY, 157 .req_canceled = ATML_STATUS_READY,
diff --git a/drivers/char/tpm/tpm_infineon.c b/drivers/char/tpm/tpm_infineon.c
index 939e51e119e6..5b2ed539c26f 100644
--- a/drivers/char/tpm/tpm_infineon.c
+++ b/drivers/char/tpm/tpm_infineon.c
@@ -316,6 +316,11 @@ static void tpm_inf_cancel(struct tpm_chip *chip)
316 */ 316 */
317} 317}
318 318
319static u8 tpm_inf_status(struct tpm_chip *chip)
320{
321 return inb(chip->vendor->base + 1);
322}
323
319static DEVICE_ATTR(pubek, S_IRUGO, tpm_show_pubek, NULL); 324static DEVICE_ATTR(pubek, S_IRUGO, tpm_show_pubek, NULL);
320static DEVICE_ATTR(pcrs, S_IRUGO, tpm_show_pcrs, NULL); 325static DEVICE_ATTR(pcrs, S_IRUGO, tpm_show_pcrs, NULL);
321static DEVICE_ATTR(caps, S_IRUGO, tpm_show_caps, NULL); 326static DEVICE_ATTR(caps, S_IRUGO, tpm_show_caps, NULL);
@@ -344,6 +349,7 @@ static struct tpm_vendor_specific tpm_inf = {
344 .recv = tpm_inf_recv, 349 .recv = tpm_inf_recv,
345 .send = tpm_inf_send, 350 .send = tpm_inf_send,
346 .cancel = tpm_inf_cancel, 351 .cancel = tpm_inf_cancel,
352 .status = tpm_inf_status,
347 .req_complete_mask = 0, 353 .req_complete_mask = 0,
348 .req_complete_val = 0, 354 .req_complete_val = 0,
349 .attr_group = &inf_attr_grp, 355 .attr_group = &inf_attr_grp,
diff --git a/drivers/char/tpm/tpm_nsc.c b/drivers/char/tpm/tpm_nsc.c
index b4127348c063..bf3e774c4dce 100644
--- a/drivers/char/tpm/tpm_nsc.c
+++ b/drivers/char/tpm/tpm_nsc.c
@@ -220,6 +220,11 @@ static void tpm_nsc_cancel(struct tpm_chip *chip)
220 outb(NSC_COMMAND_CANCEL, chip->vendor->base + NSC_COMMAND); 220 outb(NSC_COMMAND_CANCEL, chip->vendor->base + NSC_COMMAND);
221} 221}
222 222
223static u8 tpm_nsc_status(struct tpm_chip *chip)
224{
225 return inb(chip->vendor->base + NSC_STATUS);
226}
227
223static struct file_operations nsc_ops = { 228static struct file_operations nsc_ops = {
224 .owner = THIS_MODULE, 229 .owner = THIS_MODULE,
225 .llseek = no_llseek, 230 .llseek = no_llseek,
@@ -248,6 +253,7 @@ static struct tpm_vendor_specific tpm_nsc = {
248 .recv = tpm_nsc_recv, 253 .recv = tpm_nsc_recv,
249 .send = tpm_nsc_send, 254 .send = tpm_nsc_send,
250 .cancel = tpm_nsc_cancel, 255 .cancel = tpm_nsc_cancel,
256 .status = tpm_nsc_status,
251 .req_complete_mask = NSC_STATUS_OBF, 257 .req_complete_mask = NSC_STATUS_OBF,
252 .req_complete_val = NSC_STATUS_OBF, 258 .req_complete_val = NSC_STATUS_OBF,
253 .req_canceled = NSC_STATUS_RDY, 259 .req_canceled = NSC_STATUS_RDY,