linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / drivers / char / tpm / tpm_atmel.c
index ad8ffe4..ff36549 100644 (file)
@@ -47,12 +47,12 @@ static int tpm_atml_recv(struct tpm_chip *chip, u8 *buf, size_t count)
                return -EIO;
 
        for (i = 0; i < 6; i++) {
-               status = ioread8(chip->vendor.iobase + 1);
+               status = ioread8(chip->vendor->iobase + 1);
                if ((status & ATML_STATUS_DATA_AVAIL) == 0) {
                        dev_err(chip->dev, "error reading header\n");
                        return -EIO;
                }
-               *buf++ = ioread8(chip->vendor.iobase);
+               *buf++ = ioread8(chip->vendor->iobase);
        }
 
        /* size of the data received */
@@ -63,7 +63,7 @@ static int tpm_atml_recv(struct tpm_chip *chip, u8 *buf, size_t count)
                dev_err(chip->dev,
                        "Recv size(%d) less than available space\n", size);
                for (; i < size; i++) { /* clear the waiting data anyway */
-                       status = ioread8(chip->vendor.iobase + 1);
+                       status = ioread8(chip->vendor->iobase + 1);
                        if ((status & ATML_STATUS_DATA_AVAIL) == 0) {
                                dev_err(chip->dev, "error reading data\n");
                                return -EIO;
@@ -74,16 +74,16 @@ static int tpm_atml_recv(struct tpm_chip *chip, u8 *buf, size_t count)
 
        /* read all the data available */
        for (; i < size; i++) {
-               status = ioread8(chip->vendor.iobase + 1);
+               status = ioread8(chip->vendor->iobase + 1);
                if ((status & ATML_STATUS_DATA_AVAIL) == 0) {
                        dev_err(chip->dev, "error reading data\n");
                        return -EIO;
                }
-               *buf++ = ioread8(chip->vendor.iobase);
+               *buf++ = ioread8(chip->vendor->iobase);
        }
 
        /* make sure data available is gone */
-       status = ioread8(chip->vendor.iobase + 1);
+       status = ioread8(chip->vendor->iobase + 1);
 
        if (status & ATML_STATUS_DATA_AVAIL) {
                dev_err(chip->dev, "data available is stuck\n");
@@ -100,7 +100,7 @@ static int tpm_atml_send(struct tpm_chip *chip, u8 *buf, size_t count)
        dev_dbg(chip->dev, "tpm_atml_send:\n");
        for (i = 0; i < count; i++) {
                dev_dbg(chip->dev, "%d 0x%x(%d)\n",  i, buf[i], buf[i]);
-               iowrite8(buf[i], chip->vendor.iobase);
+               iowrite8(buf[i], chip->vendor->iobase);
        }
 
        return count;
@@ -108,15 +108,15 @@ static int tpm_atml_send(struct tpm_chip *chip, u8 *buf, size_t count)
 
 static void tpm_atml_cancel(struct tpm_chip *chip)
 {
-       iowrite8(ATML_STATUS_ABORT, chip->vendor.iobase + 1);
+       iowrite8(ATML_STATUS_ABORT, chip->vendor->iobase + 1);
 }
 
 static u8 tpm_atml_status(struct tpm_chip *chip)
 {
-       return ioread8(chip->vendor.iobase + 1);
+       return ioread8(chip->vendor->iobase + 1);
 }
 
-static const struct file_operations atmel_ops = {
+static struct file_operations atmel_ops = {
        .owner = THIS_MODULE,
        .llseek = no_llseek,
        .open = tpm_open,
@@ -140,7 +140,7 @@ static struct attribute* atmel_attrs[] = {
 
 static struct attribute_group atmel_attr_grp = { .attrs = atmel_attrs };
 
-static const struct tpm_vendor_specific tpm_atmel = {
+static struct tpm_vendor_specific tpm_atmel = {
        .recv = tpm_atml_recv,
        .send = tpm_atml_send,
        .cancel = tpm_atml_cancel,
@@ -159,10 +159,10 @@ static void atml_plat_remove(void)
        struct tpm_chip *chip = dev_get_drvdata(&pdev->dev);
 
        if (chip) {
-               if (chip->vendor.have_region)
-                       atmel_release_region(chip->vendor.base,
-                                            chip->vendor.region_size);
-               atmel_put_base_addr(chip->vendor.iobase);
+               if (chip->vendor->have_region)
+                       atmel_release_region(chip->vendor->base,
+                                            chip->vendor->region_size);
+               atmel_put_base_addr(chip->vendor);
                tpm_remove_hardware(chip->dev);
                platform_device_unregister(pdev);
        }
@@ -179,22 +179,18 @@ static struct device_driver atml_drv = {
 static int __init init_atmel(void)
 {
        int rc = 0;
-       void __iomem *iobase = NULL;
-       int have_region, region_size;
-       unsigned long base;
-       struct  tpm_chip *chip;
 
        driver_register(&atml_drv);
 
-       if ((iobase = atmel_get_base_addr(&base, &region_size)) == NULL) {
+       if ((tpm_atmel.iobase = atmel_get_base_addr(&tpm_atmel)) == NULL) {
                rc = -ENODEV;
                goto err_unreg_drv;
        }
 
-       have_region =
+       tpm_atmel.have_region =
            (atmel_request_region
-            (tpm_atmel.base, region_size, "tpm_atmel0") == NULL) ? 0 : 1;
-
+            (tpm_atmel.base, tpm_atmel.region_size,
+             "tpm_atmel0") == NULL) ? 0 : 1;
 
        if (IS_ERR
            (pdev =
@@ -203,25 +199,17 @@ static int __init init_atmel(void)
                goto err_rel_reg;
        }
 
-       if (!(chip = tpm_register_hardware(&pdev->dev, &tpm_atmel))) {
-               rc = -ENODEV;
+       if ((rc = tpm_register_hardware(&pdev->dev, &tpm_atmel)) < 0)
                goto err_unreg_dev;
-       }
-
-       chip->vendor.iobase = iobase;
-       chip->vendor.base = base;
-       chip->vendor.have_region = have_region;
-       chip->vendor.region_size = region_size;
-
        return 0;
 
 err_unreg_dev:
        platform_device_unregister(pdev);
 err_rel_reg:
-       atmel_put_base_addr(iobase);
-       if (have_region)
-               atmel_release_region(base,
-                                    region_size);
+       atmel_put_base_addr(&tpm_atmel);
+       if (tpm_atmel.have_region)
+               atmel_release_region(tpm_atmel.base,
+                                    tpm_atmel.region_size);
 err_unreg_drv:
        driver_unregister(&atml_drv);
        return rc;