All of lore.kernel.org
 help / color / mirror / Atom feed
From: greg@kroah.com (Greg KH)
To: linux-kernel@vger.kernel.org, sensors@Stimpy.netroedge.com
Cc: galak@somerset.sps.mot.com
Subject: [PATCH] I2C-MPC: use wait_event_interruptible_timeout between
Date: Thu, 19 May 2005 06:25:31 +0000	[thread overview]
Message-ID: <11059983961556@kroah.com> (raw)
In-Reply-To: <11059983962750@kroah.com>
In-Reply-To: <Pine.LNX.4.61.0501131647540.26980@blarg.somerset.sps.mot.com>

ChangeSet 1.2329.2.10, 2005/01/14 14:44:42-08:00, galak@somerset.sps.mot.com

[PATCH] I2C-MPC: use wait_event_interruptible_timeout between transactions

Use wait_event_interruptible_timeout so we dont waste time waiting between
transactions like we use to.  Also, we use the adapters timeout so the
ioctl cmd I2C_TIMEOUT will now work.

Signed-off-by: Kumar Gala <kumar.gala@freescale.com>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>


 drivers/i2c/busses/i2c-mpc.c |   36 +++++++++++++++---------------------
 1 files changed, 15 insertions(+), 21 deletions(-)


diff -Nru a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
--- a/drivers/i2c/busses/i2c-mpc.c	2005-01-17 13:19:57 -08:00
+++ b/drivers/i2c/busses/i2c-mpc.c	2005-01-17 13:19:57 -08:00
@@ -6,7 +6,7 @@
  * MPC107/Tsi107 PowerPC northbridge and processors that include
  * the same I2C unit (8240, 8245, 85xx). 
  *
- * Release 0.6
+ * Release 0.7
  *
  * This file is licensed under the terms of the GNU General Public
  * License version 2. This program is licensed "as is" without any
