Commit 9e0d39d8 authored by Christophe Ricard's avatar Christophe Ricard Committed by Jarkko Sakkinen

tpm: Remove useless priv field in struct tpm_vendor_specific

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: default avatarChristophe Ricard <christophe-h.ricard@st.com>
Reviewed-by: default avatarJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: default avatarJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
parent af782f33
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <linux/tpm.h> #include <linux/tpm.h>
#include <linux/platform_data/st33zp24.h> #include <linux/platform_data/st33zp24.h>
#include "../tpm.h"
#include "st33zp24.h" #include "st33zp24.h"
#define TPM_DUMMY_BYTE 0xAA #define TPM_DUMMY_BYTE 0xAA
...@@ -112,7 +113,9 @@ static const struct st33zp24_phy_ops i2c_phy_ops = { ...@@ -112,7 +113,9 @@ static const struct st33zp24_phy_ops i2c_phy_ops = {
static int st33zp24_i2c_acpi_request_resources(struct i2c_client *client) 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 gpio_desc *gpiod_lpcpd;
struct device *dev = &client->dev; struct device *dev = &client->dev;
...@@ -138,7 +141,9 @@ static int st33zp24_i2c_acpi_request_resources(struct i2c_client *client) ...@@ -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) 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; struct device_node *pp;
int gpio; int gpio;
int ret; int ret;
...@@ -176,8 +181,10 @@ static int st33zp24_i2c_of_request_resources(struct i2c_client *client) ...@@ -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) 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_platform_data *pdata;
struct st33zp24_i2c_phy *phy = i2c_get_clientdata(client);
int ret; int ret;
pdata = client->dev.platform_data; pdata = client->dev.platform_data;
...@@ -234,8 +241,6 @@ static int st33zp24_i2c_probe(struct i2c_client *client, ...@@ -234,8 +241,6 @@ static int st33zp24_i2c_probe(struct i2c_client *client,
phy->client = client; phy->client = client;
i2c_set_clientdata(client, phy);
pdata = client->dev.platform_data; pdata = client->dev.platform_data;
if (!pdata && client->dev.of_node) { if (!pdata && client->dev.of_node) {
ret = st33zp24_i2c_of_request_resources(client); ret = st33zp24_i2c_of_request_resources(client);
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <linux/tpm.h> #include <linux/tpm.h>
#include <linux/platform_data/st33zp24.h> #include <linux/platform_data/st33zp24.h>
#include "../tpm.h"
#include "st33zp24.h" #include "st33zp24.h"
#define TPM_DATA_FIFO 0x24 #define TPM_DATA_FIFO 0x24
...@@ -231,7 +232,9 @@ static const struct st33zp24_phy_ops spi_phy_ops = { ...@@ -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) 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 gpio_desc *gpiod_lpcpd;
struct device *dev = &spi_dev->dev; struct device *dev = &spi_dev->dev;
...@@ -256,7 +259,9 @@ static int st33zp24_spi_acpi_request_resources(struct spi_device *spi_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) 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; struct device_node *pp;
int gpio; int gpio;
int ret; int ret;
...@@ -294,7 +299,9 @@ static int st33zp24_spi_of_request_resources(struct spi_device *spi_dev) ...@@ -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) 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; struct st33zp24_platform_data *pdata;
int ret; int ret;
...@@ -347,8 +354,6 @@ static int st33zp24_spi_probe(struct spi_device *dev) ...@@ -347,8 +354,6 @@ static int st33zp24_spi_probe(struct spi_device *dev)
phy->spi_device = dev; phy->spi_device = dev;
spi_set_drvdata(dev, phy);
pdata = dev->dev.platform_data; pdata = dev->dev.platform_data;
if (!pdata && dev->dev.of_node) { if (!pdata && dev->dev.of_node) {
ret = st33zp24_spi_of_request_resources(dev); ret = st33zp24_spi_of_request_resources(dev);
......
...@@ -94,11 +94,9 @@ static u8 clear_interruption(struct st33zp24_dev *tpm_dev) ...@@ -94,11 +94,9 @@ static u8 clear_interruption(struct st33zp24_dev *tpm_dev)
*/ */
static void st33zp24_cancel(struct tpm_chip *chip) 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; u8 data;
tpm_dev = (struct st33zp24_dev *)TPM_VPRIV(chip);
data = TPM_STS_COMMAND_READY; data = TPM_STS_COMMAND_READY;
tpm_dev->ops->send(tpm_dev->phy_id, TPM_STS, &data, 1); tpm_dev->ops->send(tpm_dev->phy_id, TPM_STS, &data, 1);
} /* st33zp24_cancel() */ } /* st33zp24_cancel() */
...@@ -110,11 +108,9 @@ static void st33zp24_cancel(struct tpm_chip *chip) ...@@ -110,11 +108,9 @@ static void st33zp24_cancel(struct tpm_chip *chip)
*/ */
static u8 st33zp24_status(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; u8 data;
tpm_dev = (struct st33zp24_dev *)TPM_VPRIV(chip);
tpm_dev->ops->recv(tpm_dev->phy_id, TPM_STS, &data, 1); tpm_dev->ops->recv(tpm_dev->phy_id, TPM_STS, &data, 1);
return data; return data;
} /* st33zp24_status() */ } /* st33zp24_status() */
...@@ -126,12 +122,10 @@ static u8 st33zp24_status(struct tpm_chip *chip) ...@@ -126,12 +122,10 @@ static u8 st33zp24_status(struct tpm_chip *chip)
*/ */
static int check_locality(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 data;
u8 status; u8 status;
tpm_dev = (struct st33zp24_dev *)TPM_VPRIV(chip);
status = tpm_dev->ops->recv(tpm_dev->phy_id, TPM_ACCESS, &data, 1); status = tpm_dev->ops->recv(tpm_dev->phy_id, TPM_ACCESS, &data, 1);
if (status && (data & if (status && (data &
(TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID)) == (TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID)) ==
...@@ -148,13 +142,11 @@ static int check_locality(struct tpm_chip *chip) ...@@ -148,13 +142,11 @@ static int check_locality(struct tpm_chip *chip)
*/ */
static int request_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; unsigned long stop;
long ret; long ret;
struct st33zp24_dev *tpm_dev;
u8 data; u8 data;
tpm_dev = (struct st33zp24_dev *)TPM_VPRIV(chip);
if (check_locality(chip) == tpm_dev->locality) if (check_locality(chip) == tpm_dev->locality)
return tpm_dev->locality; return tpm_dev->locality;
...@@ -182,10 +174,9 @@ static int request_locality(struct tpm_chip *chip) ...@@ -182,10 +174,9 @@ static int request_locality(struct tpm_chip *chip)
*/ */
static void release_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; u8 data;
tpm_dev = (struct st33zp24_dev *)TPM_VPRIV(chip);
data = TPM_ACCESS_ACTIVE_LOCALITY; data = TPM_ACCESS_ACTIVE_LOCALITY;
tpm_dev->ops->send(tpm_dev->phy_id, TPM_ACCESS, &data, 1); tpm_dev->ops->send(tpm_dev->phy_id, TPM_ACCESS, &data, 1);
...@@ -198,12 +189,10 @@ static void release_locality(struct tpm_chip *chip) ...@@ -198,12 +189,10 @@ static void release_locality(struct tpm_chip *chip)
*/ */
static int get_burstcount(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; unsigned long stop;
int burstcnt, status; int burstcnt, status;
u8 temp; u8 temp;
struct st33zp24_dev *tpm_dev;
tpm_dev = (struct st33zp24_dev *)TPM_VPRIV(chip);
stop = jiffies + chip->timeout_d; stop = jiffies + chip->timeout_d;
do { do {
...@@ -263,15 +252,13 @@ static bool wait_for_tpm_stat_cond(struct tpm_chip *chip, u8 mask, ...@@ -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, static int wait_for_stat(struct tpm_chip *chip, u8 mask, unsigned long timeout,
wait_queue_head_t *queue, bool check_cancel) wait_queue_head_t *queue, bool check_cancel)
{ {
struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev);
unsigned long stop; unsigned long stop;
int ret = 0; int ret = 0;
bool canceled = false; bool canceled = false;
bool condition; bool condition;
u32 cur_intrs; u32 cur_intrs;
u8 status; u8 status;
struct st33zp24_dev *tpm_dev;
tpm_dev = (struct st33zp24_dev *)TPM_VPRIV(chip);
/* check current status */ /* check current status */
status = st33zp24_status(chip); status = st33zp24_status(chip);
...@@ -329,10 +316,8 @@ static int wait_for_stat(struct tpm_chip *chip, u8 mask, unsigned long timeout, ...@@ -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) 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; int size = 0, burstcnt, len, ret;
struct st33zp24_dev *tpm_dev;
tpm_dev = (struct st33zp24_dev *)TPM_VPRIV(chip);
while (size < count && while (size < count &&
wait_for_stat(chip, wait_for_stat(chip,
...@@ -362,9 +347,7 @@ static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count) ...@@ -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) static irqreturn_t tpm_ioserirq_handler(int irq, void *dev_id)
{ {
struct tpm_chip *chip = dev_id; struct tpm_chip *chip = dev_id;
struct st33zp24_dev *tpm_dev; struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev);
tpm_dev = (struct st33zp24_dev *)TPM_VPRIV(chip);
tpm_dev->intrs++; tpm_dev->intrs++;
wake_up_interruptible(&tpm_dev->read_queue); wake_up_interruptible(&tpm_dev->read_queue);
...@@ -385,19 +368,17 @@ static irqreturn_t tpm_ioserirq_handler(int irq, void *dev_id) ...@@ -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, static int st33zp24_send(struct tpm_chip *chip, unsigned char *buf,
size_t len) size_t len)
{ {
struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev);
u32 status, i, size, ordinal; u32 status, i, size, ordinal;
int burstcnt = 0; int burstcnt = 0;
int ret; int ret;
u8 data; u8 data;
struct st33zp24_dev *tpm_dev;
if (!chip) if (!chip)
return -EBUSY; return -EBUSY;
if (len < TPM_HEADER_SIZE) if (len < TPM_HEADER_SIZE)
return -EBUSY; return -EBUSY;
tpm_dev = (struct st33zp24_dev *)TPM_VPRIV(chip);
ret = request_locality(chip); ret = request_locality(chip);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -557,9 +538,9 @@ int st33zp24_probe(void *phy_id, const struct st33zp24_phy_ops *ops, ...@@ -557,9 +538,9 @@ int st33zp24_probe(void *phy_id, const struct st33zp24_phy_ops *ops,
if (!tpm_dev) if (!tpm_dev)
return -ENOMEM; return -ENOMEM;
TPM_VPRIV(chip) = tpm_dev;
tpm_dev->phy_id = phy_id; tpm_dev->phy_id = phy_id;
tpm_dev->ops = ops; tpm_dev->ops = ops;
dev_set_drvdata(&chip->dev, tpm_dev);
chip->timeout_a = 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_b = msecs_to_jiffies(TIS_LONG_TIMEOUT);
...@@ -643,10 +624,9 @@ EXPORT_SYMBOL(st33zp24_remove); ...@@ -643,10 +624,9 @@ EXPORT_SYMBOL(st33zp24_remove);
int st33zp24_pm_suspend(struct device *dev) int st33zp24_pm_suspend(struct device *dev)
{ {
struct tpm_chip *chip = dev_get_drvdata(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); int ret = 0;
if (gpio_is_valid(tpm_dev->io_lpcpd)) if (gpio_is_valid(tpm_dev->io_lpcpd))
gpio_set_value(tpm_dev->io_lpcpd, 0); gpio_set_value(tpm_dev->io_lpcpd, 0);
...@@ -665,11 +645,9 @@ EXPORT_SYMBOL(st33zp24_pm_suspend); ...@@ -665,11 +645,9 @@ EXPORT_SYMBOL(st33zp24_pm_suspend);
int st33zp24_pm_resume(struct device *dev) int st33zp24_pm_resume(struct device *dev)
{ {
struct tpm_chip *chip = dev_get_drvdata(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; int ret = 0;
tpm_dev = (struct st33zp24_dev *)TPM_VPRIV(chip);
if (gpio_is_valid(tpm_dev->io_lpcpd)) { if (gpio_is_valid(tpm_dev->io_lpcpd)) {
gpio_set_value(tpm_dev->io_lpcpd, 1); gpio_set_value(tpm_dev->io_lpcpd, 1);
ret = wait_for_stat(chip, ret = wait_for_stat(chip,
......
...@@ -128,14 +128,6 @@ enum tpm2_startup_types { ...@@ -128,14 +128,6 @@ enum tpm2_startup_types {
TPM2_SU_STATE = 0x0001, 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_INTEL 0x8086
#define TPM_VID_WINBOND 0x1050 #define TPM_VID_WINBOND 0x1050
#define TPM_VID_STM 0x104A #define TPM_VID_STM 0x104A
...@@ -166,7 +158,6 @@ struct tpm_chip { ...@@ -166,7 +158,6 @@ struct tpm_chip {
struct mutex tpm_mutex; /* tpm is processing */ struct mutex tpm_mutex; /* tpm is processing */
struct tpm_vendor_specific vendor;
unsigned long timeout_a; /* jiffies */ unsigned long timeout_a; /* jiffies */
unsigned long timeout_b; /* jiffies */ unsigned long timeout_b; /* jiffies */
unsigned long timeout_c; /* jiffies */ unsigned long timeout_c; /* jiffies */
......
...@@ -37,7 +37,7 @@ enum tpm_atmel_read_status { ...@@ -37,7 +37,7 @@ enum tpm_atmel_read_status {
static int tpm_atml_recv(struct tpm_chip *chip, u8 *buf, size_t count) 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; u8 status, *hdr = buf;
u32 size; u32 size;
int i; int i;
...@@ -96,7 +96,7 @@ static int tpm_atml_recv(struct tpm_chip *chip, u8 *buf, size_t count) ...@@ -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) 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; int i;
dev_dbg(&chip->dev, "tpm_atml_send:\n"); 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) ...@@ -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) 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); iowrite8(ATML_STATUS_ABORT, priv->iobase + 1);
} }
static u8 tpm_atml_status(struct tpm_chip *chip) 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); return ioread8(priv->iobase + 1);
} }
...@@ -142,7 +142,7 @@ static struct platform_device *pdev; ...@@ -142,7 +142,7 @@ static struct platform_device *pdev;
static void atml_plat_remove(void) static void atml_plat_remove(void)
{ {
struct tpm_chip *chip = dev_get_drvdata(&pdev->dev); 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) { if (chip) {
tpm_chip_unregister(chip); tpm_chip_unregister(chip);
...@@ -207,7 +207,7 @@ static int __init init_atmel(void) ...@@ -207,7 +207,7 @@ static int __init init_atmel(void)
goto err_unreg_dev; goto err_unreg_dev;
} }
chip->vendor.priv = priv; dev_set_drvdata(&chip->dev, priv);
rc = tpm_chip_register(chip); rc = tpm_chip_register(chip);
if (rc) if (rc)
......
...@@ -29,11 +29,6 @@ struct tpm_atmel_priv { ...@@ -29,11 +29,6 @@ struct tpm_atmel_priv {
void __iomem *iobase; void __iomem *iobase;
}; };
static inline struct tpm_atmel_priv *atmel_get_priv(struct tpm_chip *chip)
{
return chip->vendor.priv;
}
#ifdef CONFIG_PPC64 #ifdef CONFIG_PPC64
#include <asm/prom.h> #include <asm/prom.h>
......
...@@ -87,7 +87,7 @@ static SIMPLE_DEV_PM_OPS(crb_pm, tpm_pm_suspend, tpm_pm_resume); ...@@ -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) 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; u8 sts = 0;
if ((ioread32(&priv->cca->start) & CRB_START_INVOKE) != if ((ioread32(&priv->cca->start) & CRB_START_INVOKE) !=
...@@ -99,7 +99,7 @@ static u8 crb_status(struct tpm_chip *chip) ...@@ -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) 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; unsigned int expected;
/* sanity check */ /* sanity check */
...@@ -139,7 +139,7 @@ static int crb_do_acpi_start(struct tpm_chip *chip) ...@@ -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) 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; int rc = 0;
if (len > ioread32(&priv->cca->cmd_size)) { if (len > ioread32(&priv->cca->cmd_size)) {
...@@ -166,7 +166,7 @@ static int crb_send(struct tpm_chip *chip, u8 *buf, size_t len) ...@@ -166,7 +166,7 @@ static int crb_send(struct tpm_chip *chip, u8 *buf, size_t len)
static void crb_cancel(struct tpm_chip *chip) 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); iowrite32(cpu_to_le32(CRB_CANCEL_INVOKE), &priv->cca->cancel);
...@@ -181,7 +181,7 @@ static void crb_cancel(struct tpm_chip *chip) ...@@ -181,7 +181,7 @@ static void crb_cancel(struct tpm_chip *chip)
static bool crb_req_canceled(struct tpm_chip *chip, u8 status) 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); u32 cancel = ioread32(&priv->cca->cancel);
return (cancel & CRB_CANCEL_INVOKE) == CRB_CANCEL_INVOKE; return (cancel & CRB_CANCEL_INVOKE) == CRB_CANCEL_INVOKE;
...@@ -206,7 +206,7 @@ static int crb_init(struct acpi_device *device, struct crb_priv *priv) ...@@ -206,7 +206,7 @@ static int crb_init(struct acpi_device *device, struct crb_priv *priv)
if (IS_ERR(chip)) if (IS_ERR(chip))
return PTR_ERR(chip); return PTR_ERR(chip);
chip->vendor.priv = priv; dev_set_drvdata(&chip->dev, priv);
chip->acpi_dev_handle = device->handle; chip->acpi_dev_handle = device->handle;
chip->flags = TPM_CHIP_FLAG_TPM2; chip->flags = TPM_CHIP_FLAG_TPM2;
......
...@@ -51,7 +51,7 @@ struct priv_data { ...@@ -51,7 +51,7 @@ struct priv_data {
static int i2c_atmel_send(struct tpm_chip *chip, u8 *buf, size_t len) 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); struct i2c_client *client = to_i2c_client(chip->dev.parent);
s32 status; s32 status;
...@@ -70,7 +70,7 @@ static int i2c_atmel_send(struct tpm_chip *chip, u8 *buf, size_t len) ...@@ -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) 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 i2c_client *client = to_i2c_client(chip->dev.parent);
struct tpm_output_header *hdr = struct tpm_output_header *hdr =
(struct tpm_output_header *)priv->buffer; (struct tpm_output_header *)priv->buffer;
...@@ -111,7 +111,7 @@ static void i2c_atmel_cancel(struct tpm_chip *chip) ...@@ -111,7 +111,7 @@ static void i2c_atmel_cancel(struct tpm_chip *chip)
static u8 i2c_atmel_read_status(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); struct i2c_client *client = to_i2c_client(chip->dev.parent);
int rc; int rc;
...@@ -155,6 +155,7 @@ static int i2c_atmel_probe(struct i2c_client *client, ...@@ -155,6 +155,7 @@ static int i2c_atmel_probe(struct i2c_client *client,
{ {
struct tpm_chip *chip; struct tpm_chip *chip;
struct device *dev = &client->dev; struct device *dev = &client->dev;
struct priv_data *priv;
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
return -ENODEV; return -ENODEV;
...@@ -163,9 +164,8 @@ static int i2c_atmel_probe(struct i2c_client *client, ...@@ -163,9 +164,8 @@ static int i2c_atmel_probe(struct i2c_client *client,
if (IS_ERR(chip)) if (IS_ERR(chip))
return PTR_ERR(chip); return PTR_ERR(chip);
chip->vendor.priv = devm_kzalloc(dev, sizeof(struct priv_data), priv = devm_kzalloc(dev, sizeof(struct priv_data), GFP_KERNEL);
GFP_KERNEL); if (!priv)
if (!chip->vendor.priv)
return -ENOMEM; return -ENOMEM;
/* Default timeouts */ /* Default timeouts */
...@@ -174,6 +174,8 @@ static int i2c_atmel_probe(struct i2c_client *client, ...@@ -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_c = msecs_to_jiffies(TPM_I2C_SHORT_TIMEOUT);
chip->timeout_d = 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 /* 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 * information seems to be read via TPM commands. Thus we rely on the
* TPM startup process in the common code to detect the device. */ * TPM startup process in the common code to detect the device. */
......
...@@ -180,7 +180,7 @@ static int i2c_nuvoton_wait_for_stat(struct tpm_chip *chip, u8 mask, u8 value, ...@@ -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) { if ((chip->flags & TPM_CHIP_FLAG_IRQ) && queue) {
s32 rc; s32 rc;
struct priv_data *priv = chip->vendor.priv; struct priv_data *priv = dev_get_drvdata(&chip->dev);
unsigned int cur_intrs = priv->intrs; unsigned int cur_intrs = priv->intrs;
enable_irq(priv->irq); enable_irq(priv->irq);
...@@ -233,7 +233,7 @@ static int i2c_nuvoton_wait_for_data_avail(struct tpm_chip *chip, u32 timeout, ...@@ -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, static int i2c_nuvoton_recv_data(struct i2c_client *client,
struct tpm_chip *chip, u8 *buf, size_t count) 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; s32 rc;
int burst_count, bytes2read, size = 0; int burst_count, bytes2read, size = 0;
...@@ -267,7 +267,7 @@ static int i2c_nuvoton_recv_data(struct i2c_client *client, ...@@ -267,7 +267,7 @@ static int i2c_nuvoton_recv_data(struct i2c_client *client,
/* Read TPM command results */ /* Read TPM command results */
static int i2c_nuvoton_recv(struct tpm_chip *chip, u8 *buf, size_t count) 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 device *dev = chip->dev.parent;
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev);
s32 rc; s32 rc;
...@@ -351,7 +351,7 @@ static int i2c_nuvoton_recv(struct tpm_chip *chip, u8 *buf, size_t count) ...@@ -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) 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 device *dev = chip->dev.parent;
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev);
u32 ordinal; u32 ordinal;
...@@ -478,7 +478,7 @@ static const struct tpm_class_ops tpm_i2c = { ...@@ -478,7 +478,7 @@ static const struct tpm_class_ops tpm_i2c = {
static irqreturn_t i2c_nuvoton_int_handler(int dummy, void *dev_id) static irqreturn_t i2c_nuvoton_int_handler(int dummy, void *dev_id)
{ {
struct tpm_chip *chip = 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++; priv->intrs++;
wake_up(&priv->read_queue); wake_up(&priv->read_queue);
...@@ -543,7 +543,6 @@ static int i2c_nuvoton_probe(struct i2c_client *client, ...@@ -543,7 +543,6 @@ static int i2c_nuvoton_probe(struct i2c_client *client,
priv = devm_kzalloc(dev, sizeof(struct priv_data), GFP_KERNEL); priv = devm_kzalloc(dev, sizeof(struct priv_data), GFP_KERNEL);
if (!priv) if (!priv)
return -ENOMEM; return -ENOMEM;
chip->vendor.priv = priv;
init_waitqueue_head(&priv->read_queue); init_waitqueue_head(&priv->read_queue);
...@@ -553,6 +552,8 @@ static int i2c_nuvoton_probe(struct i2c_client *client, ...@@ -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_c = msecs_to_jiffies(TPM_I2C_SHORT_TIMEOUT);
chip->timeout_d = 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: * I2C intfcaps (interrupt capabilitieis) in the chip are hard coded to:
* TPM_INTF_INT_LEVEL_LOW | TPM_INTF_DATA_AVAIL_INT * TPM_INTF_INT_LEVEL_LOW | TPM_INTF_DATA_AVAIL_INT
...@@ -619,8 +620,8 @@ static int i2c_nuvoton_probe(struct i2c_client *client, ...@@ -619,8 +620,8 @@ static int i2c_nuvoton_probe(struct i2c_client *client,
static int i2c_nuvoton_remove(struct i2c_client *client) static int i2c_nuvoton_remove(struct i2c_client *client)
{ {
struct device *dev = &(client->dev); struct tpm_chip *chip = i2c_get_clientdata(client);
struct tpm_chip *chip = dev_get_drvdata(dev);
tpm_chip_unregister(chip); tpm_chip_unregister(chip);
return 0; return 0;
} }
......
...@@ -53,21 +53,6 @@ static int ibmvtpm_send_crq(struct vio_dev *vdev, u64 w1, u64 w2) ...@@ -53,21 +53,6 @@ static int ibmvtpm_send_crq(struct vio_dev *vdev, u64 w1, u64 w2)
return plpar_hcall_norets(H_SEND_CRQ, vdev->unit_address, w1, w2); return plpar_hcall_norets(H_SEND_CRQ, vdev->unit_address, w1, 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 * tpm_ibmvtpm_recv - Receive data after send
* @chip: tpm chip struct * @chip: tpm chip struct
...@@ -79,12 +64,10 @@ static struct ibmvtpm_dev *ibmvtpm_get_data(const struct device *dev) ...@@ -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) 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; u16 len;
int sig; int sig;
ibmvtpm = (struct ibmvtpm_dev *)TPM_VPRIV(chip);
if (!ibmvtpm->rtce_buf) { if (!ibmvtpm->rtce_buf) {
dev_err(ibmvtpm->dev, "ibmvtpm device is not ready\n"); dev_err(ibmvtpm->dev, "ibmvtpm device is not ready\n");
return 0; return 0;
...@@ -122,13 +105,11 @@ static int tpm_ibmvtpm_recv(struct tpm_chip *chip, u8 *buf, size_t count) ...@@ -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) 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; struct ibmvtpm_crq crq;
__be64 *word = (__be64 *)&crq; __be64 *word = (__be64 *)&crq;
int rc, sig; int rc, sig;
ibmvtpm = (struct ibmvtpm_dev *)TPM_VPRIV(chip);
if (!ibmvtpm->rtce_buf) { if (!ibmvtpm->rtce_buf) {
dev_err(ibmvtpm->dev, "ibmvtpm device is not ready\n"); dev_err(ibmvtpm->dev, "ibmvtpm device is not ready\n");
return 0; return 0;
...@@ -289,8 +270,8 @@ static int ibmvtpm_crq_send_init(struct ibmvtpm_dev *ibmvtpm) ...@@ -289,8 +270,8 @@ static int ibmvtpm_crq_send_init(struct ibmvtpm_dev *ibmvtpm)
*/ */
static int tpm_ibmvtpm_remove(struct vio_dev *vdev) 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(&vdev->dev);
struct tpm_chip *chip = dev_get_drvdata(ibmvtpm->dev); struct ibmvtpm_dev *ibmvtpm = dev_get_drvdata(&chip->dev);
int rc = 0; int rc = 0;
tpm_chip_unregister(chip); tpm_chip_unregister(chip);
...@@ -327,7 +308,8 @@ static int tpm_ibmvtpm_remove(struct vio_dev *vdev) ...@@ -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) 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 /* ibmvtpm initializes at probe time, so the data we are
* asking for may not be set yet. Estimate that 4K required * 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) ...@@ -348,7 +330,8 @@ static unsigned long tpm_ibmvtpm_get_desired_dma(struct vio_dev *vdev)
*/ */
static int tpm_ibmvtpm_suspend(struct device *dev) 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; struct ibmvtpm_crq crq;
u64 *buf = (u64 *) &crq; u64 *buf = (u64 *) &crq;
int rc = 0; int rc = 0;
...@@ -400,7 +383,8 @@ static int ibmvtpm_reset_crq(struct ibmvtpm_dev *ibmvtpm) ...@@ -400,7 +383,8 @@ static int ibmvtpm_reset_crq(struct ibmvtpm_dev *ibmvtpm)
*/ */
static int tpm_ibmvtpm_resume(struct device *dev) 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; int rc = 0;
do { do {
...@@ -643,7 +627,7 @@ static int tpm_ibmvtpm_probe(struct vio_dev *vio_dev, ...@@ -643,7 +627,7 @@ static int tpm_ibmvtpm_probe(struct vio_dev *vio_dev,
crq_q->index = 0; crq_q->index = 0;
TPM_VPRIV(chip) = (void *)ibmvtpm; dev_set_drvdata(&chip->dev, ibmvtpm)
spin_lock_init(&ibmvtpm->rtce_lock); spin_lock_init(&ibmvtpm->rtce_lock);
......
...@@ -69,20 +69,16 @@ struct tpm_nsc_priv { ...@@ -69,20 +69,16 @@ struct tpm_nsc_priv {
unsigned long base; 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 * Wait for a certain status to appear
*/ */
static int wait_for_stat(struct tpm_chip *chip, u8 mask, u8 val, u8 * data) 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; unsigned long stop;
/* status immediately available check */ /* status immediately available check */
*data = inb(nsc_get_priv(chip)->base + NSC_STATUS); *data = inb(priv->base + NSC_STATUS);
if ((*data & mask) == val) if ((*data & mask) == val)
return 0; return 0;
...@@ -90,7 +86,7 @@ static int wait_for_stat(struct tpm_chip *chip, u8 mask, u8 val, u8 * data) ...@@ -90,7 +86,7 @@ static int wait_for_stat(struct tpm_chip *chip, u8 mask, u8 val, u8 * data)
stop = jiffies + 10 * HZ; stop = jiffies + 10 * HZ;
do { do {
msleep(TPM_TIMEOUT); msleep(TPM_TIMEOUT);
*data = inb(nsc_get_priv(chip)->base + 1); *data = inb(priv->base + 1);
if ((*data & mask) == val) if ((*data & mask) == val)
return 0; return 0;
} }
...@@ -101,13 +97,14 @@ static int wait_for_stat(struct tpm_chip *chip, u8 mask, u8 val, u8 * data) ...@@ -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) static int nsc_wait_for_ready(struct tpm_chip *chip)
{ {
struct tpm_nsc_priv *priv = dev_get_drvdata(&chip->dev);
int status; int status;
unsigned long stop; unsigned long stop;
/* status immediately available check */ /* status immediately available check */
status = inb(nsc_get_priv(chip)->base + NSC_STATUS); status = inb(priv->base + NSC_STATUS);
if (status & NSC_STATUS_OBF) 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) if (status & NSC_STATUS_RDY)
return 0; return 0;
...@@ -115,9 +112,9 @@ static int nsc_wait_for_ready(struct tpm_chip *chip) ...@@ -115,9 +112,9 @@ static int nsc_wait_for_ready(struct tpm_chip *chip)
stop = jiffies + 100; stop = jiffies + 100;
do { do {
msleep(TPM_TIMEOUT); msleep(TPM_TIMEOUT);
status = inb(nsc_get_priv(chip)->base + NSC_STATUS); status = inb(priv->base + NSC_STATUS);
if (status & NSC_STATUS_OBF) 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) if (status & NSC_STATUS_RDY)
return 0; return 0;
} }
...@@ -130,6 +127,7 @@ static int nsc_wait_for_ready(struct tpm_chip *chip) ...@@ -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) 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 *buffer = buf;
u8 data, *p; u8 data, *p;
u32 size; u32 size;
...@@ -143,7 +141,7 @@ static int tpm_nsc_recv(struct tpm_chip *chip, u8 * buf, size_t count) ...@@ -143,7 +141,7 @@ static int tpm_nsc_recv(struct tpm_chip *chip, u8 * buf, size_t count)
return -EIO; return -EIO;
} }
data = inb(nsc_get_priv(chip)->base + NSC_DATA); data = inb(priv->base + NSC_DATA);
if (data != NSC_COMMAND_NORMAL) { if (data != NSC_COMMAND_NORMAL) {
dev_err(&chip->dev, "not in normal mode (0x%x)\n", dev_err(&chip->dev, "not in normal mode (0x%x)\n",
data); data);
...@@ -160,7 +158,7 @@ static int tpm_nsc_recv(struct tpm_chip *chip, u8 * buf, size_t count) ...@@ -160,7 +158,7 @@ static int tpm_nsc_recv(struct tpm_chip *chip, u8 * buf, size_t count)
} }
if (data & NSC_STATUS_F0) if (data & NSC_STATUS_F0)
break; break;
*p = inb(nsc_get_priv(chip)->base + NSC_DATA); *p = inb(priv->base + NSC_DATA);
} }
if ((data & NSC_STATUS_F0) == 0 && if ((data & NSC_STATUS_F0) == 0 &&
...@@ -169,7 +167,7 @@ static int tpm_nsc_recv(struct tpm_chip *chip, u8 * buf, size_t count) ...@@ -169,7 +167,7 @@ static int tpm_nsc_recv(struct tpm_chip *chip, u8 * buf, size_t count)
return -EIO; return -EIO;
} }
data = inb(nsc_get_priv(chip)->base + NSC_DATA); data = inb(priv->base + NSC_DATA);
if (data != NSC_COMMAND_EOC) { if (data != NSC_COMMAND_EOC) {
dev_err(&chip->dev, dev_err(&chip->dev,
"expected end of command(0x%x)\n", data); "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) ...@@ -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) 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; u8 data;
int i; int i;
...@@ -196,7 +195,7 @@ static int tpm_nsc_send(struct tpm_chip *chip, u8 * buf, size_t count) ...@@ -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 * fix it. Not sure why this is needed, we followed the flow
* chart in the manual to the letter. * 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) if (nsc_wait_for_ready(chip) != 0)
return -EIO; return -EIO;
...@@ -206,7 +205,7 @@ static int tpm_nsc_send(struct tpm_chip *chip, u8 * buf, size_t count) ...@@ -206,7 +205,7 @@ static int tpm_nsc_send(struct tpm_chip *chip, u8 * buf, size_t count)
return -EIO; 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) { if (wait_for_stat(chip, NSC_STATUS_IBR, NSC_STATUS_IBR, &data) < 0) {
dev_err(&chip->dev, "IBR timeout\n"); dev_err(&chip->dev, "IBR timeout\n");
return -EIO; return -EIO;
...@@ -218,26 +217,30 @@ static int tpm_nsc_send(struct tpm_chip *chip, u8 * buf, size_t count) ...@@ -218,26 +217,30 @@ static int tpm_nsc_send(struct tpm_chip *chip, u8 * buf, size_t count)
"IBF timeout (while writing data)\n"); "IBF timeout (while writing data)\n");
return -EIO; 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) { if (wait_for_stat(chip, NSC_STATUS_IBF, 0, &data) < 0) {
dev_err(&chip->dev, "IBF timeout\n"); dev_err(&chip->dev, "IBF timeout\n");
return -EIO; return -EIO;
} }
outb(NSC_COMMAND_EOC, nsc_get_priv(chip)->base + NSC_COMMAND); outb(NSC_COMMAND_EOC, priv->base + NSC_COMMAND);
return count; return count;
} }
static void tpm_nsc_cancel(struct tpm_chip *chip) 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) 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) static bool tpm_nsc_req_canceled(struct tpm_chip *chip, u8 status)
...@@ -260,9 +263,10 @@ static struct platform_device *pdev = NULL; ...@@ -260,9 +263,10 @@ static struct platform_device *pdev = NULL;
static void tpm_nsc_remove(struct device *dev) static void tpm_nsc_remove(struct device *dev)
{ {
struct tpm_chip *chip = dev_get_drvdata(dev); struct tpm_chip *chip = dev_get_drvdata(dev);
struct tpm_nsc_priv *priv = dev_get_drvdata(&chip->dev);
tpm_chip_unregister(chip); 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); static SIMPLE_DEV_PM_OPS(tpm_nsc_pm, tpm_pm_suspend, tpm_pm_resume);
...@@ -334,7 +338,7 @@ static int __init init_nsc(void) ...@@ -334,7 +338,7 @@ static int __init init_nsc(void)
goto err_rel_reg; goto err_rel_reg;
} }
chip->vendor.priv = priv; dev_set_drvdata(&chip->dev, priv);
rc = tpm_chip_register(chip); rc = tpm_chip_register(chip);
if (rc) if (rc)
......
...@@ -132,7 +132,7 @@ static inline int is_itpm(struct acpi_device *dev) ...@@ -132,7 +132,7 @@ static inline int is_itpm(struct acpi_device *dev)
* correct values in the other bits.' */ * correct values in the other bits.' */
static int wait_startup(struct tpm_chip *chip, int l) 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; unsigned long stop = jiffies + chip->timeout_a;
do { do {
if (ioread8(priv->iobase + TPM_ACCESS(l)) & if (ioread8(priv->iobase + TPM_ACCESS(l)) &
...@@ -145,7 +145,7 @@ static int wait_startup(struct tpm_chip *chip, int 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) 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)) & if ((ioread8(priv->iobase + TPM_ACCESS(l)) &
(TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID)) == (TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID)) ==
...@@ -157,7 +157,7 @@ static int check_locality(struct tpm_chip *chip, int l) ...@@ -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) 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)) & if (force || (ioread8(priv->iobase + TPM_ACCESS(l)) &
(TPM_ACCESS_REQUEST_PENDING | TPM_ACCESS_VALID)) == (TPM_ACCESS_REQUEST_PENDING | TPM_ACCESS_VALID)) ==
...@@ -168,7 +168,7 @@ static void release_locality(struct tpm_chip *chip, int l, int force) ...@@ -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) 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; unsigned long stop, timeout;
long rc; long rc;
...@@ -209,7 +209,7 @@ static int request_locality(struct tpm_chip *chip, int l) ...@@ -209,7 +209,7 @@ static int request_locality(struct tpm_chip *chip, int l)
static u8 tpm_tis_status(struct tpm_chip *chip) 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 + return ioread8(priv->iobase +
TPM_STS(priv->locality)); TPM_STS(priv->locality));
...@@ -217,7 +217,7 @@ static u8 tpm_tis_status(struct tpm_chip *chip) ...@@ -217,7 +217,7 @@ static u8 tpm_tis_status(struct tpm_chip *chip)
static void tpm_tis_ready(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 */ /* this causes the current command to be aborted */
iowrite8(TPM_STS_COMMAND_READY, iowrite8(TPM_STS_COMMAND_READY,
...@@ -226,7 +226,7 @@ static void tpm_tis_ready(struct tpm_chip *chip) ...@@ -226,7 +226,7 @@ static void tpm_tis_ready(struct tpm_chip *chip)
static int get_burstcount(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; unsigned long stop;
int burstcnt; int burstcnt;
...@@ -248,7 +248,7 @@ static int get_burstcount(struct tpm_chip *chip) ...@@ -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) 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; int size = 0, burstcnt;
while (size < count && while (size < count &&
wait_for_tpm_stat(chip, wait_for_tpm_stat(chip,
...@@ -266,7 +266,7 @@ static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count) ...@@ -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) 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 size = 0;
int expected, status; int expected, status;
...@@ -322,7 +322,7 @@ MODULE_PARM_DESC(itpm, "Force iTPM workarounds (found on some Lenovo laptops)"); ...@@ -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) 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; int rc, status, burstcnt;
size_t count = 0; size_t count = 0;
...@@ -378,7 +378,7 @@ static int tpm_tis_send_data(struct tpm_chip *chip, u8 *buf, size_t len) ...@@ -378,7 +378,7 @@ static int tpm_tis_send_data(struct tpm_chip *chip, u8 *buf, size_t len)
static void disable_interrupts(struct tpm_chip *chip) 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; u32 intmask;
intmask = intmask =
...@@ -399,7 +399,7 @@ static void disable_interrupts(struct tpm_chip *chip) ...@@ -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) 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; int rc;
u32 ordinal; u32 ordinal;
unsigned long dur; unsigned long dur;
...@@ -437,7 +437,7 @@ static int tpm_tis_send_main(struct tpm_chip *chip, u8 *buf, size_t len) ...@@ -437,7 +437,7 @@ static int tpm_tis_send_main(struct tpm_chip *chip, u8 *buf, size_t len)
static int tpm_tis_send(struct tpm_chip *chip, u8 *buf, size_t len) static int tpm_tis_send(struct tpm_chip *chip, u8 *buf, size_t len)
{ {
int rc, irq; 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) if (!(chip->flags & TPM_CHIP_FLAG_IRQ) || priv->irq_tested)
return tpm_tis_send_main(chip, buf, len); return tpm_tis_send_main(chip, buf, len);
...@@ -471,7 +471,7 @@ static const struct tis_vendor_timeout_override vendor_timeout_overrides[] = { ...@@ -471,7 +471,7 @@ static const struct tis_vendor_timeout_override vendor_timeout_overrides[] = {
static bool tpm_tis_update_timeouts(struct tpm_chip *chip, static bool tpm_tis_update_timeouts(struct tpm_chip *chip,
unsigned long *timeout_cap) unsigned long *timeout_cap)
{ {
struct priv_data *priv = chip->vendor.priv; struct priv_data *priv = dev_get_drvdata(&chip->dev);
int i; int i;
u32 did_vid; u32 did_vid;
...@@ -495,7 +495,7 @@ static bool tpm_tis_update_timeouts(struct tpm_chip *chip, ...@@ -495,7 +495,7 @@ static bool tpm_tis_update_timeouts(struct tpm_chip *chip,
*/ */
static int probe_itpm(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; int rc = 0;
u8 cmd_getticks[] = { u8 cmd_getticks[] = {
0x00, 0xc1, 0x00, 0x00, 0x00, 0x0a, 0x00, 0xc1, 0x00, 0x00, 0x00, 0x0a,
...@@ -537,7 +537,7 @@ static int probe_itpm(struct tpm_chip *chip) ...@@ -537,7 +537,7 @@ static int probe_itpm(struct tpm_chip *chip)
static bool tpm_tis_req_canceled(struct tpm_chip *chip, u8 status) 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) { switch (priv->manufacturer_id) {
case TPM_VID_WINBOND: case TPM_VID_WINBOND:
...@@ -564,7 +564,7 @@ static const struct tpm_class_ops tpm_tis = { ...@@ -564,7 +564,7 @@ static const struct tpm_class_ops tpm_tis = {
static irqreturn_t tis_int_handler(int dummy, void *dev_id) static irqreturn_t tis_int_handler(int dummy, void *dev_id)
{ {
struct tpm_chip *chip = 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; u32 interrupt;
int i; int i;
...@@ -574,7 +574,7 @@ static irqreturn_t tis_int_handler(int dummy, void *dev_id) ...@@ -574,7 +574,7 @@ static irqreturn_t tis_int_handler(int dummy, void *dev_id)
if (interrupt == 0) if (interrupt == 0)
return IRQ_NONE; return IRQ_NONE;
((struct priv_data *)chip->vendor.priv)->irq_tested = true; priv->irq_tested = true;
if (interrupt & TPM_INTF_DATA_AVAIL_INT) if (interrupt & TPM_INTF_DATA_AVAIL_INT)
wake_up_interruptible(&priv->read_queue); wake_up_interruptible(&priv->read_queue);
if (interrupt & TPM_INTF_LOCALITY_CHANGE_INT) if (interrupt & TPM_INTF_LOCALITY_CHANGE_INT)
...@@ -601,7 +601,7 @@ static irqreturn_t tis_int_handler(int dummy, void *dev_id) ...@@ -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, static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask,
int flags, int irq) int flags, int irq)
{ {
struct priv_data *priv = chip->vendor.priv; struct priv_data *priv = dev_get_drvdata(&chip->dev);
u8 original_int_vec; u8 original_int_vec;
if (devm_request_irq(&chip->dev, irq, tis_int_handler, flags, 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, ...@@ -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) 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; u8 original_int_vec;
int i; int i;
...@@ -678,7 +678,7 @@ MODULE_PARM_DESC(interrupts, "Enable interrupts"); ...@@ -678,7 +678,7 @@ MODULE_PARM_DESC(interrupts, "Enable interrupts");
static void tpm_tis_remove(struct tpm_chip *chip) 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); void __iomem *reg = priv->iobase + TPM_INT_ENABLE(priv->locality);
iowrite32(~TPM_GLOBAL_INT_ENABLE & ioread32(reg), reg); iowrite32(~TPM_GLOBAL_INT_ENABLE & ioread32(reg), reg);
...@@ -701,7 +701,6 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info, ...@@ -701,7 +701,6 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info,
if (IS_ERR(chip)) if (IS_ERR(chip))
return PTR_ERR(chip); return PTR_ERR(chip);
chip->vendor.priv = priv;
#ifdef CONFIG_ACPI #ifdef CONFIG_ACPI
chip->acpi_dev_handle = acpi_dev_handle; chip->acpi_dev_handle = acpi_dev_handle;
#endif #endif
...@@ -716,6 +715,8 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info, ...@@ -716,6 +715,8 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info,
chip->timeout_c = TIS_TIMEOUT_C_MAX; chip->timeout_c = TIS_TIMEOUT_C_MAX;
chip->timeout_d = TIS_TIMEOUT_D_MAX; chip->timeout_d = TIS_TIMEOUT_D_MAX;
dev_set_drvdata(&chip->dev, priv);
if (wait_startup(chip, 0) != 0) { if (wait_startup(chip, 0) != 0) {
rc = -ENODEV; rc = -ENODEV;
goto out_err; goto out_err;
...@@ -840,7 +841,7 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info, ...@@ -840,7 +841,7 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info,
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
static void tpm_tis_reenable_interrupts(struct tpm_chip *chip) 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; u32 intmask;
/* reenable interrupts that device may have lost or /* reenable interrupts that device may have lost or
......
...@@ -41,7 +41,7 @@ enum status_bits { ...@@ -41,7 +41,7 @@ enum status_bits {
static u8 vtpm_status(struct tpm_chip *chip) 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) { switch (priv->shr->state) {
case VTPM_STATE_IDLE: case VTPM_STATE_IDLE:
return VTPM_STATUS_IDLE | VTPM_STATUS_CANCELED; return VTPM_STATUS_IDLE | VTPM_STATUS_CANCELED;
...@@ -62,7 +62,7 @@ static bool vtpm_req_canceled(struct tpm_chip *chip, u8 status) ...@@ -62,7 +62,7 @@ static bool vtpm_req_canceled(struct tpm_chip *chip, u8 status)
static void vtpm_cancel(struct tpm_chip *chip) 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; priv->shr->state = VTPM_STATE_CANCEL;
wmb(); wmb();
notify_remote_via_evtchn(priv->evtchn); notify_remote_via_evtchn(priv->evtchn);
...@@ -75,7 +75,7 @@ static unsigned int shr_data_offset(struct vtpm_shared_page *shr) ...@@ -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) 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; struct vtpm_shared_page *shr = priv->shr;
unsigned int offset = shr_data_offset(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) ...@@ -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) 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; struct vtpm_shared_page *shr = priv->shr;
unsigned int offset = shr_data_offset(shr); unsigned int offset = shr_data_offset(shr);
size_t length = shr->length; size_t length = shr->length;
...@@ -184,7 +184,7 @@ static int setup_chip(struct device *dev, struct tpm_private *priv) ...@@ -184,7 +184,7 @@ static int setup_chip(struct device *dev, struct tpm_private *priv)
init_waitqueue_head(&priv->read_queue); init_waitqueue_head(&priv->read_queue);
priv->chip = chip; priv->chip = chip;
TPM_VPRIV(chip) = priv; dev_set_drvdata(&chip->dev, priv);
return 0; return 0;
} }
...@@ -320,10 +320,10 @@ static int tpmfront_probe(struct xenbus_device *dev, ...@@ -320,10 +320,10 @@ static int tpmfront_probe(struct xenbus_device *dev,
static int tpmfront_remove(struct xenbus_device *dev) static int tpmfront_remove(struct xenbus_device *dev)
{ {
struct tpm_chip *chip = dev_get_drvdata(&dev->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); tpm_chip_unregister(chip);
ring_free(priv); ring_free(priv);
TPM_VPRIV(chip) = NULL; dev_set_drvdata(&chip->dev, NULL);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment