Remove the tpm_vendor_specific structure
Subsystems (3)
v2 cover Remove the tpm_vendor_specific structure
Hi Jarkko,
This is the latest steps to cleanup tpm_vendor_specific structure.
I have also included some few obvious cleanup inside the drivers. I have been able to test tpm_tis on a HP Desktop machine.
In v2 i have added a patch fixing:
'tpm: drop 'iobase' from struct tpm_vendor_specific' 691f211398bb93878b727be0c5c523e2371074f5
It may be merged with the mention commit.
Best Regards
Christophe
Christophe Ricard (7):
tpm/tpm_atmel: drop remaining 'iobase' usage
tpm: Remove useless priv field in struct tpm_vendor_specific tpm/tpm_i2c_atmel: simplify patch to get tpm_chip from an i2c_client tpm/tpm_i2c_atmel: Few code style fixes
tpm: drop 'irq' from struct tpm_vendor_specific
tpm: Move remaining tpm_vendor_specific structure data to tpm_chip
tpm: drop 'read_queue' from 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 | 9 ++ drivers/char/tpm/tpm-interface.c | 52 +++++----- drivers/char/tpm/tpm-sysfs.c | 20 ++-- drivers/char/tpm/tpm.h | 24 ++--- drivers/char/tpm/tpm2-cmd.c | 2 +- drivers/char/tpm/tpm_atmel.c | 12 +-- drivers/char/tpm/tpm_atmel.h | 9 +- drivers/char/tpm/tpm_crb.c | 12 +-- drivers/char/tpm/tpm_i2c_atmel.c | 30 +++--- drivers/char/tpm/tpm_i2c_infineon.c | 47 +++++---- 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 | 182 ++++++++++++++++++----------------- drivers/char/tpm/xen-tpmfront.c | 36 +++---- 18 files changed, 356 insertions(+), 381 deletions(-)
Signature · 9 lines
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=278785351&iu=/4140
A message that is not in the archive (sent off-list or not yet received): 1458975615-8095-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org
PATCH v2 1/7 tpm/tpm_atmel: drop remaining 'iobase' usage
Remove some sporadic iobase
--- drivers/char/tpm/tpm_atmel.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/char/tpm/tpm_atmel.h +2 -2
@@ -38,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
Signature · 9 lines
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=278785351&iu=/4140
A message that is not in the archive (sent off-list or not yet received): 1458975615-8095-2-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org
Re: [PATCH v2 1/7] tpm/tpm_atmel: drop remaining 'iobase' usage
Quoted 1 line · Christophe Ricard
Remove some sporadic iobase
This description of this commit is total crap to be honest (saying this with a polite tone but that's how it is). For me the commit meessage is the most important part of the commit and the sentence above contains exactly zero amount of information.
A proper commit message would have stated that this fixes the PPC64 builds that your earlier patch breaks. Have you tested that PPC64 builds work now?
Actually what you should have *really* done would have updated your older patch and put a remark into change log in the cover letter.
/Jarkko
Quoted 23 lines
Signed-off-by Christophe Ricard <[email protected]>--- drivers/char/tpm/tpm_atmel.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/char/tpm/tpm_atmel.h +2
-2@@ -38,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_regionSignature · 1 line
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
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v2 1/7] tpm/tpm_atmel: drop remaining 'iobase' usage
Hi Jarkko,
I just saw you have updated the master branch removing patch:
tpm: drop 'iobase' from struct tpm_vendor_specific.
I will merge both in a new v3 serie and will make sure it will build for PPC64
as well.
Does that sound acceptable for you ?
Best Regards
Christophe
Quoted 36 lines · Jarkko Sakkinen
Quoted 1 line · Christophe Ricard
Remove some sporadic iobase
This description of this commit is total crap to be honest (saying this with a polite tone but that's how it is). For me the commit meessage is the most important part of the commit and the sentence above contains exactly zero amount of information.
A proper commit message would have stated that this fixes the PPC64 builds that your earlier patch breaks. Have you tested that PPC64 builds work now?
Actually what you should have *really* done would have updated your older patch and put a remark into change log in the cover letter.
/Jarkko
Quoted 20 lines
Signed-off-by Christophe Ricard <[email protected]>--- drivers/char/tpm/tpm_atmel.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/char/tpm/tpm_atmel.h +2
-2@@ -38,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
Quoted 3 lines
Quoted 3 lines
Signature · 1 line
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
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v2 1/7] tpm/tpm_atmel: drop remaining 'iobase' usage
Quoted 10 lines · Christophe Ricard
Hi Jarkko,
I just saw you have updated the master branch removing patch:
tpm: drop 'iobase' from structtpm_vendor_specific.I will merge both in a new v3 serie and will make sure it will build for PPC64
as well.Does that sound acceptable for you ?
It does. No worries.
Quoted 2 lines
Best Regards
Christophe
/Jarkko
Quoted 23 lines · Jarkko Sakkinen
Quoted 21 lines · Christophe Ricard
Quoted 1 line
Remove some sporadic iobase
This description of this commit is total crap to be honest (saying this with a polite tone but that's how it is). For me the commit meessage is the most important part of the commit and the sentence above contains exactly zero amount of information.
A proper commit message would have stated that this fixes the PPC64 builds that your earlier patch breaks. Have you tested that PPC64 builds work now?
Actually what you should have *really* done would have updated your older patch and put a remark into change log in the cover letter.
/Jarkko
Quoted 5 lines
Signed-off-by Christophe Ricard <[email protected]>--- drivers/char/tpm/tpm_atmel.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 16 lines
Quoted 7 lines
Quoted 7 lines
drivers/char/tpm/tpm_atmel.h +0
-1@@ -38,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);Quoted 8 lines
Quoted 8 lines
drivers/char/tpm/tpm_atmel.h +2
-1-#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_regionSignature · 1 line
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
PATCH v2 2/7 tpm: Remove useless priv field in struct tpm_vendor_specific
In reply to a message not in the archiveRemove useless priv field in struct tpm_vendor_specific and take benefit of chip->dev.driver_data.
--- drivers/char/tpm/st33zp24/i2c.c | 15 ++++++---- drivers/char/tpm/st33zp24/spi.c | 15 ++++++---- drivers/char/tpm/st33zp24/st33zp24.c | 58 +++++++++--------------------------- drivers/char/tpm/st33zp24/st33zp24.h | 7 +++++ drivers/char/tpm/tpm.h | 3 -- 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 | 16 +++++----- drivers/char/tpm/tpm_ibmvtpm.c | 38 +++++++---------------- drivers/char/tpm/tpm_nsc.c | 48 +++++++++++++++-------------- drivers/char/tpm/tpm_tis.c | 48 +++++++++++++++-------------- drivers/char/tpm/xen-tpmfront.c | 14 ++++----- 14 files changed, 139 insertions(+), 166 deletions(-)
drivers/char/tpm/st33zp24/i2c.c +10 -5
@@ -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);
drivers/char/tpm/st33zp24/spi.c +10 -5
@@ -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);
drivers/char/tpm/st33zp24/st33zp24.c +14 -44
181 lines not on this page · raw message
drivers/char/tpm/st33zp24/st33zp24.h +7 -0
@@ -21,6 +21,13 @@#define TPM_WRITE_DIRECTION 0x80#define TPM_BUFSIZE 2048 +struct st33zp24_dev { +void *phy_id; +const struct st33zp24_phy_ops *ops; +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);
drivers/char/tpm/tpm.h +0 -3
@@ -138,13 +138,10 @@ struct tpm_vendor_specific {bool timeout_adjusted;unsigned long duration[3 ];/* jiffies */ bool duration_adjusted; -void *priv;wait_queue_head_t read_queue; }; -#define TPM_VPRIV (c) ((c)->vendor.priv) -#define TPM_VID_INTEL 0x8086#define TPM_VID_WINBOND 0x1050#define TPM_VID_STM 0x104A
drivers/char/tpm/tpm_atmel.c +6 -6
@@ -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)
drivers/char/tpm/tpm_atmel.h +0 -5
@@ -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>
drivers/char/tpm/tpm_crb.c +6 -6
@@ -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 ;
drivers/char/tpm/tpm_i2c_atmel.c +8 -6
@@ -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 */
@@ -175,6 +175,8 @@ static int i2c_atmel_probe(struct i2c_client *client, chip->vendor.timeout_d =msecs_to_jiffies (TPM_I2C_SHORT_TIMEOUT ); chip->vendor.irq =0 ; +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. */
drivers/char/tpm/tpm_i2c_nuvoton.c +9 -7
@@ -178,7 +178,7 @@ static int i2c_nuvoton_wait_for_stat(struct tpm_chip *chip, u8 mask, u8 value, {if (chip->vendor.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 (chip->vendor.irq);
@@ -473,7 +473,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 (&chip->vendor.read_queue);
@@ -520,6 +520,7 @@ static int i2c_nuvoton_probe(struct i2c_client *client, {int rc;struct tpm_chip *chip; +struct priv_data *priv;struct device *dev = &client->dev;u32 vid =0 ;
@@ -534,9 +535,8 @@ 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 ;init_waitqueue_head (&chip->vendor.read_queue);
@@ -547,6 +547,8 @@ static int i2c_nuvoton_probe(struct i2c_client *client, chip->vendor.timeout_c =msecs_to_jiffies (TPM_I2C_SHORT_TIMEOUT ); chip->vendor.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
@@ -611,8 +613,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 ; }
drivers/char/tpm/tpm_ibmvtpm.c +11 -27
@@ -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);
drivers/char/tpm/tpm_nsc.c +26 -22
164 lines not on this page · raw message
drivers/char/tpm/tpm_tis.c +25 -23
193 lines not on this page · raw message
drivers/char/tpm/xen-tpmfront.c +7 -7
@@ -39,7 +39,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 ;
@@ -60,7 +60,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);
@@ -73,7 +73,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);
@@ -115,7 +115,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;
@@ -182,7 +182,7 @@ static int setup_chip(struct device *dev, struct tpm_private *priv)init_waitqueue_head (&chip->vendor.read_queue); priv->chip = chip; -TPM_VPRIV (chip) = priv; +dev_set_drvdata (&chip->dev, priv);return 0 ; }
@@ -318,10 +318,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 ; }
Signature · 9 lines
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=278785351&iu=/4140
A message that is not in the archive (sent off-list or not yet received): 1458975615-8095-3-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org
Re: [PATCH v2 2/7] tpm: Remove useless priv field in struct tpm_vendor_specific
Quoted 2 lines · Christophe Ricard
Remove useless priv field in struct
tpm_vendor_specificand take benefit ofchip->dev.driver_data.
NAK. The order should be take all the fields from vendor specific and then as a final step remove it when there is only the field 'priv'.
/Jarkko
Quoted 1,188 lines
Signed-off-by Christophe Ricard <[email protected]>--- drivers/char/tpm/st33zp24/i2c.c | 15 ++++++---- drivers/char/tpm/st33zp24/spi.c | 15 ++++++---- drivers/char/tpm/st33zp24/st33zp24.c | 58 +++++++++--------------------------- drivers/char/tpm/st33zp24/st33zp24.h | 7 +++++ drivers/char/tpm/tpm.h | 3 -- 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 | 16 +++++----- drivers/char/tpm/tpm_ibmvtpm.c | 38 +++++++---------------- drivers/char/tpm/tpm_nsc.c | 48 +++++++++++++++-------------- drivers/char/tpm/tpm_tis.c | 48 +++++++++++++++-------------- drivers/char/tpm/xen-tpmfront.c | 14 ++++----- 14 files changed, 139 insertions(+), 166 deletions(-)drivers/char/tpm/st33zp24/i2c.c +10
-5@@ -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);drivers/char/tpm/st33zp24/spi.c +10
-5@@ -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);drivers/char/tpm/st33zp24/st33zp24.c +14
-44@@ -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. @@ -102,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() */ @@ -118,10 +108,9 @@ static void st33zp24_cancel(struct tpm_chip *chip)*/ static u8 st33zp24_status (struct tpm_chip *chip) { -struct st33zp24_dev *tpm_dev; -u8 data; +struct st33zp24_dev *tpm_dev =dev_get_drvdata (&chip->dev); - tpm_dev = (struct st33zp24_dev *)TPM_VPRIV (chip); +u8 data; tpm_dev->ops->recv (tpm_dev->phy_id,TPM_STS , &data,1 );return data;@@ -134,12 +123,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)) ==@@ -158,14 +145,12 @@ static int request_locality(struct tpm_chip *chip) {unsigned long stop;long ret; -struct st33zp24_dev *tpm_dev; +struct st33zp24_dev *tpm_dev =dev_get_drvdata (&chip->dev);u8 data;if (check_locality (chip) == chip->vendor.locality)return chip->vendor.locality; - tpm_dev = (struct st33zp24_dev *)TPM_VPRIV (chip); - data =TPM_ACCESS_REQUEST_USE ; ret = tpm_dev->ops->send (tpm_dev->phy_id,TPM_ACCESS , &data,1 );if (ret <0 )@@ -190,10 +175,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 );@@ -206,12 +190,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->vendor.timeout_d; do {@@ -271,15 +253,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);@@ -337,10 +317,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,@@ -370,9 +348,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 (&chip->vendor.read_queue);@@ -393,19 +369,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;@@ -565,9 +539,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->vendor.timeout_a =msecs_to_jiffies (TIS_SHORT_TIMEOUT ); chip->vendor.timeout_b =msecs_to_jiffies (TIS_LONG_TIMEOUT );@@ -650,11 +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; +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,0 );else @@ -672,11 +644,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,drivers/char/tpm/st33zp24/st33zp24.h +7
-0@@ -21,6 +21,13 @@#define TPM_WRITE_DIRECTION 0x80#define TPM_BUFSIZE 2048 +struct st33zp24_dev { +void *phy_id; +const struct st33zp24_phy_ops *ops; +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);drivers/char/tpm/tpm.h +0
-3@@ -138,13 +138,10 @@ struct tpm_vendor_specific {bool timeout_adjusted;unsigned long duration[3 ];/* jiffies */ bool duration_adjusted; -void *priv;wait_queue_head_t read_queue; }; -#define TPM_VPRIV (c) ((c)->vendor.priv) -#define TPM_VID_INTEL 0x8086#define TPM_VID_WINBOND 0x1050#define TPM_VID_STM 0x104Adrivers/char/tpm/tpm_atmel.c +6
-6@@ -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)drivers/char/tpm/tpm_atmel.h +0
-5@@ -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> drivers/char/tpm/tpm_crb.c +6
-6@@ -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 ;drivers/char/tpm/tpm_i2c_atmel.c +8
-6@@ -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 */ @@ -175,6 +175,8 @@ static int i2c_atmel_probe(struct i2c_client *client, chip->vendor.timeout_d =msecs_to_jiffies (TPM_I2C_SHORT_TIMEOUT ); chip->vendor.irq =0 ; +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. */ drivers/char/tpm/tpm_i2c_nuvoton.c +9
-7@@ -178,7 +178,7 @@ static int i2c_nuvoton_wait_for_stat(struct tpm_chip *chip, u8 mask, u8 value, {if (chip->vendor.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 (chip->vendor.irq);@@ -473,7 +473,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 (&chip->vendor.read_queue);@@ -520,6 +520,7 @@ static int i2c_nuvoton_probe(struct i2c_client *client, {int rc;struct tpm_chip *chip; +struct priv_data *priv;struct device *dev = &client->dev;u32 vid =0 ;@@ -534,9 +535,8 @@ 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 ;init_waitqueue_head (&chip->vendor.read_queue);@@ -547,6 +547,8 @@ static int i2c_nuvoton_probe(struct i2c_client *client, chip->vendor.timeout_c =msecs_to_jiffies (TPM_I2C_SHORT_TIMEOUT ); chip->vendor.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 @@ -611,8 +613,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 ; }drivers/char/tpm/tpm_ibmvtpm.c +11
-27@@ -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);drivers/char/tpm/tpm_nsc.c +26
-22@@ -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)drivers/char/tpm/tpm_tis.c +25
-23@@ -129,8 +129,9 @@ 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->vendor.timeout_a; + do { if (ioread8(priv->iobase + TPM_ACCESS(l)) & TPM_ACCESS_VALID)@@ -142,7 +143,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)) ==@@ -154,7 +155,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)) ==@@ -165,7 +166,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;@@ -206,7 +207,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 (chip->vendor.locality));@@ -214,7 +215,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,@@ -223,7 +224,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;@@ -245,7 +246,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,@@ -264,7 +265,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;@@ -320,7 +321,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 ;@@ -376,7 +377,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 =@@ -396,7 +397,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;@@ -434,7 +435,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->vendor.irq || priv->irq_tested)return tpm_tis_send_main (chip, buf, len);@@ -466,7 +467,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;@@ -490,7 +491,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 ,@@ -532,7 +533,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 :@@ -559,7 +560,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;@@ -569,7 +570,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 (&chip->vendor.read_queue);if (interrupt &TPM_INTF_LOCALITY_CHANGE_INT )@@ -596,7 +597,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,@@ -649,7 +650,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;@@ -673,7 +674,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);if (chip->flags &TPM_CHIP_FLAG_TPM2 )tpm2_shutdown (chip,TPM2_SU_CLEAR );@@ -702,7 +703,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 @@ -717,6 +717,8 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info, chip->vendor.timeout_c =TIS_TIMEOUT_C_MAX ; chip->vendor.timeout_d =TIS_TIMEOUT_D_MAX ; +dev_set_drvdata (&chip->dev, priv); +if (wait_startup (chip,0 ) !=0 ) { rc = -ENODEV ; goto out_err;@@ -841,7 +843,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 drivers/char/tpm/xen-tpmfront.c +7
-7@@ -39,7 +39,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 ;@@ -60,7 +60,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);@@ -73,7 +73,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);@@ -115,7 +115,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;@@ -182,7 +182,7 @@ static int setup_chip(struct device *dev, struct tpm_private *priv)init_waitqueue_head (&chip->vendor.read_queue); priv->chip = chip; -TPM_VPRIV (chip) = priv; +dev_set_drvdata (&chip->dev, priv);return 0 ; }@@ -318,10 +318,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 ; }Signature · 1 line
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
PATCH v2 3/7 tpm/tpm_i2c_atmel: simplify patch to get tpm_chip from an i2c_client
In reply to a message not in the archivei2c_get_clientdata allows to simplify the current way to retrieve a tpm_chip structure.
--- drivers/char/tpm/tpm_i2c_atmel.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/char/tpm/tpm_i2c_atmel.c +1 -2
@@ -191,8 +191,7 @@ static int i2c_atmel_probe(struct i2c_client *client,static int i2c_atmel_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 ; }
Signature · 9 lines
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=278785351&iu=/4140
PATCH v2 4/7 tpm/tpm_i2c_atmel: Few code style fixes
In reply to a message not in the archiveFew code style fixes.
--- drivers/char/tpm/tpm_i2c_atmel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/char/tpm/tpm_i2c_atmel.c +2 -2
@@ -125,8 +125,7 @@ static u8 i2c_atmel_read_status(struct tpm_chip *chip)/* Once the TPM has completed the command the command remains readable * until another command is issued. */ rc =i2c_master_recv (client, priv->buffer,sizeof (priv->buffer)); -dev_dbg (&chip->dev, -"%s: sts=%d" , __func__, rc); +dev_dbg (&chip->dev,"%s: sts=%d" , __func__, rc);if (rc <=0 )return 0 ;
@@ -192,6 +191,7 @@ static int i2c_atmel_probe(struct i2c_client *client,static int i2c_atmel_remove (struct i2c_client *client) {struct tpm_chip *chip =i2c_get_clientdata (client); +tpm_chip_unregister (chip);return 0 ; }
Signature · 9 lines
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=278785351&iu=/4140
A message that is not in the archive (sent off-list or not yet received): 1458975615-8095-5-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org
Re: [PATCH v2 4/7] tpm/tpm_i2c_atmel: Few code style fixes
Quoted 1 line · Christophe Ricard
Few code style fixes.
Sorry but I don't care to apply this patch as there is much more This just adds noise and brings almost no benefit.
/Jarkko
Quoted 30 lines
Signed-off-by Christophe Ricard <[email protected]>--- drivers/char/tpm/tpm_i2c_atmel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/char/tpm/tpm_i2c_atmel.c +2
-2@@ -125,8 +125,7 @@ static u8 i2c_atmel_read_status(struct tpm_chip *chip)/* Once the TPM has completed the command the command remains readable * until another command is issued. */ rc =i2c_master_recv (client, priv->buffer,sizeof (priv->buffer)); -dev_dbg (&chip->dev, -"%s: sts=%d" , __func__, rc); +dev_dbg (&chip->dev,"%s: sts=%d" , __func__, rc);if (rc <=0 )return 0 ;@@ -192,6 +191,7 @@ static int i2c_atmel_probe(struct i2c_client *client,static int i2c_atmel_remove (struct i2c_client *client) {struct tpm_chip *chip =i2c_get_clientdata (client); +tpm_chip_unregister (chip);return 0 ; }Signature · 1 line
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
PATCH v2 5/7 tpm: drop 'irq' from struct tpm_vendor_specific
In reply to a message not in the archiveDropped 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_USES_IRQ is added for the upper layers.
--- drivers/char/tpm/st33zp24/st33zp24.c | 15 ++++++++------- drivers/char/tpm/st33zp24/st33zp24.h | 1 + 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 | 21 ++++++++++++--------- drivers/char/tpm/tpm_tis.c | 30 +++++++++++++++++------------- drivers/char/tpm/xen-tpmfront.c | 7 ++++--- 9 files changed, 45 insertions(+), 40 deletions(-)
drivers/char/tpm/st33zp24/st33zp24.c +8 -7
@@ -268,10 +268,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_USES_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))
@@ -294,7 +294,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 {
@@ -352,7 +352,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() */
@@ -430,7 +430,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_USES_IRQ ) { ordinal =be32_to_cpu (*((__be32 *) (buf +6 ))); ret = wait_for_stat(chip, TPM_STS_DATA_AVAIL | TPM_STS_VALID,
@@ -585,9 +585,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_USES_IRQ ; -disable_irq_nosync (chip->vendor.irq); +disable_irq_nosync (tpm_dev->irq);tpm_gen_interrupt (chip); }
drivers/char/tpm/st33zp24/st33zp24.h +1 -0
@@ -24,6 +24,7 @@struct st33zp24_dev {void *phy_id;const struct st33zp24_phy_ops *ops; +int irq;u32 intrs;int io_lpcpd; };
drivers/char/tpm/tpm-interface.c +2 -2
@@ -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_USES_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_USES_IRQ ) { again: timeout = stop - jiffies;if ((long )timeout <=0 )
drivers/char/tpm/tpm.h +1 -2
@@ -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;
@@ -151,6 +149,7 @@ struct tpm_vendor_specific {enum tpm_chip_flags {TPM_CHIP_FLAG_REGISTERED =BIT (0 ),TPM_CHIP_FLAG_TPM2 =BIT (1 ), +TPM_CHIP_FLAG_USES_IRQ =BIT (2 ), };struct tpm_chip {
drivers/char/tpm/tpm_i2c_atmel.c +0 -1
@@ -172,7 +172,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 ;dev_set_drvdata (&chip->dev, priv);
drivers/char/tpm/tpm_i2c_infineon.c +0 -3
@@ -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 );
drivers/char/tpm/tpm_i2c_nuvoton.c +12 -9
@@ -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_USES_IRQ && queue) {s32 rc;struct priv_data *priv =dev_get_drvdata (&chip->dev);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 ; }
@@ -554,19 +555,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_USES_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_USES_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_USES_IRQ ; + priv->irq =0 ; }else {/* Clear any pending interrupt */ i2c_nuvoton_ready (chip);
drivers/char/tpm/tpm_tis.c +17 -13
@@ -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; };
@@ -178,7 +179,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_USES_IRQ ) { again: timeout = stop - jiffies;if ((long )timeout <=0 )
@@ -386,8 +387,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_USES_IRQ ; }/*
@@ -410,7 +412,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_USES_IRQ ) { ordinal =be32_to_cpu (*((__be32 *) (buf +6 )));if (chip->flags &TPM_CHIP_FLAG_TPM2 )
@@ -437,14 +439,16 @@ static int tpm_tis_send(struct tpm_chip *chip, u8 *buf, size_t len)int rc, irq;struct priv_data *priv =dev_get_drvdata (&chip->dev); -if (!chip->vendor.irq || priv->irq_tested) +if (!(chip->flags &TPM_CHIP_FLAG_USES_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_USES_IRQ ; rc =tpm_tis_send_main (chip, buf, len); - chip->vendor.irq = irq; + priv->irq = irq; + chip->flags |=TPM_CHIP_FLAG_USES_IRQ ;if (!priv->irq_tested)msleep (1 );if (!priv->irq_tested)
@@ -606,7 +610,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));
@@ -635,7 +639,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_USES_IRQ )) {iowrite8 (original_int_vec, priv->iobase +TPM_INT_VECTOR (chip->vendor.locality));return 1 ;
@@ -804,7 +808,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_USES_IRQ ))dev_err (&chip->dev,FW_BUG "TPM interrupt not working, polling instead\n" ); }else
@@ -848,7 +852,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 =
@@ -867,7 +871,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_USES_IRQ )tpm_tis_reenable_interrupts (chip); ret =tpm_pm_resume (dev);
drivers/char/tpm/xen-tpmfront.c +4 -3
@@ -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); }
Signature · 9 lines
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=278785351&iu=/4140
A message that is not in the archive (sent off-list or not yet received): 1458975615-8095-6-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org
Re: [PATCH v2 5/7] tpm: drop 'irq' from struct tpm_vendor_specific
Quoted 4 lines · Christophe Ricard
Dropped the field 'irq' from struct
tpm_vendor_specificand make it available to the various private structures in the drivers using irqs.A dedicated flag
TPM_CHIP_FLAG_USES_IRQis added for the upper layers.
TPM_CHIP_FLAG_IRQ
/Jarkko
Quoted 358 lines
Signed-off-by Christophe Ricard <[email protected]>--- drivers/char/tpm/st33zp24/st33zp24.c | 15 ++++++++------- drivers/char/tpm/st33zp24/st33zp24.h | 1 + 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 | 21 ++++++++++++--------- drivers/char/tpm/tpm_tis.c | 30 +++++++++++++++++------------- drivers/char/tpm/xen-tpmfront.c | 7 ++++--- 9 files changed, 45 insertions(+), 40 deletions(-)drivers/char/tpm/st33zp24/st33zp24.c +8
-7@@ -268,10 +268,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_USES_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))@@ -294,7 +294,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 {@@ -352,7 +352,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() */ @@ -430,7 +430,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_USES_IRQ ) { ordinal =be32_to_cpu (*((__be32 *) (buf +6 ))); ret = wait_for_stat(chip, TPM_STS_DATA_AVAIL | TPM_STS_VALID,@@ -585,9 +585,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_USES_IRQ ; -disable_irq_nosync (chip->vendor.irq); +disable_irq_nosync (tpm_dev->irq);tpm_gen_interrupt (chip); }drivers/char/tpm/st33zp24/st33zp24.h +1
-0@@ -24,6 +24,7 @@struct st33zp24_dev {void *phy_id;const struct st33zp24_phy_ops *ops; +int irq;u32 intrs;int io_lpcpd; };drivers/char/tpm/tpm-interface.c +2
-2@@ -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_USES_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_USES_IRQ ) { again: timeout = stop - jiffies;if ((long )timeout <=0 )drivers/char/tpm/tpm.h +1
-2@@ -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;@@ -151,6 +149,7 @@ struct tpm_vendor_specific {enum tpm_chip_flags {TPM_CHIP_FLAG_REGISTERED =BIT (0 ),TPM_CHIP_FLAG_TPM2 =BIT (1 ), +TPM_CHIP_FLAG_USES_IRQ =BIT (2 ), };struct tpm_chip {drivers/char/tpm/tpm_i2c_atmel.c +0
-1@@ -172,7 +172,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 ;dev_set_drvdata (&chip->dev, priv);drivers/char/tpm/tpm_i2c_infineon.c +0
-3@@ -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 );drivers/char/tpm/tpm_i2c_nuvoton.c +12
-9@@ -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_USES_IRQ && queue) {s32 rc;struct priv_data *priv =dev_get_drvdata (&chip->dev);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 ; }@@ -554,19 +555,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_USES_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_USES_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_USES_IRQ ; + priv->irq =0 ; }else {/* Clear any pending interrupt */ i2c_nuvoton_ready (chip);drivers/char/tpm/tpm_tis.c +17
-13@@ -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; };@@ -178,7 +179,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_USES_IRQ ) { again: timeout = stop - jiffies;if ((long )timeout <=0 )@@ -386,8 +387,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_USES_IRQ ; }/* @@ -410,7 +412,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_USES_IRQ ) { ordinal =be32_to_cpu (*((__be32 *) (buf +6 )));if (chip->flags &TPM_CHIP_FLAG_TPM2 )@@ -437,14 +439,16 @@ static int tpm_tis_send(struct tpm_chip *chip, u8 *buf, size_t len)int rc, irq;struct priv_data *priv =dev_get_drvdata (&chip->dev); -if (!chip->vendor.irq || priv->irq_tested) +if (!(chip->flags &TPM_CHIP_FLAG_USES_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_USES_IRQ ; rc =tpm_tis_send_main (chip, buf, len); - chip->vendor.irq = irq; + priv->irq = irq; + chip->flags |=TPM_CHIP_FLAG_USES_IRQ ;if (!priv->irq_tested)msleep (1 );if (!priv->irq_tested)@@ -606,7 +610,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));@@ -635,7 +639,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_USES_IRQ )) {iowrite8 (original_int_vec, priv->iobase +TPM_INT_VECTOR (chip->vendor.locality));return 1 ;@@ -804,7 +808,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_USES_IRQ ))dev_err (&chip->dev,FW_BUG "TPM interrupt not working, polling instead\n" ); }else @@ -848,7 +852,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 =@@ -867,7 +871,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_USES_IRQ )tpm_tis_reenable_interrupts (chip); ret =tpm_pm_resume (dev);drivers/char/tpm/xen-tpmfront.c +4
-3@@ -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); }Signature · 1 line
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
PATCH v2 6/7 tpm: Move remaining tpm_vendor_specific structure data to tpm_chip
In reply to a message not in the archiveAs no more information in tpm_vendor_specific structure are available in tpm_vendor_specific structure move them to tpm_chip structure.
--- drivers/char/tpm/st33zp24/st33zp24.c | 28 +++++------ drivers/char/tpm/tpm-interface.c | 48 +++++++++--------- drivers/char/tpm/tpm-sysfs.c | 20 ++++---- drivers/char/tpm/tpm.h | 12 ++--- drivers/char/tpm/tpm2-cmd.c | 2 +- drivers/char/tpm/tpm_i2c_atmel.c | 8 +-- drivers/char/tpm/tpm_i2c_infineon.c | 44 ++++++++--------- drivers/char/tpm/tpm_i2c_nuvoton.c | 24 ++++----- drivers/char/tpm/tpm_tis.c | 95 ++++++++++++++++++------------------ drivers/char/tpm/xen-tpmfront.c | 4 +- 10 files changed, 141 insertions(+), 144 deletions(-)
drivers/char/tpm/st33zp24/st33zp24.c +14 -14
@@ -131,7 +131,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 chip->locality;return -EACCES ; }/* check_locality() */
@@ -148,20 +148,20 @@ static int request_locality(struct tpm_chip *chip)struct st33zp24_dev *tpm_dev =dev_get_drvdata (&chip->dev);u8 data; -if (check_locality (chip) == chip->vendor.locality) -return chip->vendor.locality; +if (check_locality (chip) == chip->locality) +return chip->locality; data =TPM_ACCESS_REQUEST_USE ; ret = tpm_dev->ops->send (tpm_dev->phy_id,TPM_ACCESS , &data,1 );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 {if (check_locality (chip) >=0 ) -return chip->vendor.locality; +return chip->locality;msleep (TPM_TIMEOUT ); }while (time_before (jiffies, stop));
@@ -195,7 +195,7 @@ static int get_burstcount(struct tpm_chip *chip)int burstcnt, status;u8 temp; - 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);
@@ -323,7 +323,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, &chip->vendor.read_queue, true) ==0 ) { burstcnt =get_burstcount (chip);if (burstcnt <0 )
@@ -388,7 +388,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, &chip->vendor.read_queue, false) <0 ) { ret = -ETIME ; goto out_err;
@@ -543,12 +543,12 @@ int st33zp24_probe(void *phy_id, const struct st33zp24_phy_ops *ops, tpm_dev->ops = ops;dev_set_drvdata (&chip->dev, tpm_dev); - 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 ); - chip->vendor.locality =LOCALITY0 ; + chip->locality =LOCALITY0 ;if (irq) {/* INTERRUPT Setup */
@@ -651,7 +651,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, &chip->vendor.read_queue, false); }else { ret =tpm_pm_resume (dev);
drivers/char/tpm/tpm-interface.c +24 -24
100 lines not on this page · raw message
drivers/char/tpm/tpm-sysfs.c +10 -10
@@ -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);
drivers/char/tpm/tpm.h +5 -7
@@ -131,12 +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 */ -bool duration_adjusted; -wait_queue_head_t read_queue; };
@@ -170,7 +164,11 @@ struct tpm_chip {struct mutex tpm_mutex;/* tpm is processing */ -struct tpm_vendor_specific vendor; +int locality; +unsigned long timeout_a, timeout_b, timeout_c, timeout_d;/* jiffies */ +bool timeout_adjusted; +unsigned long duration[3 ];/* jiffies */ +bool duration_adjusted;struct dentry **bios_dir;
drivers/char/tpm/tpm2-cmd.c +1 -1
@@ -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 ;
drivers/char/tpm/tpm_i2c_atmel.c +4 -4
@@ -168,10 +168,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 );dev_set_drvdata (&chip->dev, priv);
drivers/char/tpm/tpm_i2c_infineon.c +22 -22
148 lines not on this page · raw message
drivers/char/tpm/tpm_i2c_nuvoton.c +12 -12
@@ -143,7 +143,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;
@@ -237,7 +237,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, &chip->vendor.read_queue) ==0 ) { burst_count =i2c_nuvoton_get_burstcount (client, chip);if (burst_count <0 ) {
@@ -286,7 +286,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->timeout_c, &chip->vendor.read_queue);if (status !=0 ) {dev_err (dev,"%s() timeout on dataAvail\n" , __func__); size = -ETIMEDOUT ;
@@ -326,7 +326,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 ;
@@ -358,7 +358,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 ;
@@ -390,7 +390,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",
@@ -415,7 +415,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__);
@@ -543,10 +543,10 @@ static int i2c_nuvoton_probe(struct i2c_client *client,init_waitqueue_head (&chip->vendor.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 );dev_set_drvdata (&chip->dev, priv);
@@ -577,7 +577,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 ) {/*
drivers/char/tpm/tpm_tis.c +47 -48
296 lines not on this page · raw message
drivers/char/tpm/xen-tpmfront.c +2 -2
@@ -88,7 +88,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, &chip->vendor.read_queue, true) <0 ) {vtpm_cancel (chip);return -ETIME ;
@@ -125,7 +125,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, &chip->vendor.read_queue, true) <0 ) {vtpm_cancel (chip);return -ETIME ;
Signature · 9 lines
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=278785351&iu=/4140
A message that is not in the archive (sent off-list or not yet received): 1458975615-8095-7-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org
Re: [PATCH v2 6/7] tpm: Move remaining tpm_vendor_specific structure data to tpm_chip
Quoted 2 lines · Christophe Ricard
As no more information in
tpm_vendor_specificstructure are available intpm_vendor_specificstructure move them totpm_chipstructure.
The commit message is just horrible and it is lying as there are still fields in that struct after this change.
Quoted 276 lines
Signed-off-by Christophe Ricard <[email protected]>--- drivers/char/tpm/st33zp24/st33zp24.c | 28 +++++------ drivers/char/tpm/tpm-interface.c | 48 +++++++++--------- drivers/char/tpm/tpm-sysfs.c | 20 ++++---- drivers/char/tpm/tpm.h | 12 ++--- drivers/char/tpm/tpm2-cmd.c | 2 +- drivers/char/tpm/tpm_i2c_atmel.c | 8 +-- drivers/char/tpm/tpm_i2c_infineon.c | 44 ++++++++--------- drivers/char/tpm/tpm_i2c_nuvoton.c | 24 ++++----- drivers/char/tpm/tpm_tis.c | 95 ++++++++++++++++++------------------ drivers/char/tpm/xen-tpmfront.c | 4 +- 10 files changed, 141 insertions(+), 144 deletions(-)drivers/char/tpm/st33zp24/st33zp24.c +14
-14@@ -131,7 +131,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 chip->locality;return -EACCES ; }/* check_locality() */ @@ -148,20 +148,20 @@ static int request_locality(struct tpm_chip *chip)struct st33zp24_dev *tpm_dev =dev_get_drvdata (&chip->dev);u8 data; -if (check_locality (chip) == chip->vendor.locality) -return chip->vendor.locality; +if (check_locality (chip) == chip->locality) +return chip->locality; data =TPM_ACCESS_REQUEST_USE ; ret = tpm_dev->ops->send (tpm_dev->phy_id,TPM_ACCESS , &data,1 );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 {if (check_locality (chip) >=0 ) -return chip->vendor.locality; +return chip->locality;msleep (TPM_TIMEOUT ); }while (time_before (jiffies, stop));@@ -195,7 +195,7 @@ static int get_burstcount(struct tpm_chip *chip)int burstcnt, status;u8 temp; - 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);@@ -323,7 +323,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, &chip->vendor.read_queue, true) ==0 ) { burstcnt =get_burstcount (chip);if (burstcnt <0 )@@ -388,7 +388,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, &chip->vendor.read_queue, false) <0 ) { ret = -ETIME ; goto out_err;@@ -543,12 +543,12 @@ int st33zp24_probe(void *phy_id, const struct st33zp24_phy_ops *ops, tpm_dev->ops = ops;dev_set_drvdata (&chip->dev, tpm_dev); - 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 ); - chip->vendor.locality =LOCALITY0 ; + chip->locality =LOCALITY0 ;if (irq) {/* INTERRUPT Setup */ @@ -651,7 +651,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, &chip->vendor.read_queue, false); }else { ret =tpm_pm_resume (dev);drivers/char/tpm/tpm-interface.c +24
-24@@ -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 ;drivers/char/tpm/tpm-sysfs.c +10
-10@@ -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);drivers/char/tpm/tpm.h +0
-6@@ -131,12 +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 */ -bool duration_adjusted; -wait_queue_head_t read_queue; };
drivers/char/tpm/tpm.h struct tpm_chip { · line 168
Quoted 6 lines
drivers/char/tpm/tpm.h +2
-1@@ -170,7 +164,11 @@ struct tpm_chip {struct mutex tpm_mutex;/* tpm is processing */ -struct tpm_vendor_specific vendor; +int locality; +unsigned long timeout_a, timeout_b, timeout_c, timeout_d;/* jiffies */
One line per field.
Quoted 650 lines
drivers/char/tpm/tpm.h +3
-0+bool timeout_adjusted; +unsigned long duration[3 ];/* jiffies */ +bool duration_adjusted;struct dentry **bios_dir;drivers/char/tpm/tpm2-cmd.c +1
-1@@ -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 ;drivers/char/tpm/tpm_i2c_atmel.c +4
-4@@ -168,10 +168,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 );dev_set_drvdata (&chip->dev, priv);drivers/char/tpm/tpm_i2c_infineon.c +22
-22@@ -288,7 +288,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; + chip->locality = loc;return loc; }@@ -320,7 +320,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;@@ -337,7 +337,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(chip->locality), &buf, 1) < 0) return 0; i++;@@ -351,7 +351,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 (chip->locality), &buf,1 ); }static ssize_t get_burstcount (struct tpm_chip *chip)@@ -362,10 +362,10 @@ 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(chip->vendor.locality)+1, buf, 3) < 0) + if (iic_tpm_read(TPM_STS(chip->locality)+1, buf, 3) < 0) burstcnt = 0; else burstcnt = (buf[2] << 16) + (buf[1] << 8) + buf[0];@@ -419,7 +419,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 (chip->locality), &(buf[size]), burstcnt);if (rc ==0 ) size += burstcnt;@@ -464,7 +464,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 ;@@ -477,7 +477,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, chip->locality,0 );return size; }@@ -500,7 +500,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; }@@ -516,7 +516,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 (chip->locality), &(buf[count]), burstcnt);if (rc ==0 ) count += burstcnt;@@ -530,7 +530,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 ;@@ -539,15 +539,15 @@ 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 ); -wait_for_stat (chip,TPM_STS_VALID , chip->vendor.timeout_c, &status); +iic_tpm_write (TPM_DATA_FIFO (chip->locality), &(buf[count]),1 ); +wait_for_stat (chip,TPM_STS_VALID , chip->timeout_c, &status);if ((status &TPM_STS_DATA_EXPECT ) !=0 ) { rc = -EIO ; goto out_err; }/* go and do it */ -iic_tpm_write (TPM_STS (chip->vendor.locality), &sts,1 ); +iic_tpm_write (TPM_STS (chip->locality), &sts,1 );return len; out_err:@@ -556,7 +556,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, chip->locality,0 );return rc; }@@ -586,10 +586,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" );@@ -623,7 +623,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, chip->locality,1 ); tpm_dev.client =NULL ; out_err:return rc;@@ -695,7 +695,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, chip->locality,1 ); tpm_dev.client =NULL ;return 0 ;drivers/char/tpm/tpm_i2c_nuvoton.c +12
-12@@ -143,7 +143,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;@@ -237,7 +237,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, &chip->vendor.read_queue) ==0 ) { burst_count =i2c_nuvoton_get_burstcount (client, chip);if (burst_count <0 ) {@@ -286,7 +286,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->timeout_c, &chip->vendor.read_queue);if (status !=0 ) {dev_err (dev,"%s() timeout on dataAvail\n" , __func__); size = -ETIMEDOUT ;@@ -326,7 +326,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 ;@@ -358,7 +358,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 ;@@ -390,7 +390,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",@@ -415,7 +415,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__);@@ -543,10 +543,10 @@ static int i2c_nuvoton_probe(struct i2c_client *client,init_waitqueue_head (&chip->vendor.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 );dev_set_drvdata (&chip->dev, priv);@@ -577,7 +577,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 ) {/* drivers/char/tpm/tpm_tis.c +47
-48@@ -131,7 +131,7 @@ static inline int is_itpm(struct acpi_device *dev) static int wait_startup(struct tpm_chip *chip, int l) { struct priv_data *priv = dev_get_drvdata(&chip->dev); - unsigned long stop = jiffies + chip->vendor.timeout_a; + unsigned long stop = jiffies + chip->timeout_a; do { if (ioread8(priv->iobase + TPM_ACCESS(l)) &@@ -149,7 +149,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 chip->locality = l;return -1 ; }@@ -177,7 +177,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_USES_IRQ ) { again:@@ -211,7 +211,7 @@ static u8 tpm_tis_status(struct tpm_chip *chip)struct priv_data *priv =dev_get_drvdata (&chip->dev);return ioread8 (priv->iobase + -TPM_STS (chip->vendor.locality)); +TPM_STS (chip->locality)); }static void tpm_tis_ready (struct tpm_chip *chip)@@ -220,7 +220,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 (chip->locality)); }static int get_burstcount (struct tpm_chip *chip)@@ -231,12 +231,12 @@ 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(chip->vendor.locality) + 1); + TPM_STS(chip->locality) + 1); burstcnt += ioread8(priv->iobase + - TPM_STS(chip->vendor.locality) + + TPM_STS(chip->locality) + 2) << 8; if (burstcnt) return burstcnt;@@ -252,14 +252,13 @@ 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, &chip->vendor.read_queue, true) ==0 ) { burstcnt =get_burstcount (chip);for (; burstcnt >0 && size < count; burstcnt--) buf[size++] =ioread8 (priv->iobase + -TPM_DATA_FIFO (chip->vendor. - locality)); +TPM_DATA_FIFO (chip->locality)); }return size; }@@ -296,7 +295,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? */ @@ -307,7 +306,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, chip->locality,0 );return size; }@@ -333,7 +332,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;@@ -344,11 +343,11 @@ 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 (chip->locality)); 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 ) {@@ -359,8 +358,8 @@ 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)); -wait_for_tpm_stat (chip,TPM_STS_VALID , chip->vendor.timeout_c, + priv->iobase +TPM_DATA_FIFO (chip->locality)); +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 ) {@@ -372,7 +371,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, chip->locality,0 );return rc; }@@ -383,10 +382,10 @@ static void disable_interrupts(struct tpm_chip *chip) intmask =ioread32 (priv->iobase + -TPM_INT_ENABLE (chip->vendor.locality)); +TPM_INT_ENABLE (chip->locality)); intmask &= ~TPM_GLOBAL_INT_ENABLE ;iowrite32 (intmask, - priv->iobase +TPM_INT_ENABLE (chip->vendor.locality)); + priv->iobase +TPM_INT_ENABLE (chip->locality));devm_free_irq (&chip->dev, priv->irq, chip); priv->irq =0 ; chip->flags &= ~TPM_CHIP_FLAG_USES_IRQ ;@@ -410,7 +409,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 (chip->locality));if (chip->flags &TPM_CHIP_FLAG_USES_IRQ ) { ordinal =be32_to_cpu (*((__be32 *) (buf +6 )));@@ -430,7 +429,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, chip->locality,0 );return rc; }@@ -516,7 +515,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, chip->locality,0 ); itpm = true;@@ -530,7 +529,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, chip->locality,0 );return rc; }@@ -569,7 +568,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 (chip->locality));if (interrupt ==0 )return IRQ_NONE ;@@ -589,8 +588,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 (chip->locality)); +ioread32 (priv->iobase +TPM_INT_STATUS (chip->locality));return IRQ_HANDLED ; }@@ -613,18 +612,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 (chip->locality));iowrite8 (irq, - priv->iobase +TPM_INT_VECTOR (chip->vendor.locality)); + priv->iobase +TPM_INT_VECTOR (chip->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 (chip->locality)), + priv->iobase +TPM_INT_STATUS (chip->locality));/* Turn on */ iowrite32 (intmask |TPM_GLOBAL_INT_ENABLE , - priv->iobase +TPM_INT_ENABLE (chip->vendor.locality)); + priv->iobase +TPM_INT_ENABLE (chip->locality)); priv->irq_tested = false;@@ -641,7 +640,7 @@ static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask,*/ if (!(chip->flags &TPM_CHIP_FLAG_USES_IRQ )) {iowrite8 (original_int_vec, - priv->iobase +TPM_INT_VECTOR (chip->vendor.locality)); + priv->iobase +TPM_INT_VECTOR (chip->locality));return 1 ; }@@ -659,7 +658,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 (chip->locality));if (!original_int_vec) {if (IS_ENABLED (CONFIG_X86 ))@@ -685,10 +684,10 @@ static void tpm_tis_remove(struct tpm_chip *chip)iowrite32 (~TPM_GLOBAL_INT_ENABLE &ioread32 (priv->iobase + -TPM_INT_ENABLE (chip->vendor. +TPM_INT_ENABLE (chip-> locality)), - priv->iobase +TPM_INT_ENABLE (chip->vendor.locality)); -release_locality (chip, chip->vendor.locality,1 ); + priv->iobase +TPM_INT_ENABLE (chip->locality)); +release_locality (chip, chip->locality,1 ); } static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info,@@ -716,10 +715,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 ;dev_set_drvdata (&chip->dev, priv);@@ -730,12 +729,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 (chip->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 (chip->locality));if (request_locality (chip,0 ) !=0 ) { rc = -ENODEV ;@@ -769,7 +768,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 (chip->locality));dev_dbg (dev,"TPM interface capabilities (0x%x):\n" , intfcaps);if (intfcaps &TPM_INTF_BURST_COUNT_STATIC )@@ -853,17 +852,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 (chip->locality)); intmask = -ioread32 (priv->iobase +TPM_INT_ENABLE (chip->vendor.locality)); +ioread32 (priv->iobase +TPM_INT_ENABLE (chip->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 (chip->locality)); }static int tpm_tis_resume (struct device *dev)drivers/char/tpm/xen-tpmfront.c +2
-2@@ -88,7 +88,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, &chip->vendor.read_queue, true) <0 ) {vtpm_cancel (chip);return -ETIME ;@@ -125,7 +125,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, &chip->vendor.read_queue, true) <0 ) {vtpm_cancel (chip);return -ETIME ;Signature · 1 line
2.5.0
/Jarkko
------------------------------------------------------------------------------
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
PATCH v2 7/7 tpm: drop 'read_queue' from struct tpm_vendor_specific
In reply to a message not in the archiveDropped the field 'read_queue' from struct tpm_vendor_specific and make it available to the various private structures in the drivers.
--- drivers/char/tpm/st33zp24/st33zp24.c | 12 ++++++------ drivers/char/tpm/st33zp24/st33zp24.h | 1 + drivers/char/tpm/tpm.h | 6 ------ 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(+), 26 deletions(-)
drivers/char/tpm/st33zp24/st33zp24.c +6 -6
@@ -324,7 +324,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->timeout_c, - &chip->vendor.read_queue, true) == 0) { + &tpm_dev->read_queue, true) == 0) { burstcnt =get_burstcount (chip);if (burstcnt <0 )return burstcnt;
@@ -351,7 +351,7 @@ static irqreturn_t tpm_ioserirq_handler(int irq, void *dev_id)struct st33zp24_dev *tpm_dev =dev_get_drvdata (&chip->dev); 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 ;
@@ -389,7 +389,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->timeout_b, - &chip->vendor.read_queue, false) <0 ) { + &tpm_dev->read_queue, false) <0 ) { ret = -ETIME ; goto out_err; }
@@ -435,7 +435,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; }
@@ -552,7 +552,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 ) {
@@ -652,7 +652,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->timeout_b, - &chip->vendor.read_queue, false); + &tpm_dev->read_queue, false); }else { ret =tpm_pm_resume (dev);if (!ret)
drivers/char/tpm/st33zp24/st33zp24.h +1 -0
@@ -27,6 +27,7 @@ struct st33zp24_dev {int irq;u32 intrs;int io_lpcpd; +wait_queue_head_t read_queue; };struct st33zp24_phy_ops {
drivers/char/tpm/tpm.h +0 -6
@@ -128,12 +128,6 @@ enum tpm2_startup_types { TPM2_SU_STATE = 0x0001, }; -struct tpm_chip ; - -struct tpm_vendor_specific { -wait_queue_head_t read_queue; -}; -#define TPM_VID_INTEL 0x8086#define TPM_VID_WINBOND 0x1050#define TPM_VID_STM 0x104A
drivers/char/tpm/tpm_i2c_nuvoton.c +9 -5
@@ -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 =dev_get_drvdata (&chip->dev);s32 rc;int burst_count, bytes2read, size =0 ;while (size < count &&i2c_nuvoton_wait_for_data_avail (chip, chip->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 =dev_get_drvdata (&chip->dev);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->timeout_c, &chip->vendor.read_queue); + chip, chip->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 =dev_get_drvdata (&chip->dev);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 =dev_get_drvdata (&chip->dev); priv->intrs++; -wake_up (&chip->vendor.read_queue); +wake_up (&priv->read_queue);disable_irq_nosync (priv->irq);return IRQ_HANDLED ; }
@@ -540,7 +544,7 @@ static int i2c_nuvoton_probe(struct i2c_client *client,if (!priv)return -ENOMEM ; -init_waitqueue_head (&chip->vendor.read_queue); +init_waitqueue_head (&priv->read_queue);/* Default timeouts */ chip->timeout_a =msecs_to_jiffies (TPM_I2C_SHORT_TIMEOUT );
drivers/char/tpm/tpm_tis.c +5 -4
@@ -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 )
@@ -253,7 +254,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->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) 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 )
@@ -801,7 +802,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) {
drivers/char/tpm/xen-tpmfront.c +6 -5
@@ -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->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->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->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;dev_set_drvdata (&chip->dev, priv);
Signature · 9 lines
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=278785351&iu=/4140
Quoted 9 lines · Christophe Ricard
Hi Jarkko,
This is the latest steps to cleanup
tpm_vendor_specificstructure.I have also included some few obvious cleanup inside the drivers. I have been able to test
tpm_tison a HP Desktop machine.In v2 i have added a patch fixing:
'tpm: drop 'iobase' from structtpm_vendor_specific'691f211398bb93878b727be0c5c523e2371074f5
You give zero information here what you are fixing and why. For the next version of the patch set just put a remark about fixing PPC64 builds and include the full patch. I'll drop the current iobase patch from my master branch.
/Jarkko
Quoted 26 lines
It may be merged with the mention commit.
Best Regards
ChristopheChristophe Ricard (7):
tpm/tpm_atmel: drop remaining 'iobase' usage
tpm: Remove useless priv field in structtpm_vendor_specifictpm/tpm_i2c_atmel: simplify patch to gettpm_chipfrom ani2c_clienttpm/tpm_i2c_atmel: Few code style fixes
tpm: drop 'irq' from structtpm_vendor_specific
tpm: Move remainingtpm_vendor_specificstructure data totpm_chip
tpm: drop 'read_queue' from structtpm_vendor_specificdrivers/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 | 9 ++ drivers/char/tpm/tpm-interface.c | 52 +++++----- drivers/char/tpm/tpm-sysfs.c | 20 ++-- drivers/char/tpm/tpm.h | 24 ++--- drivers/char/tpm/tpm2-cmd.c | 2 +- drivers/char/tpm/tpm_atmel.c | 12 +-- drivers/char/tpm/tpm_atmel.h | 9 +- drivers/char/tpm/tpm_crb.c | 12 +--
Quoted 12 lines
drivers/char/tpm/tpm_i2c_atmel.c | 30 +++--- drivers/char/tpm/tpm_i2c_infineon.c | 47 +++++---- 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 | 182 ++++++++++++++++++----------------- drivers/char/tpm/xen-tpmfront.c | 36 +++---- 18 files changed, 356 insertions(+), 381 deletions(-)Signature · 1 line
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
A message that is not in the archive (sent off-list or not yet received): [email protected]
ok clear.
Thanks
Christophe
Quoted 8 lines · Jarkko Sakkinen
Quoted 7 lines · Christophe Ricard
Hi Jarkko,
This is the latest steps to cleanup
tpm_vendor_specificstructure.I have also included some few obvious cleanup inside the drivers. I have been able to test
tpm_tison a HP Desktop machine.
Quoted 47 lines
Quoted 2 lines
In v2 i have added a patch fixing:
'tpm: drop 'iobase' from structtpm_vendor_specific'691f211398bb93878b727be0c5c523e2371074f5You give zero information here what you are fixing and why. For the next version of the patch set just put a remark about fixing PPC64 builds and include the full patch. I'll drop the current iobase patch from my master branch.
/Jarkko
Quoted 38 lines
It may be merged with the mention commit.
Best Regards
ChristopheChristophe Ricard (7):
tpm/tpm_atmel: drop remaining 'iobase' usage
tpm: Remove useless priv field in structtpm_vendor_specifictpm/tpm_i2c_atmel: simplify patch to gettpm_chipfrom ani2c_clienttpm/tpm_i2c_atmel: Few code style fixes
tpm: drop 'irq' from structtpm_vendor_specific
tpm: Move remainingtpm_vendor_specificstructure data totpm_chip
tpm: drop 'read_queue' from structtpm_vendor_specificdrivers/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 | 9 ++ drivers/char/tpm/tpm-interface.c | 52 +++++----- drivers/char/tpm/tpm-sysfs.c | 20 ++-- drivers/char/tpm/tpm.h | 24 ++--- drivers/char/tpm/tpm2-cmd.c | 2 +- drivers/char/tpm/tpm_atmel.c | 12 +-- drivers/char/tpm/tpm_atmel.h | 9 +- drivers/char/tpm/tpm_crb.c | 12 +-- drivers/char/tpm/tpm_i2c_atmel.c | 30 +++--- drivers/char/tpm/tpm_i2c_infineon.c | 47 +++++---- 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 | 182 ++++++++++++++++++----------------- drivers/char/tpm/xen-tpmfront.c | 36 +++---- 18 files changed, 356 insertions(+), 381 deletions(-)Signature · 1 line
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