tpm: drop tpm_atmel specific fields from tpm_vendor_specific
authorJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Wed, 23 Mar 2016 05:10:22 +0000 (07:10 +0200)
committerJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Sat, 25 Jun 2016 14:26:35 +0000 (17:26 +0300)
Introduced a private struct tpm_atmel_priv that contains the variables
have_region and region_size that were previously located in struct
tpm_vendor_specific. These fields were only used by tpm_atmel.

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Reviewed-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
drivers/char/tpm/tpm.h
drivers/char/tpm/tpm_atmel.c
drivers/char/tpm/tpm_atmel.h

index f5e1846f4aaae9258575d6fe925aec8dafd07fd1..c5f8d9e4f9539fcf2c6cc6e77968cf0ba1e150b5 100644 (file)
@@ -136,9 +136,6 @@ struct tpm_vendor_specific {
 
        int irq;
 
-       int region_size;
-       int have_region;
-
        struct list_head list;
        int locality;
        unsigned long timeout_a, timeout_b, timeout_c, timeout_d; /* jiffies */
index a48a878f791d9e65f28ae5b2580a59c3d8bcd3c2..0267d85875187e3be8cfa7f703f4c7c0a0265f6b 100644 (file)
@@ -136,12 +136,13 @@ static struct platform_device *pdev;
 static void atml_plat_remove(void)
 {
        struct tpm_chip *chip = dev_get_drvdata(&pdev->dev);
+       struct tpm_atmel_priv *priv = chip->vendor.priv;
 
        if (chip) {
                tpm_chip_unregister(chip);
-               if (chip->vendor.have_region)
+               if (priv->have_region)
                        atmel_release_region(chip->vendor.base,
-                                            chip->vendor.region_size);
+                                            priv->region_size);
                atmel_put_base_addr(chip->vendor.iobase);
                platform_device_unregister(pdev);
        }
@@ -163,6 +164,7 @@ static int __init init_atmel(void)
        int have_region, region_size;
        unsigned long base;
        struct  tpm_chip *chip;
+       struct tpm_atmel_priv *priv;
 
        rc = platform_driver_register(&atml_drv);
        if (rc)
@@ -183,6 +185,15 @@ static int __init init_atmel(void)
                goto err_rel_reg;
        }
 
+       priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
+       if (!priv) {
+               rc = -ENOMEM;
+               goto err_unreg_dev;
+       }
+
+       priv->have_region = have_region;
+       priv->region_size = region_size;
+
        chip = tpmm_chip_alloc(&pdev->dev, &tpm_atmel);
        if (IS_ERR(chip)) {
                rc = PTR_ERR(chip);
@@ -191,8 +202,7 @@ static int __init init_atmel(void)
 
        chip->vendor.iobase = iobase;
        chip->vendor.base = base;
-       chip->vendor.have_region = have_region;
-       chip->vendor.region_size = region_size;
+       chip->vendor.priv = priv;
 
        rc = tpm_chip_register(chip);
        if (rc)
index 6c831f9466b70c6e4399a09bc89278aed2eeaa7e..3fd929de97391b8da10fd50f6ec18371770d179d 100644 (file)
  *
  */
 
+struct tpm_atmel_priv {
+       int region_size;
+       int have_region;
+};
+
 #ifdef CONFIG_PPC64
 
 #include <asm/prom.h>