Skip to content

Commit 4490e38

Browse files
cricard13Jarkko Sakkinen
authored andcommitted
tpm: drop 'iobase' from struct tpm_vendor_specific
Dropped the field 'iobase' from struct tpm_vendor_specific and migrated it to the private structures of tpm_atmel and tpm_tis. Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com> Reviewed-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com> Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
1 parent a6b0860 commit 4490e38

File tree

4 files changed

+78
-57
lines changed

4 files changed

+78
-57
lines changed

drivers/char/tpm/tpm.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,6 @@ enum tpm2_startup_types {
131131
struct tpm_chip;
132132

133133
struct tpm_vendor_specific {
134-
void __iomem *iobase; /* ioremapped address */
135-
136134
int irq;
137135

138136
int locality;

drivers/char/tpm/tpm_atmel.c

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ enum tpm_atmel_read_status {
3737

3838
static int tpm_atml_recv(struct tpm_chip *chip, u8 *buf, size_t count)
3939
{
40+
struct tpm_atmel_priv *priv = chip->vendor.priv;
4041
u8 status, *hdr = buf;
4142
u32 size;
4243
int i;
@@ -47,12 +48,12 @@ static int tpm_atml_recv(struct tpm_chip *chip, u8 *buf, size_t count)
4748
return -EIO;
4849

4950
for (i = 0; i < 6; i++) {
50-
status = ioread8(chip->vendor.iobase + 1);
51+
status = ioread8(priv->iobase + 1);
5152
if ((status & ATML_STATUS_DATA_AVAIL) == 0) {
5253
dev_err(&chip->dev, "error reading header\n");
5354
return -EIO;
5455
}
55-
*buf++ = ioread8(chip->vendor.iobase);
56+
*buf++ = ioread8(priv->iobase);
5657
}
5758

5859
/* size of the data received */
@@ -63,7 +64,7 @@ static int tpm_atml_recv(struct tpm_chip *chip, u8 *buf, size_t count)
6364
dev_err(&chip->dev,
6465
"Recv size(%d) less than available space\n", size);
6566
for (; i < size; i++) { /* clear the waiting data anyway */
66-
status = ioread8(chip->vendor.iobase + 1);
67+
status = ioread8(priv->iobase + 1);
6768
if ((status & ATML_STATUS_DATA_AVAIL) == 0) {
6869
dev_err(&chip->dev, "error reading data\n");
6970
return -EIO;
@@ -74,16 +75,16 @@ static int tpm_atml_recv(struct tpm_chip *chip, u8 *buf, size_t count)
7475

7576
/* read all the data available */
7677
for (; i < size; i++) {
77-
status = ioread8(chip->vendor.iobase + 1);
78+
status = ioread8(priv->iobase + 1);
7879
if ((status & ATML_STATUS_DATA_AVAIL) == 0) {
7980
dev_err(&chip->dev, "error reading data\n");
8081
return -EIO;
8182
}
82-
*buf++ = ioread8(chip->vendor.iobase);
83+
*buf++ = ioread8(priv->iobase);
8384
}
8485

8586
/* make sure data available is gone */
86-
status = ioread8(chip->vendor.iobase + 1);
87+
status = ioread8(priv->iobase + 1);
8788

8889
if (status & ATML_STATUS_DATA_AVAIL) {
8990
dev_err(&chip->dev, "data available is stuck\n");
@@ -95,25 +96,30 @@ static int tpm_atml_recv(struct tpm_chip *chip, u8 *buf, size_t count)
9596

9697
static int tpm_atml_send(struct tpm_chip *chip, u8 *buf, size_t count)
9798
{
99+
struct tpm_atmel_priv *priv = chip->vendor.priv;
98100
int i;
99101

100102
dev_dbg(&chip->dev, "tpm_atml_send:\n");
101103
for (i = 0; i < count; i++) {
102104
dev_dbg(&chip->dev, "%d 0x%x(%d)\n", i, buf[i], buf[i]);
103-
iowrite8(buf[i], chip->vendor.iobase);
105+
iowrite8(buf[i], priv->iobase);
104106
}
105107

106108
return count;
107109
}
108110

109111
static void tpm_atml_cancel(struct tpm_chip *chip)
110112
{
111-
iowrite8(ATML_STATUS_ABORT, chip->vendor.iobase + 1);
113+
struct tpm_atmel_priv *priv = chip->vendor.priv;
114+
115+
iowrite8(ATML_STATUS_ABORT, priv->iobase + 1);
112116
}
113117

114118
static u8 tpm_atml_status(struct tpm_chip *chip)
115119
{
116-
return ioread8(chip->vendor.iobase + 1);
120+
struct tpm_atmel_priv *priv = chip->vendor.priv;
121+
122+
return ioread8(priv->iobase + 1);
117123
}
118124

119125
static bool tpm_atml_req_canceled(struct tpm_chip *chip, u8 status)
@@ -142,7 +148,7 @@ static void atml_plat_remove(void)
142148
tpm_chip_unregister(chip);
143149
if (priv->have_region)
144150
atmel_release_region(priv->base, priv->region_size);
145-
atmel_put_base_addr(chip->vendor.iobase);
151+
atmel_put_base_addr(priv->iobase);
146152
platform_device_unregister(pdev);
147153
}
148154
}
@@ -190,6 +196,7 @@ static int __init init_atmel(void)
190196
goto err_unreg_dev;
191197
}
192198

199+
priv->iobase = iobase;
193200
priv->base = base;
194201
priv->have_region = have_region;
195202
priv->region_size = region_size;
@@ -200,7 +207,6 @@ static int __init init_atmel(void)
200207
goto err_unreg_dev;
201208
}
202209

203-
chip->vendor.iobase = iobase;
204210
chip->vendor.priv = priv;
205211

206212
rc = tpm_chip_register(chip);

drivers/char/tpm/tpm_atmel.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ struct tpm_atmel_priv {
2626
int region_size;
2727
int have_region;
2828
unsigned long base;
29+
void __iomem *iobase;
2930
};
3031

3132
static inline struct tpm_atmel_priv *atmel_get_priv(struct tpm_chip *chip)
@@ -37,8 +38,8 @@ static inline struct tpm_atmel_priv *atmel_get_priv(struct tpm_chip *chip)
3738

3839
#include <asm/prom.h>
3940

40-
#define atmel_getb(chip, offset) readb(chip->vendor->iobase + offset);
41-
#define atmel_putb(val, chip, offset) writeb(val, chip->vendor->iobase + offset)
41+
#define atmel_getb(priv, offset) readb(priv->iobase + offset)
42+
#define atmel_putb(val, priv, offset) writeb(val, priv->iobase + offset)
4243
#define atmel_request_region request_mem_region
4344
#define atmel_release_region release_mem_region
4445

0 commit comments

Comments
 (0)