public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Kylene Jo Hall <kjhall@us.ibm.com>
To: Nish Aravamudan <nish.aravamudan@gmail.com>,
	Ingo Oeser <ioe-lkml@rameria.de>
Cc: Andrew Morton <akpm@osdl.org>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	TPM Device Driver List <tpmdd-devel@lists.sourceforge.net>
Subject: [PATCH] tpm: use wait_event return code and msecs_to_jiffies
Date: Tue, 11 Apr 2006 17:32:36 -0500	[thread overview]
Message-ID: <1144794756.12054.32.camel@localhost.localdomain> (raw)
In-Reply-To: <29495f1d0604111331t7741e6b2g994c234585a59af0@mail.gmail.com>

On Tue, 2006-04-11 at 13:31 -0700, Nish Aravamudan wrote:
> Rather than check the condition you slept on right away, couldn't you
> just store the return value of wait_event_interruptible_timeout()? If
> it's positive, the condition should be true, if it's negative, then
> you got a signal, if it's 0, then you timed out. Same would go for the
> other change.

On Tue, 2006-04-11 at 22:40 +0200, Ingo Oeser wrote:
> what about using msecs_to_jiffies(chip->vendor.timeout_a) for this?

Great ideas, patch included below.

Update the usage of wait_event calls to utilize the return code and
msecs_to_jiffies.

Signed-off-by: Kylie Hall <kjhall@us.ibm.com>
---
 drivers/char/tpm/tpm_tis.c |   28 +++++++++++++++++-----------
 1 files changed, 17 insertions(+), 11 deletions(-)

--- linux-2.6.17-rc1-mm2/drivers/char/tpm/tpm_tis.c	2006-04-11 17:36:08.247422750 -0500
+++ linux-2.6.17-rc1/drivers/char/tpm/tpm_tis.c	2006-04-11 17:26:24.134918000 -0500
@@ -87,6 +87,7 @@ static void release_locality(struct tpm_
 static int request_locality(struct tpm_chip *chip, int l)
 {
 	unsigned long stop;
+	long rc;
 
 	if (check_locality(chip, l) >= 0)
 		return l;
@@ -95,11 +96,14 @@ static int request_locality(struct tpm_c
 		 chip->vendor.iobase + TPM_ACCESS(l));
 
 	if (chip->vendor.irq) {
-		wait_event_interruptible_timeout(chip->vendor.int_queue,
-						 (check_locality(chip, l) >= 0),
-						 HZ * chip->vendor.timeout_a /
-						 1000);
-		if (check_locality(chip, l) >= 0)
+		rc = wait_event_interruptible_timeout(chip->vendor.
+						      int_queue,
+						      (check_locality
+						       (chip, l) >= 0),
+						      msecs_to_jiffies
+						      (chip->vendor.
+						       timeout_a));
+		if (rc > 0)
 			return l;
 
 	} else {
@@ -153,6 +157,7 @@ static int wait_for_stat(struct tpm_chip
 			 wait_queue_head_t *queue)
 {
 	unsigned long stop;
+	long rc;
 	u8 status;
 
 	/* check current status */
@@ -161,12 +166,13 @@ static int wait_for_stat(struct tpm_chip
 		return 0;
 
 	if (chip->vendor.irq) {
-		wait_event_interruptible_timeout(*queue,
-						 ((tpm_tis_status(chip) &
-						   mask) == mask),
-						 HZ * timeout / 1000);
-		status = tpm_tis_status(chip);
-		if ((status & mask) == mask)
+		rc = wait_event_interruptible_timeout(*queue,
+						      ((tpm_tis_status
+							(chip) & mask) ==
+						       mask),
+						      msecs_to_jiffies
+						      (timeout));
+		if (rc > 0)
 			return 0;
 	} else {
 		stop = jiffies + (HZ * timeout / 1000);



  reply	other threads:[~2006-04-11 22:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-10 14:37 [PATCH 7/7] tpm: Driver for next generation TPM chips Kylene Jo Hall
2006-04-10 22:03 ` Andrew Morton
2006-04-11 20:15   ` [PATCH] tpm: update to use wait_event calls Kylene Jo Hall
2006-04-11 20:31     ` Nish Aravamudan
2006-04-11 22:32       ` Kylene Jo Hall [this message]
2006-04-11 20:40     ` Ingo Oeser
2006-04-11 23:05 ` [PATCH 7/7] tpm: Driver for next generation TPM chips Nishanth Aravamudan
2006-04-12 17:29   ` Kylene Jo Hall
2006-04-12 17:32     ` Nishanth Aravamudan
2006-04-12 21:48       ` [PATCH] tpm: msecs_to_jiffies cleanups Kylene Jo Hall

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=1144794756.12054.32.camel@localhost.localdomain \
    --to=kjhall@us.ibm.com \
    --cc=akpm@osdl.org \
    --cc=ioe-lkml@rameria.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nish.aravamudan@gmail.com \
    --cc=tpmdd-devel@lists.sourceforge.net \
    /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