linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / drivers / char / tpm / tpm_infineon.c
index 1353b5a..24095f6 100644 (file)
@@ -15,7 +15,6 @@
  * License.
  */
 
-#include <linux/init.h>
 #include <linux/pnp.h>
 #include "tpm.h"
 
@@ -105,7 +104,7 @@ static int empty_fifo(struct tpm_chip *chip, int clear_wrfifo)
 
        if (clear_wrfifo) {
                for (i = 0; i < 4096; i++) {
-                       status = inb(chip->vendor.base + WRFIFO);
+                       status = inb(chip->vendor->base + WRFIFO);
                        if (status == 0xff) {
                                if (check == 5)
                                        break;
@@ -125,8 +124,8 @@ static int empty_fifo(struct tpm_chip *chip, int clear_wrfifo)
         */
        i = 0;
        do {
-               status = inb(chip->vendor.base + RDFIFO);
-               status = inb(chip->vendor.base + STAT);
+               status = inb(chip->vendor->base + RDFIFO);
+               status = inb(chip->vendor->base + STAT);
                i++;
                if (i == TPM_MAX_TRIES)
                        return -EIO;
@@ -139,7 +138,7 @@ static int wait(struct tpm_chip *chip, int wait_for_bit)
        int status;
        int i;
        for (i = 0; i < TPM_MAX_TRIES; i++) {
-               status = inb(chip->vendor.base + STAT);
+               status = inb(chip->vendor->base + STAT);
                /* check the status-register if wait_for_bit is set */
                if (status & 1 << wait_for_bit)
                        break;
@@ -158,7 +157,7 @@ static int wait(struct tpm_chip *chip, int wait_for_bit)
 static void wait_and_send(struct tpm_chip *chip, u8 sendbyte)
 {
        wait(chip, STAT_XFE);
-       outb(sendbyte, chip->vendor.base + WRFIFO);
+       outb(sendbyte, chip->vendor->base + WRFIFO);
 }
 
     /* Note: WTX means Waiting-Time-Extension. Whenever the TPM needs more
@@ -205,7 +204,7 @@ recv_begin:
                ret = wait(chip, STAT_RDA);
                if (ret)
                        return -EIO;
-               buf[i] = inb(chip->vendor.base + RDFIFO);
+               buf[i] = inb(chip->vendor->base + RDFIFO);
        }
 
        if (buf[0] != TPM_VL_VER) {
@@ -220,7 +219,7 @@ recv_begin:
 
                for (i = 0; i < size; i++) {
                        wait(chip, STAT_RDA);
-                       buf[i] = inb(chip->vendor.base + RDFIFO);
+                       buf[i] = inb(chip->vendor->base + RDFIFO);
                }
 
                if ((size == 0x6D00) && (buf[1] == 0x80)) {
@@ -269,7 +268,7 @@ static int tpm_inf_send(struct tpm_chip *chip, u8 * buf, size_t count)
        u8 count_high, count_low, count_4, count_3, count_2, count_1;
 
        /* Disabling Reset, LP and IRQC */
-       outb(RESET_LP_IRQC_DISABLE, chip->vendor.base + CMD);
+       outb(RESET_LP_IRQC_DISABLE, chip->vendor->base + CMD);
 
        ret = empty_fifo(chip, 1);
        if (ret) {
@@ -320,7 +319,7 @@ static void tpm_inf_cancel(struct tpm_chip *chip)
 
 static u8 tpm_inf_status(struct tpm_chip *chip)
 {
-       return inb(chip->vendor.base + STAT);
+       return inb(chip->vendor->base + STAT);
 }
 
 static DEVICE_ATTR(pubek, S_IRUGO, tpm_show_pubek, NULL);
@@ -338,7 +337,7 @@ static struct attribute *inf_attrs[] = {
 
 static struct attribute_group inf_attr_grp = {.attrs = inf_attrs };
 
-static const struct file_operations inf_ops = {
+static struct file_operations inf_ops = {
        .owner = THIS_MODULE,
        .llseek = no_llseek,
        .open = tpm_open,
@@ -347,7 +346,7 @@ static const struct file_operations inf_ops = {
        .release = tpm_release,
 };
 
-static const struct tpm_vendor_specific tpm_inf = {
+static struct tpm_vendor_specific tpm_inf = {
        .recv = tpm_inf_recv,
        .send = tpm_inf_send,
        .cancel = tpm_inf_cancel,
@@ -376,7 +375,6 @@ static int __devinit tpm_inf_pnp_probe(struct pnp_dev *dev,
        int version[2];
        int productid[2];
        char chipname[20];
-       struct tpm_chip *chip;
 
        /* read IO-ports through PnP */
        if (pnp_port_valid(dev, 0) && pnp_port_valid(dev, 1) &&
@@ -397,13 +395,14 @@ static int __devinit tpm_inf_pnp_probe(struct pnp_dev *dev,
                        goto err_last;
                }
                /* publish my base address and request region */
+               tpm_inf.base = TPM_INF_BASE;
                if (request_region
-                   (TPM_INF_BASE, TPM_INF_PORT_LEN, "tpm_infineon0") == NULL) {
+                   (tpm_inf.base, TPM_INF_PORT_LEN, "tpm_infineon0") == NULL) {
                        rc = -EINVAL;
                        goto err_last;
                }
-               if (request_region
-                   (TPM_INF_ADDR, TPM_INF_ADDR_LEN, "tpm_infineon0") == NULL) {
+               if (request_region(TPM_INF_ADDR, TPM_INF_ADDR_LEN,
+                               "tpm_infineon0") == NULL) {
                        rc = -EINVAL;
                        goto err_last;
                }
@@ -443,9 +442,9 @@ static int __devinit tpm_inf_pnp_probe(struct pnp_dev *dev,
 
                /* configure TPM with IO-ports */
                outb(IOLIMH, TPM_INF_ADDR);
-               outb(((TPM_INF_BASE >> 8) & 0xff), TPM_INF_DATA);
+               outb(((tpm_inf.base >> 8) & 0xff), TPM_INF_DATA);
                outb(IOLIML, TPM_INF_ADDR);
-               outb((TPM_INF_BASE & 0xff), TPM_INF_DATA);
+               outb((tpm_inf.base & 0xff), TPM_INF_DATA);
 
                /* control if IO-ports are set correctly */
                outb(IOLIMH, TPM_INF_ADDR);
@@ -453,10 +452,10 @@ static int __devinit tpm_inf_pnp_probe(struct pnp_dev *dev,
                outb(IOLIML, TPM_INF_ADDR);
                iol = inb(TPM_INF_DATA);
 
-               if ((ioh << 8 | iol) != TPM_INF_BASE) {
+               if ((ioh << 8 | iol) != tpm_inf.base) {
                        dev_err(&dev->dev,
-                               "Could not set IO-ports to 0x%x\n",
-                               TPM_INF_BASE);
+                               "Could not set IO-ports to 0x%lx\n",
+                               tpm_inf.base);
                        rc = -EIO;
                        goto err_release_region;
                }
@@ -467,15 +466,15 @@ static int __devinit tpm_inf_pnp_probe(struct pnp_dev *dev,
                outb(DISABLE_REGISTER_PAIR, TPM_INF_ADDR);
 
                /* disable RESET, LP and IRQC */
-               outb(RESET_LP_IRQC_DISABLE, TPM_INF_BASE + CMD);
+               outb(RESET_LP_IRQC_DISABLE, tpm_inf.base + CMD);
 
                /* Finally, we're done, print some infos */
                dev_info(&dev->dev, "TPM found: "
                         "config base 0x%x, "
                         "io base 0x%x, "
-                        "chip version 0x%02x%02x, "
-                        "vendor id 0x%x%x (Infineon), "
-                        "product id 0x%02x%02x"
+                        "chip version %02x%02x, "
+                        "vendor id %x%x (Infineon), "
+                        "product id %02x%02x"
                         "%s\n",
                         TPM_INF_ADDR,
                         TPM_INF_BASE,
@@ -483,10 +482,11 @@ static int __devinit tpm_inf_pnp_probe(struct pnp_dev *dev,
                         vendorid[0], vendorid[1],
                         productid[0], productid[1], chipname);
 
-               if (!(chip = tpm_register_hardware(&dev->dev, &tpm_inf))) {
+               rc = tpm_register_hardware(&dev->dev, &tpm_inf);
+               if (rc < 0) {
+                       rc = -ENODEV;
                        goto err_release_region;
                }
-               chip->vendor.base = TPM_INF_BASE;
                return 0;
        } else {
                rc = -ENODEV;
@@ -494,7 +494,7 @@ static int __devinit tpm_inf_pnp_probe(struct pnp_dev *dev,
        }
 
 err_release_region:
-       release_region(TPM_INF_BASE, TPM_INF_PORT_LEN);
+       release_region(tpm_inf.base, TPM_INF_PORT_LEN);
        release_region(TPM_INF_ADDR, TPM_INF_ADDR_LEN);
 
 err_last:
@@ -506,8 +506,7 @@ static __devexit void tpm_inf_pnp_remove(struct pnp_dev *dev)
        struct tpm_chip *chip = pnp_get_drvdata(dev);
 
        if (chip) {
-               release_region(TPM_INF_BASE, TPM_INF_PORT_LEN);
-               release_region(TPM_INF_ADDR, TPM_INF_ADDR_LEN);
+               release_region(chip->vendor->base, TPM_INF_PORT_LEN);
                tpm_remove_hardware(chip->dev);
        }
 }
@@ -521,7 +520,7 @@ static struct pnp_driver tpm_inf_pnp = {
        },
        .id_table = tpm_pnp_tbl,
        .probe = tpm_inf_pnp_probe,
-       .remove = __devexit_p(tpm_inf_pnp_remove),
+       .remove = tpm_inf_pnp_remove,
 };
 
 static int __init init_inf(void)
@@ -539,5 +538,5 @@ module_exit(cleanup_inf);
 
 MODULE_AUTHOR("Marcel Selhorst <selhorst@crypto.rub.de>");
 MODULE_DESCRIPTION("Driver for Infineon TPM SLD 9630 TT 1.1 / SLB 9635 TT 1.2");
-MODULE_VERSION("1.8");
+MODULE_VERSION("1.7");
 MODULE_LICENSE("GPL");