[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>
diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index 0275930..1cb5a7f 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ b/drivers/char/tpm/tpm_tis.c
@@ -51,6 +51,11 @@
 	TPM_INTF_DATA_AVAIL_INT = 0x001,
 };
 
+enum tis_defaults {
+	TIS_SHORT_TIMEOUT = 750, /* ms */
+	TIS_LONG_TIMEOUT = 2000, /* 2 sec */
+};
+
 #define	TPM_ACCESS(l)			(0x0000 | ((l) << 12))
 #define	TPM_INT_ENABLE(l)		(0x0008 | ((l) << 12))
 #define	TPM_INT_VECTOR(l)		(0x000C | ((l) << 12))
@@ -96,19 +101,16 @@
 		 chip->vendor.iobase + TPM_ACCESS(l));
 
 	if (chip->vendor.irq) {
-		rc = wait_event_interruptible_timeout(chip->vendor.
-						      int_queue,
+		rc = wait_event_interruptible_timeout(chip->vendor.int_queue,
 						      (check_locality
 						       (chip, l) >= 0),
-						      msecs_to_jiffies
-						      (chip->vendor.
-						       timeout_a));
+						      chip->vendor.timeout_a);
 		if (rc > 0)
 			return l;
 
 	} else {
 		/* wait for burstcount */
-		stop = jiffies + (HZ * chip->vendor.timeout_a / 1000);
+		stop = jiffies + chip->vendor.timeout_a;
 		do {
 			if (check_locality(chip, l) >= 0)
 				return l;
@@ -139,7 +141,7 @@
 
 	/* wait for burstcount */
 	/* which timeout value, spec has 2 answers (c & d) */
-	stop = jiffies + (HZ * chip->vendor.timeout_d / 1000);
+	stop = jiffies + chip->vendor.timeout_d;
 	do {
 		burstcnt = ioread8(chip->vendor.iobase +
 				   TPM_STS(chip->vendor.locality) + 1);
@@ -153,7 +155,7 @@
 	return -EBUSY;
 }
 
-static int wait_for_stat(struct tpm_chip *chip, u8 mask, u32 timeout,
+static int wait_for_stat(struct tpm_chip *chip, u8 mask, unsigned long timeout,
 			 wait_queue_head_t *queue)
 {
 	unsigned long stop;
@@ -169,13 +171,11 @@
 		rc = wait_event_interruptible_timeout(*queue,
 						      ((tpm_tis_status
 							(chip) & mask) ==
-						       mask),
-						      msecs_to_jiffies
-						      (timeout));
+						       mask), timeout);
 		if (rc > 0)
 			return 0;
 	} else {
-		stop = jiffies + (HZ * timeout / 1000);
+		stop = jiffies + timeout;
 		do {
 			msleep(TPM_TIMEOUT);
 			status = tpm_tis_status(chip);
@@ -453,10 +453,10 @@
 	}
 
 	/* Default timeouts */
-	chip->vendor.timeout_a = 750;	/* ms */
-	chip->vendor.timeout_b = 2000;	/* 2 sec */
-	chip->vendor.timeout_c = 750;	/* ms */
-	chip->vendor.timeout_d = 750;	/* ms */
+	chip->vendor.timeout_a = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
+	chip->vendor.timeout_b = msecs_to_jiffies(TIS_LONG_TIMEOUT);
+	chip->vendor.timeout_c = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
+	chip->vendor.timeout_d = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
 
 	dev_info(&pnp_dev->dev,
 		 "1.2 TPM (device-id 0x%X, rev-id %d)\n",