This patch puts in the missing up call on the tpm_mutex on an 
error condition in the tpm_transmit function.  Bug reported by Stefan 
Berger <[EMAIL PROTECTED]>.  This patch also implements a new status 
function to handle future chip configurations which may generate status 
differntly. 

Thanks,
Kylie
  
Signed-off-by: Kylene Hall <[EMAIL PROTECTED]>
---
diff -uprN linux-2.6.10/drivers/char/tpm/tpm_atmel.c 
linux-2.6.10-tpm/drivers/char/tpm/tpm_atmel.c
--- linux-2.6.10/drivers/char/tpm/tpm_atmel.c   2005-01-18 16:42:17.000000000 
-0600
+++ linux-2.6.10-tpm/drivers/char/tpm/tpm_atmel.c       2005-01-21 
13:11:11.000000000 -0600
@@ -112,6 +112,11 @@ static void tpm_atml_cancel(struct tpm_c
        outb(ATML_STATUS_ABORT, chip->vendor->base + 1);
 }
 
+static u8 tpm_atml_status(struct tpm_chip *chip)
+{
+       return inb( chip->vendor->base + 1);
+}
+
 static struct file_operations atmel_ops = {
        .owner = THIS_MODULE,
        .llseek = no_llseek,
@@ -125,6 +130,7 @@ static struct tpm_vendor_specific tpm_at
        .recv = tpm_atml_recv,
        .send = tpm_atml_send,
        .cancel = tpm_atml_cancel,
+       .status = tpm_atml_status,
        .req_complete_mask = ATML_STATUS_BUSY | ATML_STATUS_DATA_AVAIL,
        .req_complete_val = ATML_STATUS_DATA_AVAIL,
        .base = TPM_ATML_BASE,
diff -uprN linux-2.6.10/drivers/char/tpm/tpm.c 
linux-2.6.10-tpm/drivers/char/tpm/tpm.c
--- linux-2.6.10/drivers/char/tpm/tpm.c 2005-01-21 12:53:26.000000000 -0600
+++ linux-2.6.10-tpm/drivers/char/tpm/tpm.c     2005-01-28 16:28:45.578493680 
-0600
@@ -152,6 +151,7 @@ static ssize_t tpm_transmit(struct tpm_c
        if ((len = chip->vendor->send(chip, (u8 *) buf, count)) < 0) {
                dev_err(&chip->pci_dev->dev,
                        "tpm_transmit: tpm_send: error %d\n", len);
+               up(&chip->tpm_mutex);
                return len;
        }
 
@@ -165,7 +165,7 @@ static ssize_t tpm_transmit(struct tpm_c
        up(&chip->timer_manipulation_mutex);
 
        do {
-               u8 status = inb(chip->vendor->base + 1);
+               u8 status = chip->vendor->status(chip);
                if ((status & chip->vendor->req_complete_mask) ==
                    chip->vendor->req_complete_val) {
                        down(&chip->timer_manipulation_mutex);
diff -uprN linux-2.6.10/drivers/char/tpm/tpm.h 
linux-2.6.10-tpm/drivers/char/tpm/tpm.h
--- linux-2.6.10/drivers/char/tpm/tpm.h 2005-01-18 16:42:17.000000000 -0600
+++ linux-2.6.10-tpm/drivers/char/tpm/tpm.h     2005-01-21 13:10:20.000000000 
-0600
@@ -40,6 +40,7 @@ struct tpm_vendor_specific {
        int (*recv) (struct tpm_chip *, u8 *, size_t);
        int (*send) (struct tpm_chip *, u8 *, size_t);
        void (*cancel) (struct tpm_chip *);
+       u8 (*status) (struct tpm_chip *);
        struct miscdevice miscdev;
 };
 
diff -uprN linux-2.6.10/drivers/char/tpm/tpm_nsc.c 
linux-2.6.10-tpm/drivers/char/tpm/tpm_nsc.c
--- linux-2.6.10/drivers/char/tpm/tpm_nsc.c     2005-01-18 16:42:17.000000000 
-0600
+++ linux-2.6.10-tpm/drivers/char/tpm/tpm_nsc.c 2005-01-21 13:12:27.000000000 
-0600
@@ -219,6 +219,12 @@ static void tpm_nsc_cancel(struct tpm_ch
        outb(NSC_COMMAND_CANCEL, chip->vendor->base + NSC_COMMAND);
 }
 
+
+static u8 tpm_nsc_status(struct tpm_chip *chip)
+{
+       return inb(chip->vendor->base + NSC_STATUS);
+}
+
 static struct file_operations nsc_ops = {
        .owner = THIS_MODULE,
        .llseek = no_llseek,
@@ -232,6 +238,7 @@ static struct tpm_vendor_specific tpm_ns
        .recv = tpm_nsc_recv,
        .send = tpm_nsc_send,
        .cancel = tpm_nsc_cancel,
+       .status = tpm_nsc_status,
        .req_complete_mask = NSC_STATUS_OBF,
        .req_complete_val = NSC_STATUS_OBF,
        .base = TPM_NSC_BASE,
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to