* [PATCH v4 0/6] Remove the tpm_vendor_specific structure
@ 2016-03-31 20:56 Christophe Ricard
[not found] ` <1459457820-30542-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
0 siblings, 1 reply; 8+ messages in thread
From: Christophe Ricard @ 2016-03-31 20:56 UTC (permalink / raw)
To: jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA
Cc: jean-luc.blanc-qxv4g6HH51o, ashley-fm2HMyfA2y6tG0bUXCXiUA,
tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
christophe-h.ricard-qxv4g6HH51o, benoit.houyere-qxv4g6HH51o
Hi Jarkko,
After our discussion, please find an updated v4 serie allowing to
completely remove reference to the tpm_vendor_specific structure.
I have been able to test tpm_tis on a HP8200 Desktop machine.
It applies cleanly on top of:
tpm: cleanup tpm_tis_remove()
72e454274bc1a05d561ae5f6959c15a26604a25d
In v4:
- Added Jarkko's Review in patch 2, 3, 4, 6
- Fixed checkpatch Warning in patch 1
macros should not use a trailing semicolon
#165: FILE: drivers/char/tpm/tpm_atmel.h:41:
+#define atmel_getb(priv, offset) readb(priv->iobase + offset);'
Note: this warning is not directly linked with patch one.
It was mention in v3 cover-letter.
- Reduced patch 5 commit message and moved each timeout_X to a new line/declaration.
In v3:
- Merged 'tpm/tpm_atmel: drop remaining 'iobase' usage' from v2 and
'tpm: drop 'iobase' from struct tpm_vendor_specific' sent in v1
- Move patch tpm: Remove useless priv field in struct tpm_vendor_specific
at the end of the serie,
- Dropped codestyle/cleanup patches. May be send later...
(e.g: tpm/tpm_i2c_atmel: simplify patch to get tpm_chip from an i2c_client,
tpm/tpm_i2c_atmel: Few code style fixes)
- In patch 'tpm: drop 'irq' from struct tpm_vendor_specific', Renamed
TPM_CHIP_FLAG_USES_IRQ to TPM_CHIP_FLAG_IRQ
- Added patch 'tpm: drop 'locality' from struct tpm_vendor_specific'.
v2 serie was dropped.
Best Regards
Christophe
Christophe Ricard (6):
tpm: drop 'iobase' from struct tpm_vendor_specific
tpm: drop 'irq' from struct tpm_vendor_specific
tpm: drop 'read_queue' from struct tpm_vendor_specific
tpm: drop 'locality' from struct tpm_vendor_specific
tpm: Move tpm_vendor_specific data related with PTP specification to
tpm_chip
tpm: Remove useless priv field in struct tpm_vendor_specific
drivers/char/tpm/st33zp24/i2c.c | 15 ++-
drivers/char/tpm/st33zp24/spi.c | 15 ++-
drivers/char/tpm/st33zp24/st33zp24.c | 113 +++++++-----------
drivers/char/tpm/st33zp24/st33zp24.h | 12 ++
drivers/char/tpm/tpm-interface.c | 52 ++++----
drivers/char/tpm/tpm-sysfs.c | 20 ++--
drivers/char/tpm/tpm.h | 28 ++---
drivers/char/tpm/tpm2-cmd.c | 2 +-
drivers/char/tpm/tpm_atmel.c | 32 +++--
drivers/char/tpm/tpm_atmel.h | 10 +-
drivers/char/tpm/tpm_crb.c | 12 +-
drivers/char/tpm/tpm_i2c_atmel.c | 23 ++--
drivers/char/tpm/tpm_i2c_infineon.c | 48 ++++----
drivers/char/tpm/tpm_i2c_nuvoton.c | 73 +++++++-----
drivers/char/tpm/tpm_ibmvtpm.c | 38 ++----
drivers/char/tpm/tpm_nsc.c | 48 ++++----
drivers/char/tpm/tpm_tis.c | 225 +++++++++++++++++++----------------
drivers/char/tpm/xen-tpmfront.c | 36 +++---
18 files changed, 402 insertions(+), 400 deletions(-)
--
2.5.0
------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785471&iu=/4140
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v4 1/6] tpm: drop 'iobase' from struct tpm_vendor_specific
[not found] ` <1459457820-30542-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
@ 2016-03-31 20:56 ` Christophe Ricard
2016-03-31 20:56 ` [PATCH v4 2/6] tpm: drop 'irq' " Christophe Ricard
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Christophe Ricard @ 2016-03-31 20:56 UTC (permalink / raw)
To: jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA
Cc: jean-luc.blanc-qxv4g6HH51o, ashley-fm2HMyfA2y6tG0bUXCXiUA,
tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
christophe-h.ricard-qxv4g6HH51o, benoit.houyere-qxv4g6HH51o
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-qxv4g6HH51o@public.gmane.org>
Reviewed-by: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
drivers/char/tpm/tpm.h | 2 -
drivers/char/tpm/tpm_atmel.c | 28 +++++++-----
drivers/char/tpm/tpm_atmel.h | 5 ++-
drivers/char/tpm/tpm_tis.c | 100 +++++++++++++++++++++++++------------------
4 files changed, 78 insertions(+), 57 deletions(-)
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index cd780c7..357ac14 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -131,8 +131,6 @@ enum tpm2_startup_types {
struct tpm_chip;
struct tpm_vendor_specific {
- void __iomem *iobase; /* ioremapped address */
-
int irq;
int locality;
diff --git a/drivers/char/tpm/tpm_atmel.c b/drivers/char/tpm/tpm_atmel.c
index 68d5c09..b769299 100644
--- a/drivers/char/tpm/tpm_atmel.c
+++ b/drivers/char/tpm/tpm_atmel.c
@@ -37,6 +37,7 @@ enum tpm_atmel_read_status {
static int tpm_atml_recv(struct tpm_chip *chip, u8 *buf, size_t count)
{
+ struct tpm_atmel_priv *priv = chip->vendor.priv;
u8 status, *hdr = buf;
u32 size;
int i;
@@ -47,12 +48,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(priv->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(priv->iobase);
}
/* size of the data received */
@@ -63,7 +64,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(priv->iobase + 1);
if ((status & ATML_STATUS_DATA_AVAIL) == 0) {
dev_err(&chip->dev, "error reading data\n");
return -EIO;
@@ -74,16 +75,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(priv->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(priv->iobase);
}
/* make sure data available is gone */
- status = ioread8(chip->vendor.iobase + 1);
+ status = ioread8(priv->iobase + 1);
if (status & ATML_STATUS_DATA_AVAIL) {
dev_err(&chip->dev, "data available is stuck\n");
@@ -95,12 +96,13 @@ static int tpm_atml_recv(struct tpm_chip *chip, u8 *buf, size_t count)
static int tpm_atml_send(struct tpm_chip *chip, u8 *buf, size_t count)
{
+ struct tpm_atmel_priv *priv = chip->vendor.priv;
int i;
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], priv->iobase);
}
return count;
@@ -108,12 +110,16 @@ 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);
+ struct tpm_atmel_priv *priv = chip->vendor.priv;
+
+ iowrite8(ATML_STATUS_ABORT, priv->iobase + 1);
}
static u8 tpm_atml_status(struct tpm_chip *chip)
{
- return ioread8(chip->vendor.iobase + 1);
+ struct tpm_atmel_priv *priv = chip->vendor.priv;
+
+ return ioread8(priv->iobase + 1);
}
static bool tpm_atml_req_canceled(struct tpm_chip *chip, u8 status)
@@ -142,7 +148,7 @@ static void atml_plat_remove(void)
tpm_chip_unregister(chip);
if (priv->have_region)
atmel_release_region(priv->base, priv->region_size);
- atmel_put_base_addr(chip->vendor.iobase);
+ atmel_put_base_addr(priv->iobase);
platform_device_unregister(pdev);
}
}
@@ -190,6 +196,7 @@ static int __init init_atmel(void)
goto err_unreg_dev;
}
+ priv->iobase = iobase;
priv->base = base;
priv->have_region = have_region;
priv->region_size = region_size;
@@ -200,7 +207,6 @@ static int __init init_atmel(void)
goto err_unreg_dev;
}
- chip->vendor.iobase = iobase;
chip->vendor.priv = priv;
rc = tpm_chip_register(chip);
diff --git a/drivers/char/tpm/tpm_atmel.h b/drivers/char/tpm/tpm_atmel.h
index bced678..1938c0b 100644
--- a/drivers/char/tpm/tpm_atmel.h
+++ b/drivers/char/tpm/tpm_atmel.h
@@ -26,6 +26,7 @@ struct tpm_atmel_priv {
int region_size;
int have_region;
unsigned long base;
+ void __iomem *iobase;
};
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)
#include <asm/prom.h>
-#define atmel_getb(chip, offset) readb(chip->vendor->iobase + offset);
-#define atmel_putb(val, chip, offset) writeb(val, chip->vendor->iobase + offset)
+#define atmel_getb(priv, offset) readb(priv->iobase + offset)
+#define atmel_putb(val, priv, offset) writeb(val, priv->iobase + offset)
#define atmel_request_region request_mem_region
#define atmel_release_region release_mem_region
diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index 8a69e71..27c35c0 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ b/drivers/char/tpm/tpm_tis.c
@@ -94,6 +94,7 @@ struct tpm_info {
#define TPM_RID(l) (0x0F04 | ((l) << 12))
struct priv_data {
+ void __iomem *iobase;
u16 manufacturer_id;
bool irq_tested;
wait_queue_head_t int_queue;
@@ -128,9 +129,10 @@ static inline int is_itpm(struct acpi_device *dev)
* correct values in the other bits.' */
static int wait_startup(struct tpm_chip *chip, int l)
{
+ struct priv_data *priv = chip->vendor.priv;
unsigned long stop = jiffies + chip->vendor.timeout_a;
do {
- if (ioread8(chip->vendor.iobase + TPM_ACCESS(l)) &
+ if (ioread8(priv->iobase + TPM_ACCESS(l)) &
TPM_ACCESS_VALID)
return 0;
msleep(TPM_TIMEOUT);
@@ -140,7 +142,9 @@ static int wait_startup(struct tpm_chip *chip, int l)
static int check_locality(struct tpm_chip *chip, int l)
{
- if ((ioread8(chip->vendor.iobase + TPM_ACCESS(l)) &
+ struct priv_data *priv = chip->vendor.priv;
+
+ if ((ioread8(priv->iobase + TPM_ACCESS(l)) &
(TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID)) ==
(TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID))
return chip->vendor.locality = l;
@@ -150,11 +154,13 @@ static int check_locality(struct tpm_chip *chip, int l)
static void release_locality(struct tpm_chip *chip, int l, int force)
{
- if (force || (ioread8(chip->vendor.iobase + TPM_ACCESS(l)) &
+ struct priv_data *priv = chip->vendor.priv;
+
+ if (force || (ioread8(priv->iobase + TPM_ACCESS(l)) &
(TPM_ACCESS_REQUEST_PENDING | TPM_ACCESS_VALID)) ==
(TPM_ACCESS_REQUEST_PENDING | TPM_ACCESS_VALID))
iowrite8(TPM_ACCESS_ACTIVE_LOCALITY,
- chip->vendor.iobase + TPM_ACCESS(l));
+ priv->iobase + TPM_ACCESS(l));
}
static int request_locality(struct tpm_chip *chip, int l)
@@ -167,7 +173,7 @@ static int request_locality(struct tpm_chip *chip, int l)
return l;
iowrite8(TPM_ACCESS_REQUEST_USE,
- chip->vendor.iobase + TPM_ACCESS(l));
+ priv->iobase + TPM_ACCESS(l));
stop = jiffies + chip->vendor.timeout_a;
@@ -200,19 +206,24 @@ again:
static u8 tpm_tis_status(struct tpm_chip *chip)
{
- return ioread8(chip->vendor.iobase +
+ struct priv_data *priv = chip->vendor.priv;
+
+ return ioread8(priv->iobase +
TPM_STS(chip->vendor.locality));
}
static void tpm_tis_ready(struct tpm_chip *chip)
{
+ struct priv_data *priv = chip->vendor.priv;
+
/* this causes the current command to be aborted */
iowrite8(TPM_STS_COMMAND_READY,
- chip->vendor.iobase + TPM_STS(chip->vendor.locality));
+ priv->iobase + TPM_STS(chip->vendor.locality));
}
static int get_burstcount(struct tpm_chip *chip)
{
+ struct priv_data *priv = chip->vendor.priv;
unsigned long stop;
int burstcnt;
@@ -220,9 +231,9 @@ static int get_burstcount(struct tpm_chip *chip)
/* which timeout value, spec has 2 answers (c & d) */
stop = jiffies + chip->vendor.timeout_d;
do {
- burstcnt = ioread8(chip->vendor.iobase +
+ burstcnt = ioread8(priv->iobase +
TPM_STS(chip->vendor.locality) + 1);
- burstcnt += ioread8(chip->vendor.iobase +
+ burstcnt += ioread8(priv->iobase +
TPM_STS(chip->vendor.locality) +
2) << 8;
if (burstcnt)
@@ -234,6 +245,7 @@ static int get_burstcount(struct tpm_chip *chip)
static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count)
{
+ struct priv_data *priv = chip->vendor.priv;
int size = 0, burstcnt;
while (size < count &&
wait_for_tpm_stat(chip,
@@ -243,7 +255,7 @@ static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count)
== 0) {
burstcnt = get_burstcount(chip);
for (; burstcnt > 0 && size < count; burstcnt--)
- buf[size++] = ioread8(chip->vendor.iobase +
+ buf[size++] = ioread8(priv->iobase +
TPM_DATA_FIFO(chip->vendor.
locality));
}
@@ -329,7 +341,7 @@ static int tpm_tis_send_data(struct tpm_chip *chip, u8 *buf, size_t len)
while (count < len - 1) {
burstcnt = get_burstcount(chip);
for (; burstcnt > 0 && count < len - 1; burstcnt--) {
- iowrite8(buf[count], chip->vendor.iobase +
+ iowrite8(buf[count], priv->iobase +
TPM_DATA_FIFO(chip->vendor.locality));
count++;
}
@@ -345,7 +357,7 @@ static int tpm_tis_send_data(struct tpm_chip *chip, u8 *buf, size_t len)
/* write last byte */
iowrite8(buf[count],
- chip->vendor.iobase + TPM_DATA_FIFO(chip->vendor.locality));
+ priv->iobase + TPM_DATA_FIFO(chip->vendor.locality));
wait_for_tpm_stat(chip, TPM_STS_VALID, chip->vendor.timeout_c,
&priv->int_queue, false);
status = tpm_tis_status(chip);
@@ -364,15 +376,15 @@ out_err:
static void disable_interrupts(struct tpm_chip *chip)
{
+ struct priv_data *priv = chip->vendor.priv;
u32 intmask;
intmask =
- ioread32(chip->vendor.iobase +
+ ioread32(priv->iobase +
TPM_INT_ENABLE(chip->vendor.locality));
intmask &= ~TPM_GLOBAL_INT_ENABLE;
iowrite32(intmask,
- chip->vendor.iobase +
- TPM_INT_ENABLE(chip->vendor.locality));
+ priv->iobase + TPM_INT_ENABLE(chip->vendor.locality));
devm_free_irq(&chip->dev, chip->vendor.irq, chip);
chip->vendor.irq = 0;
}
@@ -384,6 +396,7 @@ static void disable_interrupts(struct tpm_chip *chip)
*/
static int tpm_tis_send_main(struct tpm_chip *chip, u8 *buf, size_t len)
{
+ struct priv_data *priv = chip->vendor.priv;
int rc;
u32 ordinal;
unsigned long dur;
@@ -394,7 +407,7 @@ static int tpm_tis_send_main(struct tpm_chip *chip, u8 *buf, size_t len)
/* go and do it */
iowrite8(TPM_STS_GO,
- chip->vendor.iobase + TPM_STS(chip->vendor.locality));
+ priv->iobase + TPM_STS(chip->vendor.locality));
if (chip->vendor.irq) {
ordinal = be32_to_cpu(*((__be32 *) (buf + 6)));
@@ -453,10 +466,11 @@ static const struct tis_vendor_timeout_override vendor_timeout_overrides[] = {
static bool tpm_tis_update_timeouts(struct tpm_chip *chip,
unsigned long *timeout_cap)
{
+ struct priv_data *priv = chip->vendor.priv;
int i;
u32 did_vid;
- did_vid = ioread32(chip->vendor.iobase + TPM_DID_VID(0));
+ did_vid = ioread32(priv->iobase + TPM_DID_VID(0));
for (i = 0; i != ARRAY_SIZE(vendor_timeout_overrides); i++) {
if (vendor_timeout_overrides[i].did_vid != did_vid)
@@ -476,6 +490,7 @@ static bool tpm_tis_update_timeouts(struct tpm_chip *chip,
*/
static int probe_itpm(struct tpm_chip *chip)
{
+ struct priv_data *priv = chip->vendor.priv;
int rc = 0;
u8 cmd_getticks[] = {
0x00, 0xc1, 0x00, 0x00, 0x00, 0x0a,
@@ -483,7 +498,7 @@ static int probe_itpm(struct tpm_chip *chip)
};
size_t len = sizeof(cmd_getticks);
bool rem_itpm = itpm;
- u16 vendor = ioread16(chip->vendor.iobase + TPM_DID_VID(0));
+ u16 vendor = ioread16(priv->iobase + TPM_DID_VID(0));
/* probe only iTPMS */
if (vendor != TPM_VID_INTEL)
@@ -548,7 +563,7 @@ static irqreturn_t tis_int_handler(int dummy, void *dev_id)
u32 interrupt;
int i;
- interrupt = ioread32(chip->vendor.iobase +
+ interrupt = ioread32(priv->iobase +
TPM_INT_STATUS(chip->vendor.locality));
if (interrupt == 0)
@@ -568,9 +583,9 @@ static irqreturn_t tis_int_handler(int dummy, void *dev_id)
/* Clear interrupts handled with TPM_EOI */
iowrite32(interrupt,
- chip->vendor.iobase +
+ priv->iobase +
TPM_INT_STATUS(chip->vendor.locality));
- ioread32(chip->vendor.iobase + TPM_INT_STATUS(chip->vendor.locality));
+ ioread32(priv->iobase + TPM_INT_STATUS(chip->vendor.locality));
return IRQ_HANDLED;
}
@@ -592,19 +607,19 @@ static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask,
}
chip->vendor.irq = irq;
- original_int_vec = ioread8(chip->vendor.iobase +
+ original_int_vec = ioread8(priv->iobase +
TPM_INT_VECTOR(chip->vendor.locality));
iowrite8(irq,
- chip->vendor.iobase + TPM_INT_VECTOR(chip->vendor.locality));
+ priv->iobase + TPM_INT_VECTOR(chip->vendor.locality));
/* Clear all existing */
- iowrite32(ioread32(chip->vendor.iobase +
+ iowrite32(ioread32(priv->iobase +
TPM_INT_STATUS(chip->vendor.locality)),
- chip->vendor.iobase + TPM_INT_STATUS(chip->vendor.locality));
+ priv->iobase + TPM_INT_STATUS(chip->vendor.locality));
/* Turn on */
iowrite32(intmask | TPM_GLOBAL_INT_ENABLE,
- chip->vendor.iobase + TPM_INT_ENABLE(chip->vendor.locality));
+ priv->iobase + TPM_INT_ENABLE(chip->vendor.locality));
priv->irq_tested = false;
@@ -621,8 +636,7 @@ static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask,
*/
if (!chip->vendor.irq) {
iowrite8(original_int_vec,
- chip->vendor.iobase +
- TPM_INT_VECTOR(chip->vendor.locality));
+ priv->iobase + TPM_INT_VECTOR(chip->vendor.locality));
return 1;
}
@@ -635,10 +649,11 @@ static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask,
*/
static void tpm_tis_probe_irq(struct tpm_chip *chip, u32 intmask)
{
+ struct priv_data *priv = chip->vendor.priv;
u8 original_int_vec;
int i;
- original_int_vec = ioread8(chip->vendor.iobase +
+ original_int_vec = ioread8(priv->iobase +
TPM_INT_VECTOR(chip->vendor.locality));
if (!original_int_vec) {
@@ -658,7 +673,8 @@ MODULE_PARM_DESC(interrupts, "Enable interrupts");
static void tpm_tis_remove(struct tpm_chip *chip)
{
- void __iomem *reg = chip->vendor.iobase +
+ struct priv_data *priv = chip->vendor.priv;
+ void __iomem *reg = priv->iobase +
TPM_INT_ENABLE(chip->vendor.locality);
if (chip->flags & TPM_CHIP_FLAG_TPM2)
@@ -689,9 +705,9 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info,
chip->acpi_dev_handle = acpi_dev_handle;
#endif
- chip->vendor.iobase = devm_ioremap_resource(dev, &tpm_info->res);
- if (IS_ERR(chip->vendor.iobase))
- return PTR_ERR(chip->vendor.iobase);
+ priv->iobase = devm_ioremap_resource(dev, &tpm_info->res);
+ if (IS_ERR(priv->iobase))
+ return PTR_ERR(priv->iobase);
/* Maximum timeouts */
chip->vendor.timeout_a = TIS_TIMEOUT_A_MAX;
@@ -705,13 +721,13 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info,
}
/* Take control of the TPM's interrupt hardware and shut it off */
- intmask = ioread32(chip->vendor.iobase +
+ intmask = ioread32(priv->iobase +
TPM_INT_ENABLE(chip->vendor.locality));
intmask |= TPM_INTF_CMD_READY_INT | TPM_INTF_LOCALITY_CHANGE_INT |
TPM_INTF_DATA_AVAIL_INT | TPM_INTF_STS_VALID_INT;
intmask &= ~TPM_GLOBAL_INT_ENABLE;
iowrite32(intmask,
- chip->vendor.iobase + TPM_INT_ENABLE(chip->vendor.locality));
+ priv->iobase + TPM_INT_ENABLE(chip->vendor.locality));
if (request_locality(chip, 0) != 0) {
rc = -ENODEV;
@@ -722,12 +738,12 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info,
if (rc)
goto out_err;
- vendor = ioread32(chip->vendor.iobase + TPM_DID_VID(0));
+ vendor = ioread32(priv->iobase + TPM_DID_VID(0));
priv->manufacturer_id = vendor;
dev_info(dev, "%s TPM (device-id 0x%X, rev-id %d)\n",
(chip->flags & TPM_CHIP_FLAG_TPM2) ? "2.0" : "1.2",
- vendor >> 16, ioread8(chip->vendor.iobase + TPM_RID(0)));
+ vendor >> 16, ioread8(priv->iobase + TPM_RID(0)));
if (!itpm) {
probe = probe_itpm(chip);
@@ -744,7 +760,7 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info,
/* Figure out the capabilities */
intfcaps =
- ioread32(chip->vendor.iobase +
+ ioread32(priv->iobase +
TPM_INTF_CAPS(chip->vendor.locality));
dev_dbg(dev, "TPM interface capabilities (0x%x):\n",
intfcaps);
@@ -823,23 +839,23 @@ out_err:
#ifdef CONFIG_PM_SLEEP
static void tpm_tis_reenable_interrupts(struct tpm_chip *chip)
{
+ struct priv_data *priv = chip->vendor.priv;
u32 intmask;
/* reenable interrupts that device may have lost or
BIOS/firmware may have disabled */
- iowrite8(chip->vendor.irq, chip->vendor.iobase +
+ iowrite8(chip->vendor.irq, priv->iobase +
TPM_INT_VECTOR(chip->vendor.locality));
intmask =
- ioread32(chip->vendor.iobase +
- TPM_INT_ENABLE(chip->vendor.locality));
+ ioread32(priv->iobase + TPM_INT_ENABLE(chip->vendor.locality));
intmask |= TPM_INTF_CMD_READY_INT
| TPM_INTF_LOCALITY_CHANGE_INT | TPM_INTF_DATA_AVAIL_INT
| TPM_INTF_STS_VALID_INT | TPM_GLOBAL_INT_ENABLE;
iowrite32(intmask,
- chip->vendor.iobase + TPM_INT_ENABLE(chip->vendor.locality));
+ priv->iobase + TPM_INT_ENABLE(chip->vendor.locality));
}
static int tpm_tis_resume(struct device *dev)
--
2.5.0
------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785471&iu=/4140
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v4 2/6] tpm: drop 'irq' from struct tpm_vendor_specific
[not found] ` <1459457820-30542-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
2016-03-31 20:56 ` [PATCH v4 1/6] tpm: drop 'iobase' from struct tpm_vendor_specific Christophe Ricard
@ 2016-03-31 20:56 ` Christophe Ricard
2016-03-31 20:56 ` [PATCH v4 3/6] tpm: drop 'read_queue' " Christophe Ricard
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Christophe Ricard @ 2016-03-31 20:56 UTC (permalink / raw)
To: jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA
Cc: jean-luc.blanc-qxv4g6HH51o, ashley-fm2HMyfA2y6tG0bUXCXiUA,
tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
christophe-h.ricard-qxv4g6HH51o, benoit.houyere-qxv4g6HH51o
Dropped the field 'irq' from struct tpm_vendor_specific and make it
available to the various private structures in the drivers using irqs.
A dedicated flag TPM_CHIP_FLAG_IRQ is added for the upper layers.
In st33zp24, struct st33zp24_dev declaration is moved to st33zp24.h in
order to make accessible irq from other phy's(i2c, spi).
In tpm_i2c_nuvoton, chip->vendor.priv is not directly allocated. We can
access irq field from priv_data in a cleaner way.
Signed-off-by: Christophe Ricard <christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
drivers/char/tpm/st33zp24/st33zp24.c | 23 ++++++++---------------
drivers/char/tpm/st33zp24/st33zp24.h | 10 ++++++++++
drivers/char/tpm/tpm-interface.c | 4 ++--
drivers/char/tpm/tpm.h | 3 +--
drivers/char/tpm/tpm_i2c_atmel.c | 1 -
drivers/char/tpm/tpm_i2c_infineon.c | 3 ---
drivers/char/tpm/tpm_i2c_nuvoton.c | 28 ++++++++++++++++------------
drivers/char/tpm/tpm_tis.c | 30 +++++++++++++++++-------------
drivers/char/tpm/xen-tpmfront.c | 7 ++++---
9 files changed, 58 insertions(+), 51 deletions(-)
diff --git a/drivers/char/tpm/st33zp24/st33zp24.c b/drivers/char/tpm/st33zp24/st33zp24.c
index 9e91ca7..f4a44ad 100644
--- a/drivers/char/tpm/st33zp24/st33zp24.c
+++ b/drivers/char/tpm/st33zp24/st33zp24.c
@@ -73,14 +73,6 @@ enum tis_defaults {
TIS_LONG_TIMEOUT = 2000,
};
-struct st33zp24_dev {
- struct tpm_chip *chip;
- void *phy_id;
- const struct st33zp24_phy_ops *ops;
- u32 intrs;
- int io_lpcpd;
-};
-
/*
* clear_interruption clear the pending interrupt.
* @param: tpm_dev, the tpm device device.
@@ -288,10 +280,10 @@ static int wait_for_stat(struct tpm_chip *chip, u8 mask, unsigned long timeout,
stop = jiffies + timeout;
- if (chip->vendor.irq) {
+ if (chip->flags & TPM_CHIP_FLAG_IRQ) {
cur_intrs = tpm_dev->intrs;
clear_interruption(tpm_dev);
- enable_irq(chip->vendor.irq);
+ enable_irq(tpm_dev->irq);
do {
if (ret == -ERESTARTSYS && freezing(current))
@@ -314,7 +306,7 @@ static int wait_for_stat(struct tpm_chip *chip, u8 mask, unsigned long timeout,
}
} while (ret == -ERESTARTSYS && freezing(current));
- disable_irq_nosync(chip->vendor.irq);
+ disable_irq_nosync(tpm_dev->irq);
} else {
do {
@@ -376,7 +368,7 @@ static irqreturn_t tpm_ioserirq_handler(int irq, void *dev_id)
tpm_dev->intrs++;
wake_up_interruptible(&chip->vendor.read_queue);
- disable_irq_nosync(chip->vendor.irq);
+ disable_irq_nosync(tpm_dev->irq);
return IRQ_HANDLED;
} /* tpm_ioserirq_handler() */
@@ -456,7 +448,7 @@ static int st33zp24_send(struct tpm_chip *chip, unsigned char *buf,
if (ret < 0)
goto out_err;
- if (chip->vendor.irq) {
+ if (chip->flags & TPM_CHIP_FLAG_IRQ) {
ordinal = be32_to_cpu(*((__be32 *) (buf + 6)));
ret = wait_for_stat(chip, TPM_STS_DATA_AVAIL | TPM_STS_VALID,
@@ -611,9 +603,10 @@ int st33zp24_probe(void *phy_id, const struct st33zp24_phy_ops *ops,
if (ret < 0)
goto _tpm_clean_answer;
- chip->vendor.irq = irq;
+ tpm_dev->irq = irq;
+ chip->flags |= TPM_CHIP_FLAG_IRQ;
- disable_irq_nosync(chip->vendor.irq);
+ disable_irq_nosync(tpm_dev->irq);
tpm_gen_interrupt(chip);
}
diff --git a/drivers/char/tpm/st33zp24/st33zp24.h b/drivers/char/tpm/st33zp24/st33zp24.h
index bcbd5ff..27e7564 100644
--- a/drivers/char/tpm/st33zp24/st33zp24.h
+++ b/drivers/char/tpm/st33zp24/st33zp24.h
@@ -21,6 +21,16 @@
#define TPM_WRITE_DIRECTION 0x80
#define TPM_BUFSIZE 2048
+struct st33zp24_dev {
+ struct tpm_chip *chip;
+ void *phy_id;
+ const struct st33zp24_phy_ops *ops;
+ int irq;
+ u32 intrs;
+ int io_lpcpd;
+};
+
+
struct st33zp24_phy_ops {
int (*send)(void *phy_id, u8 tpm_register, u8 *tpm_data, int tpm_size);
int (*recv)(void *phy_id, u8 tpm_register, u8 *tpm_data, int tpm_size);
diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
index 5397b64..101bb47 100644
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -359,7 +359,7 @@ ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
goto out;
}
- if (chip->vendor.irq)
+ if (chip->flags & TPM_CHIP_FLAG_IRQ)
goto out_recv;
if (chip->flags & TPM_CHIP_FLAG_TPM2)
@@ -890,7 +890,7 @@ int wait_for_tpm_stat(struct tpm_chip *chip, u8 mask, unsigned long timeout,
stop = jiffies + timeout;
- if (chip->vendor.irq) {
+ if (chip->flags & TPM_CHIP_FLAG_IRQ) {
again:
timeout = stop - jiffies;
if ((long)timeout <= 0)
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index 357ac14..ad4799c 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -131,8 +131,6 @@ enum tpm2_startup_types {
struct tpm_chip;
struct tpm_vendor_specific {
- int irq;
-
int locality;
unsigned long timeout_a, timeout_b, timeout_c, timeout_d; /* jiffies */
bool timeout_adjusted;
@@ -154,6 +152,7 @@ struct tpm_vendor_specific {
enum tpm_chip_flags {
TPM_CHIP_FLAG_REGISTERED = BIT(0),
TPM_CHIP_FLAG_TPM2 = BIT(1),
+ TPM_CHIP_FLAG_IRQ = BIT(2),
};
struct tpm_chip {
diff --git a/drivers/char/tpm/tpm_i2c_atmel.c b/drivers/char/tpm/tpm_i2c_atmel.c
index dd8f0eb..55fa51f 100644
--- a/drivers/char/tpm/tpm_i2c_atmel.c
+++ b/drivers/char/tpm/tpm_i2c_atmel.c
@@ -173,7 +173,6 @@ static int i2c_atmel_probe(struct i2c_client *client,
chip->vendor.timeout_b = msecs_to_jiffies(TPM_I2C_LONG_TIMEOUT);
chip->vendor.timeout_c = msecs_to_jiffies(TPM_I2C_SHORT_TIMEOUT);
chip->vendor.timeout_d = msecs_to_jiffies(TPM_I2C_SHORT_TIMEOUT);
- chip->vendor.irq = 0;
/* There is no known way to probe for this device, and all version
* information seems to be read via TPM commands. Thus we rely on the
diff --git a/drivers/char/tpm/tpm_i2c_infineon.c b/drivers/char/tpm/tpm_i2c_infineon.c
index e74f1c1..093daf9 100644
--- a/drivers/char/tpm/tpm_i2c_infineon.c
+++ b/drivers/char/tpm/tpm_i2c_infineon.c
@@ -585,9 +585,6 @@ static int tpm_tis_i2c_init(struct device *dev)
if (IS_ERR(chip))
return PTR_ERR(chip);
- /* Disable interrupts */
- chip->vendor.irq = 0;
-
/* Default timeouts */
chip->vendor.timeout_a = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
chip->vendor.timeout_b = msecs_to_jiffies(TIS_LONG_TIMEOUT);
diff --git a/drivers/char/tpm/tpm_i2c_nuvoton.c b/drivers/char/tpm/tpm_i2c_nuvoton.c
index a43b5f3..75a80e466 100644
--- a/drivers/char/tpm/tpm_i2c_nuvoton.c
+++ b/drivers/char/tpm/tpm_i2c_nuvoton.c
@@ -55,6 +55,7 @@
#define I2C_DRIVER_NAME "tpm_i2c_nuvoton"
struct priv_data {
+ int irq;
unsigned int intrs;
};
@@ -176,12 +177,12 @@ static bool i2c_nuvoton_check_status(struct tpm_chip *chip, u8 mask, u8 value)
static int i2c_nuvoton_wait_for_stat(struct tpm_chip *chip, u8 mask, u8 value,
u32 timeout, wait_queue_head_t *queue)
{
- if (chip->vendor.irq && queue) {
+ if ((chip->flags & TPM_CHIP_FLAG_IRQ) && queue) {
s32 rc;
struct priv_data *priv = chip->vendor.priv;
unsigned int cur_intrs = priv->intrs;
- enable_irq(chip->vendor.irq);
+ enable_irq(priv->irq);
rc = wait_event_interruptible_timeout(*queue,
cur_intrs != priv->intrs,
timeout);
@@ -477,7 +478,7 @@ static irqreturn_t i2c_nuvoton_int_handler(int dummy, void *dev_id)
priv->intrs++;
wake_up(&chip->vendor.read_queue);
- disable_irq_nosync(chip->vendor.irq);
+ disable_irq_nosync(priv->irq);
return IRQ_HANDLED;
}
@@ -521,6 +522,7 @@ static int i2c_nuvoton_probe(struct i2c_client *client,
int rc;
struct tpm_chip *chip;
struct device *dev = &client->dev;
+ struct priv_data *priv;
u32 vid = 0;
rc = get_vid(client, &vid);
@@ -534,10 +536,10 @@ static int i2c_nuvoton_probe(struct i2c_client *client,
if (IS_ERR(chip))
return PTR_ERR(chip);
- chip->vendor.priv = devm_kzalloc(dev, sizeof(struct priv_data),
- GFP_KERNEL);
- if (!chip->vendor.priv)
+ priv = devm_kzalloc(dev, sizeof(struct priv_data), GFP_KERNEL);
+ if (!priv)
return -ENOMEM;
+ chip->vendor.priv = priv;
init_waitqueue_head(&chip->vendor.read_queue);
@@ -552,19 +554,21 @@ static int i2c_nuvoton_probe(struct i2c_client *client,
* TPM_INTF_INT_LEVEL_LOW | TPM_INTF_DATA_AVAIL_INT
* The IRQ should be set in the i2c_board_info (which is done
* automatically in of_i2c_register_devices, for device tree users */
- chip->vendor.irq = client->irq;
+ chip->flags |= TPM_CHIP_FLAG_IRQ;
+ priv->irq = client->irq;
- if (chip->vendor.irq) {
- dev_dbg(dev, "%s() chip-vendor.irq\n", __func__);
- rc = devm_request_irq(dev, chip->vendor.irq,
+ if (chip->flags & TPM_CHIP_FLAG_IRQ) {
+ dev_dbg(dev, "%s() priv->irq\n", __func__);
+ rc = devm_request_irq(dev, client->irq,
i2c_nuvoton_int_handler,
IRQF_TRIGGER_LOW,
dev_name(&chip->dev),
chip);
if (rc) {
dev_err(dev, "%s() Unable to request irq: %d for use\n",
- __func__, chip->vendor.irq);
- chip->vendor.irq = 0;
+ __func__, priv->irq);
+ chip->flags &= ~TPM_CHIP_FLAG_IRQ;
+ priv->irq = 0;
} else {
/* Clear any pending interrupt */
i2c_nuvoton_ready(chip);
diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index 27c35c0..7235233 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ b/drivers/char/tpm/tpm_tis.c
@@ -96,6 +96,7 @@ struct tpm_info {
struct priv_data {
void __iomem *iobase;
u16 manufacturer_id;
+ int irq;
bool irq_tested;
wait_queue_head_t int_queue;
};
@@ -177,7 +178,7 @@ static int request_locality(struct tpm_chip *chip, int l)
stop = jiffies + chip->vendor.timeout_a;
- if (chip->vendor.irq) {
+ if (chip->flags & TPM_CHIP_FLAG_IRQ) {
again:
timeout = stop - jiffies;
if ((long)timeout <= 0)
@@ -385,8 +386,9 @@ static void disable_interrupts(struct tpm_chip *chip)
intmask &= ~TPM_GLOBAL_INT_ENABLE;
iowrite32(intmask,
priv->iobase + TPM_INT_ENABLE(chip->vendor.locality));
- devm_free_irq(&chip->dev, chip->vendor.irq, chip);
- chip->vendor.irq = 0;
+ devm_free_irq(&chip->dev, priv->irq, chip);
+ priv->irq = 0;
+ chip->flags &= ~TPM_CHIP_FLAG_IRQ;
}
/*
@@ -409,7 +411,7 @@ static int tpm_tis_send_main(struct tpm_chip *chip, u8 *buf, size_t len)
iowrite8(TPM_STS_GO,
priv->iobase + TPM_STS(chip->vendor.locality));
- if (chip->vendor.irq) {
+ if (chip->flags & TPM_CHIP_FLAG_IRQ) {
ordinal = be32_to_cpu(*((__be32 *) (buf + 6)));
if (chip->flags & TPM_CHIP_FLAG_TPM2)
@@ -436,14 +438,16 @@ static int tpm_tis_send(struct tpm_chip *chip, u8 *buf, size_t len)
int rc, irq;
struct priv_data *priv = chip->vendor.priv;
- if (!chip->vendor.irq || priv->irq_tested)
+ if (!(chip->flags & TPM_CHIP_FLAG_IRQ) || priv->irq_tested)
return tpm_tis_send_main(chip, buf, len);
/* Verify receipt of the expected IRQ */
- irq = chip->vendor.irq;
- chip->vendor.irq = 0;
+ irq = priv->irq;
+ priv->irq = 0;
+ chip->flags &= ~TPM_CHIP_FLAG_IRQ;
rc = tpm_tis_send_main(chip, buf, len);
- chip->vendor.irq = irq;
+ priv->irq = irq;
+ chip->flags |= TPM_CHIP_FLAG_IRQ;
if (!priv->irq_tested)
msleep(1);
if (!priv->irq_tested)
@@ -605,7 +609,7 @@ static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask,
irq);
return -1;
}
- chip->vendor.irq = irq;
+ priv->irq = irq;
original_int_vec = ioread8(priv->iobase +
TPM_INT_VECTOR(chip->vendor.locality));
@@ -634,7 +638,7 @@ static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask,
/* tpm_tis_send will either confirm the interrupt is working or it
* will call disable_irq which undoes all of the above.
*/
- if (!chip->vendor.irq) {
+ if (!(chip->flags & TPM_CHIP_FLAG_IRQ)) {
iowrite8(original_int_vec,
priv->iobase + TPM_INT_VECTOR(chip->vendor.locality));
return 1;
@@ -800,7 +804,7 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info,
if (tpm_info->irq) {
tpm_tis_probe_irq_single(chip, intmask, IRQF_SHARED,
tpm_info->irq);
- if (!chip->vendor.irq)
+ if (!(chip->flags & TPM_CHIP_FLAG_IRQ))
dev_err(&chip->dev, FW_BUG
"TPM interrupt not working, polling instead\n");
} else
@@ -844,7 +848,7 @@ static void tpm_tis_reenable_interrupts(struct tpm_chip *chip)
/* reenable interrupts that device may have lost or
BIOS/firmware may have disabled */
- iowrite8(chip->vendor.irq, priv->iobase +
+ iowrite8(priv->irq, priv->iobase +
TPM_INT_VECTOR(chip->vendor.locality));
intmask =
@@ -863,7 +867,7 @@ static int tpm_tis_resume(struct device *dev)
struct tpm_chip *chip = dev_get_drvdata(dev);
int ret;
- if (chip->vendor.irq)
+ if (chip->flags & TPM_CHIP_FLAG_IRQ)
tpm_tis_reenable_interrupts(chip);
ret = tpm_pm_resume(dev);
diff --git a/drivers/char/tpm/xen-tpmfront.c b/drivers/char/tpm/xen-tpmfront.c
index 3111f27..329941d 100644
--- a/drivers/char/tpm/xen-tpmfront.c
+++ b/drivers/char/tpm/xen-tpmfront.c
@@ -28,6 +28,7 @@ struct tpm_private {
unsigned int evtchn;
int ring_ref;
domid_t backend_id;
+ int irq;
};
enum status_bits {
@@ -217,7 +218,7 @@ static int setup_ring(struct xenbus_device *dev, struct tpm_private *priv)
xenbus_dev_fatal(dev, rv, "allocating TPM irq");
return rv;
}
- priv->chip->vendor.irq = rv;
+ priv->irq = rv;
again:
rv = xenbus_transaction_start(&xbt);
@@ -277,8 +278,8 @@ static void ring_free(struct tpm_private *priv)
else
free_page((unsigned long)priv->shr);
- if (priv->chip && priv->chip->vendor.irq)
- unbind_from_irqhandler(priv->chip->vendor.irq, priv);
+ if (priv->irq)
+ unbind_from_irqhandler(priv->irq, priv);
kfree(priv);
}
--
2.5.0
------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785471&iu=/4140
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v4 3/6] tpm: drop 'read_queue' from struct tpm_vendor_specific
[not found] ` <1459457820-30542-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
2016-03-31 20:56 ` [PATCH v4 1/6] tpm: drop 'iobase' from struct tpm_vendor_specific Christophe Ricard
2016-03-31 20:56 ` [PATCH v4 2/6] tpm: drop 'irq' " Christophe Ricard
@ 2016-03-31 20:56 ` Christophe Ricard
2016-03-31 20:56 ` [PATCH v4 4/6] tpm: drop 'locality' " Christophe Ricard
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Christophe Ricard @ 2016-03-31 20:56 UTC (permalink / raw)
To: jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA
Cc: jean-luc.blanc-qxv4g6HH51o, ashley-fm2HMyfA2y6tG0bUXCXiUA,
tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
christophe-h.ricard-qxv4g6HH51o, benoit.houyere-qxv4g6HH51o
Dropped the field 'read_queue' from struct tpm_vendor_specific and make it
available to the various private structures in the drivers.
Signed-off-by: Christophe Ricard <christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
drivers/char/tpm/st33zp24/st33zp24.c | 12 ++++++------
drivers/char/tpm/st33zp24/st33zp24.h | 1 +
drivers/char/tpm/tpm.h | 2 --
drivers/char/tpm/tpm_i2c_nuvoton.c | 14 +++++++++-----
drivers/char/tpm/tpm_tis.c | 9 +++++----
drivers/char/tpm/xen-tpmfront.c | 11 ++++++-----
6 files changed, 27 insertions(+), 22 deletions(-)
diff --git a/drivers/char/tpm/st33zp24/st33zp24.c b/drivers/char/tpm/st33zp24/st33zp24.c
index f4a44ad..d2e0175 100644
--- a/drivers/char/tpm/st33zp24/st33zp24.c
+++ b/drivers/char/tpm/st33zp24/st33zp24.c
@@ -338,7 +338,7 @@ static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count)
wait_for_stat(chip,
TPM_STS_DATA_AVAIL | TPM_STS_VALID,
chip->vendor.timeout_c,
- &chip->vendor.read_queue, true) == 0) {
+ &tpm_dev->read_queue, true) == 0) {
burstcnt = get_burstcount(chip);
if (burstcnt < 0)
return burstcnt;
@@ -367,7 +367,7 @@ static irqreturn_t tpm_ioserirq_handler(int irq, void *dev_id)
tpm_dev = (struct st33zp24_dev *)TPM_VPRIV(chip);
tpm_dev->intrs++;
- wake_up_interruptible(&chip->vendor.read_queue);
+ wake_up_interruptible(&tpm_dev->read_queue);
disable_irq_nosync(tpm_dev->irq);
return IRQ_HANDLED;
@@ -407,7 +407,7 @@ static int st33zp24_send(struct tpm_chip *chip, unsigned char *buf,
st33zp24_cancel(chip);
if (wait_for_stat
(chip, TPM_STS_COMMAND_READY, chip->vendor.timeout_b,
- &chip->vendor.read_queue, false) < 0) {
+ &tpm_dev->read_queue, false) < 0) {
ret = -ETIME;
goto out_err;
}
@@ -453,7 +453,7 @@ static int st33zp24_send(struct tpm_chip *chip, unsigned char *buf,
ret = wait_for_stat(chip, TPM_STS_DATA_AVAIL | TPM_STS_VALID,
tpm_calc_ordinal_duration(chip, ordinal),
- &chip->vendor.read_queue, false);
+ &tpm_dev->read_queue, false);
if (ret < 0)
goto out_err;
}
@@ -570,7 +570,7 @@ int st33zp24_probe(void *phy_id, const struct st33zp24_phy_ops *ops,
if (irq) {
/* INTERRUPT Setup */
- init_waitqueue_head(&chip->vendor.read_queue);
+ init_waitqueue_head(&tpm_dev->read_queue);
tpm_dev->intrs = 0;
if (request_locality(chip) != LOCALITY0) {
@@ -674,7 +674,7 @@ int st33zp24_pm_resume(struct device *dev)
gpio_set_value(tpm_dev->io_lpcpd, 1);
ret = wait_for_stat(chip,
TPM_STS_VALID, chip->vendor.timeout_b,
- &chip->vendor.read_queue, false);
+ &tpm_dev->read_queue, false);
} else {
ret = tpm_pm_resume(dev);
if (!ret)
diff --git a/drivers/char/tpm/st33zp24/st33zp24.h b/drivers/char/tpm/st33zp24/st33zp24.h
index 27e7564..9b5cdc7 100644
--- a/drivers/char/tpm/st33zp24/st33zp24.h
+++ b/drivers/char/tpm/st33zp24/st33zp24.h
@@ -28,6 +28,7 @@ struct st33zp24_dev {
int irq;
u32 intrs;
int io_lpcpd;
+ wait_queue_head_t read_queue;
};
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index ad4799c..62e711b 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -137,8 +137,6 @@ struct tpm_vendor_specific {
unsigned long duration[3]; /* jiffies */
bool duration_adjusted;
void *priv;
-
- wait_queue_head_t read_queue;
};
#define TPM_VPRIV(c) ((c)->vendor.priv)
diff --git a/drivers/char/tpm/tpm_i2c_nuvoton.c b/drivers/char/tpm/tpm_i2c_nuvoton.c
index 75a80e466..2c1fa26 100644
--- a/drivers/char/tpm/tpm_i2c_nuvoton.c
+++ b/drivers/char/tpm/tpm_i2c_nuvoton.c
@@ -57,6 +57,7 @@
struct priv_data {
int irq;
unsigned int intrs;
+ wait_queue_head_t read_queue;
};
static s32 i2c_nuvoton_read_buf(struct i2c_client *client, u8 offset, u8 size,
@@ -232,13 +233,14 @@ static int i2c_nuvoton_wait_for_data_avail(struct tpm_chip *chip, u32 timeout,
static int i2c_nuvoton_recv_data(struct i2c_client *client,
struct tpm_chip *chip, u8 *buf, size_t count)
{
+ struct priv_data *priv = chip->vendor.priv;
s32 rc;
int burst_count, bytes2read, size = 0;
while (size < count &&
i2c_nuvoton_wait_for_data_avail(chip,
chip->vendor.timeout_c,
- &chip->vendor.read_queue) == 0) {
+ &priv->read_queue) == 0) {
burst_count = i2c_nuvoton_get_burstcount(client, chip);
if (burst_count < 0) {
dev_err(&chip->dev,
@@ -265,6 +267,7 @@ static int i2c_nuvoton_recv_data(struct i2c_client *client,
/* Read TPM command results */
static int i2c_nuvoton_recv(struct tpm_chip *chip, u8 *buf, size_t count)
{
+ struct priv_data *priv = chip->vendor.priv;
struct device *dev = chip->dev.parent;
struct i2c_client *client = to_i2c_client(dev);
s32 rc;
@@ -286,7 +289,7 @@ static int i2c_nuvoton_recv(struct tpm_chip *chip, u8 *buf, size_t count)
* tag, paramsize, and result
*/
status = i2c_nuvoton_wait_for_data_avail(
- chip, chip->vendor.timeout_c, &chip->vendor.read_queue);
+ chip, chip->vendor.timeout_c, &priv->read_queue);
if (status != 0) {
dev_err(dev, "%s() timeout on dataAvail\n", __func__);
size = -ETIMEDOUT;
@@ -348,6 +351,7 @@ static int i2c_nuvoton_recv(struct tpm_chip *chip, u8 *buf, size_t count)
*/
static int i2c_nuvoton_send(struct tpm_chip *chip, u8 *buf, size_t len)
{
+ struct priv_data *priv = chip->vendor.priv;
struct device *dev = chip->dev.parent;
struct i2c_client *client = to_i2c_client(dev);
u32 ordinal;
@@ -440,7 +444,7 @@ static int i2c_nuvoton_send(struct tpm_chip *chip, u8 *buf, size_t len)
rc = i2c_nuvoton_wait_for_data_avail(chip,
tpm_calc_ordinal_duration(chip,
ordinal),
- &chip->vendor.read_queue);
+ &priv->read_queue);
if (rc) {
dev_err(dev, "%s() timeout command duration\n", __func__);
i2c_nuvoton_ready(chip);
@@ -477,7 +481,7 @@ static irqreturn_t i2c_nuvoton_int_handler(int dummy, void *dev_id)
struct priv_data *priv = chip->vendor.priv;
priv->intrs++;
- wake_up(&chip->vendor.read_queue);
+ wake_up(&priv->read_queue);
disable_irq_nosync(priv->irq);
return IRQ_HANDLED;
}
@@ -541,7 +545,7 @@ static int i2c_nuvoton_probe(struct i2c_client *client,
return -ENOMEM;
chip->vendor.priv = priv;
- init_waitqueue_head(&chip->vendor.read_queue);
+ init_waitqueue_head(&priv->read_queue);
/* Default timeouts */
chip->vendor.timeout_a = msecs_to_jiffies(TPM_I2C_SHORT_TIMEOUT);
diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index 7235233..c52cfe1 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ b/drivers/char/tpm/tpm_tis.c
@@ -99,6 +99,7 @@ struct priv_data {
int irq;
bool irq_tested;
wait_queue_head_t int_queue;
+ wait_queue_head_t read_queue;
};
#if defined(CONFIG_PNP) && defined(CONFIG_ACPI)
@@ -252,7 +253,7 @@ static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count)
wait_for_tpm_stat(chip,
TPM_STS_DATA_AVAIL | TPM_STS_VALID,
chip->vendor.timeout_c,
- &chip->vendor.read_queue, true)
+ &priv->read_queue, true)
== 0) {
burstcnt = get_burstcount(chip);
for (; burstcnt > 0 && size < count; burstcnt--)
@@ -421,7 +422,7 @@ static int tpm_tis_send_main(struct tpm_chip *chip, u8 *buf, size_t len)
if (wait_for_tpm_stat
(chip, TPM_STS_DATA_AVAIL | TPM_STS_VALID, dur,
- &chip->vendor.read_queue, false) < 0) {
+ &priv->read_queue, false) < 0) {
rc = -ETIME;
goto out_err;
}
@@ -575,7 +576,7 @@ static irqreturn_t tis_int_handler(int dummy, void *dev_id)
((struct priv_data *)chip->vendor.priv)->irq_tested = true;
if (interrupt & TPM_INTF_DATA_AVAIL_INT)
- wake_up_interruptible(&chip->vendor.read_queue);
+ wake_up_interruptible(&priv->read_queue);
if (interrupt & TPM_INTF_LOCALITY_CHANGE_INT)
for (i = 0; i < 5; i++)
if (check_locality(chip, i) >= 0)
@@ -798,7 +799,7 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info,
}
/* INTERRUPT Setup */
- init_waitqueue_head(&chip->vendor.read_queue);
+ init_waitqueue_head(&priv->read_queue);
init_waitqueue_head(&priv->int_queue);
if (interrupts && tpm_info->irq != -1) {
if (tpm_info->irq) {
diff --git a/drivers/char/tpm/xen-tpmfront.c b/drivers/char/tpm/xen-tpmfront.c
index 329941d..cca89d9 100644
--- a/drivers/char/tpm/xen-tpmfront.c
+++ b/drivers/char/tpm/xen-tpmfront.c
@@ -29,6 +29,7 @@ struct tpm_private {
int ring_ref;
domid_t backend_id;
int irq;
+ wait_queue_head_t read_queue;
};
enum status_bits {
@@ -89,7 +90,7 @@ static int vtpm_send(struct tpm_chip *chip, u8 *buf, size_t count)
/* Wait for completion of any existing command or cancellation */
if (wait_for_tpm_stat(chip, VTPM_STATUS_IDLE, chip->vendor.timeout_c,
- &chip->vendor.read_queue, true) < 0) {
+ &priv->read_queue, true) < 0) {
vtpm_cancel(chip);
return -ETIME;
}
@@ -105,7 +106,7 @@ static int vtpm_send(struct tpm_chip *chip, u8 *buf, size_t count)
duration = tpm_calc_ordinal_duration(chip, ordinal);
if (wait_for_tpm_stat(chip, VTPM_STATUS_IDLE, duration,
- &chip->vendor.read_queue, true) < 0) {
+ &priv->read_queue, true) < 0) {
/* got a signal or timeout, try to cancel */
vtpm_cancel(chip);
return -ETIME;
@@ -126,7 +127,7 @@ static int vtpm_recv(struct tpm_chip *chip, u8 *buf, size_t count)
/* In theory the wait at the end of _send makes this one unnecessary */
if (wait_for_tpm_stat(chip, VTPM_STATUS_RESULT, chip->vendor.timeout_c,
- &chip->vendor.read_queue, true) < 0) {
+ &priv->read_queue, true) < 0) {
vtpm_cancel(chip);
return -ETIME;
}
@@ -162,7 +163,7 @@ static irqreturn_t tpmif_interrupt(int dummy, void *dev_id)
switch (priv->shr->state) {
case VTPM_STATE_IDLE:
case VTPM_STATE_FINISH:
- wake_up_interruptible(&priv->chip->vendor.read_queue);
+ wake_up_interruptible(&priv->read_queue);
break;
case VTPM_STATE_SUBMIT:
case VTPM_STATE_CANCEL:
@@ -180,7 +181,7 @@ static int setup_chip(struct device *dev, struct tpm_private *priv)
if (IS_ERR(chip))
return PTR_ERR(chip);
- init_waitqueue_head(&chip->vendor.read_queue);
+ init_waitqueue_head(&priv->read_queue);
priv->chip = chip;
TPM_VPRIV(chip) = priv;
--
2.5.0
------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785471&iu=/4140
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v4 4/6] tpm: drop 'locality' from struct tpm_vendor_specific
[not found] ` <1459457820-30542-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
` (2 preceding siblings ...)
2016-03-31 20:56 ` [PATCH v4 3/6] tpm: drop 'read_queue' " Christophe Ricard
@ 2016-03-31 20:56 ` Christophe Ricard
2016-03-31 20:56 ` [PATCH v4 5/6] tpm: Move tpm_vendor_specific data related with PTP specification to tpm_chip Christophe Ricard
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Christophe Ricard @ 2016-03-31 20:56 UTC (permalink / raw)
To: jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA
Cc: jean-luc.blanc-qxv4g6HH51o, ashley-fm2HMyfA2y6tG0bUXCXiUA,
tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
christophe-h.ricard-qxv4g6HH51o, benoit.houyere-qxv4g6HH51o
Dropped the field 'locality' from struct tpm_vendor_specific migrated it to
the private structures of st33zp24, tpm_i2c_infineon and tpm_tis.
Signed-off-by: Christophe Ricard <christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
drivers/char/tpm/st33zp24/st33zp24.c | 12 +++---
drivers/char/tpm/st33zp24/st33zp24.h | 1 +
drivers/char/tpm/tpm.h | 1 -
drivers/char/tpm/tpm_i2c_infineon.c | 25 +++++++------
drivers/char/tpm/tpm_tis.c | 71 ++++++++++++++++++------------------
5 files changed, 55 insertions(+), 55 deletions(-)
diff --git a/drivers/char/tpm/st33zp24/st33zp24.c b/drivers/char/tpm/st33zp24/st33zp24.c
index d2e0175..3802c58 100644
--- a/drivers/char/tpm/st33zp24/st33zp24.c
+++ b/drivers/char/tpm/st33zp24/st33zp24.c
@@ -136,7 +136,7 @@ static int check_locality(struct tpm_chip *chip)
if (status && (data &
(TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID)) ==
(TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID))
- return chip->vendor.locality;
+ return tpm_dev->locality;
return -EACCES;
} /* check_locality() */
@@ -153,11 +153,11 @@ static int request_locality(struct tpm_chip *chip)
struct st33zp24_dev *tpm_dev;
u8 data;
- if (check_locality(chip) == chip->vendor.locality)
- return chip->vendor.locality;
-
tpm_dev = (struct st33zp24_dev *)TPM_VPRIV(chip);
+ if (check_locality(chip) == tpm_dev->locality)
+ return tpm_dev->locality;
+
data = TPM_ACCESS_REQUEST_USE;
ret = tpm_dev->ops->send(tpm_dev->phy_id, TPM_ACCESS, &data, 1);
if (ret < 0)
@@ -168,7 +168,7 @@ static int request_locality(struct tpm_chip *chip)
/* Request locality is usually effective after the request */
do {
if (check_locality(chip) >= 0)
- return chip->vendor.locality;
+ return tpm_dev->locality;
msleep(TPM_TIMEOUT);
} while (time_before(jiffies, stop));
@@ -566,7 +566,7 @@ int st33zp24_probe(void *phy_id, const struct st33zp24_phy_ops *ops,
chip->vendor.timeout_c = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
chip->vendor.timeout_d = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
- chip->vendor.locality = LOCALITY0;
+ tpm_dev->locality = LOCALITY0;
if (irq) {
/* INTERRUPT Setup */
diff --git a/drivers/char/tpm/st33zp24/st33zp24.h b/drivers/char/tpm/st33zp24/st33zp24.h
index 9b5cdc7..6f4a419 100644
--- a/drivers/char/tpm/st33zp24/st33zp24.h
+++ b/drivers/char/tpm/st33zp24/st33zp24.h
@@ -25,6 +25,7 @@ struct st33zp24_dev {
struct tpm_chip *chip;
void *phy_id;
const struct st33zp24_phy_ops *ops;
+ int locality;
int irq;
u32 intrs;
int io_lpcpd;
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index 62e711b..68a40c6 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -131,7 +131,6 @@ enum tpm2_startup_types {
struct tpm_chip;
struct tpm_vendor_specific {
- int locality;
unsigned long timeout_a, timeout_b, timeout_c, timeout_d; /* jiffies */
bool timeout_adjusted;
unsigned long duration[3]; /* jiffies */
diff --git a/drivers/char/tpm/tpm_i2c_infineon.c b/drivers/char/tpm/tpm_i2c_infineon.c
index 093daf9..8318946 100644
--- a/drivers/char/tpm/tpm_i2c_infineon.c
+++ b/drivers/char/tpm/tpm_i2c_infineon.c
@@ -66,6 +66,7 @@ enum i2c_chip_type {
/* Structure to store I2C TPM specific stuff */
struct tpm_inf_dev {
struct i2c_client *client;
+ int locality;
u8 buf[TPM_BUFSIZE + sizeof(u8)]; /* max. buffer size + addr */
struct tpm_chip *chip;
enum i2c_chip_type chip_type;
@@ -288,7 +289,7 @@ static int check_locality(struct tpm_chip *chip, int loc)
if ((buf & (TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID)) ==
(TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID)) {
- chip->vendor.locality = loc;
+ tpm_dev.locality = loc;
return loc;
}
@@ -337,7 +338,7 @@ static u8 tpm_tis_i2c_status(struct tpm_chip *chip)
u8 i = 0;
do {
- if (iic_tpm_read(TPM_STS(chip->vendor.locality), &buf, 1) < 0)
+ if (iic_tpm_read(TPM_STS(tpm_dev.locality), &buf, 1) < 0)
return 0;
i++;
@@ -351,7 +352,7 @@ static void tpm_tis_i2c_ready(struct tpm_chip *chip)
{
/* this causes the current command to be aborted */
u8 buf = TPM_STS_COMMAND_READY;
- iic_tpm_write_long(TPM_STS(chip->vendor.locality), &buf, 1);
+ iic_tpm_write_long(TPM_STS(tpm_dev.locality), &buf, 1);
}
static ssize_t get_burstcount(struct tpm_chip *chip)
@@ -365,7 +366,7 @@ static ssize_t get_burstcount(struct tpm_chip *chip)
stop = jiffies + chip->vendor.timeout_d;
do {
/* Note: STS is little endian */
- if (iic_tpm_read(TPM_STS(chip->vendor.locality)+1, buf, 3) < 0)
+ if (iic_tpm_read(TPM_STS(tpm_dev.locality)+1, buf, 3) < 0)
burstcnt = 0;
else
burstcnt = (buf[2] << 16) + (buf[1] << 8) + buf[0];
@@ -419,7 +420,7 @@ static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count)
if (burstcnt > (count - size))
burstcnt = count - size;
- rc = iic_tpm_read(TPM_DATA_FIFO(chip->vendor.locality),
+ rc = iic_tpm_read(TPM_DATA_FIFO(tpm_dev.locality),
&(buf[size]), burstcnt);
if (rc == 0)
size += burstcnt;
@@ -477,7 +478,7 @@ out:
* so we sleep rather than keeping the bus busy
*/
usleep_range(SLEEP_DURATION_RESET_LOW, SLEEP_DURATION_RESET_HI);
- release_locality(chip, chip->vendor.locality, 0);
+ release_locality(chip, tpm_dev.locality, 0);
return size;
}
@@ -516,7 +517,7 @@ static int tpm_tis_i2c_send(struct tpm_chip *chip, u8 *buf, size_t len)
if (burstcnt > (len - 1 - count))
burstcnt = len - 1 - count;
- rc = iic_tpm_write(TPM_DATA_FIFO(chip->vendor.locality),
+ rc = iic_tpm_write(TPM_DATA_FIFO(tpm_dev.locality),
&(buf[count]), burstcnt);
if (rc == 0)
count += burstcnt;
@@ -539,7 +540,7 @@ static int tpm_tis_i2c_send(struct tpm_chip *chip, u8 *buf, size_t len)
}
/* write last byte */
- iic_tpm_write(TPM_DATA_FIFO(chip->vendor.locality), &(buf[count]), 1);
+ iic_tpm_write(TPM_DATA_FIFO(tpm_dev.locality), &(buf[count]), 1);
wait_for_stat(chip, TPM_STS_VALID, chip->vendor.timeout_c, &status);
if ((status & TPM_STS_DATA_EXPECT) != 0) {
rc = -EIO;
@@ -547,7 +548,7 @@ static int tpm_tis_i2c_send(struct tpm_chip *chip, u8 *buf, size_t len)
}
/* go and do it */
- iic_tpm_write(TPM_STS(chip->vendor.locality), &sts, 1);
+ iic_tpm_write(TPM_STS(tpm_dev.locality), &sts, 1);
return len;
out_err:
@@ -556,7 +557,7 @@ out_err:
* so we sleep rather than keeping the bus busy
*/
usleep_range(SLEEP_DURATION_RESET_LOW, SLEEP_DURATION_RESET_HI);
- release_locality(chip, chip->vendor.locality, 0);
+ release_locality(chip, tpm_dev.locality, 0);
return rc;
}
@@ -623,7 +624,7 @@ static int tpm_tis_i2c_init(struct device *dev)
return tpm_chip_register(chip);
out_release:
- release_locality(chip, chip->vendor.locality, 1);
+ release_locality(chip, tpm_dev.locality, 1);
tpm_dev.client = NULL;
out_err:
return rc;
@@ -695,7 +696,7 @@ static int tpm_tis_i2c_remove(struct i2c_client *client)
struct tpm_chip *chip = tpm_dev.chip;
tpm_chip_unregister(chip);
- release_locality(chip, chip->vendor.locality, 1);
+ release_locality(chip, tpm_dev.locality, 1);
tpm_dev.client = NULL;
return 0;
diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index c52cfe1..33e18c9 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ b/drivers/char/tpm/tpm_tis.c
@@ -96,6 +96,7 @@ struct tpm_info {
struct priv_data {
void __iomem *iobase;
u16 manufacturer_id;
+ int locality;
int irq;
bool irq_tested;
wait_queue_head_t int_queue;
@@ -149,7 +150,7 @@ static int check_locality(struct tpm_chip *chip, int l)
if ((ioread8(priv->iobase + TPM_ACCESS(l)) &
(TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID)) ==
(TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID))
- return chip->vendor.locality = l;
+ return priv->locality = l;
return -1;
}
@@ -211,7 +212,7 @@ static u8 tpm_tis_status(struct tpm_chip *chip)
struct priv_data *priv = chip->vendor.priv;
return ioread8(priv->iobase +
- TPM_STS(chip->vendor.locality));
+ TPM_STS(priv->locality));
}
static void tpm_tis_ready(struct tpm_chip *chip)
@@ -220,7 +221,7 @@ static void tpm_tis_ready(struct tpm_chip *chip)
/* this causes the current command to be aborted */
iowrite8(TPM_STS_COMMAND_READY,
- priv->iobase + TPM_STS(chip->vendor.locality));
+ priv->iobase + TPM_STS(priv->locality));
}
static int get_burstcount(struct tpm_chip *chip)
@@ -234,9 +235,9 @@ static int get_burstcount(struct tpm_chip *chip)
stop = jiffies + chip->vendor.timeout_d;
do {
burstcnt = ioread8(priv->iobase +
- TPM_STS(chip->vendor.locality) + 1);
+ TPM_STS(priv->locality) + 1);
burstcnt += ioread8(priv->iobase +
- TPM_STS(chip->vendor.locality) +
+ TPM_STS(priv->locality) +
2) << 8;
if (burstcnt)
return burstcnt;
@@ -258,8 +259,7 @@ static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count)
burstcnt = get_burstcount(chip);
for (; burstcnt > 0 && size < count; burstcnt--)
buf[size++] = ioread8(priv->iobase +
- TPM_DATA_FIFO(chip->vendor.
- locality));
+ TPM_DATA_FIFO(priv->locality));
}
return size;
}
@@ -307,7 +307,7 @@ static int tpm_tis_recv(struct tpm_chip *chip, u8 *buf, size_t count)
out:
tpm_tis_ready(chip);
- release_locality(chip, chip->vendor.locality, 0);
+ release_locality(chip, priv->locality, 0);
return size;
}
@@ -344,7 +344,7 @@ static int tpm_tis_send_data(struct tpm_chip *chip, u8 *buf, size_t len)
burstcnt = get_burstcount(chip);
for (; burstcnt > 0 && count < len - 1; burstcnt--) {
iowrite8(buf[count], priv->iobase +
- TPM_DATA_FIFO(chip->vendor.locality));
+ TPM_DATA_FIFO(priv->locality));
count++;
}
@@ -359,7 +359,7 @@ static int tpm_tis_send_data(struct tpm_chip *chip, u8 *buf, size_t len)
/* write last byte */
iowrite8(buf[count],
- priv->iobase + TPM_DATA_FIFO(chip->vendor.locality));
+ priv->iobase + TPM_DATA_FIFO(priv->locality));
wait_for_tpm_stat(chip, TPM_STS_VALID, chip->vendor.timeout_c,
&priv->int_queue, false);
status = tpm_tis_status(chip);
@@ -372,7 +372,7 @@ static int tpm_tis_send_data(struct tpm_chip *chip, u8 *buf, size_t len)
out_err:
tpm_tis_ready(chip);
- release_locality(chip, chip->vendor.locality, 0);
+ release_locality(chip, priv->locality, 0);
return rc;
}
@@ -383,10 +383,10 @@ static void disable_interrupts(struct tpm_chip *chip)
intmask =
ioread32(priv->iobase +
- TPM_INT_ENABLE(chip->vendor.locality));
+ TPM_INT_ENABLE(priv->locality));
intmask &= ~TPM_GLOBAL_INT_ENABLE;
iowrite32(intmask,
- priv->iobase + TPM_INT_ENABLE(chip->vendor.locality));
+ priv->iobase + TPM_INT_ENABLE(priv->locality));
devm_free_irq(&chip->dev, priv->irq, chip);
priv->irq = 0;
chip->flags &= ~TPM_CHIP_FLAG_IRQ;
@@ -410,7 +410,7 @@ static int tpm_tis_send_main(struct tpm_chip *chip, u8 *buf, size_t len)
/* go and do it */
iowrite8(TPM_STS_GO,
- priv->iobase + TPM_STS(chip->vendor.locality));
+ priv->iobase + TPM_STS(priv->locality));
if (chip->flags & TPM_CHIP_FLAG_IRQ) {
ordinal = be32_to_cpu(*((__be32 *) (buf + 6)));
@@ -430,7 +430,7 @@ static int tpm_tis_send_main(struct tpm_chip *chip, u8 *buf, size_t len)
return len;
out_err:
tpm_tis_ready(chip);
- release_locality(chip, chip->vendor.locality, 0);
+ release_locality(chip, priv->locality, 0);
return rc;
}
@@ -516,7 +516,7 @@ static int probe_itpm(struct tpm_chip *chip)
goto out;
tpm_tis_ready(chip);
- release_locality(chip, chip->vendor.locality, 0);
+ release_locality(chip, priv->locality, 0);
itpm = true;
@@ -530,7 +530,7 @@ static int probe_itpm(struct tpm_chip *chip)
out:
itpm = rem_itpm;
tpm_tis_ready(chip);
- release_locality(chip, chip->vendor.locality, 0);
+ release_locality(chip, priv->locality, 0);
return rc;
}
@@ -569,7 +569,7 @@ static irqreturn_t tis_int_handler(int dummy, void *dev_id)
int i;
interrupt = ioread32(priv->iobase +
- TPM_INT_STATUS(chip->vendor.locality));
+ TPM_INT_STATUS(priv->locality));
if (interrupt == 0)
return IRQ_NONE;
@@ -589,8 +589,8 @@ static irqreturn_t tis_int_handler(int dummy, void *dev_id)
/* Clear interrupts handled with TPM_EOI */
iowrite32(interrupt,
priv->iobase +
- TPM_INT_STATUS(chip->vendor.locality));
- ioread32(priv->iobase + TPM_INT_STATUS(chip->vendor.locality));
+ TPM_INT_STATUS(priv->locality));
+ ioread32(priv->iobase + TPM_INT_STATUS(priv->locality));
return IRQ_HANDLED;
}
@@ -613,18 +613,18 @@ static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask,
priv->irq = irq;
original_int_vec = ioread8(priv->iobase +
- TPM_INT_VECTOR(chip->vendor.locality));
+ TPM_INT_VECTOR(priv->locality));
iowrite8(irq,
- priv->iobase + TPM_INT_VECTOR(chip->vendor.locality));
+ priv->iobase + TPM_INT_VECTOR(priv->locality));
/* Clear all existing */
iowrite32(ioread32(priv->iobase +
- TPM_INT_STATUS(chip->vendor.locality)),
- priv->iobase + TPM_INT_STATUS(chip->vendor.locality));
+ TPM_INT_STATUS(priv->locality)),
+ priv->iobase + TPM_INT_STATUS(priv->locality));
/* Turn on */
iowrite32(intmask | TPM_GLOBAL_INT_ENABLE,
- priv->iobase + TPM_INT_ENABLE(chip->vendor.locality));
+ priv->iobase + TPM_INT_ENABLE(priv->locality));
priv->irq_tested = false;
@@ -641,7 +641,7 @@ static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask,
*/
if (!(chip->flags & TPM_CHIP_FLAG_IRQ)) {
iowrite8(original_int_vec,
- priv->iobase + TPM_INT_VECTOR(chip->vendor.locality));
+ priv->iobase + TPM_INT_VECTOR(priv->locality));
return 1;
}
@@ -659,7 +659,7 @@ static void tpm_tis_probe_irq(struct tpm_chip *chip, u32 intmask)
int i;
original_int_vec = ioread8(priv->iobase +
- TPM_INT_VECTOR(chip->vendor.locality));
+ TPM_INT_VECTOR(priv->locality));
if (!original_int_vec) {
if (IS_ENABLED(CONFIG_X86))
@@ -679,14 +679,13 @@ MODULE_PARM_DESC(interrupts, "Enable interrupts");
static void tpm_tis_remove(struct tpm_chip *chip)
{
struct priv_data *priv = chip->vendor.priv;
- void __iomem *reg = priv->iobase +
- TPM_INT_ENABLE(chip->vendor.locality);
+ void __iomem *reg = priv->iobase + TPM_INT_ENABLE(priv->locality);
if (chip->flags & TPM_CHIP_FLAG_TPM2)
tpm2_shutdown(chip, TPM2_SU_CLEAR);
iowrite32(~TPM_GLOBAL_INT_ENABLE & ioread32(reg), reg);
- release_locality(chip, chip->vendor.locality, 1);
+ release_locality(chip, priv->locality, 1);
}
static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info,
@@ -727,12 +726,12 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info,
/* Take control of the TPM's interrupt hardware and shut it off */
intmask = ioread32(priv->iobase +
- TPM_INT_ENABLE(chip->vendor.locality));
+ TPM_INT_ENABLE(priv->locality));
intmask |= TPM_INTF_CMD_READY_INT | TPM_INTF_LOCALITY_CHANGE_INT |
TPM_INTF_DATA_AVAIL_INT | TPM_INTF_STS_VALID_INT;
intmask &= ~TPM_GLOBAL_INT_ENABLE;
iowrite32(intmask,
- priv->iobase + TPM_INT_ENABLE(chip->vendor.locality));
+ priv->iobase + TPM_INT_ENABLE(priv->locality));
if (request_locality(chip, 0) != 0) {
rc = -ENODEV;
@@ -766,7 +765,7 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info,
/* Figure out the capabilities */
intfcaps =
ioread32(priv->iobase +
- TPM_INTF_CAPS(chip->vendor.locality));
+ TPM_INTF_CAPS(priv->locality));
dev_dbg(dev, "TPM interface capabilities (0x%x):\n",
intfcaps);
if (intfcaps & TPM_INTF_BURST_COUNT_STATIC)
@@ -850,17 +849,17 @@ static void tpm_tis_reenable_interrupts(struct tpm_chip *chip)
/* reenable interrupts that device may have lost or
BIOS/firmware may have disabled */
iowrite8(priv->irq, priv->iobase +
- TPM_INT_VECTOR(chip->vendor.locality));
+ TPM_INT_VECTOR(priv->locality));
intmask =
- ioread32(priv->iobase + TPM_INT_ENABLE(chip->vendor.locality));
+ ioread32(priv->iobase + TPM_INT_ENABLE(priv->locality));
intmask |= TPM_INTF_CMD_READY_INT
| TPM_INTF_LOCALITY_CHANGE_INT | TPM_INTF_DATA_AVAIL_INT
| TPM_INTF_STS_VALID_INT | TPM_GLOBAL_INT_ENABLE;
iowrite32(intmask,
- priv->iobase + TPM_INT_ENABLE(chip->vendor.locality));
+ priv->iobase + TPM_INT_ENABLE(priv->locality));
}
static int tpm_tis_resume(struct device *dev)
--
2.5.0
------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785471&iu=/4140
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v4 5/6] tpm: Move tpm_vendor_specific data related with PTP specification to tpm_chip
[not found] ` <1459457820-30542-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
` (3 preceding siblings ...)
2016-03-31 20:56 ` [PATCH v4 4/6] tpm: drop 'locality' " Christophe Ricard
@ 2016-03-31 20:56 ` Christophe Ricard
2016-03-31 20:57 ` [PATCH v4 6/6] tpm: Remove useless priv field in struct tpm_vendor_specific Christophe Ricard
2016-04-01 12:05 ` [PATCH v4 0/6] Remove the tpm_vendor_specific structure Jarkko Sakkinen
6 siblings, 0 replies; 8+ messages in thread
From: Christophe Ricard @ 2016-03-31 20:56 UTC (permalink / raw)
To: jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA
Cc: jean-luc.blanc-qxv4g6HH51o, ashley-fm2HMyfA2y6tG0bUXCXiUA,
tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
christophe-h.ricard-qxv4g6HH51o, benoit.houyere-qxv4g6HH51o
Move tpm_vendor_specific data related to TCG PTP specification to tpm_chip.
Move all fields directly linked with well known TCG concepts and used in
TPM drivers (tpm_i2c_atmel, tpm_i2c_infineon, tpm_i2c_nuvoton, tpm_tis and xen-tpmfront) as well as in TPM core files
(tpm-sysfs, tpm-interface and tpm2-cmd) in tpm_chip.
Signed-off-by: Christophe Ricard <christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
---
drivers/char/tpm/st33zp24/st33zp24.c | 18 +++++++-------
drivers/char/tpm/tpm-interface.c | 48 ++++++++++++++++++------------------
drivers/char/tpm/tpm-sysfs.c | 20 +++++++--------
drivers/char/tpm/tpm.h | 11 ++++++---
drivers/char/tpm/tpm2-cmd.c | 2 +-
drivers/char/tpm/tpm_i2c_atmel.c | 8 +++---
drivers/char/tpm/tpm_i2c_infineon.c | 20 +++++++--------
drivers/char/tpm/tpm_i2c_nuvoton.c | 24 +++++++++---------
drivers/char/tpm/tpm_tis.c | 24 +++++++++---------
drivers/char/tpm/xen-tpmfront.c | 4 +--
10 files changed, 91 insertions(+), 88 deletions(-)
diff --git a/drivers/char/tpm/st33zp24/st33zp24.c b/drivers/char/tpm/st33zp24/st33zp24.c
index 3802c58..07531e9 100644
--- a/drivers/char/tpm/st33zp24/st33zp24.c
+++ b/drivers/char/tpm/st33zp24/st33zp24.c
@@ -163,7 +163,7 @@ static int request_locality(struct tpm_chip *chip)
if (ret < 0)
return ret;
- stop = jiffies + chip->vendor.timeout_a;
+ stop = jiffies + chip->timeout_a;
/* Request locality is usually effective after the request */
do {
@@ -205,7 +205,7 @@ static int get_burstcount(struct tpm_chip *chip)
tpm_dev = (struct st33zp24_dev *)TPM_VPRIV(chip);
- stop = jiffies + chip->vendor.timeout_d;
+ stop = jiffies + chip->timeout_d;
do {
status = tpm_dev->ops->recv(tpm_dev->phy_id, TPM_STS + 1,
&temp, 1);
@@ -337,7 +337,7 @@ static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count)
while (size < count &&
wait_for_stat(chip,
TPM_STS_DATA_AVAIL | TPM_STS_VALID,
- chip->vendor.timeout_c,
+ chip->timeout_c,
&tpm_dev->read_queue, true) == 0) {
burstcnt = get_burstcount(chip);
if (burstcnt < 0)
@@ -406,7 +406,7 @@ static int st33zp24_send(struct tpm_chip *chip, unsigned char *buf,
if ((status & TPM_STS_COMMAND_READY) == 0) {
st33zp24_cancel(chip);
if (wait_for_stat
- (chip, TPM_STS_COMMAND_READY, chip->vendor.timeout_b,
+ (chip, TPM_STS_COMMAND_READY, chip->timeout_b,
&tpm_dev->read_queue, false) < 0) {
ret = -ETIME;
goto out_err;
@@ -561,10 +561,10 @@ int st33zp24_probe(void *phy_id, const struct st33zp24_phy_ops *ops,
tpm_dev->phy_id = phy_id;
tpm_dev->ops = ops;
- chip->vendor.timeout_a = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
- chip->vendor.timeout_b = msecs_to_jiffies(TIS_LONG_TIMEOUT);
- chip->vendor.timeout_c = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
- chip->vendor.timeout_d = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
+ chip->timeout_a = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
+ chip->timeout_b = msecs_to_jiffies(TIS_LONG_TIMEOUT);
+ chip->timeout_c = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
+ chip->timeout_d = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
tpm_dev->locality = LOCALITY0;
@@ -673,7 +673,7 @@ int st33zp24_pm_resume(struct device *dev)
if (gpio_is_valid(tpm_dev->io_lpcpd)) {
gpio_set_value(tpm_dev->io_lpcpd, 1);
ret = wait_for_stat(chip,
- TPM_STS_VALID, chip->vendor.timeout_b,
+ TPM_STS_VALID, chip->timeout_b,
&tpm_dev->read_queue, false);
} else {
ret = tpm_pm_resume(dev);
diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
index 101bb47..7cba092 100644
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -319,7 +319,7 @@ unsigned long tpm_calc_ordinal_duration(struct tpm_chip *chip,
duration_idx = tpm_ordinal_duration[ordinal];
if (duration_idx != TPM_UNDEFINED)
- duration = chip->vendor.duration[duration_idx];
+ duration = chip->duration[duration_idx];
if (duration <= 0)
return 2 * 60 * HZ;
else
@@ -505,15 +505,15 @@ int tpm_get_timeouts(struct tpm_chip *chip)
if (chip->flags & TPM_CHIP_FLAG_TPM2) {
/* Fixed timeouts for TPM2 */
- chip->vendor.timeout_a = msecs_to_jiffies(TPM2_TIMEOUT_A);
- chip->vendor.timeout_b = msecs_to_jiffies(TPM2_TIMEOUT_B);
- chip->vendor.timeout_c = msecs_to_jiffies(TPM2_TIMEOUT_C);
- chip->vendor.timeout_d = msecs_to_jiffies(TPM2_TIMEOUT_D);
- chip->vendor.duration[TPM_SHORT] =
+ chip->timeout_a = msecs_to_jiffies(TPM2_TIMEOUT_A);
+ chip->timeout_b = msecs_to_jiffies(TPM2_TIMEOUT_B);
+ chip->timeout_c = msecs_to_jiffies(TPM2_TIMEOUT_C);
+ chip->timeout_d = msecs_to_jiffies(TPM2_TIMEOUT_D);
+ chip->duration[TPM_SHORT] =
msecs_to_jiffies(TPM2_DURATION_SHORT);
- chip->vendor.duration[TPM_MEDIUM] =
+ chip->duration[TPM_MEDIUM] =
msecs_to_jiffies(TPM2_DURATION_MEDIUM);
- chip->vendor.duration[TPM_LONG] =
+ chip->duration[TPM_LONG] =
msecs_to_jiffies(TPM2_DURATION_LONG);
return 0;
}
@@ -561,10 +561,10 @@ int tpm_get_timeouts(struct tpm_chip *chip)
* of misreporting.
*/
if (chip->ops->update_timeouts != NULL)
- chip->vendor.timeout_adjusted =
+ chip->timeout_adjusted =
chip->ops->update_timeouts(chip, new_timeout);
- if (!chip->vendor.timeout_adjusted) {
+ if (!chip->timeout_adjusted) {
/* Don't overwrite default if value is 0 */
if (new_timeout[0] != 0 && new_timeout[0] < 1000) {
int i;
@@ -572,12 +572,12 @@ int tpm_get_timeouts(struct tpm_chip *chip)
/* timeouts in msec rather usec */
for (i = 0; i != ARRAY_SIZE(new_timeout); i++)
new_timeout[i] *= 1000;
- chip->vendor.timeout_adjusted = true;
+ chip->timeout_adjusted = true;
}
}
/* Report adjusted timeouts */
- if (chip->vendor.timeout_adjusted) {
+ if (chip->timeout_adjusted) {
dev_info(&chip->dev,
HW_ERR "Adjusting reported timeouts: A %lu->%luus B %lu->%luus C %lu->%luus D %lu->%luus\n",
old_timeout[0], new_timeout[0],
@@ -586,10 +586,10 @@ int tpm_get_timeouts(struct tpm_chip *chip)
old_timeout[3], new_timeout[3]);
}
- chip->vendor.timeout_a = usecs_to_jiffies(new_timeout[0]);
- chip->vendor.timeout_b = usecs_to_jiffies(new_timeout[1]);
- chip->vendor.timeout_c = usecs_to_jiffies(new_timeout[2]);
- chip->vendor.timeout_d = usecs_to_jiffies(new_timeout[3]);
+ chip->timeout_a = usecs_to_jiffies(new_timeout[0]);
+ chip->timeout_b = usecs_to_jiffies(new_timeout[1]);
+ chip->timeout_c = usecs_to_jiffies(new_timeout[2]);
+ chip->timeout_d = usecs_to_jiffies(new_timeout[3]);
duration:
tpm_cmd.header.in = tpm_getcap_header;
@@ -608,11 +608,11 @@ duration:
return -EINVAL;
duration_cap = &tpm_cmd.params.getcap_out.cap.duration;
- chip->vendor.duration[TPM_SHORT] =
+ chip->duration[TPM_SHORT] =
usecs_to_jiffies(be32_to_cpu(duration_cap->tpm_short));
- chip->vendor.duration[TPM_MEDIUM] =
+ chip->duration[TPM_MEDIUM] =
usecs_to_jiffies(be32_to_cpu(duration_cap->tpm_medium));
- chip->vendor.duration[TPM_LONG] =
+ chip->duration[TPM_LONG] =
usecs_to_jiffies(be32_to_cpu(duration_cap->tpm_long));
/* The Broadcom BCM0102 chipset in a Dell Latitude D820 gets the above
@@ -620,11 +620,11 @@ duration:
* fix up the resulting too-small TPM_SHORT value to make things work.
* We also scale the TPM_MEDIUM and -_LONG values by 1000.
*/
- if (chip->vendor.duration[TPM_SHORT] < (HZ / 100)) {
- chip->vendor.duration[TPM_SHORT] = HZ;
- chip->vendor.duration[TPM_MEDIUM] *= 1000;
- chip->vendor.duration[TPM_LONG] *= 1000;
- chip->vendor.duration_adjusted = true;
+ if (chip->duration[TPM_SHORT] < (HZ / 100)) {
+ chip->duration[TPM_SHORT] = HZ;
+ chip->duration[TPM_MEDIUM] *= 1000;
+ chip->duration[TPM_LONG] *= 1000;
+ chip->duration_adjusted = true;
dev_info(&chip->dev, "Adjusting TPM timeout parameters.");
}
return 0;
diff --git a/drivers/char/tpm/tpm-sysfs.c b/drivers/char/tpm/tpm-sysfs.c
index 34e7fc7..a7c3473 100644
--- a/drivers/char/tpm/tpm-sysfs.c
+++ b/drivers/char/tpm/tpm-sysfs.c
@@ -236,14 +236,14 @@ static ssize_t durations_show(struct device *dev, struct device_attribute *attr,
{
struct tpm_chip *chip = dev_get_drvdata(dev);
- if (chip->vendor.duration[TPM_LONG] == 0)
+ if (chip->duration[TPM_LONG] == 0)
return 0;
return sprintf(buf, "%d %d %d [%s]\n",
- jiffies_to_usecs(chip->vendor.duration[TPM_SHORT]),
- jiffies_to_usecs(chip->vendor.duration[TPM_MEDIUM]),
- jiffies_to_usecs(chip->vendor.duration[TPM_LONG]),
- chip->vendor.duration_adjusted
+ jiffies_to_usecs(chip->duration[TPM_SHORT]),
+ jiffies_to_usecs(chip->duration[TPM_MEDIUM]),
+ jiffies_to_usecs(chip->duration[TPM_LONG]),
+ chip->duration_adjusted
? "adjusted" : "original");
}
static DEVICE_ATTR_RO(durations);
@@ -254,11 +254,11 @@ static ssize_t timeouts_show(struct device *dev, struct device_attribute *attr,
struct tpm_chip *chip = dev_get_drvdata(dev);
return sprintf(buf, "%d %d %d %d [%s]\n",
- jiffies_to_usecs(chip->vendor.timeout_a),
- jiffies_to_usecs(chip->vendor.timeout_b),
- jiffies_to_usecs(chip->vendor.timeout_c),
- jiffies_to_usecs(chip->vendor.timeout_d),
- chip->vendor.timeout_adjusted
+ jiffies_to_usecs(chip->timeout_a),
+ jiffies_to_usecs(chip->timeout_b),
+ jiffies_to_usecs(chip->timeout_c),
+ jiffies_to_usecs(chip->timeout_d),
+ chip->timeout_adjusted
? "adjusted" : "original");
}
static DEVICE_ATTR_RO(timeouts);
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index 68a40c6..93757e8 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -131,10 +131,6 @@ enum tpm2_startup_types {
struct tpm_chip;
struct tpm_vendor_specific {
- unsigned long timeout_a, timeout_b, timeout_c, timeout_d; /* jiffies */
- bool timeout_adjusted;
- unsigned long duration[3]; /* jiffies */
- bool duration_adjusted;
void *priv;
};
@@ -171,6 +167,13 @@ struct tpm_chip {
struct mutex tpm_mutex; /* tpm is processing */
struct tpm_vendor_specific vendor;
+ unsigned long timeout_a; /* jiffies */
+ unsigned long timeout_b; /* jiffies */
+ unsigned long timeout_c; /* jiffies */
+ unsigned long timeout_d; /* jiffies */
+ bool timeout_adjusted;
+ unsigned long duration[3]; /* jiffies */
+ bool duration_adjusted;
struct dentry **bios_dir;
diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c
index 5fc0e7c..9ce8031 100644
--- a/drivers/char/tpm/tpm2-cmd.c
+++ b/drivers/char/tpm/tpm2-cmd.c
@@ -793,7 +793,7 @@ unsigned long tpm2_calc_ordinal_duration(struct tpm_chip *chip, u32 ordinal)
index = tpm2_ordinal_duration[ordinal - TPM2_CC_FIRST];
if (index != TPM_UNDEFINED)
- duration = chip->vendor.duration[index];
+ duration = chip->duration[index];
if (duration <= 0)
duration = 2 * 60 * HZ;
diff --git a/drivers/char/tpm/tpm_i2c_atmel.c b/drivers/char/tpm/tpm_i2c_atmel.c
index 55fa51f..1b66da6 100644
--- a/drivers/char/tpm/tpm_i2c_atmel.c
+++ b/drivers/char/tpm/tpm_i2c_atmel.c
@@ -169,10 +169,10 @@ static int i2c_atmel_probe(struct i2c_client *client,
return -ENOMEM;
/* Default timeouts */
- chip->vendor.timeout_a = msecs_to_jiffies(TPM_I2C_SHORT_TIMEOUT);
- chip->vendor.timeout_b = msecs_to_jiffies(TPM_I2C_LONG_TIMEOUT);
- chip->vendor.timeout_c = msecs_to_jiffies(TPM_I2C_SHORT_TIMEOUT);
- chip->vendor.timeout_d = msecs_to_jiffies(TPM_I2C_SHORT_TIMEOUT);
+ chip->timeout_a = msecs_to_jiffies(TPM_I2C_SHORT_TIMEOUT);
+ chip->timeout_b = msecs_to_jiffies(TPM_I2C_LONG_TIMEOUT);
+ chip->timeout_c = msecs_to_jiffies(TPM_I2C_SHORT_TIMEOUT);
+ chip->timeout_d = msecs_to_jiffies(TPM_I2C_SHORT_TIMEOUT);
/* There is no known way to probe for this device, and all version
* information seems to be read via TPM commands. Thus we rely on the
diff --git a/drivers/char/tpm/tpm_i2c_infineon.c b/drivers/char/tpm/tpm_i2c_infineon.c
index 8318946..a426b6f 100644
--- a/drivers/char/tpm/tpm_i2c_infineon.c
+++ b/drivers/char/tpm/tpm_i2c_infineon.c
@@ -321,7 +321,7 @@ static int request_locality(struct tpm_chip *chip, int loc)
iic_tpm_write(TPM_ACCESS(loc), &buf, 1);
/* wait for burstcount */
- stop = jiffies + chip->vendor.timeout_a;
+ stop = jiffies + chip->timeout_a;
do {
if (check_locality(chip, loc) >= 0)
return loc;
@@ -363,7 +363,7 @@ static ssize_t get_burstcount(struct tpm_chip *chip)
/* wait for burstcount */
/* which timeout value, spec has 2 answers (c & d) */
- stop = jiffies + chip->vendor.timeout_d;
+ stop = jiffies + chip->timeout_d;
do {
/* Note: STS is little endian */
if (iic_tpm_read(TPM_STS(tpm_dev.locality)+1, buf, 3) < 0)
@@ -465,7 +465,7 @@ static int tpm_tis_i2c_recv(struct tpm_chip *chip, u8 *buf, size_t count)
goto out;
}
- wait_for_stat(chip, TPM_STS_VALID, chip->vendor.timeout_c, &status);
+ wait_for_stat(chip, TPM_STS_VALID, chip->timeout_c, &status);
if (status & TPM_STS_DATA_AVAIL) { /* retry? */
dev_err(&chip->dev, "Error left over data\n");
size = -EIO;
@@ -501,7 +501,7 @@ static int tpm_tis_i2c_send(struct tpm_chip *chip, u8 *buf, size_t len)
tpm_tis_i2c_ready(chip);
if (wait_for_stat
(chip, TPM_STS_COMMAND_READY,
- chip->vendor.timeout_b, &status) < 0) {
+ chip->timeout_b, &status) < 0) {
rc = -ETIME;
goto out_err;
}
@@ -531,7 +531,7 @@ static int tpm_tis_i2c_send(struct tpm_chip *chip, u8 *buf, size_t len)
}
wait_for_stat(chip, TPM_STS_VALID,
- chip->vendor.timeout_c, &status);
+ chip->timeout_c, &status);
if ((status & TPM_STS_DATA_EXPECT) == 0) {
rc = -EIO;
@@ -541,7 +541,7 @@ static int tpm_tis_i2c_send(struct tpm_chip *chip, u8 *buf, size_t len)
/* write last byte */
iic_tpm_write(TPM_DATA_FIFO(tpm_dev.locality), &(buf[count]), 1);
- wait_for_stat(chip, TPM_STS_VALID, chip->vendor.timeout_c, &status);
+ wait_for_stat(chip, TPM_STS_VALID, chip->timeout_c, &status);
if ((status & TPM_STS_DATA_EXPECT) != 0) {
rc = -EIO;
goto out_err;
@@ -587,10 +587,10 @@ static int tpm_tis_i2c_init(struct device *dev)
return PTR_ERR(chip);
/* Default timeouts */
- chip->vendor.timeout_a = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
- chip->vendor.timeout_b = msecs_to_jiffies(TIS_LONG_TIMEOUT);
- chip->vendor.timeout_c = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
- chip->vendor.timeout_d = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
+ chip->timeout_a = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
+ chip->timeout_b = msecs_to_jiffies(TIS_LONG_TIMEOUT);
+ chip->timeout_c = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
+ chip->timeout_d = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
if (request_locality(chip, 0) != 0) {
dev_err(dev, "could not request locality\n");
diff --git a/drivers/char/tpm/tpm_i2c_nuvoton.c b/drivers/char/tpm/tpm_i2c_nuvoton.c
index 2c1fa26..491a16a 100644
--- a/drivers/char/tpm/tpm_i2c_nuvoton.c
+++ b/drivers/char/tpm/tpm_i2c_nuvoton.c
@@ -144,7 +144,7 @@ static void i2c_nuvoton_ready(struct tpm_chip *chip)
static int i2c_nuvoton_get_burstcount(struct i2c_client *client,
struct tpm_chip *chip)
{
- unsigned long stop = jiffies + chip->vendor.timeout_d;
+ unsigned long stop = jiffies + chip->timeout_d;
s32 status;
int burst_count = -1;
u8 data;
@@ -239,7 +239,7 @@ static int i2c_nuvoton_recv_data(struct i2c_client *client,
while (size < count &&
i2c_nuvoton_wait_for_data_avail(chip,
- chip->vendor.timeout_c,
+ chip->timeout_c,
&priv->read_queue) == 0) {
burst_count = i2c_nuvoton_get_burstcount(client, chip);
if (burst_count < 0) {
@@ -289,7 +289,7 @@ static int i2c_nuvoton_recv(struct tpm_chip *chip, u8 *buf, size_t count)
* tag, paramsize, and result
*/
status = i2c_nuvoton_wait_for_data_avail(
- chip, chip->vendor.timeout_c, &priv->read_queue);
+ chip, chip->timeout_c, &priv->read_queue);
if (status != 0) {
dev_err(dev, "%s() timeout on dataAvail\n", __func__);
size = -ETIMEDOUT;
@@ -329,7 +329,7 @@ static int i2c_nuvoton_recv(struct tpm_chip *chip, u8 *buf, size_t count)
}
if (i2c_nuvoton_wait_for_stat(
chip, TPM_STS_VALID | TPM_STS_DATA_AVAIL,
- TPM_STS_VALID, chip->vendor.timeout_c,
+ TPM_STS_VALID, chip->timeout_c,
NULL)) {
dev_err(dev, "%s() error left over data\n", __func__);
size = -ETIMEDOUT;
@@ -362,7 +362,7 @@ static int i2c_nuvoton_send(struct tpm_chip *chip, u8 *buf, size_t len)
i2c_nuvoton_ready(chip);
if (i2c_nuvoton_wait_for_stat(chip, TPM_STS_COMMAND_READY,
TPM_STS_COMMAND_READY,
- chip->vendor.timeout_b, NULL)) {
+ chip->timeout_b, NULL)) {
dev_err(dev, "%s() timeout on commandReady\n",
__func__);
rc = -EIO;
@@ -394,7 +394,7 @@ static int i2c_nuvoton_send(struct tpm_chip *chip, u8 *buf, size_t len)
TPM_STS_EXPECT,
TPM_STS_VALID |
TPM_STS_EXPECT,
- chip->vendor.timeout_c,
+ chip->timeout_c,
NULL);
if (rc < 0) {
dev_err(dev, "%s() timeout on Expect\n",
@@ -419,7 +419,7 @@ static int i2c_nuvoton_send(struct tpm_chip *chip, u8 *buf, size_t len)
rc = i2c_nuvoton_wait_for_stat(chip,
TPM_STS_VALID | TPM_STS_EXPECT,
TPM_STS_VALID,
- chip->vendor.timeout_c, NULL);
+ chip->timeout_c, NULL);
if (rc) {
dev_err(dev, "%s() timeout on Expect to clear\n",
__func__);
@@ -548,10 +548,10 @@ static int i2c_nuvoton_probe(struct i2c_client *client,
init_waitqueue_head(&priv->read_queue);
/* Default timeouts */
- chip->vendor.timeout_a = msecs_to_jiffies(TPM_I2C_SHORT_TIMEOUT);
- chip->vendor.timeout_b = msecs_to_jiffies(TPM_I2C_LONG_TIMEOUT);
- chip->vendor.timeout_c = msecs_to_jiffies(TPM_I2C_SHORT_TIMEOUT);
- chip->vendor.timeout_d = msecs_to_jiffies(TPM_I2C_SHORT_TIMEOUT);
+ chip->timeout_a = msecs_to_jiffies(TPM_I2C_SHORT_TIMEOUT);
+ chip->timeout_b = msecs_to_jiffies(TPM_I2C_LONG_TIMEOUT);
+ chip->timeout_c = msecs_to_jiffies(TPM_I2C_SHORT_TIMEOUT);
+ chip->timeout_d = msecs_to_jiffies(TPM_I2C_SHORT_TIMEOUT);
/*
* I2C intfcaps (interrupt capabilitieis) in the chip are hard coded to:
@@ -580,7 +580,7 @@ static int i2c_nuvoton_probe(struct i2c_client *client,
rc = i2c_nuvoton_wait_for_stat(chip,
TPM_STS_COMMAND_READY,
TPM_STS_COMMAND_READY,
- chip->vendor.timeout_b,
+ chip->timeout_b,
NULL);
if (rc == 0) {
/*
diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index 33e18c9..edad5dc 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ b/drivers/char/tpm/tpm_tis.c
@@ -133,7 +133,7 @@ static inline int is_itpm(struct acpi_device *dev)
static int wait_startup(struct tpm_chip *chip, int l)
{
struct priv_data *priv = chip->vendor.priv;
- unsigned long stop = jiffies + chip->vendor.timeout_a;
+ unsigned long stop = jiffies + chip->timeout_a;
do {
if (ioread8(priv->iobase + TPM_ACCESS(l)) &
TPM_ACCESS_VALID)
@@ -178,7 +178,7 @@ static int request_locality(struct tpm_chip *chip, int l)
iowrite8(TPM_ACCESS_REQUEST_USE,
priv->iobase + TPM_ACCESS(l));
- stop = jiffies + chip->vendor.timeout_a;
+ stop = jiffies + chip->timeout_a;
if (chip->flags & TPM_CHIP_FLAG_IRQ) {
again:
@@ -232,7 +232,7 @@ static int get_burstcount(struct tpm_chip *chip)
/* wait for burstcount */
/* which timeout value, spec has 2 answers (c & d) */
- stop = jiffies + chip->vendor.timeout_d;
+ stop = jiffies + chip->timeout_d;
do {
burstcnt = ioread8(priv->iobase +
TPM_STS(priv->locality) + 1);
@@ -253,7 +253,7 @@ static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count)
while (size < count &&
wait_for_tpm_stat(chip,
TPM_STS_DATA_AVAIL | TPM_STS_VALID,
- chip->vendor.timeout_c,
+ chip->timeout_c,
&priv->read_queue, true)
== 0) {
burstcnt = get_burstcount(chip);
@@ -296,7 +296,7 @@ static int tpm_tis_recv(struct tpm_chip *chip, u8 *buf, size_t count)
goto out;
}
- wait_for_tpm_stat(chip, TPM_STS_VALID, chip->vendor.timeout_c,
+ wait_for_tpm_stat(chip, TPM_STS_VALID, chip->timeout_c,
&priv->int_queue, false);
status = tpm_tis_status(chip);
if (status & TPM_STS_DATA_AVAIL) { /* retry? */
@@ -333,7 +333,7 @@ static int tpm_tis_send_data(struct tpm_chip *chip, u8 *buf, size_t len)
if ((status & TPM_STS_COMMAND_READY) == 0) {
tpm_tis_ready(chip);
if (wait_for_tpm_stat
- (chip, TPM_STS_COMMAND_READY, chip->vendor.timeout_b,
+ (chip, TPM_STS_COMMAND_READY, chip->timeout_b,
&priv->int_queue, false) < 0) {
rc = -ETIME;
goto out_err;
@@ -348,7 +348,7 @@ static int tpm_tis_send_data(struct tpm_chip *chip, u8 *buf, size_t len)
count++;
}
- wait_for_tpm_stat(chip, TPM_STS_VALID, chip->vendor.timeout_c,
+ wait_for_tpm_stat(chip, TPM_STS_VALID, chip->timeout_c,
&priv->int_queue, false);
status = tpm_tis_status(chip);
if (!itpm && (status & TPM_STS_DATA_EXPECT) == 0) {
@@ -360,7 +360,7 @@ static int tpm_tis_send_data(struct tpm_chip *chip, u8 *buf, size_t len)
/* write last byte */
iowrite8(buf[count],
priv->iobase + TPM_DATA_FIFO(priv->locality));
- wait_for_tpm_stat(chip, TPM_STS_VALID, chip->vendor.timeout_c,
+ wait_for_tpm_stat(chip, TPM_STS_VALID, chip->timeout_c,
&priv->int_queue, false);
status = tpm_tis_status(chip);
if ((status & TPM_STS_DATA_EXPECT) != 0) {
@@ -714,10 +714,10 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info,
return PTR_ERR(priv->iobase);
/* Maximum timeouts */
- chip->vendor.timeout_a = TIS_TIMEOUT_A_MAX;
- chip->vendor.timeout_b = TIS_TIMEOUT_B_MAX;
- chip->vendor.timeout_c = TIS_TIMEOUT_C_MAX;
- chip->vendor.timeout_d = TIS_TIMEOUT_D_MAX;
+ chip->timeout_a = TIS_TIMEOUT_A_MAX;
+ chip->timeout_b = TIS_TIMEOUT_B_MAX;
+ chip->timeout_c = TIS_TIMEOUT_C_MAX;
+ chip->timeout_d = TIS_TIMEOUT_D_MAX;
if (wait_startup(chip, 0) != 0) {
rc = -ENODEV;
diff --git a/drivers/char/tpm/xen-tpmfront.c b/drivers/char/tpm/xen-tpmfront.c
index cca89d9..1b28f96 100644
--- a/drivers/char/tpm/xen-tpmfront.c
+++ b/drivers/char/tpm/xen-tpmfront.c
@@ -89,7 +89,7 @@ static int vtpm_send(struct tpm_chip *chip, u8 *buf, size_t count)
return -EINVAL;
/* Wait for completion of any existing command or cancellation */
- if (wait_for_tpm_stat(chip, VTPM_STATUS_IDLE, chip->vendor.timeout_c,
+ if (wait_for_tpm_stat(chip, VTPM_STATUS_IDLE, chip->timeout_c,
&priv->read_queue, true) < 0) {
vtpm_cancel(chip);
return -ETIME;
@@ -126,7 +126,7 @@ static int vtpm_recv(struct tpm_chip *chip, u8 *buf, size_t count)
return -ECANCELED;
/* In theory the wait at the end of _send makes this one unnecessary */
- if (wait_for_tpm_stat(chip, VTPM_STATUS_RESULT, chip->vendor.timeout_c,
+ if (wait_for_tpm_stat(chip, VTPM_STATUS_RESULT, chip->timeout_c,
&priv->read_queue, true) < 0) {
vtpm_cancel(chip);
return -ETIME;
--
2.5.0
------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785471&iu=/4140
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v4 6/6] tpm: Remove useless priv field in struct tpm_vendor_specific
[not found] ` <1459457820-30542-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
` (4 preceding siblings ...)
2016-03-31 20:56 ` [PATCH v4 5/6] tpm: Move tpm_vendor_specific data related with PTP specification to tpm_chip Christophe Ricard
@ 2016-03-31 20:57 ` Christophe Ricard
2016-04-01 12:05 ` [PATCH v4 0/6] Remove the tpm_vendor_specific structure Jarkko Sakkinen
6 siblings, 0 replies; 8+ messages in thread
From: Christophe Ricard @ 2016-03-31 20:57 UTC (permalink / raw)
To: jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA
Cc: jean-luc.blanc-qxv4g6HH51o, ashley-fm2HMyfA2y6tG0bUXCXiUA,
tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
christophe-h.ricard-qxv4g6HH51o, benoit.houyere-qxv4g6HH51o
Remove useless priv field in struct tpm_vendor_specific and take benefit
of chip->dev.driver_data.
As priv is the latest field available in struct tpm_vendor_specific,
remove any reference to that structure.
Signed-off-by: Christophe Ricard <christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
drivers/char/tpm/st33zp24/i2c.c | 15 +++++++----
drivers/char/tpm/st33zp24/spi.c | 15 +++++++----
drivers/char/tpm/st33zp24/st33zp24.c | 50 ++++++++++--------------------------
drivers/char/tpm/tpm.h | 9 -------
drivers/char/tpm/tpm_atmel.c | 12 ++++-----
drivers/char/tpm/tpm_atmel.h | 5 ----
drivers/char/tpm/tpm_crb.c | 12 ++++-----
drivers/char/tpm/tpm_i2c_atmel.c | 14 +++++-----
drivers/char/tpm/tpm_i2c_nuvoton.c | 17 ++++++------
drivers/char/tpm/tpm_ibmvtpm.c | 38 ++++++++-------------------
drivers/char/tpm/tpm_nsc.c | 48 ++++++++++++++++++----------------
drivers/char/tpm/tpm_tis.c | 47 ++++++++++++++++-----------------
drivers/char/tpm/xen-tpmfront.c | 14 +++++-----
13 files changed, 131 insertions(+), 165 deletions(-)
diff --git a/drivers/char/tpm/st33zp24/i2c.c b/drivers/char/tpm/st33zp24/i2c.c
index f8e8123..028a9cd 100644
--- a/drivers/char/tpm/st33zp24/i2c.c
+++ b/drivers/char/tpm/st33zp24/i2c.c
@@ -26,6 +26,7 @@
#include <linux/tpm.h>
#include <linux/platform_data/st33zp24.h>
+#include "../tpm.h"
#include "st33zp24.h"
#define TPM_DUMMY_BYTE 0xAA
@@ -112,7 +113,9 @@ static const struct st33zp24_phy_ops i2c_phy_ops = {
static int st33zp24_i2c_acpi_request_resources(struct i2c_client *client)
{
- struct st33zp24_i2c_phy *phy = i2c_get_clientdata(client);
+ struct tpm_chip *chip = i2c_get_clientdata(client);
+ struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev);
+ struct st33zp24_i2c_phy *phy = tpm_dev->phy_id;
struct gpio_desc *gpiod_lpcpd;
struct device *dev = &client->dev;
@@ -138,7 +141,9 @@ static int st33zp24_i2c_acpi_request_resources(struct i2c_client *client)
static int st33zp24_i2c_of_request_resources(struct i2c_client *client)
{
- struct st33zp24_i2c_phy *phy = i2c_get_clientdata(client);
+ struct tpm_chip *chip = i2c_get_clientdata(client);
+ struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev);
+ struct st33zp24_i2c_phy *phy = tpm_dev->phy_id;
struct device_node *pp;
int gpio;
int ret;
@@ -176,8 +181,10 @@ static int st33zp24_i2c_of_request_resources(struct i2c_client *client)
static int st33zp24_i2c_request_resources(struct i2c_client *client)
{
+ struct tpm_chip *chip = i2c_get_clientdata(client);
+ struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev);
+ struct st33zp24_i2c_phy *phy = tpm_dev->phy_id;
struct st33zp24_platform_data *pdata;
- struct st33zp24_i2c_phy *phy = i2c_get_clientdata(client);
int ret;
pdata = client->dev.platform_data;
@@ -234,8 +241,6 @@ static int st33zp24_i2c_probe(struct i2c_client *client,
phy->client = client;
- i2c_set_clientdata(client, phy);
-
pdata = client->dev.platform_data;
if (!pdata && client->dev.of_node) {
ret = st33zp24_i2c_of_request_resources(client);
diff --git a/drivers/char/tpm/st33zp24/spi.c b/drivers/char/tpm/st33zp24/spi.c
index 608dbc6..9f5a011 100644
--- a/drivers/char/tpm/st33zp24/spi.c
+++ b/drivers/char/tpm/st33zp24/spi.c
@@ -26,6 +26,7 @@
#include <linux/tpm.h>
#include <linux/platform_data/st33zp24.h>
+#include "../tpm.h"
#include "st33zp24.h"
#define TPM_DATA_FIFO 0x24
@@ -231,7 +232,9 @@ static const struct st33zp24_phy_ops spi_phy_ops = {
static int st33zp24_spi_acpi_request_resources(struct spi_device *spi_dev)
{
- struct st33zp24_spi_phy *phy = spi_get_drvdata(spi_dev);
+ struct tpm_chip *chip = spi_get_drvdata(spi_dev);
+ struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev);
+ struct st33zp24_spi_phy *phy = tpm_dev->phy_id;
struct gpio_desc *gpiod_lpcpd;
struct device *dev = &spi_dev->dev;
@@ -256,7 +259,9 @@ static int st33zp24_spi_acpi_request_resources(struct spi_device *spi_dev)
static int st33zp24_spi_of_request_resources(struct spi_device *spi_dev)
{
- struct st33zp24_spi_phy *phy = spi_get_drvdata(spi_dev);
+ struct tpm_chip *chip = spi_get_drvdata(spi_dev);
+ struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev);
+ struct st33zp24_spi_phy *phy = tpm_dev->phy_id;
struct device_node *pp;
int gpio;
int ret;
@@ -294,7 +299,9 @@ static int st33zp24_spi_of_request_resources(struct spi_device *spi_dev)
static int st33zp24_spi_request_resources(struct spi_device *dev)
{
- struct st33zp24_spi_phy *phy = spi_get_drvdata(dev);
+ struct tpm_chip *chip = spi_get_drvdata(dev);
+ struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev);
+ struct st33zp24_spi_phy *phy = tpm_dev->phy_id;
struct st33zp24_platform_data *pdata;
int ret;
@@ -347,8 +354,6 @@ static int st33zp24_spi_probe(struct spi_device *dev)
phy->spi_device = dev;
- spi_set_drvdata(dev, phy);
-
pdata = dev->dev.platform_data;
if (!pdata && dev->dev.of_node) {
ret = st33zp24_spi_of_request_resources(dev);
diff --git a/drivers/char/tpm/st33zp24/st33zp24.c b/drivers/char/tpm/st33zp24/st33zp24.c
index 07531e9..a7c99a2 100644
--- a/drivers/char/tpm/st33zp24/st33zp24.c
+++ b/drivers/char/tpm/st33zp24/st33zp24.c
@@ -94,11 +94,9 @@ static u8 clear_interruption(struct st33zp24_dev *tpm_dev)
*/
static void st33zp24_cancel(struct tpm_chip *chip)
{
- struct st33zp24_dev *tpm_dev;
+ struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev);
u8 data;
- tpm_dev = (struct st33zp24_dev *)TPM_VPRIV(chip);
-
data = TPM_STS_COMMAND_READY;
tpm_dev->ops->send(tpm_dev->phy_id, TPM_STS, &data, 1);
} /* st33zp24_cancel() */
@@ -110,11 +108,9 @@ static void st33zp24_cancel(struct tpm_chip *chip)
*/
static u8 st33zp24_status(struct tpm_chip *chip)
{
- struct st33zp24_dev *tpm_dev;
+ struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev);
u8 data;
- tpm_dev = (struct st33zp24_dev *)TPM_VPRIV(chip);
-
tpm_dev->ops->recv(tpm_dev->phy_id, TPM_STS, &data, 1);
return data;
} /* st33zp24_status() */
@@ -126,12 +122,10 @@ static u8 st33zp24_status(struct tpm_chip *chip)
*/
static int check_locality(struct tpm_chip *chip)
{
- struct st33zp24_dev *tpm_dev;
+ struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev);
u8 data;
u8 status;
- tpm_dev = (struct st33zp24_dev *)TPM_VPRIV(chip);
-
status = tpm_dev->ops->recv(tpm_dev->phy_id, TPM_ACCESS, &data, 1);
if (status && (data &
(TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID)) ==
@@ -148,13 +142,11 @@ static int check_locality(struct tpm_chip *chip)
*/
static int request_locality(struct tpm_chip *chip)
{
+ struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev);
unsigned long stop;
long ret;
- struct st33zp24_dev *tpm_dev;
u8 data;
- tpm_dev = (struct st33zp24_dev *)TPM_VPRIV(chip);
-
if (check_locality(chip) == tpm_dev->locality)
return tpm_dev->locality;
@@ -182,10 +174,9 @@ static int request_locality(struct tpm_chip *chip)
*/
static void release_locality(struct tpm_chip *chip)
{
- struct st33zp24_dev *tpm_dev;
+ struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev);
u8 data;
- tpm_dev = (struct st33zp24_dev *)TPM_VPRIV(chip);
data = TPM_ACCESS_ACTIVE_LOCALITY;
tpm_dev->ops->send(tpm_dev->phy_id, TPM_ACCESS, &data, 1);
@@ -198,12 +189,10 @@ static void release_locality(struct tpm_chip *chip)
*/
static int get_burstcount(struct tpm_chip *chip)
{
+ struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev);
unsigned long stop;
int burstcnt, status;
u8 temp;
- struct st33zp24_dev *tpm_dev;
-
- tpm_dev = (struct st33zp24_dev *)TPM_VPRIV(chip);
stop = jiffies + chip->timeout_d;
do {
@@ -263,15 +252,13 @@ static bool wait_for_tpm_stat_cond(struct tpm_chip *chip, u8 mask,
static int wait_for_stat(struct tpm_chip *chip, u8 mask, unsigned long timeout,
wait_queue_head_t *queue, bool check_cancel)
{
+ struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev);
unsigned long stop;
int ret = 0;
bool canceled = false;
bool condition;
u32 cur_intrs;
u8 status;
- struct st33zp24_dev *tpm_dev;
-
- tpm_dev = (struct st33zp24_dev *)TPM_VPRIV(chip);
/* check current status */
status = st33zp24_status(chip);
@@ -329,10 +316,8 @@ static int wait_for_stat(struct tpm_chip *chip, u8 mask, unsigned long timeout,
*/
static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count)
{
+ struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev);
int size = 0, burstcnt, len, ret;
- struct st33zp24_dev *tpm_dev;
-
- tpm_dev = (struct st33zp24_dev *)TPM_VPRIV(chip);
while (size < count &&
wait_for_stat(chip,
@@ -362,9 +347,7 @@ static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count)
static irqreturn_t tpm_ioserirq_handler(int irq, void *dev_id)
{
struct tpm_chip *chip = dev_id;
- struct st33zp24_dev *tpm_dev;
-
- tpm_dev = (struct st33zp24_dev *)TPM_VPRIV(chip);
+ struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev);
tpm_dev->intrs++;
wake_up_interruptible(&tpm_dev->read_queue);
@@ -385,19 +368,17 @@ static irqreturn_t tpm_ioserirq_handler(int irq, void *dev_id)
static int st33zp24_send(struct tpm_chip *chip, unsigned char *buf,
size_t len)
{
+ struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev);
u32 status, i, size, ordinal;
int burstcnt = 0;
int ret;
u8 data;
- struct st33zp24_dev *tpm_dev;
if (!chip)
return -EBUSY;
if (len < TPM_HEADER_SIZE)
return -EBUSY;
- tpm_dev = (struct st33zp24_dev *)TPM_VPRIV(chip);
-
ret = request_locality(chip);
if (ret < 0)
return ret;
@@ -557,9 +538,9 @@ int st33zp24_probe(void *phy_id, const struct st33zp24_phy_ops *ops,
if (!tpm_dev)
return -ENOMEM;
- TPM_VPRIV(chip) = tpm_dev;
tpm_dev->phy_id = phy_id;
tpm_dev->ops = ops;
+ dev_set_drvdata(&chip->dev, tpm_dev);
chip->timeout_a = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
chip->timeout_b = msecs_to_jiffies(TIS_LONG_TIMEOUT);
@@ -643,10 +624,9 @@ EXPORT_SYMBOL(st33zp24_remove);
int st33zp24_pm_suspend(struct device *dev)
{
struct tpm_chip *chip = dev_get_drvdata(dev);
- struct st33zp24_dev *tpm_dev;
- int ret = 0;
+ struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev);
- tpm_dev = (struct st33zp24_dev *)TPM_VPRIV(chip);
+ int ret = 0;
if (gpio_is_valid(tpm_dev->io_lpcpd))
gpio_set_value(tpm_dev->io_lpcpd, 0);
@@ -665,11 +645,9 @@ EXPORT_SYMBOL(st33zp24_pm_suspend);
int st33zp24_pm_resume(struct device *dev)
{
struct tpm_chip *chip = dev_get_drvdata(dev);
- struct st33zp24_dev *tpm_dev;
+ struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev);
int ret = 0;
- tpm_dev = (struct st33zp24_dev *)TPM_VPRIV(chip);
-
if (gpio_is_valid(tpm_dev->io_lpcpd)) {
gpio_set_value(tpm_dev->io_lpcpd, 1);
ret = wait_for_stat(chip,
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index 93757e8..8bc6fb8 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -128,14 +128,6 @@ enum tpm2_startup_types {
TPM2_SU_STATE = 0x0001,
};
-struct tpm_chip;
-
-struct tpm_vendor_specific {
- void *priv;
-};
-
-#define TPM_VPRIV(c) ((c)->vendor.priv)
-
#define TPM_VID_INTEL 0x8086
#define TPM_VID_WINBOND 0x1050
#define TPM_VID_STM 0x104A
@@ -166,7 +158,6 @@ struct tpm_chip {
struct mutex tpm_mutex; /* tpm is processing */
- struct tpm_vendor_specific vendor;
unsigned long timeout_a; /* jiffies */
unsigned long timeout_b; /* jiffies */
unsigned long timeout_c; /* jiffies */
diff --git a/drivers/char/tpm/tpm_atmel.c b/drivers/char/tpm/tpm_atmel.c
index b769299..0d322ab 100644
--- a/drivers/char/tpm/tpm_atmel.c
+++ b/drivers/char/tpm/tpm_atmel.c
@@ -37,7 +37,7 @@ enum tpm_atmel_read_status {
static int tpm_atml_recv(struct tpm_chip *chip, u8 *buf, size_t count)
{
- struct tpm_atmel_priv *priv = chip->vendor.priv;
+ struct tpm_atmel_priv *priv = dev_get_drvdata(&chip->dev);
u8 status, *hdr = buf;
u32 size;
int i;
@@ -96,7 +96,7 @@ static int tpm_atml_recv(struct tpm_chip *chip, u8 *buf, size_t count)
static int tpm_atml_send(struct tpm_chip *chip, u8 *buf, size_t count)
{
- struct tpm_atmel_priv *priv = chip->vendor.priv;
+ struct tpm_atmel_priv *priv = dev_get_drvdata(&chip->dev);
int i;
dev_dbg(&chip->dev, "tpm_atml_send:\n");
@@ -110,14 +110,14 @@ static int tpm_atml_send(struct tpm_chip *chip, u8 *buf, size_t count)
static void tpm_atml_cancel(struct tpm_chip *chip)
{
- struct tpm_atmel_priv *priv = chip->vendor.priv;
+ struct tpm_atmel_priv *priv = dev_get_drvdata(&chip->dev);
iowrite8(ATML_STATUS_ABORT, priv->iobase + 1);
}
static u8 tpm_atml_status(struct tpm_chip *chip)
{
- struct tpm_atmel_priv *priv = chip->vendor.priv;
+ struct tpm_atmel_priv *priv = dev_get_drvdata(&chip->dev);
return ioread8(priv->iobase + 1);
}
@@ -142,7 +142,7 @@ 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;
+ struct tpm_atmel_priv *priv = dev_get_drvdata(&chip->dev);
if (chip) {
tpm_chip_unregister(chip);
@@ -207,7 +207,7 @@ static int __init init_atmel(void)
goto err_unreg_dev;
}
- chip->vendor.priv = priv;
+ dev_set_drvdata(&chip->dev, priv);
rc = tpm_chip_register(chip);
if (rc)
diff --git a/drivers/char/tpm/tpm_atmel.h b/drivers/char/tpm/tpm_atmel.h
index 1938c0b..4f96d80 100644
--- a/drivers/char/tpm/tpm_atmel.h
+++ b/drivers/char/tpm/tpm_atmel.h
@@ -29,11 +29,6 @@ struct tpm_atmel_priv {
void __iomem *iobase;
};
-static inline struct tpm_atmel_priv *atmel_get_priv(struct tpm_chip *chip)
-{
- return chip->vendor.priv;
-}
-
#ifdef CONFIG_PPC64
#include <asm/prom.h>
diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c
index 8767da6..20155d5 100644
--- a/drivers/char/tpm/tpm_crb.c
+++ b/drivers/char/tpm/tpm_crb.c
@@ -87,7 +87,7 @@ static SIMPLE_DEV_PM_OPS(crb_pm, tpm_pm_suspend, tpm_pm_resume);
static u8 crb_status(struct tpm_chip *chip)
{
- struct crb_priv *priv = chip->vendor.priv;
+ struct crb_priv *priv = dev_get_drvdata(&chip->dev);
u8 sts = 0;
if ((ioread32(&priv->cca->start) & CRB_START_INVOKE) !=
@@ -99,7 +99,7 @@ static u8 crb_status(struct tpm_chip *chip)
static int crb_recv(struct tpm_chip *chip, u8 *buf, size_t count)
{
- struct crb_priv *priv = chip->vendor.priv;
+ struct crb_priv *priv = dev_get_drvdata(&chip->dev);
unsigned int expected;
/* sanity check */
@@ -139,7 +139,7 @@ static int crb_do_acpi_start(struct tpm_chip *chip)
static int crb_send(struct tpm_chip *chip, u8 *buf, size_t len)
{
- struct crb_priv *priv = chip->vendor.priv;
+ struct crb_priv *priv = dev_get_drvdata(&chip->dev);
int rc = 0;
if (len > ioread32(&priv->cca->cmd_size)) {
@@ -163,7 +163,7 @@ static int crb_send(struct tpm_chip *chip, u8 *buf, size_t len)
static void crb_cancel(struct tpm_chip *chip)
{
- struct crb_priv *priv = chip->vendor.priv;
+ struct crb_priv *priv = dev_get_drvdata(&chip->dev);
iowrite32(cpu_to_le32(CRB_CANCEL_INVOKE), &priv->cca->cancel);
@@ -175,7 +175,7 @@ static void crb_cancel(struct tpm_chip *chip)
static bool crb_req_canceled(struct tpm_chip *chip, u8 status)
{
- struct crb_priv *priv = chip->vendor.priv;
+ struct crb_priv *priv = dev_get_drvdata(&chip->dev);
u32 cancel = ioread32(&priv->cca->cancel);
return (cancel & CRB_CANCEL_INVOKE) == CRB_CANCEL_INVOKE;
@@ -200,7 +200,7 @@ static int crb_init(struct acpi_device *device, struct crb_priv *priv)
if (IS_ERR(chip))
return PTR_ERR(chip);
- chip->vendor.priv = priv;
+ dev_set_drvdata(&chip->dev, priv);
chip->acpi_dev_handle = device->handle;
chip->flags = TPM_CHIP_FLAG_TPM2;
diff --git a/drivers/char/tpm/tpm_i2c_atmel.c b/drivers/char/tpm/tpm_i2c_atmel.c
index 1b66da6..c37aa72 100644
--- a/drivers/char/tpm/tpm_i2c_atmel.c
+++ b/drivers/char/tpm/tpm_i2c_atmel.c
@@ -51,7 +51,7 @@ struct priv_data {
static int i2c_atmel_send(struct tpm_chip *chip, u8 *buf, size_t len)
{
- struct priv_data *priv = chip->vendor.priv;
+ struct priv_data *priv = dev_get_drvdata(&chip->dev);
struct i2c_client *client = to_i2c_client(chip->dev.parent);
s32 status;
@@ -70,7 +70,7 @@ static int i2c_atmel_send(struct tpm_chip *chip, u8 *buf, size_t len)
static int i2c_atmel_recv(struct tpm_chip *chip, u8 *buf, size_t count)
{
- struct priv_data *priv = chip->vendor.priv;
+ struct priv_data *priv = dev_get_drvdata(&chip->dev);
struct i2c_client *client = to_i2c_client(chip->dev.parent);
struct tpm_output_header *hdr =
(struct tpm_output_header *)priv->buffer;
@@ -111,7 +111,7 @@ static void i2c_atmel_cancel(struct tpm_chip *chip)
static u8 i2c_atmel_read_status(struct tpm_chip *chip)
{
- struct priv_data *priv = chip->vendor.priv;
+ struct priv_data *priv = dev_get_drvdata(&chip->dev);
struct i2c_client *client = to_i2c_client(chip->dev.parent);
int rc;
@@ -155,6 +155,7 @@ static int i2c_atmel_probe(struct i2c_client *client,
{
struct tpm_chip *chip;
struct device *dev = &client->dev;
+ struct priv_data *priv;
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
return -ENODEV;
@@ -163,9 +164,8 @@ static int i2c_atmel_probe(struct i2c_client *client,
if (IS_ERR(chip))
return PTR_ERR(chip);
- chip->vendor.priv = devm_kzalloc(dev, sizeof(struct priv_data),
- GFP_KERNEL);
- if (!chip->vendor.priv)
+ priv = devm_kzalloc(dev, sizeof(struct priv_data), GFP_KERNEL);
+ if (!priv)
return -ENOMEM;
/* Default timeouts */
@@ -174,6 +174,8 @@ static int i2c_atmel_probe(struct i2c_client *client,
chip->timeout_c = msecs_to_jiffies(TPM_I2C_SHORT_TIMEOUT);
chip->timeout_d = msecs_to_jiffies(TPM_I2C_SHORT_TIMEOUT);
+ dev_set_drvdata(&chip->dev, priv);
+
/* There is no known way to probe for this device, and all version
* information seems to be read via TPM commands. Thus we rely on the
* TPM startup process in the common code to detect the device. */
diff --git a/drivers/char/tpm/tpm_i2c_nuvoton.c b/drivers/char/tpm/tpm_i2c_nuvoton.c
index 491a16a..4e32094 100644
--- a/drivers/char/tpm/tpm_i2c_nuvoton.c
+++ b/drivers/char/tpm/tpm_i2c_nuvoton.c
@@ -180,7 +180,7 @@ static int i2c_nuvoton_wait_for_stat(struct tpm_chip *chip, u8 mask, u8 value,
{
if ((chip->flags & TPM_CHIP_FLAG_IRQ) && queue) {
s32 rc;
- struct priv_data *priv = chip->vendor.priv;
+ struct priv_data *priv = dev_get_drvdata(&chip->dev);
unsigned int cur_intrs = priv->intrs;
enable_irq(priv->irq);
@@ -233,7 +233,7 @@ static int i2c_nuvoton_wait_for_data_avail(struct tpm_chip *chip, u32 timeout,
static int i2c_nuvoton_recv_data(struct i2c_client *client,
struct tpm_chip *chip, u8 *buf, size_t count)
{
- struct priv_data *priv = chip->vendor.priv;
+ struct priv_data *priv = dev_get_drvdata(&chip->dev);
s32 rc;
int burst_count, bytes2read, size = 0;
@@ -267,7 +267,7 @@ static int i2c_nuvoton_recv_data(struct i2c_client *client,
/* Read TPM command results */
static int i2c_nuvoton_recv(struct tpm_chip *chip, u8 *buf, size_t count)
{
- struct priv_data *priv = chip->vendor.priv;
+ struct priv_data *priv = dev_get_drvdata(&chip->dev);
struct device *dev = chip->dev.parent;
struct i2c_client *client = to_i2c_client(dev);
s32 rc;
@@ -351,7 +351,7 @@ static int i2c_nuvoton_recv(struct tpm_chip *chip, u8 *buf, size_t count)
*/
static int i2c_nuvoton_send(struct tpm_chip *chip, u8 *buf, size_t len)
{
- struct priv_data *priv = chip->vendor.priv;
+ struct priv_data *priv = dev_get_drvdata(&chip->dev);
struct device *dev = chip->dev.parent;
struct i2c_client *client = to_i2c_client(dev);
u32 ordinal;
@@ -478,7 +478,7 @@ static const struct tpm_class_ops tpm_i2c = {
static irqreturn_t i2c_nuvoton_int_handler(int dummy, void *dev_id)
{
struct tpm_chip *chip = dev_id;
- struct priv_data *priv = chip->vendor.priv;
+ struct priv_data *priv = dev_get_drvdata(&chip->dev);
priv->intrs++;
wake_up(&priv->read_queue);
@@ -543,7 +543,6 @@ static int i2c_nuvoton_probe(struct i2c_client *client,
priv = devm_kzalloc(dev, sizeof(struct priv_data), GFP_KERNEL);
if (!priv)
return -ENOMEM;
- chip->vendor.priv = priv;
init_waitqueue_head(&priv->read_queue);
@@ -553,6 +552,8 @@ static int i2c_nuvoton_probe(struct i2c_client *client,
chip->timeout_c = msecs_to_jiffies(TPM_I2C_SHORT_TIMEOUT);
chip->timeout_d = msecs_to_jiffies(TPM_I2C_SHORT_TIMEOUT);
+ dev_set_drvdata(&chip->dev, priv);
+
/*
* I2C intfcaps (interrupt capabilitieis) in the chip are hard coded to:
* TPM_INTF_INT_LEVEL_LOW | TPM_INTF_DATA_AVAIL_INT
@@ -619,8 +620,8 @@ static int i2c_nuvoton_probe(struct i2c_client *client,
static int i2c_nuvoton_remove(struct i2c_client *client)
{
- struct device *dev = &(client->dev);
- struct tpm_chip *chip = dev_get_drvdata(dev);
+ struct tpm_chip *chip = i2c_get_clientdata(client);
+
tpm_chip_unregister(chip);
return 0;
}
diff --git a/drivers/char/tpm/tpm_ibmvtpm.c b/drivers/char/tpm/tpm_ibmvtpm.c
index b0a9a9e..6b22826 100644
--- a/drivers/char/tpm/tpm_ibmvtpm.c
+++ b/drivers/char/tpm/tpm_ibmvtpm.c
@@ -54,21 +54,6 @@ static int ibmvtpm_send_crq(struct vio_dev *vdev, u64 w1, u64 w2)
}
/**
- * ibmvtpm_get_data - Retrieve ibm vtpm data
- * @dev: device struct
- *
- * Return value:
- * vtpm device struct
- */
-static struct ibmvtpm_dev *ibmvtpm_get_data(const struct device *dev)
-{
- struct tpm_chip *chip = dev_get_drvdata(dev);
- if (chip)
- return (struct ibmvtpm_dev *)TPM_VPRIV(chip);
- return NULL;
-}
-
-/**
* tpm_ibmvtpm_recv - Receive data after send
* @chip: tpm chip struct
* @buf: buffer to read
@@ -79,12 +64,10 @@ static struct ibmvtpm_dev *ibmvtpm_get_data(const struct device *dev)
*/
static int tpm_ibmvtpm_recv(struct tpm_chip *chip, u8 *buf, size_t count)
{
- struct ibmvtpm_dev *ibmvtpm;
+ struct ibmvtpm_dev *ibmvtpm = dev_get_drvdata(&chip->dev);
u16 len;
int sig;
- ibmvtpm = (struct ibmvtpm_dev *)TPM_VPRIV(chip);
-
if (!ibmvtpm->rtce_buf) {
dev_err(ibmvtpm->dev, "ibmvtpm device is not ready\n");
return 0;
@@ -122,13 +105,11 @@ static int tpm_ibmvtpm_recv(struct tpm_chip *chip, u8 *buf, size_t count)
*/
static int tpm_ibmvtpm_send(struct tpm_chip *chip, u8 *buf, size_t count)
{
- struct ibmvtpm_dev *ibmvtpm;
+ struct ibmvtpm_dev *ibmvtpm = dev_get_drvdata(&chip->dev);
struct ibmvtpm_crq crq;
__be64 *word = (__be64 *)&crq;
int rc, sig;
- ibmvtpm = (struct ibmvtpm_dev *)TPM_VPRIV(chip);
-
if (!ibmvtpm->rtce_buf) {
dev_err(ibmvtpm->dev, "ibmvtpm device is not ready\n");
return 0;
@@ -289,8 +270,8 @@ static int ibmvtpm_crq_send_init(struct ibmvtpm_dev *ibmvtpm)
*/
static int tpm_ibmvtpm_remove(struct vio_dev *vdev)
{
- struct ibmvtpm_dev *ibmvtpm = ibmvtpm_get_data(&vdev->dev);
- struct tpm_chip *chip = dev_get_drvdata(ibmvtpm->dev);
+ struct tpm_chip *chip = dev_get_drvdata(&vdev->dev);
+ struct ibmvtpm_dev *ibmvtpm = dev_get_drvdata(&chip->dev);
int rc = 0;
tpm_chip_unregister(chip);
@@ -327,7 +308,8 @@ static int tpm_ibmvtpm_remove(struct vio_dev *vdev)
*/
static unsigned long tpm_ibmvtpm_get_desired_dma(struct vio_dev *vdev)
{
- struct ibmvtpm_dev *ibmvtpm = ibmvtpm_get_data(&vdev->dev);
+ struct tpm_chip *chip = dev_get_drvdata(&vdev->dev);
+ struct ibmvtpm_dev *ibmvtpm = dev_get_drvdata(&chip->dev);
/* ibmvtpm initializes at probe time, so the data we are
* asking for may not be set yet. Estimate that 4K required
@@ -348,7 +330,8 @@ static unsigned long tpm_ibmvtpm_get_desired_dma(struct vio_dev *vdev)
*/
static int tpm_ibmvtpm_suspend(struct device *dev)
{
- struct ibmvtpm_dev *ibmvtpm = ibmvtpm_get_data(dev);
+ struct tpm_chip *chip = dev_get_drvdata(dev);
+ struct ibmvtpm_dev *ibmvtpm = dev_get_drvdata(&chip->dev);
struct ibmvtpm_crq crq;
u64 *buf = (u64 *) &crq;
int rc = 0;
@@ -400,7 +383,8 @@ static int ibmvtpm_reset_crq(struct ibmvtpm_dev *ibmvtpm)
*/
static int tpm_ibmvtpm_resume(struct device *dev)
{
- struct ibmvtpm_dev *ibmvtpm = ibmvtpm_get_data(dev);
+ struct tpm_chip *chip = dev_get_drvdata(dev);
+ struct ibmvtpm_dev *ibmvtpm = dev_get_drvdata(&chip->dev);
int rc = 0;
do {
@@ -643,7 +627,7 @@ static int tpm_ibmvtpm_probe(struct vio_dev *vio_dev,
crq_q->index = 0;
- TPM_VPRIV(chip) = (void *)ibmvtpm;
+ dev_set_drvdata(&chip->dev, ibmvtpm)
spin_lock_init(&ibmvtpm->rtce_lock);
diff --git a/drivers/char/tpm/tpm_nsc.c b/drivers/char/tpm/tpm_nsc.c
index 07163a4..9ff0e07 100644
--- a/drivers/char/tpm/tpm_nsc.c
+++ b/drivers/char/tpm/tpm_nsc.c
@@ -69,20 +69,16 @@ struct tpm_nsc_priv {
unsigned long base;
};
-static inline struct tpm_nsc_priv *nsc_get_priv(struct tpm_chip *chip)
-{
- return chip->vendor.priv;
-}
-
/*
* Wait for a certain status to appear
*/
static int wait_for_stat(struct tpm_chip *chip, u8 mask, u8 val, u8 * data)
{
+ struct tpm_nsc_priv *priv = dev_get_drvdata(&chip->dev);
unsigned long stop;
/* status immediately available check */
- *data = inb(nsc_get_priv(chip)->base + NSC_STATUS);
+ *data = inb(priv->base + NSC_STATUS);
if ((*data & mask) == val)
return 0;
@@ -90,7 +86,7 @@ static int wait_for_stat(struct tpm_chip *chip, u8 mask, u8 val, u8 * data)
stop = jiffies + 10 * HZ;
do {
msleep(TPM_TIMEOUT);
- *data = inb(nsc_get_priv(chip)->base + 1);
+ *data = inb(priv->base + 1);
if ((*data & mask) == val)
return 0;
}
@@ -101,13 +97,14 @@ static int wait_for_stat(struct tpm_chip *chip, u8 mask, u8 val, u8 * data)
static int nsc_wait_for_ready(struct tpm_chip *chip)
{
+ struct tpm_nsc_priv *priv = dev_get_drvdata(&chip->dev);
int status;
unsigned long stop;
/* status immediately available check */
- status = inb(nsc_get_priv(chip)->base + NSC_STATUS);
+ status = inb(priv->base + NSC_STATUS);
if (status & NSC_STATUS_OBF)
- status = inb(nsc_get_priv(chip)->base + NSC_DATA);
+ status = inb(priv->base + NSC_DATA);
if (status & NSC_STATUS_RDY)
return 0;
@@ -115,9 +112,9 @@ static int nsc_wait_for_ready(struct tpm_chip *chip)
stop = jiffies + 100;
do {
msleep(TPM_TIMEOUT);
- status = inb(nsc_get_priv(chip)->base + NSC_STATUS);
+ status = inb(priv->base + NSC_STATUS);
if (status & NSC_STATUS_OBF)
- status = inb(nsc_get_priv(chip)->base + NSC_DATA);
+ status = inb(priv->base + NSC_DATA);
if (status & NSC_STATUS_RDY)
return 0;
}
@@ -130,6 +127,7 @@ static int nsc_wait_for_ready(struct tpm_chip *chip)
static int tpm_nsc_recv(struct tpm_chip *chip, u8 * buf, size_t count)
{
+ struct tpm_nsc_priv *priv = dev_get_drvdata(&chip->dev);
u8 *buffer = buf;
u8 data, *p;
u32 size;
@@ -143,7 +141,7 @@ static int tpm_nsc_recv(struct tpm_chip *chip, u8 * buf, size_t count)
return -EIO;
}
- data = inb(nsc_get_priv(chip)->base + NSC_DATA);
+ data = inb(priv->base + NSC_DATA);
if (data != NSC_COMMAND_NORMAL) {
dev_err(&chip->dev, "not in normal mode (0x%x)\n",
data);
@@ -160,7 +158,7 @@ static int tpm_nsc_recv(struct tpm_chip *chip, u8 * buf, size_t count)
}
if (data & NSC_STATUS_F0)
break;
- *p = inb(nsc_get_priv(chip)->base + NSC_DATA);
+ *p = inb(priv->base + NSC_DATA);
}
if ((data & NSC_STATUS_F0) == 0 &&
@@ -169,7 +167,7 @@ static int tpm_nsc_recv(struct tpm_chip *chip, u8 * buf, size_t count)
return -EIO;
}
- data = inb(nsc_get_priv(chip)->base + NSC_DATA);
+ data = inb(priv->base + NSC_DATA);
if (data != NSC_COMMAND_EOC) {
dev_err(&chip->dev,
"expected end of command(0x%x)\n", data);
@@ -187,6 +185,7 @@ static int tpm_nsc_recv(struct tpm_chip *chip, u8 * buf, size_t count)
static int tpm_nsc_send(struct tpm_chip *chip, u8 * buf, size_t count)
{
+ struct tpm_nsc_priv *priv = dev_get_drvdata(&chip->dev);
u8 data;
int i;
@@ -196,7 +195,7 @@ static int tpm_nsc_send(struct tpm_chip *chip, u8 * buf, size_t count)
* fix it. Not sure why this is needed, we followed the flow
* chart in the manual to the letter.
*/
- outb(NSC_COMMAND_CANCEL, nsc_get_priv(chip)->base + NSC_COMMAND);
+ outb(NSC_COMMAND_CANCEL, priv->base + NSC_COMMAND);
if (nsc_wait_for_ready(chip) != 0)
return -EIO;
@@ -206,7 +205,7 @@ static int tpm_nsc_send(struct tpm_chip *chip, u8 * buf, size_t count)
return -EIO;
}
- outb(NSC_COMMAND_NORMAL, nsc_get_priv(chip)->base + NSC_COMMAND);
+ outb(NSC_COMMAND_NORMAL, priv->base + NSC_COMMAND);
if (wait_for_stat(chip, NSC_STATUS_IBR, NSC_STATUS_IBR, &data) < 0) {
dev_err(&chip->dev, "IBR timeout\n");
return -EIO;
@@ -218,26 +217,30 @@ static int tpm_nsc_send(struct tpm_chip *chip, u8 * buf, size_t count)
"IBF timeout (while writing data)\n");
return -EIO;
}
- outb(buf[i], nsc_get_priv(chip)->base + NSC_DATA);
+ outb(buf[i], priv->base + NSC_DATA);
}
if (wait_for_stat(chip, NSC_STATUS_IBF, 0, &data) < 0) {
dev_err(&chip->dev, "IBF timeout\n");
return -EIO;
}
- outb(NSC_COMMAND_EOC, nsc_get_priv(chip)->base + NSC_COMMAND);
+ outb(NSC_COMMAND_EOC, priv->base + NSC_COMMAND);
return count;
}
static void tpm_nsc_cancel(struct tpm_chip *chip)
{
- outb(NSC_COMMAND_CANCEL, nsc_get_priv(chip)->base + NSC_COMMAND);
+ struct tpm_nsc_priv *priv = dev_get_drvdata(&chip->dev);
+
+ outb(NSC_COMMAND_CANCEL, priv->base + NSC_COMMAND);
}
static u8 tpm_nsc_status(struct tpm_chip *chip)
{
- return inb(nsc_get_priv(chip)->base + NSC_STATUS);
+ struct tpm_nsc_priv *priv = dev_get_drvdata(&chip->dev);
+
+ return inb(priv->base + NSC_STATUS);
}
static bool tpm_nsc_req_canceled(struct tpm_chip *chip, u8 status)
@@ -260,9 +263,10 @@ static struct platform_device *pdev = NULL;
static void tpm_nsc_remove(struct device *dev)
{
struct tpm_chip *chip = dev_get_drvdata(dev);
+ struct tpm_nsc_priv *priv = dev_get_drvdata(&chip->dev);
tpm_chip_unregister(chip);
- release_region(nsc_get_priv(chip)->base, 2);
+ release_region(priv->base, 2);
}
static SIMPLE_DEV_PM_OPS(tpm_nsc_pm, tpm_pm_suspend, tpm_pm_resume);
@@ -334,7 +338,7 @@ static int __init init_nsc(void)
goto err_rel_reg;
}
- chip->vendor.priv = priv;
+ dev_set_drvdata(&chip->dev, priv);
rc = tpm_chip_register(chip);
if (rc)
diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index edad5dc..1e45e73 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ b/drivers/char/tpm/tpm_tis.c
@@ -132,7 +132,7 @@ static inline int is_itpm(struct acpi_device *dev)
* correct values in the other bits.' */
static int wait_startup(struct tpm_chip *chip, int l)
{
- struct priv_data *priv = chip->vendor.priv;
+ struct priv_data *priv = dev_get_drvdata(&chip->dev);
unsigned long stop = jiffies + chip->timeout_a;
do {
if (ioread8(priv->iobase + TPM_ACCESS(l)) &
@@ -145,7 +145,7 @@ static int wait_startup(struct tpm_chip *chip, int l)
static int check_locality(struct tpm_chip *chip, int l)
{
- struct priv_data *priv = chip->vendor.priv;
+ struct priv_data *priv = dev_get_drvdata(&chip->dev);
if ((ioread8(priv->iobase + TPM_ACCESS(l)) &
(TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID)) ==
@@ -157,7 +157,7 @@ static int check_locality(struct tpm_chip *chip, int l)
static void release_locality(struct tpm_chip *chip, int l, int force)
{
- struct priv_data *priv = chip->vendor.priv;
+ struct priv_data *priv = dev_get_drvdata(&chip->dev);
if (force || (ioread8(priv->iobase + TPM_ACCESS(l)) &
(TPM_ACCESS_REQUEST_PENDING | TPM_ACCESS_VALID)) ==
@@ -168,7 +168,7 @@ static void release_locality(struct tpm_chip *chip, int l, int force)
static int request_locality(struct tpm_chip *chip, int l)
{
- struct priv_data *priv = chip->vendor.priv;
+ struct priv_data *priv = dev_get_drvdata(&chip->dev);
unsigned long stop, timeout;
long rc;
@@ -209,7 +209,7 @@ again:
static u8 tpm_tis_status(struct tpm_chip *chip)
{
- struct priv_data *priv = chip->vendor.priv;
+ struct priv_data *priv = dev_get_drvdata(&chip->dev);
return ioread8(priv->iobase +
TPM_STS(priv->locality));
@@ -217,7 +217,7 @@ static u8 tpm_tis_status(struct tpm_chip *chip)
static void tpm_tis_ready(struct tpm_chip *chip)
{
- struct priv_data *priv = chip->vendor.priv;
+ struct priv_data *priv = dev_get_drvdata(&chip->dev);
/* this causes the current command to be aborted */
iowrite8(TPM_STS_COMMAND_READY,
@@ -226,7 +226,7 @@ static void tpm_tis_ready(struct tpm_chip *chip)
static int get_burstcount(struct tpm_chip *chip)
{
- struct priv_data *priv = chip->vendor.priv;
+ struct priv_data *priv = dev_get_drvdata(&chip->dev);
unsigned long stop;
int burstcnt;
@@ -248,7 +248,7 @@ static int get_burstcount(struct tpm_chip *chip)
static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count)
{
- struct priv_data *priv = chip->vendor.priv;
+ struct priv_data *priv = dev_get_drvdata(&chip->dev);
int size = 0, burstcnt;
while (size < count &&
wait_for_tpm_stat(chip,
@@ -266,7 +266,7 @@ static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count)
static int tpm_tis_recv(struct tpm_chip *chip, u8 *buf, size_t count)
{
- struct priv_data *priv = chip->vendor.priv;
+ struct priv_data *priv = dev_get_drvdata(&chip->dev);
int size = 0;
int expected, status;
@@ -322,7 +322,7 @@ MODULE_PARM_DESC(itpm, "Force iTPM workarounds (found on some Lenovo laptops)");
*/
static int tpm_tis_send_data(struct tpm_chip *chip, u8 *buf, size_t len)
{
- struct priv_data *priv = chip->vendor.priv;
+ struct priv_data *priv = dev_get_drvdata(&chip->dev);
int rc, status, burstcnt;
size_t count = 0;
@@ -378,7 +378,7 @@ out_err:
static void disable_interrupts(struct tpm_chip *chip)
{
- struct priv_data *priv = chip->vendor.priv;
+ struct priv_data *priv = dev_get_drvdata(&chip->dev);
u32 intmask;
intmask =
@@ -399,7 +399,7 @@ static void disable_interrupts(struct tpm_chip *chip)
*/
static int tpm_tis_send_main(struct tpm_chip *chip, u8 *buf, size_t len)
{
- struct priv_data *priv = chip->vendor.priv;
+ struct priv_data *priv = dev_get_drvdata(&chip->dev);
int rc;
u32 ordinal;
unsigned long dur;
@@ -437,7 +437,7 @@ out_err:
static int tpm_tis_send(struct tpm_chip *chip, u8 *buf, size_t len)
{
int rc, irq;
- struct priv_data *priv = chip->vendor.priv;
+ struct priv_data *priv = dev_get_drvdata(&chip->dev);
if (!(chip->flags & TPM_CHIP_FLAG_IRQ) || priv->irq_tested)
return tpm_tis_send_main(chip, buf, len);
@@ -471,7 +471,7 @@ static const struct tis_vendor_timeout_override vendor_timeout_overrides[] = {
static bool tpm_tis_update_timeouts(struct tpm_chip *chip,
unsigned long *timeout_cap)
{
- struct priv_data *priv = chip->vendor.priv;
+ struct priv_data *priv = dev_get_drvdata(&chip->dev);
int i;
u32 did_vid;
@@ -495,7 +495,7 @@ static bool tpm_tis_update_timeouts(struct tpm_chip *chip,
*/
static int probe_itpm(struct tpm_chip *chip)
{
- struct priv_data *priv = chip->vendor.priv;
+ struct priv_data *priv = dev_get_drvdata(&chip->dev);
int rc = 0;
u8 cmd_getticks[] = {
0x00, 0xc1, 0x00, 0x00, 0x00, 0x0a,
@@ -537,7 +537,7 @@ out:
static bool tpm_tis_req_canceled(struct tpm_chip *chip, u8 status)
{
- struct priv_data *priv = chip->vendor.priv;
+ struct priv_data *priv = dev_get_drvdata(&chip->dev);
switch (priv->manufacturer_id) {
case TPM_VID_WINBOND:
@@ -564,7 +564,7 @@ static const struct tpm_class_ops tpm_tis = {
static irqreturn_t tis_int_handler(int dummy, void *dev_id)
{
struct tpm_chip *chip = dev_id;
- struct priv_data *priv = chip->vendor.priv;
+ struct priv_data *priv = dev_get_drvdata(&chip->dev);
u32 interrupt;
int i;
@@ -574,7 +574,7 @@ static irqreturn_t tis_int_handler(int dummy, void *dev_id)
if (interrupt == 0)
return IRQ_NONE;
- ((struct priv_data *)chip->vendor.priv)->irq_tested = true;
+ priv->irq_tested = true;
if (interrupt & TPM_INTF_DATA_AVAIL_INT)
wake_up_interruptible(&priv->read_queue);
if (interrupt & TPM_INTF_LOCALITY_CHANGE_INT)
@@ -601,7 +601,7 @@ static irqreturn_t tis_int_handler(int dummy, void *dev_id)
static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask,
int flags, int irq)
{
- struct priv_data *priv = chip->vendor.priv;
+ struct priv_data *priv = dev_get_drvdata(&chip->dev);
u8 original_int_vec;
if (devm_request_irq(&chip->dev, irq, tis_int_handler, flags,
@@ -654,7 +654,7 @@ static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask,
*/
static void tpm_tis_probe_irq(struct tpm_chip *chip, u32 intmask)
{
- struct priv_data *priv = chip->vendor.priv;
+ struct priv_data *priv = dev_get_drvdata(&chip->dev);
u8 original_int_vec;
int i;
@@ -678,7 +678,7 @@ MODULE_PARM_DESC(interrupts, "Enable interrupts");
static void tpm_tis_remove(struct tpm_chip *chip)
{
- struct priv_data *priv = chip->vendor.priv;
+ struct priv_data *priv = dev_get_drvdata(&chip->dev);
void __iomem *reg = priv->iobase + TPM_INT_ENABLE(priv->locality);
if (chip->flags & TPM_CHIP_FLAG_TPM2)
@@ -704,7 +704,6 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info,
if (IS_ERR(chip))
return PTR_ERR(chip);
- chip->vendor.priv = priv;
#ifdef CONFIG_ACPI
chip->acpi_dev_handle = acpi_dev_handle;
#endif
@@ -719,6 +718,8 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info,
chip->timeout_c = TIS_TIMEOUT_C_MAX;
chip->timeout_d = TIS_TIMEOUT_D_MAX;
+ dev_set_drvdata(&chip->dev, priv);
+
if (wait_startup(chip, 0) != 0) {
rc = -ENODEV;
goto out_err;
@@ -843,7 +844,7 @@ out_err:
#ifdef CONFIG_PM_SLEEP
static void tpm_tis_reenable_interrupts(struct tpm_chip *chip)
{
- struct priv_data *priv = chip->vendor.priv;
+ struct priv_data *priv = dev_get_drvdata(&chip->dev);
u32 intmask;
/* reenable interrupts that device may have lost or
diff --git a/drivers/char/tpm/xen-tpmfront.c b/drivers/char/tpm/xen-tpmfront.c
index 1b28f96..62028f4 100644
--- a/drivers/char/tpm/xen-tpmfront.c
+++ b/drivers/char/tpm/xen-tpmfront.c
@@ -41,7 +41,7 @@ enum status_bits {
static u8 vtpm_status(struct tpm_chip *chip)
{
- struct tpm_private *priv = TPM_VPRIV(chip);
+ struct tpm_private *priv = dev_get_drvdata(&chip->dev);
switch (priv->shr->state) {
case VTPM_STATE_IDLE:
return VTPM_STATUS_IDLE | VTPM_STATUS_CANCELED;
@@ -62,7 +62,7 @@ static bool vtpm_req_canceled(struct tpm_chip *chip, u8 status)
static void vtpm_cancel(struct tpm_chip *chip)
{
- struct tpm_private *priv = TPM_VPRIV(chip);
+ struct tpm_private *priv = dev_get_drvdata(&chip->dev);
priv->shr->state = VTPM_STATE_CANCEL;
wmb();
notify_remote_via_evtchn(priv->evtchn);
@@ -75,7 +75,7 @@ static unsigned int shr_data_offset(struct vtpm_shared_page *shr)
static int vtpm_send(struct tpm_chip *chip, u8 *buf, size_t count)
{
- struct tpm_private *priv = TPM_VPRIV(chip);
+ struct tpm_private *priv = dev_get_drvdata(&chip->dev);
struct vtpm_shared_page *shr = priv->shr;
unsigned int offset = shr_data_offset(shr);
@@ -117,7 +117,7 @@ static int vtpm_send(struct tpm_chip *chip, u8 *buf, size_t count)
static int vtpm_recv(struct tpm_chip *chip, u8 *buf, size_t count)
{
- struct tpm_private *priv = TPM_VPRIV(chip);
+ struct tpm_private *priv = dev_get_drvdata(&chip->dev);
struct vtpm_shared_page *shr = priv->shr;
unsigned int offset = shr_data_offset(shr);
size_t length = shr->length;
@@ -184,7 +184,7 @@ static int setup_chip(struct device *dev, struct tpm_private *priv)
init_waitqueue_head(&priv->read_queue);
priv->chip = chip;
- TPM_VPRIV(chip) = priv;
+ dev_set_drvdata(&chip->dev, priv);
return 0;
}
@@ -320,10 +320,10 @@ static int tpmfront_probe(struct xenbus_device *dev,
static int tpmfront_remove(struct xenbus_device *dev)
{
struct tpm_chip *chip = dev_get_drvdata(&dev->dev);
- struct tpm_private *priv = TPM_VPRIV(chip);
+ struct tpm_private *priv = dev_get_drvdata(&chip->dev);
tpm_chip_unregister(chip);
ring_free(priv);
- TPM_VPRIV(chip) = NULL;
+ dev_set_drvdata(&chip->dev, NULL);
return 0;
}
--
2.5.0
------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785471&iu=/4140
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v4 0/6] Remove the tpm_vendor_specific structure
[not found] ` <1459457820-30542-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
` (5 preceding siblings ...)
2016-03-31 20:57 ` [PATCH v4 6/6] tpm: Remove useless priv field in struct tpm_vendor_specific Christophe Ricard
@ 2016-04-01 12:05 ` Jarkko Sakkinen
6 siblings, 0 replies; 8+ messages in thread
From: Jarkko Sakkinen @ 2016-04-01 12:05 UTC (permalink / raw)
To: Christophe Ricard
Cc: jean-luc.blanc-qxv4g6HH51o, ashley-fm2HMyfA2y6tG0bUXCXiUA,
tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
christophe-h.ricard-qxv4g6HH51o, benoit.houyere-qxv4g6HH51o
On Thu, Mar 31, 2016 at 10:56:54PM +0200, Christophe Ricard wrote:
> Hi Jarkko,
>
> After our discussion, please find an updated v4 serie allowing to
> completely remove reference to the tpm_vendor_specific structure.
>
> I have been able to test tpm_tis on a HP8200 Desktop machine.
I pushed these to my master branch so that they get easily testing
coverage.
/Jarkko
>
> It applies cleanly on top of:
> tpm: cleanup tpm_tis_remove()
> 72e454274bc1a05d561ae5f6959c15a26604a25d
>
> In v4:
> - Added Jarkko's Review in patch 2, 3, 4, 6
> - Fixed checkpatch Warning in patch 1
> macros should not use a trailing semicolon
> #165: FILE: drivers/char/tpm/tpm_atmel.h:41:
> +#define atmel_getb(priv, offset) readb(priv->iobase + offset);'
> Note: this warning is not directly linked with patch one.
> It was mention in v3 cover-letter.
> - Reduced patch 5 commit message and moved each timeout_X to a new line/declaration.
>
> In v3:
> - Merged 'tpm/tpm_atmel: drop remaining 'iobase' usage' from v2 and
> 'tpm: drop 'iobase' from struct tpm_vendor_specific' sent in v1
> - Move patch tpm: Remove useless priv field in struct tpm_vendor_specific
> at the end of the serie,
> - Dropped codestyle/cleanup patches. May be send later...
> (e.g: tpm/tpm_i2c_atmel: simplify patch to get tpm_chip from an i2c_client,
> tpm/tpm_i2c_atmel: Few code style fixes)
> - In patch 'tpm: drop 'irq' from struct tpm_vendor_specific', Renamed
> TPM_CHIP_FLAG_USES_IRQ to TPM_CHIP_FLAG_IRQ
> - Added patch 'tpm: drop 'locality' from struct tpm_vendor_specific'.
>
> v2 serie was dropped.
>
> Best Regards
> Christophe
>
> Christophe Ricard (6):
> tpm: drop 'iobase' from struct tpm_vendor_specific
> tpm: drop 'irq' from struct tpm_vendor_specific
> tpm: drop 'read_queue' from struct tpm_vendor_specific
> tpm: drop 'locality' from struct tpm_vendor_specific
> tpm: Move tpm_vendor_specific data related with PTP specification to
> tpm_chip
> tpm: Remove useless priv field in struct tpm_vendor_specific
>
> drivers/char/tpm/st33zp24/i2c.c | 15 ++-
> drivers/char/tpm/st33zp24/spi.c | 15 ++-
> drivers/char/tpm/st33zp24/st33zp24.c | 113 +++++++-----------
> drivers/char/tpm/st33zp24/st33zp24.h | 12 ++
> drivers/char/tpm/tpm-interface.c | 52 ++++----
> drivers/char/tpm/tpm-sysfs.c | 20 ++--
> drivers/char/tpm/tpm.h | 28 ++---
> drivers/char/tpm/tpm2-cmd.c | 2 +-
> drivers/char/tpm/tpm_atmel.c | 32 +++--
> drivers/char/tpm/tpm_atmel.h | 10 +-
> drivers/char/tpm/tpm_crb.c | 12 +-
> drivers/char/tpm/tpm_i2c_atmel.c | 23 ++--
> drivers/char/tpm/tpm_i2c_infineon.c | 48 ++++----
> drivers/char/tpm/tpm_i2c_nuvoton.c | 73 +++++++-----
> drivers/char/tpm/tpm_ibmvtpm.c | 38 ++----
> drivers/char/tpm/tpm_nsc.c | 48 ++++----
> drivers/char/tpm/tpm_tis.c | 225 +++++++++++++++++++----------------
> drivers/char/tpm/xen-tpmfront.c | 36 +++---
> 18 files changed, 402 insertions(+), 400 deletions(-)
>
> --
> 2.5.0
>
------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785471&iu=/4140
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2016-04-01 12:05 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-31 20:56 [PATCH v4 0/6] Remove the tpm_vendor_specific structure Christophe Ricard
[not found] ` <1459457820-30542-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
2016-03-31 20:56 ` [PATCH v4 1/6] tpm: drop 'iobase' from struct tpm_vendor_specific Christophe Ricard
2016-03-31 20:56 ` [PATCH v4 2/6] tpm: drop 'irq' " Christophe Ricard
2016-03-31 20:56 ` [PATCH v4 3/6] tpm: drop 'read_queue' " Christophe Ricard
2016-03-31 20:56 ` [PATCH v4 4/6] tpm: drop 'locality' " Christophe Ricard
2016-03-31 20:56 ` [PATCH v4 5/6] tpm: Move tpm_vendor_specific data related with PTP specification to tpm_chip Christophe Ricard
2016-03-31 20:57 ` [PATCH v4 6/6] tpm: Remove useless priv field in struct tpm_vendor_specific Christophe Ricard
2016-04-01 12:05 ` [PATCH v4 0/6] Remove the tpm_vendor_specific structure Jarkko Sakkinen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).