aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/tpm
diff options
context:
space:
mode:
authorKylene Hall <kjhall@us.ibm.com>2005-06-24 01:01:56 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-24 03:05:25 -0400
commitfe3fd48384af79e7619d3c6b0a020f801ef63c3b (patch)
tree1caf9ce5470e3a18b70547d9bb046ee379faebff /drivers/char/tpm
parent2df7111fc6b0e050b06123379821ece2f8dd5bbc (diff)
[PATCH] tpm: fix timer initialization
Fix the timer to be inited and modified properly. This work depends on the fixing of the msleep stuff which in patch 1 of this set. Signed-of-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')
-rw-r--r--drivers/char/tpm/tpm.c24
-rw-r--r--drivers/char/tpm/tpm.h2
2 files changed, 6 insertions, 20 deletions
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index 2035c15ffcce..f7fa3c3a51bd 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -434,16 +434,7 @@ int tpm_release(struct inode *inode, struct file *file)
434 434
435 spin_lock(&driver_lock); 435 spin_lock(&driver_lock);
436 chip->num_opens--; 436 chip->num_opens--;
437 spin_unlock(&driver_lock); 437 del_singleshot_timer_sync(&chip->user_read_timer);
438
439 down(&chip->timer_manipulation_mutex);
440 if (timer_pending(&chip->user_read_timer))
441 del_singleshot_timer_sync(&chip->user_read_timer);
442 else if (timer_pending(&chip->device_timer))
443 del_singleshot_timer_sync(&chip->device_timer);
444 up(&chip->timer_manipulation_mutex);
445
446 kfree(chip->data_buffer);
447 atomic_set(&chip->data_pending, 0); 438 atomic_set(&chip->data_pending, 0);
448 439
449 pci_dev_put(chip->pci_dev); 440 pci_dev_put(chip->pci_dev);
@@ -481,13 +472,7 @@ ssize_t tpm_write(struct file * file, const char __user * buf,
481 up(&chip->buffer_mutex); 472 up(&chip->buffer_mutex);
482 473
483 /* Set a timeout by which the reader must come claim the result */ 474 /* Set a timeout by which the reader must come claim the result */
484 down(&chip->timer_manipulation_mutex); 475 mod_timer(&chip->user_read_timer, jiffies + (60 * HZ));
485 init_timer(&chip->user_read_timer);
486 chip->user_read_timer.function = user_reader_timeout;
487 chip->user_read_timer.data = (unsigned long) chip;
488 chip->user_read_timer.expires = jiffies + (60 * HZ);
489 add_timer(&chip->user_read_timer);
490 up(&chip->timer_manipulation_mutex);
491 476
492 return in_size; 477 return in_size;
493} 478}
@@ -617,9 +602,12 @@ int tpm_register_hardware(struct pci_dev *pci_dev,
617 602
618 init_MUTEX(&chip->buffer_mutex); 603 init_MUTEX(&chip->buffer_mutex);
619 init_MUTEX(&chip->tpm_mutex); 604 init_MUTEX(&chip->tpm_mutex);
620 init_MUTEX(&chip->timer_manipulation_mutex);
621 INIT_LIST_HEAD(&chip->list); 605 INIT_LIST_HEAD(&chip->list);
622 606
607 init_timer(&chip->user_read_timer);
608 chip->user_read_timer.function = user_reader_timeout;
609 chip->user_read_timer.data = (unsigned long) chip;
610
623 chip->vendor = entry; 611 chip->vendor = entry;
624 612
625 chip->dev_num = -1; 613 chip->dev_num = -1;
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index 1a94a8c345e0..3a5af7e06624 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -63,8 +63,6 @@ struct tpm_chip {
63 63
64 struct timer_list user_read_timer; /* user needs to claim result */ 64 struct timer_list user_read_timer; /* user needs to claim result */
65 struct semaphore tpm_mutex; /* tpm is processing */ 65 struct semaphore tpm_mutex; /* tpm is processing */
66 struct timer_list device_timer; /* tpm is processing */
67 struct semaphore timer_manipulation_mutex;
68 66
69 struct tpm_vendor_specific *vendor; 67 struct tpm_vendor_specific *vendor;
70 68