]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
[PATCH] tpm: add status function to allow non-lpc bus chips
authorKylene Jo Hall <kjhall@us.ibm.com>
Sun, 30 Oct 2005 23:03:23 +0000 (15:03 -0800)
committerLinus Torvalds <torvalds@g5.osdl.org>
Mon, 31 Oct 2005 01:37:28 +0000 (17:37 -0800)
This patch is in preparation of supporting chips that are not necessarily on
the lpc bus and thus are not accessed with inb's and outb's.  The patch
replaces the call to get the chip's status in the tpm.c file with a vendor
specific status function.  The patch also defines the function for each of the
current supported devices.

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
drivers/char/tpm/tpm_atmel.c
drivers/char/tpm/tpm_infineon.c
drivers/char/tpm/tpm_nsc.c

index 049d128ae7f07de2605cd5cd2e3d4c4efdba26ac..328f2a97916ee1f0a32f1028e9310762dd2ab262 100644 (file)
@@ -79,7 +79,7 @@ static ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
 
        stop = jiffies + 2 * 60 * HZ;
        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) {
                        goto out_recv;
index 373b41f6b4604168fc24b0e73c2eff2a8ec6aaca..ba70bf519fc9835b1e2c443aad68da443c20e3cb 100644 (file)
@@ -55,6 +55,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;
        struct attribute_group *attr_group;
 };
index c0d64914595fe182fb31bce1d8cc207fb19d66e4..96ab9003047c4e62f0672ee02c721a83264c3b3a 100644 (file)
@@ -118,6 +118,11 @@ static void tpm_atml_cancel(struct tpm_chip *chip)
        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,
@@ -146,6 +151,7 @@ static struct tpm_vendor_specific tpm_atmel = {
        .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,
        .req_canceled = ATML_STATUS_READY,
index 939e51e119e62bb63665afbf4591887861e5ea33..5b2ed539c26f8dae12165cbbad303a2b2727e550 100644 (file)
@@ -316,6 +316,11 @@ static void tpm_inf_cancel(struct tpm_chip *chip)
         */
 }
 
+static u8 tpm_inf_status(struct tpm_chip *chip)
+{
+       return inb(chip->vendor->base + 1);
+}
+
 static DEVICE_ATTR(pubek, S_IRUGO, tpm_show_pubek, NULL);
 static DEVICE_ATTR(pcrs, S_IRUGO, tpm_show_pcrs, NULL);
 static DEVICE_ATTR(caps, S_IRUGO, tpm_show_caps, NULL);
@@ -344,6 +349,7 @@ static struct tpm_vendor_specific tpm_inf = {
        .recv = tpm_inf_recv,
        .send = tpm_inf_send,
        .cancel = tpm_inf_cancel,
+       .status = tpm_inf_status,
        .req_complete_mask = 0,
        .req_complete_val = 0,
        .attr_group = &inf_attr_grp,
index b4127348c063279ada48d3af60056e036318ae45..bf3e774c4dce5013ee70129b30a3110965bc60a1 100644 (file)
@@ -220,6 +220,11 @@ static void tpm_nsc_cancel(struct tpm_chip *chip)
        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,
@@ -248,6 +253,7 @@ static struct tpm_vendor_specific tpm_nsc = {
        .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,
        .req_canceled = NSC_STATUS_RDY,