[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-i2c
Subject:    [i2c]   [PATCH 1/2] [resend] Add polling transfer for i2c-pxa
From:       Mike Rapoport <mike () compulab ! co ! il>
Date:       2007-12-20 14:07:12
Message-ID: 476A7710.7060607 () compulab ! co ! il
[Download RAW message or body]

This patchset adds ability to make i2c transfers in interrupts-off contexts and
implements polling transfers for i2c-pxa.
The change to i2c-core allows to decide between mutex_trylock and mutex_lock.
The changes to i2c-pxa bus driver adds an i2c_algorithm for polling access to
I2C bus.

-- 
Sincerely yours,
Mike.

Signed-off-by: Mike Rapoport <mike@compulab.co.il>

 drivers/i2c/i2c-core.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index b5e13e4..4434413 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -33,6 +33,8 @@
 #include <linux/platform_device.h>
 #include <linux/mutex.h>
 #include <linux/completion.h>
+#include <linux/hardirq.h>
+#include <linux/irqflags.h>
 #include <asm/uaccess.h>

 #include "i2c-core.h"
@@ -879,7 +881,15 @@ int i2c_transfer(struct i2c_adapter * adap, struct i2c_msg *msgs, int num)
 		}
 #endif

-		mutex_lock_nested(&adap->bus_lock, adap->level);
+		if (in_atomic() || irqs_disabled()) {
+			ret = mutex_trylock(&adap->bus_lock);
+			if (!ret)
+				/* I2C activity is ongoing. */
+				return -EAGAIN;
+		} else {
+			mutex_lock_nested(&adap->bus_lock, adap->level);
+		}
+
 		ret = adap->algo->master_xfer(adap,msgs,num);
 		mutex_unlock(&adap->bus_lock);

diff --git a/include/linux/i2c.h b/include/linux/i2c.h


_______________________________________________
i2c mailing list
i2c@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/i2c
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic