[PATCH] tpm: locking fix
authorKylene Jo Hall <kjhall@us.ibm.com>
Mon, 14 Nov 2005 00:07:43 +0000 (16:07 -0800)
committerLinus Torvalds <torvalds@g5.osdl.org>
Mon, 14 Nov 2005 02:14:17 +0000 (18:14 -0800)
Use schedule_work() to avoid down()-in-timer-handler problem.

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>
drivers/char/tpm/tpm.c
drivers/char/tpm/tpm.h

index 1a53da99b58fc8af06640dc9fe2a9333dae9c689..0b283d246730b051afcc2c4d1ce76f5e1f0deb78 100644 (file)
@@ -43,6 +43,13 @@ static void user_reader_timeout(unsigned long ptr)
 {
        struct tpm_chip *chip = (struct tpm_chip *) ptr;
 
+       schedule_work(&chip->work);
+}
+
+static void timeout_work(void * ptr)
+{
+       struct tpm_chip *chip = ptr;
+
        down(&chip->buffer_mutex);
        atomic_set(&chip->data_pending, 0);
        memset(chip->data_buffer, 0, TPM_BUFSIZE);
@@ -527,6 +534,8 @@ int tpm_register_hardware(struct device *dev, struct tpm_vendor_specific *entry)
        init_MUTEX(&chip->tpm_mutex);
        INIT_LIST_HEAD(&chip->list);
 
+       INIT_WORK(&chip->work, timeout_work, chip);
+
        init_timer(&chip->user_read_timer);
        chip->user_read_timer.function = user_reader_timeout;
        chip->user_read_timer.data = (unsigned long) chip;
index ad51c6538034ed73c8c8575cc5864215ea460956..159882ca69dd03bdd18ce991b9b01428c48ee4be 100644 (file)
@@ -77,6 +77,7 @@ struct tpm_chip {
        struct semaphore buffer_mutex;
 
        struct timer_list user_read_timer;      /* user needs to claim result */
+       struct work_struct work;
        struct semaphore tpm_mutex;     /* tpm is processing */
 
        struct tpm_vendor_specific *vendor;