diff options
author | Nishanth Aravamudan <nacc@us.ibm.com> | 2005-06-24 01:01:47 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-06-24 03:05:24 -0400 |
commit | 700d8bdcd0fa815b08638b1e4d43b66d60cc6a8d (patch) | |
tree | c3defbf1cb77b9290a002cff04e1b2f054dfcb05 /drivers/char/tpm/tpm_nsc.c | |
parent | 6a94f9209762a6eb286f668e1346ad87985cc765 (diff) |
[PATCH] char/tpm: use msleep(), clean-up timers,
The TPM driver unnecessarily uses timers when it simply needs to maintain a
maximum delay via time_before(). msleep() is used instead of
schedule_timeout() to guarantee the task delays as expected. While
compile-testing, I found a typo in the driver, using tpm_chp instead of
tpm_chip. Remove the now unused timer callback function and change
TPM_TIMEOUT's units to milliseconds. Patch is compile-tested.
Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
Acked-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_nsc.c')
-rw-r--r-- | drivers/char/tpm/tpm_nsc.c | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/drivers/char/tpm/tpm_nsc.c b/drivers/char/tpm/tpm_nsc.c index 9cce833a0923..6e5ffcacea60 100644 --- a/drivers/char/tpm/tpm_nsc.c +++ b/drivers/char/tpm/tpm_nsc.c | |||
@@ -55,10 +55,7 @@ | |||
55 | */ | 55 | */ |
56 | static int wait_for_stat(struct tpm_chip *chip, u8 mask, u8 val, u8 * data) | 56 | static int wait_for_stat(struct tpm_chip *chip, u8 mask, u8 val, u8 * data) |
57 | { | 57 | { |
58 | int expired = 0; | 58 | unsigned long stop; |
59 | struct timer_list status_timer = | ||
60 | TIMER_INITIALIZER(tpm_time_expired, jiffies + 10 * HZ, | ||
61 | (unsigned long) &expired); | ||
62 | 59 | ||
63 | /* status immediately available check */ | 60 | /* status immediately available check */ |
64 | *data = inb(chip->vendor->base + NSC_STATUS); | 61 | *data = inb(chip->vendor->base + NSC_STATUS); |
@@ -66,17 +63,14 @@ static int wait_for_stat(struct tpm_chip *chip, u8 mask, u8 val, u8 * data) | |||
66 | return 0; | 63 | return 0; |
67 | 64 | ||
68 | /* wait for status */ | 65 | /* wait for status */ |
69 | add_timer(&status_timer); | 66 | stop = jiffies + 10 * HZ; |
70 | do { | 67 | do { |
71 | set_current_state(TASK_UNINTERRUPTIBLE); | 68 | msleep(TPM_TIMEOUT); |
72 | schedule_timeout(TPM_TIMEOUT); | ||
73 | *data = inb(chip->vendor->base + 1); | 69 | *data = inb(chip->vendor->base + 1); |
74 | if ((*data & mask) == val) { | 70 | if ((*data & mask) == val) |
75 | del_singleshot_timer_sync(&status_timer); | ||
76 | return 0; | 71 | return 0; |
77 | } | ||
78 | } | 72 | } |
79 | while (!expired); | 73 | while (time_before(jiffies, stop)); |
80 | 74 | ||
81 | return -EBUSY; | 75 | return -EBUSY; |
82 | } | 76 | } |
@@ -84,10 +78,7 @@ static int wait_for_stat(struct tpm_chip *chip, u8 mask, u8 val, u8 * data) | |||
84 | static int nsc_wait_for_ready(struct tpm_chip *chip) | 78 | static int nsc_wait_for_ready(struct tpm_chip *chip) |
85 | { | 79 | { |
86 | int status; | 80 | int status; |
87 | int expired = 0; | 81 | unsigned long stop; |
88 | struct timer_list status_timer = | ||
89 | TIMER_INITIALIZER(tpm_time_expired, jiffies + 100, | ||
90 | (unsigned long) &expired); | ||
91 | 82 | ||
92 | /* status immediately available check */ | 83 | /* status immediately available check */ |
93 | status = inb(chip->vendor->base + NSC_STATUS); | 84 | status = inb(chip->vendor->base + NSC_STATUS); |
@@ -97,19 +88,16 @@ static int nsc_wait_for_ready(struct tpm_chip *chip) | |||
97 | return 0; | 88 | return 0; |
98 | 89 | ||
99 | /* wait for status */ | 90 | /* wait for status */ |
100 | add_timer(&status_timer); | 91 | stop = jiffies + 100; |
101 | do { | 92 | do { |
102 | set_current_state(TASK_UNINTERRUPTIBLE); | 93 | msleep(TPM_TIMEOUT); |
103 | schedule_timeout(TPM_TIMEOUT); | ||
104 | status = inb(chip->vendor->base + NSC_STATUS); | 94 | status = inb(chip->vendor->base + NSC_STATUS); |
105 | if (status & NSC_STATUS_OBF) | 95 | if (status & NSC_STATUS_OBF) |
106 | status = inb(chip->vendor->base + NSC_DATA); | 96 | status = inb(chip->vendor->base + NSC_DATA); |
107 | if (status & NSC_STATUS_RDY) { | 97 | if (status & NSC_STATUS_RDY) |
108 | del_singleshot_timer_sync(&status_timer); | ||
109 | return 0; | 98 | return 0; |
110 | } | ||
111 | } | 99 | } |
112 | while (!expired); | 100 | while (time_before(jiffies, stop)); |
113 | 101 | ||
114 | dev_info(&chip->pci_dev->dev, "wait for ready failed\n"); | 102 | dev_info(&chip->pci_dev->dev, "wait for ready failed\n"); |
115 | return -EBUSY; | 103 | return -EBUSY; |