@@ -75,7 +75,6 @@
 
 static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing)
 {
-	DECLARE_WAITQUEUE(wait, current);
 	unsigned long orig_jiffies = jiffies;
 	u32 x;
 	int result = 0;
@@ -92,28 +91,22 @@
 		x = readb(i2c->base + MPC_I2C_SR);
 		writeb(0, i2c->base + MPC_I2C_SR);
 	} else {
-		set_current_state(TASK_INTERRUPTIBLE);
-		add_wait_queue(&i2c->queue, &wait);
-		while (!(i2c->interrupt & CSR_MIF)) {
-			if (signal_pending(current)) {
-				pr_debug("I2C: Interrupted\n");
-				result = -EINTR;
-				break;
-			}
-			if (time_after(jiffies, orig_jiffies + timeout)) {
-				pr_debug("I2C: timeout\n");
-				result = -EIO;
-				break;
-			}
-			msleep_interruptible(jiffies_to_msecs(timeout));
+		/* Interrupt mode */
+		result = wait_event_interruptible_timeout(i2c->queue, 
+			(i2c->interrupt & CSR_MIF), timeout * HZ);
+
+		if (unlikely(result < 0))
+			pr_debug("I2C: wait interrupted\n");
+		else if (unlikely(!(i2c->interrupt & CSR_MIF))) {
+			pr_debug("I2C: wait timeout\n");
+			result = -ETIMEDOUT;
 		}
-		set_current_state(TASK_RUNNING);
-		remove_wait_queue(&i2c->queue, &wait);
+
 		x = i2c->interrupt;
 		i2c->interrupt = 0;
 	}
 
-	if (result < -0)
+	if (result < 0)
 		return result;
 
 	if (!(x & CSR_MCF)) {
@@ -165,7 +158,7 @@
 		     const u8 * data, int length, int restart)
 {
 	int i;
-	unsigned timeout = HZ;
+	unsigned timeout = i2c->adap.timeout;
 	u32 flags = restart ? CCR_RSTA : 0;
 
 	/* Start with MEN */
@@ -193,7 +186,7 @@
 static int mpc_read(struct mpc_i2c *i2c, int target,
 		    u8 * data, int length, int restart)
 {
-	unsigned timeout = HZ;
+	unsigned timeout = i2c->adap.timeout;
 	int i;
 	u32 flags = restart ? CCR_RSTA : 0;
 
@@ -302,6 +295,7 @@
 	if (!(i2c = kmalloc(sizeof(*i2c), GFP_KERNEL))) {
 		return -ENOMEM;
 	}
+	memset(i2c, 0, sizeof(*i2c));
 	i2c->ocpdef = ocp->def;
 	init_waitqueue_head(&i2c->queue);
 


WARNING: multiple messages have this Message-ID (diff)
From: Greg KH <greg@kroah.com>
To: linux-kernel@vger.kernel.org, sensors@Stimpy.netroedge.com
Cc: galak@somerset.sps.mot.com
Subject: [PATCH] I2C-MPC: use wait_event_interruptible_timeout between transactions
Date: Mon, 17 Jan 2005 13:46:36 -0800	[thread overview]
Message-ID: <11059983961556@kroah.com> (raw)
In-Reply-To: <11059983962750@kroah.com>

ChangeSet 1.2329.2.10, 2005/01/14 14:44:42-08:00, galak@somerset.sps.mot.com

[PATCH] I2C-MPC: use wait_event_interruptible_timeout between transactions

Use wait_event_interruptible_timeout so we dont waste time waiting between
transactions like we use to.  Also, we use the adapters timeout so the
ioctl cmd I2C_TIMEOUT will now work.

Signed-off-by: Kumar Gala <kumar.gala@freescale.com>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>


 drivers/i2c/busses/i2c-mpc.c |   36 +++++++++++++++---------------------
 1 files changed, 15 insertions(+), 21 deletions(-)


diff -Nru a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
--- a/drivers/i2c/busses/i2c-mpc.c	2005-01-17 13:19:57 -08:00
+++ b/drivers/i2c/busses/i2c-mpc.c	2005-01-17 13:19:57 -08:00
@@ -6,7 +6,7 @@
  * MPC107/Tsi107 PowerPC northbridge and processors that include
  * the same I2C unit (8240, 8245, 85xx). 
  *
- * Release 0.6
+ * Release 0.7
  *
  * This file is licensed under the terms of the GNU General Public
  * License version 2. This program is licensed "as is" without any
@@ -75,7 +75,6 @@
 
 static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing)
 {
-	DECLARE_WAITQUEUE(wait, current);
 	unsigned long orig_jiffies = jiffies;
 	u32 x;
 	int result = 0;
@@ -92,28 +91,22 @@
 		x = readb(i2c->base + MPC_I2C_SR);
 		writeb(0, i2c->base + MPC_I2C_SR);
 	} else {
-		set_current_state(TASK_INTERRUPTIBLE);
-		add_wait_queue(&i2c->queue, &wait);
-		while (!(i2c->interrupt & CSR_MIF)) {
-			if (signal_pending(current)) {
-				pr_debug("I2C: Interrupted\n");
-				result = -EINTR;
-				break;
-			}
-			if (time_after(jiffies, orig_jiffies + timeout)) {
-				pr_debug("I2C: timeout\n");
-				result = -EIO;
-				break;
-			}
-			msleep_interruptible(jiffies_to_msecs(timeout));
+		/* Interrupt mode */
+		result = wait_event_interruptible_timeout(i2c->queue, 
+			(i2c->interrupt & CSR_MIF), timeout * HZ);
+
+		if (unlikely(result < 0))
+			pr_debug("I2C: wait interrupted\n");
+		else if (unlikely(!(i2c->interrupt & CSR_MIF))) {
+			pr_debug("I2C: wait timeout\n");
+			result = -ETIMEDOUT;
 		}
-		set_current_state(TASK_RUNNING);
-		remove_wait_queue(&i2c->queue, &wait);
+
 		x = i2c->interrupt;
 		i2c->interrupt = 0;
 	}
 
-	if (result < -0)
+	if (result < 0)
 		return result;
 
 	if (!(x & CSR_MCF)) {
@@ -165,7 +158,7 @@
 		     const u8 * data, int length, int restart)
 {
 	int i;
-	unsigned timeout = HZ;
+	unsigned timeout = i2c->adap.timeout;
 	u32 flags = restart ? CCR_RSTA : 0;
 
 	/* Start with MEN */
@@ -193,7 +186,7 @@
 static int mpc_read(struct mpc_i2c *i2c, int target,
 		    u8 * data, int length, int restart)
 {
-	unsigned timeout = HZ;
+	unsigned timeout = i2c->adap.timeout;
 	int i;
 	u32 flags = restart ? CCR_RSTA : 0;
 
@@ -302,6 +295,7 @@
 	if (!(i2c = kmalloc(sizeof(*i2c), GFP_KERNEL))) {
 		return -ENOMEM;
 	}
+	memset(i2c, 0, sizeof(*i2c));
 	i2c->ocpdef = ocp->def;
 	init_waitqueue_head(&i2c->queue);
 


  parent reply	other threads:[~2005-05-19  6:25 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-17 21:45 [BK PATCH] I2C fixes for 2.6.11-rc1 Greg KH
2005-05-19  6:25 ` Greg KH
2005-01-17 21:46 ` [PATCH] I2C: add MODULE_DEVICE_TABLE to via686a.c driver Greg KH
2005-05-19  6:25   ` Greg KH
2005-01-17 21:46   ` [PATCH] I2C support for Intel ICH7 - 2.6.10 - resubmit Greg KH
2005-05-19  6:25     ` Greg KH
2005-01-17 21:46     ` [PATCH] I2C: it87 fan update Greg KH
2005-05-19  6:25       ` Greg KH
2005-01-17 21:46       ` [PATCH] I2C: adm1026.c fixes Greg KH
2005-05-19  6:25         ` Greg KH
2005-01-17 21:46         ` [PATCH] I2C: Fix bogus bitmask in lm63 debug message Greg KH
2005-05-19  6:25           ` Greg KH
2005-01-17 21:46           ` [PATCH] I2C: Cleanups to the eeprom driver Greg KH
2005-05-19  6:25             ` Greg KH
2005-01-17 21:46             ` [PATCH] I2C: fix it87 sensor driver stops CPU fan Greg KH
2005-05-19  6:25               ` Greg KH
2005-01-17 21:46               ` [PATCH] I2C: add EMC6D100 support in lm85 driver Greg KH
2005-05-19  6:25                 ` Greg KH
2005-01-17 21:46                 ` [PATCH] I2C: Improve it87 super-i/o detection Greg KH
2005-05-19  6:25                   ` Greg KH
2005-01-17 21:46                   ` Greg KH [this message]
2005-05-19  6:25                     ` [PATCH] I2C-MPC: use wait_event_interruptible_timeout between Greg KH
2005-01-17 21:46                     ` [PATCH] I2C-MPC: Convert to platform_device driver Greg KH
2005-05-19  6:25                       ` Greg KH
2005-01-17 22:12 ` [BK PATCH] I2C fixes for 2.6.11-rc1 Greg KH
2005-05-19  6:25   ` Greg KH
  -- strict thread matches above, loose matches on Subject: below --
2005-05-19  6:25 [PATCH] I2C-MPC: use wait_event_interruptible_timeout Kumar Gala
2005-05-19  6:25 ` Greg KH
2005-05-19  6:25 ` Kumar Gala
2005-01-14  3:35 [PATCH] I2C-MPC: Convert to platform_device driver Kumar Gala
2005-05-19  6:25 ` Kumar Gala
2005-01-14  3:35 ` Kumar Gala
2005-01-14 18:42 ` Greg KH
2005-05-19  6:25   ` Greg KH
2005-01-14 18:42   ` Greg KH
2005-01-14  0:21 [PATCH] I2C-MPC: use wait_event_interruptible_timeout between transactions Kumar Gala
2005-05-19  6:25 ` [PATCH] I2C-MPC: use wait_event_interruptible_timeout between Kumar Gala
2005-01-14  0:21 ` [PATCH] I2C-MPC: use wait_event_interruptible_timeout between transactions Kumar Gala
2005-01-14 18:41 ` Greg KH
2005-05-19  6:25   ` [PATCH] I2C-MPC: use wait_event_interruptible_timeout between Greg KH
2005-01-14 18:41   ` [PATCH] I2C-MPC: use wait_event_interruptible_timeout between transactions Greg KH

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=11059983961556@kroah.com \
    --to=greg@kroah.com \
    --cc=galak@somerset.sps.mot.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sensors@Stimpy.netroedge.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.