From: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
To: Christophe Ricard
<christophe.ricard-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Jean-Luc BLANC <jean-luc.blanc-qxv4g6HH51o@public.gmane.org>,
"ashley-fm2HMyfA2y6tG0bUXCXiUA@public.gmane.org"
<ashley-fm2HMyfA2y6tG0bUXCXiUA@public.gmane.org>,
"tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org"
<tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>,
Christophe RICARD
<christophe-h.ricard-qxv4g6HH51o@public.gmane.org>,
Benoit HOUYERE <benoit.houyere-qxv4g6HH51o@public.gmane.org>
Subject: Re: [PATCH v3 1/6] tpm: drop 'iobase' from struct tpm_vendor_specific
Date: Thu, 31 Mar 2016 12:48:17 +0300 [thread overview]
Message-ID: <20160331094817.GA12189@intel.com> (raw)
In-Reply-To: <CALD+uuxRKmGHoNcyOv7kSTVccFpmi6AzKxecHWPFcER=VR1zhA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
This and 3/6 had minor style issues.
If there are nothing biggger in the patch I guess I adjust the patches
myself. I'll still hold for other comments (maybe from Jason) and test
the patches.
If there are bigger reasons to fix the series then you could fix also
style issues.
/Jarkko
On Thu, Mar 31, 2016 at 10:29:11AM +0200, Christophe Ricard wrote:
> [Resending to the mailing list]
> Hi Jarkko,
> I don't mind fixing:
> WARNING: line over 80 characters
> #465: FILE: drivers/char/tpm/tpm_tis.c:685:
> +Â Â Â Â Â Â Â Â Â Â Â Â Â priv->iobase +
> TPM_INT_ENABLE(chip->vendor.locality));
> However i wonder if:
> WARNING: macros should not use a trailing semicolon
> #175: FILE: drivers/char/tpm/tpm_atmel.h:41:
> +#define atmel_getb(priv, offset) readb(priv->iobase + offset);
> Shouldn't be fixed in a separated patch.
> What's your preferred option ? (e.g fix this warning directly in this
> patch or in a separate one).
> Best Regards
> 2016-03-31 8:45 GMT+02:00 Jarkko Sakkinen
> <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>:
>
> On Wed, Mar 30, 2016 at 11:38:10PM +0200, Christophe Ricard wrote:
> > Dropped the field 'iobase' from struct tpm_vendor_specific and
> migrated
> > it to the private structures of tpm_atmel and tpm_tis.
>
> Found couple of issues:
>
> $ scripts/checkpatch.pl
> ~/Downloads/v3-1-6-tpm-drop-iobase-from-struct-tpm_vendor_specific.patch
> WARNING: macros should not use a trailing semicolon
> #175: FILE: drivers/char/tpm/tpm_atmel.h:41:
> +#define atmel_getb(priv, offset) readb(priv->iobase + offset);
>
> WARNING: line over 80 characters
> #465: FILE: drivers/char/tpm/tpm_tis.c:685:
> +Â Â Â Â Â Â Â Â Â Â Â Â Â priv->iobase +
> TPM_INT_ENABLE(chip->vendor.locality));
>
> total: 0 errors, 2 warnings, 465 lines checked
> /Jarkko
> > Signed-off-by: Christophe Ricard <christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
> > Reviewed-by: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
> > Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
> > ---
> > drivers/char/tpm/tpm.h    |  2 -
> >Â drivers/char/tpm/tpm_atmel.c |Â 28 +++++++-----
> >Â drivers/char/tpm/tpm_atmel.h |Â Â 5 ++-
> > drivers/char/tpm/tpm_tis.c  | 104
> +++++++++++++++++++++++++------------------
> >Â 4 files changed, 80 insertions(+), 59 deletions(-)
> >
> > diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
> > index cd780c7..357ac14 100644
> > --- a/drivers/char/tpm/tpm.h
> > +++ b/drivers/char/tpm/tpm.h
> > @@ -131,8 +131,6 @@ enum tpm2_startup_types {
> >Â struct tpm_chip;
> >
> >Â struct tpm_vendor_specific {
> > -Â Â Â void __iomem *iobase;Â Â Â Â Â Â /* ioremapped address
> */
> > -
> >Â Â Â Â int irq;
> >
> >Â Â Â Â int locality;
> > diff --git a/drivers/char/tpm/tpm_atmel.c
> b/drivers/char/tpm/tpm_atmel.c
> > index 68d5c09..b769299 100644
> > --- a/drivers/char/tpm/tpm_atmel.c
> > +++ b/drivers/char/tpm/tpm_atmel.c
> > @@ -37,6 +37,7 @@ enum tpm_atmel_read_status {
> >
> >Â static int tpm_atml_recv(struct tpm_chip *chip, u8 *buf, size_t
> count)
> >Â {
> > +Â Â Â struct tpm_atmel_priv *priv = chip->vendor.priv;
> >Â Â Â Â u8 status, *hdr = buf;
> >Â Â Â Â u32 size;
> >Â Â Â Â int i;
> > @@ -47,12 +48,12 @@ static int tpm_atml_recv(struct tpm_chip *chip, u8
> *buf, size_t count)
> >Â Â Â Â Â Â Â Â return -EIO;
> >
> >Â Â Â Â for (i = 0; i < 6; i++) {
> > -Â Â Â Â Â Â Â status = ioread8(chip->vendor.iobase + 1);
> > +Â Â Â Â Â Â Â status = ioread8(priv->iobase + 1);
> >Â Â Â Â Â Â Â Â if ((status & ATML_STATUS_DATA_AVAIL) == 0) {
> >Â Â Â Â Â Â Â Â Â Â Â Â dev_err(&chip->dev, "error reading
> header\n");
> >Â Â Â Â Â Â Â Â Â Â Â Â return -EIO;
> >Â Â Â Â Â Â Â Â }
> > -Â Â Â Â Â Â Â *buf++ = ioread8(chip->vendor.iobase);
> > +Â Â Â Â Â Â Â *buf++ = ioread8(priv->iobase);
> >Â Â Â Â }
> >
> >Â Â Â Â /* size of the data received */
> > @@ -63,7 +64,7 @@ static int tpm_atml_recv(struct tpm_chip *chip, u8
> *buf, size_t count)
> >Â Â Â Â Â Â Â Â dev_err(&chip->dev,
> >Â Â Â Â Â Â Â Â Â Â Â Â "Recv size(%d) less than available
> space\n", size);
> >Â Â Â Â Â Â Â Â for (; i < size; i++) { /* clear the waiting
> data anyway */
> > -Â Â Â Â Â Â Â Â Â Â Â status = ioread8(chip->vendor.iobase
> + 1);
> > +Â Â Â Â Â Â Â Â Â Â Â status = ioread8(priv->iobase + 1);
> >Â Â Â Â Â Â Â Â Â Â Â Â if ((status &
> ATML_STATUS_DATA_AVAIL) == 0) {
> >Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dev_err(&chip->dev,
> "error reading data\n");
> >Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â return -EIO;
> > @@ -74,16 +75,16 @@ static int tpm_atml_recv(struct tpm_chip *chip, u8
> *buf, size_t count)
> >
> >Â Â Â Â /* read all the data available */
> >Â Â Â Â for (; i < size; i++) {
> > -Â Â Â Â Â Â Â status = ioread8(chip->vendor.iobase + 1);
> > +Â Â Â Â Â Â Â status = ioread8(priv->iobase + 1);
> >Â Â Â Â Â Â Â Â if ((status & ATML_STATUS_DATA_AVAIL) == 0) {
> >Â Â Â Â Â Â Â Â Â Â Â Â dev_err(&chip->dev, "error reading
> data\n");
> >Â Â Â Â Â Â Â Â Â Â Â Â return -EIO;
> >Â Â Â Â Â Â Â Â }
> > -Â Â Â Â Â Â Â *buf++ = ioread8(chip->vendor.iobase);
> > +Â Â Â Â Â Â Â *buf++ = ioread8(priv->iobase);
> >Â Â Â Â }
> >
> >Â Â Â Â /* make sure data available is gone */
> > -Â Â Â status = ioread8(chip->vendor.iobase + 1);
> > +Â Â Â status = ioread8(priv->iobase + 1);
> >
> >Â Â Â Â if (status & ATML_STATUS_DATA_AVAIL) {
> >Â Â Â Â Â Â Â Â dev_err(&chip->dev, "data available is
> stuck\n");
> > @@ -95,12 +96,13 @@ static int tpm_atml_recv(struct tpm_chip *chip, u8
> *buf, size_t count)
> >
> >Â static int tpm_atml_send(struct tpm_chip *chip, u8 *buf, size_t
> count)
> >Â {
> > +Â Â Â struct tpm_atmel_priv *priv = chip->vendor.priv;
> >Â Â Â Â int i;
> >
> >Â Â Â Â dev_dbg(&chip->dev, "tpm_atml_send:\n");
> >Â Â Â Â for (i = 0; i < count; i++) {
> >        dev_dbg(&chip->dev, "%d 0x%x(%d)\n", i,
> buf[i], buf[i]);
> > -Â Â Â Â Â Â Â iowrite8(buf[i], chip->vendor.iobase);
> > +Â Â Â Â Â Â Â iowrite8(buf[i], priv->iobase);
> >Â Â Â Â }
> >
> >Â Â Â Â return count;
> > @@ -108,12 +110,16 @@ static int tpm_atml_send(struct tpm_chip *chip,
> u8 *buf, size_t count)
> >
> >Â static void tpm_atml_cancel(struct tpm_chip *chip)
> >Â {
> > -Â Â Â iowrite8(ATML_STATUS_ABORT, chip->vendor.iobase + 1);
> > +Â Â Â struct tpm_atmel_priv *priv = chip->vendor.priv;
> > +
> > +Â Â Â iowrite8(ATML_STATUS_ABORT, priv->iobase + 1);
> >Â }
> >
> >Â static u8 tpm_atml_status(struct tpm_chip *chip)
> >Â {
> > -Â Â Â return ioread8(chip->vendor.iobase + 1);
> > +Â Â Â struct tpm_atmel_priv *priv = chip->vendor.priv;
> > +
> > +Â Â Â return ioread8(priv->iobase + 1);
> >Â }
> >
> >Â static bool tpm_atml_req_canceled(struct tpm_chip *chip, u8 status)
> > @@ -142,7 +148,7 @@ static void atml_plat_remove(void)
> >Â Â Â Â Â Â Â Â tpm_chip_unregister(chip);
> >Â Â Â Â Â Â Â Â if (priv->have_region)
> >Â Â Â Â Â Â Â Â Â Â Â Â atmel_release_region(priv->base,
> priv->region_size);
> > -Â Â Â Â Â Â Â atmel_put_base_addr(chip->vendor.iobase);
> > +Â Â Â Â Â Â Â atmel_put_base_addr(priv->iobase);
> >Â Â Â Â Â Â Â Â platform_device_unregister(pdev);
> >Â Â Â Â }
> >Â }
> > @@ -190,6 +196,7 @@ static int __init init_atmel(void)
> >Â Â Â Â Â Â Â Â goto err_unreg_dev;
> >Â Â Â Â }
> >
> > +Â Â Â priv->iobase = iobase;
> >Â Â Â Â priv->base = base;
> >Â Â Â Â priv->have_region = have_region;
> >Â Â Â Â priv->region_size = region_size;
> > @@ -200,7 +207,6 @@ static int __init init_atmel(void)
> >Â Â Â Â Â Â Â Â goto err_unreg_dev;
> >Â Â Â Â }
> >
> > -Â Â Â chip->vendor.iobase = iobase;
> >Â Â Â Â chip->vendor.priv = priv;
> >
> >Â Â Â Â rc = tpm_chip_register(chip);
> > diff --git a/drivers/char/tpm/tpm_atmel.h
> b/drivers/char/tpm/tpm_atmel.h
> > index bced678..7e37c16 100644
> > --- a/drivers/char/tpm/tpm_atmel.h
> > +++ b/drivers/char/tpm/tpm_atmel.h
> > @@ -26,6 +26,7 @@ struct tpm_atmel_priv {
> >Â Â Â Â int region_size;
> >Â Â Â Â int have_region;
> >Â Â Â Â unsigned long base;
> > +Â Â Â void __iomem *iobase;
> >Â };
> >
> >Â static inline struct tpm_atmel_priv *atmel_get_priv(struct tpm_chip
> *chip)
> > @@ -37,8 +38,8 @@ static inline struct tpm_atmel_priv
> *atmel_get_priv(struct tpm_chip *chip)
> >
> >Â #include <asm/prom.h>
> >
> > -#define atmel_getb(chip, offset) readb(chip->vendor->iobase +
> offset);
> > -#define atmel_putb(val, chip, offset) writeb(val,
> chip->vendor->iobase + offset)
> > +#define atmel_getb(priv, offset) readb(priv->iobase + offset);
> > +#define atmel_putb(val, priv, offset) writeb(val, priv->iobase +
> offset)
> >Â #define atmel_request_region request_mem_region
> >Â #define atmel_release_region release_mem_region
> >
> > diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
> > index 068f021..19dac62 100644
> > --- a/drivers/char/tpm/tpm_tis.c
> > +++ b/drivers/char/tpm/tpm_tis.c
> > @@ -94,6 +94,7 @@ struct tpm_info {
> > #define   TPM_RID(l)           (0x0F04 |
> ((l) << 12))
> >
> >Â struct priv_data {
> > +Â Â Â void __iomem *iobase;
> >Â Â Â Â u16 manufacturer_id;
> >Â Â Â Â bool irq_tested;
> >Â Â Â Â wait_queue_head_t int_queue;
> > @@ -128,9 +129,10 @@ static inline int is_itpm(struct acpi_device
> *dev)
> >Â Â * correct values in the other bits.' */
> >Â static int wait_startup(struct tpm_chip *chip, int l)
> >Â {
> > +Â Â Â struct priv_data *priv = chip->vendor.priv;
> >Â Â Â Â unsigned long stop = jiffies + chip->vendor.timeout_a;
> >Â Â Â Â do {
> > -Â Â Â Â Â Â Â if (ioread8(chip->vendor.iobase + TPM_ACCESS(l))
> &
> > +Â Â Â Â Â Â Â if (ioread8(priv->iobase + TPM_ACCESS(l)) &
> >Â Â Â Â Â Â Â Â Â Â TPM_ACCESS_VALID)
> >Â Â Â Â Â Â Â Â Â Â Â Â return 0;
> >Â Â Â Â Â Â Â Â msleep(TPM_TIMEOUT);
> > @@ -140,7 +142,9 @@ static int wait_startup(struct tpm_chip *chip, int
> l)
> >
> >Â static int check_locality(struct tpm_chip *chip, int l)
> >Â {
> > -Â Â Â if ((ioread8(chip->vendor.iobase + TPM_ACCESS(l)) &
> > +Â Â Â struct priv_data *priv = chip->vendor.priv;
> > +
> > +Â Â Â if ((ioread8(priv->iobase + TPM_ACCESS(l)) &
> >Â Â Â Â Â Â (TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID)) ==
> >Â Â Â Â Â Â (TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID))
> >Â Â Â Â Â Â Â Â return chip->vendor.locality = l;
> > @@ -150,11 +154,13 @@ static int check_locality(struct tpm_chip *chip,
> int l)
> >
> >Â static void release_locality(struct tpm_chip *chip, int l, int
> force)
> >Â {
> > -Â Â Â if (force || (ioread8(chip->vendor.iobase + TPM_ACCESS(l)) &
> > +Â Â Â struct priv_data *priv = chip->vendor.priv;
> > +
> > +Â Â Â if (force || (ioread8(priv->iobase + TPM_ACCESS(l)) &
> >Â Â Â Â Â Â Â Â Â Â Â (TPM_ACCESS_REQUEST_PENDING |
> TPM_ACCESS_VALID)) ==
> >Â Â Â Â Â Â (TPM_ACCESS_REQUEST_PENDING | TPM_ACCESS_VALID))
> >Â Â Â Â Â Â Â Â iowrite8(TPM_ACCESS_ACTIVE_LOCALITY,
> > -Â Â Â Â Â Â Â Â Â Â Â chip->vendor.iobase +
> TPM_ACCESS(l));
> > +Â Â Â Â Â Â Â Â Â Â Â priv->iobase + TPM_ACCESS(l));
> >Â }
> >
> >Â static int request_locality(struct tpm_chip *chip, int l)
> > @@ -167,7 +173,7 @@ static int request_locality(struct tpm_chip *chip,
> int l)
> >Â Â Â Â Â Â Â Â return l;
> >
> >Â Â Â Â iowrite8(TPM_ACCESS_REQUEST_USE,
> > -Â Â Â Â Â Â Â chip->vendor.iobase + TPM_ACCESS(l));
> > +Â Â Â Â Â Â Â priv->iobase + TPM_ACCESS(l));
> >
> >Â Â Â Â stop = jiffies + chip->vendor.timeout_a;
> >
> > @@ -200,19 +206,24 @@ again:
> >
> >Â static u8 tpm_tis_status(struct tpm_chip *chip)
> >Â {
> > -Â Â Â return ioread8(chip->vendor.iobase +
> > +Â Â Â struct priv_data *priv = chip->vendor.priv;
> > +
> > +Â Â Â return ioread8(priv->iobase +
> >Â Â Â Â Â Â Â Â Â Â Â TPM_STS(chip->vendor.locality));
> >Â }
> >
> >Â static void tpm_tis_ready(struct tpm_chip *chip)
> >Â {
> > +Â Â Â struct priv_data *priv = chip->vendor.priv;
> > +
> >Â Â Â Â /* this causes the current command to be aborted */
> >Â Â Â Â iowrite8(TPM_STS_COMMAND_READY,
> > -Â Â Â Â Â Â Â chip->vendor.iobase +
> TPM_STS(chip->vendor.locality));
> > +Â Â Â Â Â Â Â priv->iobase + TPM_STS(chip->vendor.locality));
> >Â }
> >
> >Â static int get_burstcount(struct tpm_chip *chip)
> >Â {
> > +Â Â Â struct priv_data *priv = chip->vendor.priv;
> >Â Â Â Â unsigned long stop;
> >Â Â Â Â int burstcnt;
> >
> > @@ -220,9 +231,9 @@ static int get_burstcount(struct tpm_chip *chip)
> >Â Â Â Â /* which timeout value, spec has 2 answers (c & d) */
> >Â Â Â Â stop = jiffies + chip->vendor.timeout_d;
> >Â Â Â Â do {
> > -Â Â Â Â Â Â Â burstcnt = ioread8(chip->vendor.iobase +
> > +Â Â Â Â Â Â Â burstcnt = ioread8(priv->iobase +
> >Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
> TPM_STS(chip->vendor.locality) + 1);
> > -Â Â Â Â Â Â Â burstcnt += ioread8(chip->vendor.iobase +
> > +Â Â Â Â Â Â Â burstcnt += ioread8(priv->iobase +
> >Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
> Â TPM_STS(chip->vendor.locality) +
> >Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 2) << 8;
> >Â Â Â Â Â Â Â Â if (burstcnt)
> > @@ -234,6 +245,7 @@ static int get_burstcount(struct tpm_chip *chip)
> >
> >Â static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count)
> >Â {
> > +Â Â Â struct priv_data *priv = chip->vendor.priv;
> >Â Â Â Â int size = 0, burstcnt;
> >Â Â Â Â while (size < count &&
> >Â Â Â Â Â Â Â wait_for_tpm_stat(chip,
> > @@ -243,7 +255,7 @@ static int recv_data(struct tpm_chip *chip, u8
> *buf, size_t count)
> >Â Â Â Â Â Â Â == 0) {
> >Â Â Â Â Â Â Â Â burstcnt = get_burstcount(chip);
> >Â Â Â Â Â Â Â Â for (; burstcnt > 0 && size < count; burstcnt--)
> > -Â Â Â Â Â Â Â Â Â Â Â buf[size++] =
> ioread8(chip->vendor.iobase +
> > +Â Â Â Â Â Â Â Â Â Â Â buf[size++] = ioread8(priv->iobase +
> >Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
> Â TPM_DATA_FIFO(chip->vendor.
> >Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
> Â Â Â Â Â Â locality));
> >Â Â Â Â }
> > @@ -329,7 +341,7 @@ static int tpm_tis_send_data(struct tpm_chip
> *chip, u8 *buf, size_t len)
> >Â Â Â Â while (count < len - 1) {
> >Â Â Â Â Â Â Â Â burstcnt = get_burstcount(chip);
> >Â Â Â Â Â Â Â Â for (; burstcnt > 0 && count < len - 1;
> burstcnt--) {
> > -Â Â Â Â Â Â Â Â Â Â Â iowrite8(buf[count],
> chip->vendor.iobase +
> > +Â Â Â Â Â Â Â Â Â Â Â iowrite8(buf[count], priv->iobase +
> >Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
> TPM_DATA_FIFO(chip->vendor.locality));
> >Â Â Â Â Â Â Â Â Â Â Â Â count++;
> >Â Â Â Â Â Â Â Â }
> > @@ -345,7 +357,7 @@ static int tpm_tis_send_data(struct tpm_chip
> *chip, u8 *buf, size_t len)
> >
> >Â Â Â Â /* write last byte */
> >Â Â Â Â iowrite8(buf[count],
> > -Â Â Â Â Â Â Â chip->vendor.iobase +
> TPM_DATA_FIFO(chip->vendor.locality));
> > +Â Â Â Â Â Â Â priv->iobase +
> TPM_DATA_FIFO(chip->vendor.locality));
> >Â Â Â Â wait_for_tpm_stat(chip, TPM_STS_VALID,
> chip->vendor.timeout_c,
> >Â Â Â Â Â Â Â Â Â Â Â Â Â &priv->int_queue, false);
> >Â Â Â Â status = tpm_tis_status(chip);
> > @@ -364,15 +376,15 @@ out_err:
> >
> >Â static void disable_interrupts(struct tpm_chip *chip)
> >Â {
> > +Â Â Â struct priv_data *priv = chip->vendor.priv;
> >Â Â Â Â u32 intmask;
> >
> >Â Â Â Â intmask =
> > -Â Â Â Â Â ioread32(chip->vendor.iobase +
> > +Â Â Â Â Â ioread32(priv->iobase +
> >Â Â Â Â Â Â Â Â Â Â TPM_INT_ENABLE(chip->vendor.locality));
> >Â Â Â Â intmask &= ~TPM_GLOBAL_INT_ENABLE;
> >Â Â Â Â iowrite32(intmask,
> > -Â Â Â Â Â Â Â Â chip->vendor.iobase +
> > -Â Â Â Â Â Â Â Â TPM_INT_ENABLE(chip->vendor.locality));
> > +Â Â Â Â Â Â Â Â priv->iobase +
> TPM_INT_ENABLE(chip->vendor.locality));
> >Â Â Â Â devm_free_irq(&chip->dev, chip->vendor.irq, chip);
> >Â Â Â Â chip->vendor.irq = 0;
> >Â }
> > @@ -384,6 +396,7 @@ static void disable_interrupts(struct tpm_chip
> *chip)
> >Â Â */
> >Â static int tpm_tis_send_main(struct tpm_chip *chip, u8 *buf, size_t
> len)
> >Â {
> > +Â Â Â struct priv_data *priv = chip->vendor.priv;
> >Â Â Â Â int rc;
> >Â Â Â Â u32 ordinal;
> >Â Â Â Â unsigned long dur;
> > @@ -394,7 +407,7 @@ static int tpm_tis_send_main(struct tpm_chip
> *chip, u8 *buf, size_t len)
> >
> >Â Â Â Â /* go and do it */
> >Â Â Â Â iowrite8(TPM_STS_GO,
> > -Â Â Â Â Â Â Â chip->vendor.iobase +
> TPM_STS(chip->vendor.locality));
> > +Â Â Â Â Â Â Â priv->iobase + TPM_STS(chip->vendor.locality));
> >
> >Â Â Â Â if (chip->vendor.irq) {
> >Â Â Â Â Â Â Â Â ordinal = be32_to_cpu(*((__be32 *) (buf + 6)));
> > @@ -453,10 +466,11 @@ static const struct tis_vendor_timeout_override
> vendor_timeout_overrides[] = {
> >Â static bool tpm_tis_update_timeouts(struct tpm_chip *chip,
> >Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â unsigned long
> *timeout_cap)
> >Â {
> > +Â Â Â struct priv_data *priv = chip->vendor.priv;
> >Â Â Â Â int i;
> >Â Â Â Â u32 did_vid;
> >
> > -Â Â Â did_vid = ioread32(chip->vendor.iobase + TPM_DID_VID(0));
> > +Â Â Â did_vid = ioread32(priv->iobase + TPM_DID_VID(0));
> >
> >Â Â Â Â for (i = 0; i != ARRAY_SIZE(vendor_timeout_overrides); i++)
> {
> >Â Â Â Â Â Â Â Â if (vendor_timeout_overrides[i].did_vid !=
> did_vid)
> > @@ -476,6 +490,7 @@ static bool tpm_tis_update_timeouts(struct
> tpm_chip *chip,
> >Â Â */
> >Â static int probe_itpm(struct tpm_chip *chip)
> >Â {
> > +Â Â Â struct priv_data *priv = chip->vendor.priv;
> >Â Â Â Â int rc = 0;
> >Â Â Â Â u8 cmd_getticks[] = {
> >Â Â Â Â Â Â Â Â 0x00, 0xc1, 0x00, 0x00, 0x00, 0x0a,
> > @@ -483,7 +498,7 @@ static int probe_itpm(struct tpm_chip *chip)
> >Â Â Â Â };
> >Â Â Â Â size_t len = sizeof(cmd_getticks);
> >Â Â Â Â bool rem_itpm = itpm;
> > -Â Â Â u16 vendor = ioread16(chip->vendor.iobase + TPM_DID_VID(0));
> > +Â Â Â u16 vendor = ioread16(priv->iobase + TPM_DID_VID(0));
> >
> >Â Â Â Â /* probe only iTPMS */
> >Â Â Â Â if (vendor != TPM_VID_INTEL)
> > @@ -548,7 +563,7 @@ static irqreturn_t tis_int_handler(int dummy, void
> *dev_id)
> >Â Â Â Â u32 interrupt;
> >Â Â Â Â int i;
> >
> > -Â Â Â interrupt = ioread32(chip->vendor.iobase +
> > +Â Â Â interrupt = ioread32(priv->iobase +
> >Â Â Â Â Â Â Â Â Â Â Â Â Â Â
> TPM_INT_STATUS(chip->vendor.locality));
> >
> >Â Â Â Â if (interrupt == 0)
> > @@ -568,9 +583,9 @@ static irqreturn_t tis_int_handler(int dummy, void
> *dev_id)
> >
> >Â Â Â Â /* Clear interrupts handled with TPM_EOI */
> >Â Â Â Â iowrite32(interrupt,
> > -Â Â Â Â Â Â Â Â chip->vendor.iobase +
> > +Â Â Â Â Â Â Â Â priv->iobase +
> >Â Â Â Â Â Â Â Â Â TPM_INT_STATUS(chip->vendor.locality));
> > -Â Â Â ioread32(chip->vendor.iobase +
> TPM_INT_STATUS(chip->vendor.locality));
> > +Â Â Â ioread32(priv->iobase +
> TPM_INT_STATUS(chip->vendor.locality));
> >Â Â Â Â return IRQ_HANDLED;
> >Â }
> >
> > @@ -592,19 +607,19 @@ static int tpm_tis_probe_irq_single(struct
> tpm_chip *chip, u32 intmask,
> >Â Â Â Â }
> >Â Â Â Â chip->vendor.irq = irq;
> >
> > -Â Â Â original_int_vec = ioread8(chip->vendor.iobase +
> > +Â Â Â original_int_vec = ioread8(priv->iobase +
> >Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
> TPM_INT_VECTOR(chip->vendor.locality));
> >Â Â Â Â iowrite8(irq,
> > -Â Â Â Â Â Â Â chip->vendor.iobase +
> TPM_INT_VECTOR(chip->vendor.locality));
> > +Â Â Â Â Â Â Â priv->iobase +
> TPM_INT_VECTOR(chip->vendor.locality));
> >
> >Â Â Â Â /* Clear all existing */
> > -Â Â Â iowrite32(ioread32(chip->vendor.iobase +
> > +Â Â Â iowrite32(ioread32(priv->iobase +
> >Â Â Â Â Â Â Â Â Â Â Â Â Â
> TPM_INT_STATUS(chip->vendor.locality)),
> > -Â Â Â Â Â Â Â Â chip->vendor.iobase +
> TPM_INT_STATUS(chip->vendor.locality));
> > +Â Â Â Â Â Â Â Â priv->iobase +
> TPM_INT_STATUS(chip->vendor.locality));
> >
> >Â Â Â Â /* Turn on */
> >Â Â Â Â iowrite32(intmask | TPM_GLOBAL_INT_ENABLE,
> > -Â Â Â Â Â Â Â Â chip->vendor.iobase +
> TPM_INT_ENABLE(chip->vendor.locality));
> > +Â Â Â Â Â Â Â Â priv->iobase +
> TPM_INT_ENABLE(chip->vendor.locality));
> >
> >Â Â Â Â priv->irq_tested = false;
> >
> > @@ -621,8 +636,7 @@ static int tpm_tis_probe_irq_single(struct
> tpm_chip *chip, u32 intmask,
> >Â Â Â Â */
> >Â Â Â Â if (!chip->vendor.irq) {
> >Â Â Â Â Â Â Â Â iowrite8(original_int_vec,
> > -Â Â Â Â Â Â Â Â Â Â Â chip->vendor.iobase +
> > -Â Â Â Â Â Â Â Â Â Â Â Â Â
> TPM_INT_VECTOR(chip->vendor.locality));
> > +Â Â Â Â Â Â Â Â Â Â Â priv->iobase +
> TPM_INT_VECTOR(chip->vendor.locality));
> >Â Â Â Â Â Â Â Â return 1;
> >Â Â Â Â }
> >
> > @@ -635,10 +649,11 @@ static int tpm_tis_probe_irq_single(struct
> tpm_chip *chip, u32 intmask,
> >Â Â */
> >Â static void tpm_tis_probe_irq(struct tpm_chip *chip, u32 intmask)
> >Â {
> > +Â Â Â struct priv_data *priv = chip->vendor.priv;
> >Â Â Â Â u8 original_int_vec;
> >Â Â Â Â int i;
> >
> > -Â Â Â original_int_vec = ioread8(chip->vendor.iobase +
> > +Â Â Â original_int_vec = ioread8(priv->iobase +
> >Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
> TPM_INT_VECTOR(chip->vendor.locality));
> >
> >Â Â Â Â if (!original_int_vec) {
> > @@ -658,15 +673,16 @@ MODULE_PARM_DESC(interrupts, "Enable
> interrupts");
> >
> >Â static void tpm_tis_remove(struct tpm_chip *chip)
> >Â {
> > +Â Â Â struct priv_data *priv = chip->vendor.priv;
> > +
> >Â Â Â Â if (chip->flags & TPM_CHIP_FLAG_TPM2)
> >Â Â Â Â Â Â Â Â tpm2_shutdown(chip, TPM2_SU_CLEAR);
> >
> >Â Â Â Â iowrite32(~TPM_GLOBAL_INT_ENABLE &
> > -Â Â Â Â Â Â Â Â ioread32(chip->vendor.iobase +
> > +Â Â Â Â Â Â Â Â ioread32(priv->iobase +
> >Â Â Â Â Â Â Â Â Â Â Â Â Â TPM_INT_ENABLE(chip->vendor.
> >Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
> Â locality)),
> > -Â Â Â Â Â Â Â Â chip->vendor.iobase +
> > -Â Â Â Â Â Â Â Â TPM_INT_ENABLE(chip->vendor.locality));
> > +Â Â Â Â Â Â Â Â Â Â Â Â priv->iobase +
> TPM_INT_ENABLE(chip->vendor.locality));
> >Â Â Â Â release_locality(chip, chip->vendor.locality, 1);
> >Â }
> >
> > @@ -691,9 +707,9 @@ static int tpm_tis_init(struct device *dev, struct
> tpm_info *tpm_info,
> >Â Â Â Â chip->acpi_dev_handle = acpi_dev_handle;
> >Â #endif
> >
> > -Â Â Â chip->vendor.iobase = devm_ioremap_resource(dev,
> &tpm_info->res);
> > -Â Â Â if (IS_ERR(chip->vendor.iobase))
> > -Â Â Â Â Â Â Â return PTR_ERR(chip->vendor.iobase);
> > +Â Â Â priv->iobase = devm_ioremap_resource(dev, &tpm_info->res);
> > +Â Â Â if (IS_ERR(priv->iobase))
> > +Â Â Â Â Â Â Â return PTR_ERR(priv->iobase);
> >
> >Â Â Â Â /* Maximum timeouts */
> >Â Â Â Â chip->vendor.timeout_a = TIS_TIMEOUT_A_MAX;
> > @@ -707,13 +723,13 @@ static int tpm_tis_init(struct device *dev,
> struct tpm_info *tpm_info,
> >Â Â Â Â }
> >
> >Â Â Â Â /* Take control of the TPM's interrupt hardware and shut it
> off */
> > -Â Â Â intmask = ioread32(chip->vendor.iobase +
> > +Â Â Â intmask = ioread32(priv->iobase +
> >Â Â Â Â Â Â Â Â Â Â Â Â Â
> TPM_INT_ENABLE(chip->vendor.locality));
> >Â Â Â Â intmask |= TPM_INTF_CMD_READY_INT |
> TPM_INTF_LOCALITY_CHANGE_INT |
> >Â Â Â Â Â Â Â Â Â TPM_INTF_DATA_AVAIL_INT |
> TPM_INTF_STS_VALID_INT;
> >Â Â Â Â intmask &= ~TPM_GLOBAL_INT_ENABLE;
> >Â Â Â Â iowrite32(intmask,
> > -Â Â Â Â Â Â Â Â chip->vendor.iobase +
> TPM_INT_ENABLE(chip->vendor.locality));
> > +Â Â Â Â Â Â Â Â priv->iobase +
> TPM_INT_ENABLE(chip->vendor.locality));
> >
> >Â Â Â Â if (request_locality(chip, 0) != 0) {
> >Â Â Â Â Â Â Â Â rc = -ENODEV;
> > @@ -724,12 +740,12 @@ static int tpm_tis_init(struct device *dev,
> struct tpm_info *tpm_info,
> >Â Â Â Â if (rc)
> >Â Â Â Â Â Â Â Â goto out_err;
> >
> > -Â Â Â vendor = ioread32(chip->vendor.iobase + TPM_DID_VID(0));
> > +Â Â Â vendor = ioread32(priv->iobase + TPM_DID_VID(0));
> >Â Â Â Â priv->manufacturer_id = vendor;
> >
> >Â Â Â Â dev_info(dev, "%s TPM (device-id 0x%X, rev-id %d)\n",
> >Â Â Â Â Â Â Â Â (chip->flags & TPM_CHIP_FLAG_TPM2) ? "2.0" :
> "1.2",
> > -Â Â Â Â Â Â Â vendor >> 16, ioread8(chip->vendor.iobase +
> TPM_RID(0)));
> > +Â Â Â Â Â Â Â vendor >> 16, ioread8(priv->iobase +
> TPM_RID(0)));
> >
> >Â Â Â Â if (!itpm) {
> >Â Â Â Â Â Â Â Â probe = probe_itpm(chip);
> > @@ -746,7 +762,7 @@ static int tpm_tis_init(struct device *dev, struct
> tpm_info *tpm_info,
> >
> >Â Â Â Â /* Figure out the capabilities */
> >Â Â Â Â intfcaps =
> > -Â Â Â Â Â ioread32(chip->vendor.iobase +
> > +Â Â Â Â Â ioread32(priv->iobase +
> >Â Â Â Â Â Â Â Â Â Â TPM_INTF_CAPS(chip->vendor.locality));
> >Â Â Â Â dev_dbg(dev, "TPM interface capabilities (0x%x):\n",
> >Â Â Â Â Â Â Â Â intfcaps);
> > @@ -825,23 +841,23 @@ out_err:
> >Â #ifdef CONFIG_PM_SLEEP
> >Â static void tpm_tis_reenable_interrupts(struct tpm_chip *chip)
> >Â {
> > +Â Â Â struct priv_data *priv = chip->vendor.priv;
> >Â Â Â Â u32 intmask;
> >
> >Â Â Â Â /* reenable interrupts that device may have lost or
> >Â Â Â Â Â BIOS/firmware may have disabled */
> > -Â Â Â iowrite8(chip->vendor.irq, chip->vendor.iobase +
> > +Â Â Â iowrite8(chip->vendor.irq, priv->iobase +
> >Â Â Â Â Â Â Â Â TPM_INT_VECTOR(chip->vendor.locality));
> >
> >Â Â Â Â intmask =
> > -Â Â Â Â Â ioread32(chip->vendor.iobase +
> > -Â Â Â Â Â Â Â Â Â TPM_INT_ENABLE(chip->vendor.locality));
> > +Â Â Â Â Â ioread32(priv->iobase +
> TPM_INT_ENABLE(chip->vendor.locality));
> >
> >Â Â Â Â intmask |= TPM_INTF_CMD_READY_INT
> >Â Â Â Â Â Â | TPM_INTF_LOCALITY_CHANGE_INT |
> TPM_INTF_DATA_AVAIL_INT
> >Â Â Â Â Â Â | TPM_INTF_STS_VALID_INT | TPM_GLOBAL_INT_ENABLE;
> >
> >Â Â Â Â iowrite32(intmask,
> > -Â Â Â Â Â Â Â Â chip->vendor.iobase +
> TPM_INT_ENABLE(chip->vendor.locality));
> > +Â Â Â Â Â Â Â Â priv->iobase +
> TPM_INT_ENABLE(chip->vendor.locality));
> >Â }
> >
> >Â static int tpm_tis_resume(struct device *dev)
> > --
> > 2.5.0
> >
------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785471&iu=/4140
next prev parent reply other threads:[~2016-03-31 9:48 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-30 21:38 [PATCH v3 0/6] Remove the tpm_vendor_specific structure Christophe Ricard
[not found] ` <1459373895-17704-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
2016-03-30 21:38 ` [PATCH v3 1/6] tpm: drop 'iobase' from struct tpm_vendor_specific Christophe Ricard
[not found] ` <1459373895-17704-2-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
2016-03-31 6:45 ` Jarkko Sakkinen
[not found] ` <20160331064500.GB6393-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2016-03-31 8:29 ` Christophe Ricard
[not found] ` <CALD+uuxRKmGHoNcyOv7kSTVccFpmi6AzKxecHWPFcER=VR1zhA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-03-31 9:48 ` Jarkko Sakkinen [this message]
2016-03-30 21:38 ` [PATCH v3 2/6] tpm: drop 'irq' " Christophe Ricard
[not found] ` <1459373895-17704-3-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
2016-03-31 6:47 ` Jarkko Sakkinen
2016-03-30 21:38 ` [PATCH v3 3/6] tpm: drop 'read_queue' " Christophe Ricard
[not found] ` <1459373895-17704-4-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
2016-03-31 6:48 ` Jarkko Sakkinen
2016-03-30 21:38 ` [PATCH v3 4/6] tpm: drop 'locality' " Christophe Ricard
[not found] ` <1459373895-17704-5-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
2016-03-31 6:50 ` Jarkko Sakkinen
2016-03-30 21:38 ` [PATCH v3 5/6] tpm: Move tpm_vendor_specific data related with PTP specification to tpm_chip Christophe Ricard
[not found] ` <1459373895-17704-6-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
2016-03-31 6:55 ` Jarkko Sakkinen
2016-03-30 21:38 ` [PATCH v3 6/6] tpm: Remove useless priv field in struct tpm_vendor_specific Christophe Ricard
[not found] ` <1459373895-17704-7-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
2016-03-31 6:56 ` Jarkko Sakkinen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160331094817.GA12189@intel.com \
--to=jarkko.sakkinen-vuqaysv1563yd54fqh9/ca@public.gmane.org \
--cc=ashley-fm2HMyfA2y6tG0bUXCXiUA@public.gmane.org \
--cc=benoit.houyere-qxv4g6HH51o@public.gmane.org \
--cc=christophe-h.ricard-qxv4g6HH51o@public.gmane.org \
--cc=christophe.ricard-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=jean-luc.blanc-qxv4g6HH51o@public.gmane.org \
--cc=tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).