[PATCH 6/8] qt2160: only read device when Change pin is active

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Check Change state and only read device when required.
Signed-off-by: Joo Aun Saw <jasaw81@xxxxxxxxx>
---
 drivers/input/keyboard/qt2160.c |   12 ++++++++++++
 include/linux/input/qt2160.h    |    5 +++++
 2 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/drivers/input/keyboard/qt2160.c b/drivers/input/keyboard/qt2160.c
index 7647849..8316fde 100755
--- a/drivers/input/keyboard/qt2160.c
+++ b/drivers/input/keyboard/qt2160.c
@@ -213,6 +213,12 @@ static irqreturn_t qt2160_irq(int irq, void *_qt2160)
 	struct qt2160_data *qt2160 = _qt2160;
 	unsigned long flags;
 
+	if (qt2160->hw_info->getchange) {
+		/* if change is not active, no IRQ to service */
+		if (qt2160->hw_info->getchange(qt2160->hw_info->data) > 0)
+			return IRQ_HANDLED;
+	}
+
 	spin_lock_irqsave(&qt2160->lock, flags);
 
 	__cancel_delayed_work(&qt2160->dwork);
@@ -225,6 +231,12 @@ static irqreturn_t qt2160_irq(int irq, void *_qt2160)
 
 static void qt2160_schedule_read(struct qt2160_data *qt2160)
 {
+	if (qt2160->hw_info->getchange) {
+		/* if change is not active, no need to read device */
+		if (qt2160->hw_info->getchange(qt2160->hw_info->data) > 0)
+			return;
+	}
+
 	spin_lock_irq(&qt2160->lock);
 	schedule_delayed_work(&qt2160->dwork, QT2160_CYCLE_INTERVAL);
 	spin_unlock_irq(&qt2160->lock);
diff --git a/include/linux/input/qt2160.h b/include/linux/input/qt2160.h
index 8a1913f..4eb7e18 100755
--- a/include/linux/input/qt2160.h
+++ b/include/linux/input/qt2160.h
@@ -7,6 +7,9 @@
 
 /**
  * struct qt2160_info - defines the chip configuration
+ * @data: private data for lowlevel IO abstraction routines
+ * @getchange: return 0 when CHANGE pin is active/low; return 1 when CHANGE pin
+ *  is deactivated/high
  * @slider_length: number of keys to use as slider, max 8 keys, min 2 keys
  * @slider_axis: absolute axis type, value 0 is ABS_X
  * @keycodes: key codes for keys that are part of the slider are ignored; slider
@@ -20,6 +23,8 @@
  *  sleep 16ms longer before detecting a touch (slower response); max 255
  */
 struct qt2160_info {
+	void *data;
+	int (*getchange) (void *data);
 	unsigned char slider_length;
 	unsigned int slider_axis;
 	unsigned short keycodes[QT2160_MAXKEYS];
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux