diff mbox

Input:Optimize events_per_packet count calculation

Message ID 1418209850-4167-1-git-send-email-anshul.g@samsung.com
State New, archived
Headers show

Commit Message

anshul.g@samsung.com Dec. 10, 2014, 11:10 a.m. UTC
From: Anshul Garg <anshul.g@samsung.com>

This patch avoids unnecessary operations while estimating events per
packet for an input device when event type is not set.

Signed-off-by: Anshul Garg <anshul.g@samsung.com>
---
 drivers/input/input.c |   22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)
diff mbox

Patch

diff --git a/drivers/input/input.c b/drivers/input/input.c
index 29ca0bb..8172296 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -1973,18 +1973,22 @@  static unsigned int input_estimate_events_per_packet(struct input_dev *dev)
 
 	events = mt_slots + 1; /* count SYN_MT_REPORT and SYN_REPORT */
 
-	for (i = 0; i < ABS_CNT; i++) {
-		if (test_bit(i, dev->absbit)) {
-			if (input_is_mt_axis(i))
-				events += mt_slots;
-			else
-				events++;
+	if (test_bit(EV_ABS, dev->evit)) {
+		for (i = 0; i < ABS_CNT; i++) {
+			if (test_bit(i, dev->absbit)) {
+				if (input_is_mt_axis(i))
+					events += mt_slots;
+				else
+					events++;
+			}
 		}
 	}
 
-	for (i = 0; i < REL_CNT; i++)
-		if (test_bit(i, dev->relbit))
-			events++;
+	if (test_bit(EV_REL, dev->evit)) {
+		for (i = 0; i < REL_CNT; i++)
+			if (test_bit(i, dev->relbit))
+				events++;
+	}
 
 	/* Make room for KEY and MSC events */
 	events += 7;