Skip to content

Commit 381e0ca

Browse files
author
Jarkko Sakkinen
committed
tpm: drop tpm_atmel specific fields from tpm_vendor_specific
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>
1 parent 682e98f commit 381e0ca

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

drivers/char/tpm/tpm.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,6 @@ struct tpm_vendor_specific {
136136

137137
int irq;
138138

139-
int region_size;
140-
int have_region;
141-
142139
struct list_head list;
143140
int locality;
144141
unsigned long timeout_a, timeout_b, timeout_c, timeout_d; /* jiffies */

drivers/char/tpm/tpm_atmel.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,13 @@ static struct platform_device *pdev;
136136
static void atml_plat_remove(void)
137137
{
138138
struct tpm_chip *chip = dev_get_drvdata(&pdev->dev);
139+
struct tpm_atmel_priv *priv = chip->vendor.priv;
139140

140141
if (chip) {
141142
tpm_chip_unregister(chip);
142-
if (chip->vendor.have_region)
143+
if (priv->have_region)
143144
atmel_release_region(chip->vendor.base,
144-
chip->vendor.region_size);
145+
priv->region_size);
145146
atmel_put_base_addr(chip->vendor.iobase);
146147
platform_device_unregister(pdev);
147148
}
@@ -163,6 +164,7 @@ static int __init init_atmel(void)
163164
int have_region, region_size;
164165
unsigned long base;
165166
struct tpm_chip *chip;
167+
struct tpm_atmel_priv *priv;
166168

167169
rc = platform_driver_register(&atml_drv);
168170
if (rc)
@@ -183,6 +185,15 @@ static int __init init_atmel(void)
183185
goto err_rel_reg;
184186
}
185187

188+
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
189+
if (!priv) {
190+
rc = -ENOMEM;
191+
goto err_unreg_dev;
192+
}
193+
194+
priv->have_region = have_region;
195+
priv->region_size = region_size;
196+
186197
chip = tpmm_chip_alloc(&pdev->dev, &tpm_atmel);
187198
if (IS_ERR(chip)) {
188199
rc = PTR_ERR(chip);
@@ -191,8 +202,7 @@ static int __init init_atmel(void)
191202

192203
chip->vendor.iobase = iobase;
193204
chip->vendor.base = base;
194-
chip->vendor.have_region = have_region;
195-
chip->vendor.region_size = region_size;
205+
chip->vendor.priv = priv;
196206

197207
rc = tpm_chip_register(chip);
198208
if (rc)

drivers/char/tpm/tpm_atmel.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
*
2323
*/
2424

25+
struct tpm_atmel_priv {
26+
int region_size;
27+
int have_region;
28+
};
29+
2530
#ifdef CONFIG_PPC64
2631

2732
#include <asm/prom.h>

0 commit comments

Comments
 (0)