tpmdd-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
To: Christophe Ricard
	<christophe.ricard-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: jean-luc.blanc-qxv4g6HH51o@public.gmane.org,
	ashley-fm2HMyfA2y6tG0bUXCXiUA@public.gmane.org,
	tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
	christophe-h.ricard-qxv4g6HH51o@public.gmane.org,
	benoit.houyere-qxv4g6HH51o@public.gmane.org
Subject: Re: [PATCH v3 3/6] tpm: drop 'read_queue' from struct tpm_vendor_specific
Date: Thu, 31 Mar 2016 09:48:35 +0300	[thread overview]
Message-ID: <20160331064835.GD6393@intel.com> (raw)
In-Reply-To: <1459373895-17704-4-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>

On Wed, Mar 30, 2016 at 11:38:12PM +0200, Christophe Ricard wrote:
> Dropped the field 'read_queue' from struct tpm_vendor_specific and make it
> available to the various private structures in the drivers.
> 
> Signed-off-by: Christophe Ricard <christophe-h.ricard-qxv4g6HH51o@public.gmane.org>

Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>

> ---
>  drivers/char/tpm/st33zp24/st33zp24.c | 12 ++++++------
>  drivers/char/tpm/st33zp24/st33zp24.h |  1 +
>  drivers/char/tpm/tpm.h               |  2 --
>  drivers/char/tpm/tpm_i2c_nuvoton.c   | 14 +++++++++-----
>  drivers/char/tpm/tpm_tis.c           |  9 +++++----
>  drivers/char/tpm/xen-tpmfront.c      | 11 ++++++-----
>  6 files changed, 27 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/char/tpm/st33zp24/st33zp24.c b/drivers/char/tpm/st33zp24/st33zp24.c
> index f4a44ad..d2e0175 100644
> --- a/drivers/char/tpm/st33zp24/st33zp24.c
> +++ b/drivers/char/tpm/st33zp24/st33zp24.c
> @@ -338,7 +338,7 @@ static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count)
>  	       wait_for_stat(chip,
>  			     TPM_STS_DATA_AVAIL | TPM_STS_VALID,
>  			     chip->vendor.timeout_c,
> -			     &chip->vendor.read_queue, true) == 0) {
> +			     &tpm_dev->read_queue, true) == 0) {
>  		burstcnt = get_burstcount(chip);
>  		if (burstcnt < 0)
>  			return burstcnt;
> @@ -367,7 +367,7 @@ static irqreturn_t tpm_ioserirq_handler(int irq, void *dev_id)
>  	tpm_dev = (struct st33zp24_dev *)TPM_VPRIV(chip);
>  
>  	tpm_dev->intrs++;
> -	wake_up_interruptible(&chip->vendor.read_queue);
> +	wake_up_interruptible(&tpm_dev->read_queue);
>  	disable_irq_nosync(tpm_dev->irq);
>  
>  	return IRQ_HANDLED;
> @@ -407,7 +407,7 @@ static int st33zp24_send(struct tpm_chip *chip, unsigned char *buf,
>  		st33zp24_cancel(chip);
>  		if (wait_for_stat
>  		    (chip, TPM_STS_COMMAND_READY, chip->vendor.timeout_b,
> -		     &chip->vendor.read_queue, false) < 0) {
> +		     &tpm_dev->read_queue, false) < 0) {
>  			ret = -ETIME;
>  			goto out_err;
>  		}
> @@ -453,7 +453,7 @@ static int st33zp24_send(struct tpm_chip *chip, unsigned char *buf,
>  
>  		ret = wait_for_stat(chip, TPM_STS_DATA_AVAIL | TPM_STS_VALID,
>  				tpm_calc_ordinal_duration(chip, ordinal),
> -				&chip->vendor.read_queue, false);
> +				&tpm_dev->read_queue, false);
>  		if (ret < 0)
>  			goto out_err;
>  	}
> @@ -570,7 +570,7 @@ int st33zp24_probe(void *phy_id, const struct st33zp24_phy_ops *ops,
>  
>  	if (irq) {
>  		/* INTERRUPT Setup */
> -		init_waitqueue_head(&chip->vendor.read_queue);
> +		init_waitqueue_head(&tpm_dev->read_queue);
>  		tpm_dev->intrs = 0;
>  
>  		if (request_locality(chip) != LOCALITY0) {
> @@ -674,7 +674,7 @@ int st33zp24_pm_resume(struct device *dev)
>  		gpio_set_value(tpm_dev->io_lpcpd, 1);
>  		ret = wait_for_stat(chip,
>  				TPM_STS_VALID, chip->vendor.timeout_b,
> -				&chip->vendor.read_queue, false);
> +				&tpm_dev->read_queue, false);
>  	} else {
>  		ret = tpm_pm_resume(dev);
>  		if (!ret)
> diff --git a/drivers/char/tpm/st33zp24/st33zp24.h b/drivers/char/tpm/st33zp24/st33zp24.h
> index 27e7564..9b5cdc7 100644
> --- a/drivers/char/tpm/st33zp24/st33zp24.h
> +++ b/drivers/char/tpm/st33zp24/st33zp24.h
> @@ -28,6 +28,7 @@ struct st33zp24_dev {
>  	int irq;
>  	u32 intrs;
>  	int io_lpcpd;
> +	wait_queue_head_t read_queue;
>  };
>  
>  
> diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
> index ad4799c..62e711b 100644
> --- a/drivers/char/tpm/tpm.h
> +++ b/drivers/char/tpm/tpm.h
> @@ -137,8 +137,6 @@ struct tpm_vendor_specific {
>  	unsigned long duration[3]; /* jiffies */
>  	bool duration_adjusted;
>  	void *priv;
> -
> -	wait_queue_head_t read_queue;
>  };
>  
>  #define TPM_VPRIV(c)     ((c)->vendor.priv)
> diff --git a/drivers/char/tpm/tpm_i2c_nuvoton.c b/drivers/char/tpm/tpm_i2c_nuvoton.c
> index 75a80e466..2c1fa26 100644
> --- a/drivers/char/tpm/tpm_i2c_nuvoton.c
> +++ b/drivers/char/tpm/tpm_i2c_nuvoton.c
> @@ -57,6 +57,7 @@
>  struct priv_data {
>  	int irq;
>  	unsigned int intrs;
> +	wait_queue_head_t read_queue;
>  };
>  
>  static s32 i2c_nuvoton_read_buf(struct i2c_client *client, u8 offset, u8 size,
> @@ -232,13 +233,14 @@ static int i2c_nuvoton_wait_for_data_avail(struct tpm_chip *chip, u32 timeout,
>  static int i2c_nuvoton_recv_data(struct i2c_client *client,
>  				 struct tpm_chip *chip, u8 *buf, size_t count)
>  {
> +	struct priv_data *priv = chip->vendor.priv;
>  	s32 rc;
>  	int burst_count, bytes2read, size = 0;
>  
>  	while (size < count &&
>  	       i2c_nuvoton_wait_for_data_avail(chip,
>  					       chip->vendor.timeout_c,
> -					       &chip->vendor.read_queue) == 0) {
> +					       &priv->read_queue) == 0) {
>  		burst_count = i2c_nuvoton_get_burstcount(client, chip);
>  		if (burst_count < 0) {
>  			dev_err(&chip->dev,
> @@ -265,6 +267,7 @@ static int i2c_nuvoton_recv_data(struct i2c_client *client,
>  /* Read TPM command results */
>  static int i2c_nuvoton_recv(struct tpm_chip *chip, u8 *buf, size_t count)
>  {
> +	struct priv_data *priv = chip->vendor.priv;
>  	struct device *dev = chip->dev.parent;
>  	struct i2c_client *client = to_i2c_client(dev);
>  	s32 rc;
> @@ -286,7 +289,7 @@ static int i2c_nuvoton_recv(struct tpm_chip *chip, u8 *buf, size_t count)
>  		 * tag, paramsize, and result
>  		 */
>  		status = i2c_nuvoton_wait_for_data_avail(
> -			chip, chip->vendor.timeout_c, &chip->vendor.read_queue);
> +			chip, chip->vendor.timeout_c, &priv->read_queue);
>  		if (status != 0) {
>  			dev_err(dev, "%s() timeout on dataAvail\n", __func__);
>  			size = -ETIMEDOUT;
> @@ -348,6 +351,7 @@ static int i2c_nuvoton_recv(struct tpm_chip *chip, u8 *buf, size_t count)
>   */
>  static int i2c_nuvoton_send(struct tpm_chip *chip, u8 *buf, size_t len)
>  {
> +	struct priv_data *priv = chip->vendor.priv;
>  	struct device *dev = chip->dev.parent;
>  	struct i2c_client *client = to_i2c_client(dev);
>  	u32 ordinal;
> @@ -440,7 +444,7 @@ static int i2c_nuvoton_send(struct tpm_chip *chip, u8 *buf, size_t len)
>  	rc = i2c_nuvoton_wait_for_data_avail(chip,
>  					     tpm_calc_ordinal_duration(chip,
>  								       ordinal),
> -					     &chip->vendor.read_queue);
> +					     &priv->read_queue);
>  	if (rc) {
>  		dev_err(dev, "%s() timeout command duration\n", __func__);
>  		i2c_nuvoton_ready(chip);
> @@ -477,7 +481,7 @@ static irqreturn_t i2c_nuvoton_int_handler(int dummy, void *dev_id)
>  	struct priv_data *priv = chip->vendor.priv;
>  
>  	priv->intrs++;
> -	wake_up(&chip->vendor.read_queue);
> +	wake_up(&priv->read_queue);
>  	disable_irq_nosync(priv->irq);
>  	return IRQ_HANDLED;
>  }
> @@ -541,7 +545,7 @@ static int i2c_nuvoton_probe(struct i2c_client *client,
>  		return -ENOMEM;
>  	chip->vendor.priv = priv;
>  
> -	init_waitqueue_head(&chip->vendor.read_queue);
> +	init_waitqueue_head(&priv->read_queue);
>  
>  	/* Default timeouts */
>  	chip->vendor.timeout_a = msecs_to_jiffies(TPM_I2C_SHORT_TIMEOUT);
> diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
> index b8bb502..403c7bd 100644
> --- a/drivers/char/tpm/tpm_tis.c
> +++ b/drivers/char/tpm/tpm_tis.c
> @@ -99,6 +99,7 @@ struct priv_data {
>  	int irq;
>  	bool irq_tested;
>  	wait_queue_head_t int_queue;
> +	wait_queue_head_t read_queue;
>  };
>  
>  #if defined(CONFIG_PNP) && defined(CONFIG_ACPI)
> @@ -252,7 +253,7 @@ static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count)
>  	       wait_for_tpm_stat(chip,
>  				 TPM_STS_DATA_AVAIL | TPM_STS_VALID,
>  				 chip->vendor.timeout_c,
> -				 &chip->vendor.read_queue, true)
> +				 &priv->read_queue, true)
>  	       == 0) {
>  		burstcnt = get_burstcount(chip);
>  		for (; burstcnt > 0 && size < count; burstcnt--)
> @@ -421,7 +422,7 @@ static int tpm_tis_send_main(struct tpm_chip *chip, u8 *buf, size_t len)
>  
>  		if (wait_for_tpm_stat
>  		    (chip, TPM_STS_DATA_AVAIL | TPM_STS_VALID, dur,
> -		     &chip->vendor.read_queue, false) < 0) {
> +		     &priv->read_queue, false) < 0) {
>  			rc = -ETIME;
>  			goto out_err;
>  		}
> @@ -575,7 +576,7 @@ static irqreturn_t tis_int_handler(int dummy, void *dev_id)
>  
>  	((struct priv_data *)chip->vendor.priv)->irq_tested = true;
>  	if (interrupt & TPM_INTF_DATA_AVAIL_INT)
> -		wake_up_interruptible(&chip->vendor.read_queue);
> +		wake_up_interruptible(&priv->read_queue);
>  	if (interrupt & TPM_INTF_LOCALITY_CHANGE_INT)
>  		for (i = 0; i < 5; i++)
>  			if (check_locality(chip, i) >= 0)
> @@ -800,7 +801,7 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info,
>  	}
>  
>  	/* INTERRUPT Setup */
> -	init_waitqueue_head(&chip->vendor.read_queue);
> +	init_waitqueue_head(&priv->read_queue);
>  	init_waitqueue_head(&priv->int_queue);
>  	if (interrupts && tpm_info->irq != -1) {
>  		if (tpm_info->irq) {
> diff --git a/drivers/char/tpm/xen-tpmfront.c b/drivers/char/tpm/xen-tpmfront.c
> index 329941d..cca89d9 100644
> --- a/drivers/char/tpm/xen-tpmfront.c
> +++ b/drivers/char/tpm/xen-tpmfront.c
> @@ -29,6 +29,7 @@ struct tpm_private {
>  	int ring_ref;
>  	domid_t backend_id;
>  	int irq;
> +	wait_queue_head_t read_queue;
>  };
>  
>  enum status_bits {
> @@ -89,7 +90,7 @@ static int vtpm_send(struct tpm_chip *chip, u8 *buf, size_t count)
>  
>  	/* Wait for completion of any existing command or cancellation */
>  	if (wait_for_tpm_stat(chip, VTPM_STATUS_IDLE, chip->vendor.timeout_c,
> -			&chip->vendor.read_queue, true) < 0) {
> +			&priv->read_queue, true) < 0) {
>  		vtpm_cancel(chip);
>  		return -ETIME;
>  	}
> @@ -105,7 +106,7 @@ static int vtpm_send(struct tpm_chip *chip, u8 *buf, size_t count)
>  	duration = tpm_calc_ordinal_duration(chip, ordinal);
>  
>  	if (wait_for_tpm_stat(chip, VTPM_STATUS_IDLE, duration,
> -			&chip->vendor.read_queue, true) < 0) {
> +			&priv->read_queue, true) < 0) {
>  		/* got a signal or timeout, try to cancel */
>  		vtpm_cancel(chip);
>  		return -ETIME;
> @@ -126,7 +127,7 @@ static int vtpm_recv(struct tpm_chip *chip, u8 *buf, size_t count)
>  
>  	/* In theory the wait at the end of _send makes this one unnecessary */
>  	if (wait_for_tpm_stat(chip, VTPM_STATUS_RESULT, chip->vendor.timeout_c,
> -			&chip->vendor.read_queue, true) < 0) {
> +			&priv->read_queue, true) < 0) {
>  		vtpm_cancel(chip);
>  		return -ETIME;
>  	}
> @@ -162,7 +163,7 @@ static irqreturn_t tpmif_interrupt(int dummy, void *dev_id)
>  	switch (priv->shr->state) {
>  	case VTPM_STATE_IDLE:
>  	case VTPM_STATE_FINISH:
> -		wake_up_interruptible(&priv->chip->vendor.read_queue);
> +		wake_up_interruptible(&priv->read_queue);
>  		break;
>  	case VTPM_STATE_SUBMIT:
>  	case VTPM_STATE_CANCEL:
> @@ -180,7 +181,7 @@ static int setup_chip(struct device *dev, struct tpm_private *priv)
>  	if (IS_ERR(chip))
>  		return PTR_ERR(chip);
>  
> -	init_waitqueue_head(&chip->vendor.read_queue);
> +	init_waitqueue_head(&priv->read_queue);
>  
>  	priv->chip = chip;
>  	TPM_VPRIV(chip) = priv;
> -- 
> 2.5.0
> 

------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785471&iu=/4140

  parent reply	other threads:[~2016-03-31  6: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
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 [this message]
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=20160331064835.GD6393@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).