aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/tpm/tpm_tis.c
diff options
context:
space:
mode:
authorKylene Jo Hall <kjhall@us.ibm.com>2006-04-22 05:38:19 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-04-22 12:19:54 -0400
commit36b20020e537036c4f9eb5b69140c88ead5da7dc (patch)
tree71a83d0da45630fe3c3a69c446823716164fbcc1 /drivers/char/tpm/tpm_tis.c
parent27084efee0c3dc0eb15b5ed750aa9f1adb3983c3 (diff)
[PATCH] tpm: msecs_to_jiffies cleanups
The timeout and duration values used in the tpm driver are not exposed to userspace. This patch converts the storage units to jiffies with msecs_to_jiffies. They were always being used in jiffies so this simplifies things removing the need for calculation all over the place. The change necessitated a type change in the tpm_chip struct to hold jiffies. Signed-off-by: Kylie 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_tis.c')
-rw-r--r--drivers/char/tpm/tpm_tis.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index 02759307f736..1cb5a7f0755d 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ b/drivers/char/tpm/tpm_tis.c
@@ -51,6 +51,11 @@ enum tis_int_flags {
51 TPM_INTF_DATA_AVAIL_INT = 0x001, 51 TPM_INTF_DATA_AVAIL_INT = 0x001,
52}; 52};
53 53
54enum tis_defaults {
55 TIS_SHORT_TIMEOUT = 750, /* ms */
56 TIS_LONG_TIMEOUT = 2000, /* 2 sec */
57};
58
54#define TPM_ACCESS(l) (0x0000 | ((l) << 12)) 59#define TPM_ACCESS(l) (0x0000 | ((l) << 12))
55#define TPM_INT_ENABLE(l) (0x0008 | ((l) << 12)) 60#define TPM_INT_ENABLE(l) (0x0008 | ((l) << 12))
56#define TPM_INT_VECTOR(l) (0x000C | ((l) << 12)) 61#define TPM_INT_VECTOR(l) (0x000C | ((l) << 12))
@@ -96,19 +101,16 @@ static int request_locality(struct tpm_chip *chip, int l)
96 chip->vendor.iobase + TPM_ACCESS(l)); 101 chip->vendor.iobase + TPM_ACCESS(l));
97 102
98 if (chip->vendor.irq) { 103 if (chip->vendor.irq) {
99 rc = wait_event_interruptible_timeout(chip->vendor. 104 rc = wait_event_interruptible_timeout(chip->vendor.int_queue,
100 int_queue,
101 (check_locality 105 (check_locality
102 (chip, l) >= 0), 106 (chip, l) >= 0),
103 msecs_to_jiffies 107 chip->vendor.timeout_a);
104 (chip->vendor.
105 timeout_a));
106 if (rc > 0) 108 if (rc > 0)
107 return l; 109 return l;
108 110
109 } else { 111 } else {
110 /* wait for burstcount */ 112 /* wait for burstcount */
111 stop = jiffies + (HZ * chip->vendor.timeout_a / 1000); 113 stop = jiffies + chip->vendor.timeout_a;
112 do { 114 do {
113 if (check_locality(chip, l) >= 0) 115 if (check_locality(chip, l) >= 0)
114 return l; 116 return l;
@@ -139,7 +141,7 @@ static int get_burstcount(struct tpm_chip *chip)
139 141
140 /* wait for burstcount */ 142 /* wait for burstcount */
141 /* which timeout value, spec has 2 answers (c & d) */ 143 /* which timeout value, spec has 2 answers (c & d) */
142 stop = jiffies + (HZ * chip->vendor.timeout_d / 1000); 144 stop = jiffies + chip->vendor.timeout_d;
143 do { 145 do {
144 burstcnt = ioread8(chip->vendor.iobase + 146 burstcnt = ioread8(chip->vendor.iobase +
145 TPM_STS(chip->vendor.locality) + 1); 147 TPM_STS(chip->vendor.locality) + 1);
@@ -153,7 +155,7 @@ static int get_burstcount(struct tpm_chip *chip)
153 return -EBUSY; 155 return -EBUSY;
154} 156}
155 157
156static int wait_for_stat(struct tpm_chip *chip, u8 mask, u32 timeout, 158static int wait_for_stat(struct tpm_chip *chip, u8 mask, unsigned long timeout,
157 wait_queue_head_t *queue) 159 wait_queue_head_t *queue)
158{ 160{
159 unsigned long stop; 161 unsigned long stop;
@@ -169,13 +171,11 @@ static int wait_for_stat(struct tpm_chip *chip, u8 mask, u32 timeout,
169 rc = wait_event_interruptible_timeout(*queue, 171 rc = wait_event_interruptible_timeout(*queue,
170 ((tpm_tis_status 172 ((tpm_tis_status
171 (chip) & mask) == 173 (chip) & mask) ==
172 mask), 174 mask), timeout);
173 msecs_to_jiffies
174 (timeout));
175 if (rc > 0) 175 if (rc > 0)
176 return 0; 176 return 0;
177 } else { 177 } else {
178 stop = jiffies + (HZ * timeout / 1000); 178 stop = jiffies + timeout;
179 do { 179 do {
180 msleep(TPM_TIMEOUT); 180 msleep(TPM_TIMEOUT);
181 status = tpm_tis_status(chip); 181 status = tpm_tis_status(chip);
@@ -453,10 +453,10 @@ static int __devinit tpm_tis_pnp_init(struct pnp_dev
453 } 453 }
454 454
455 /* Default timeouts */ 455 /* Default timeouts */
456 chip->vendor.timeout_a = 750; /* ms */ 456 chip->vendor.timeout_a = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
457 chip->vendor.timeout_b = 2000; /* 2 sec */ 457 chip->vendor.timeout_b = msecs_to_jiffies(TIS_LONG_TIMEOUT);
458 chip->vendor.timeout_c = 750; /* ms */ 458 chip->vendor.timeout_c = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
459 chip->vendor.timeout_d = 750; /* ms */ 459 chip->vendor.timeout_d = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
460 460
461 dev_info(&pnp_dev->dev, 461 dev_info(&pnp_dev->dev,
462 "1.2 TPM (device-id 0x%X, rev-id %d)\n", 462 "1.2 TPM (device-id 0x%X, rev-id %d)\n",