Skip to contentSkip to conversation

input: clps711x-keypad: Remove cond_resched() call

PATCH In review Alexander Shiyan 2 participants 2 messages Sep 19, 2014 – Oct 7, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 input: clps711x-keypad: Remove cond_resched() call

cond_resched() is not works as expected for clps711x-keypad driver and cause runtime error.
This patch replaces this call with udelay().

---
 drivers/input/keyboard/clps711x-keypad.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/input/keyboard/clps711x-keypad.c +4 -4
index 552b65c..650205d 100644
@@ -9,13 +9,13 @@
  * (at your option) any later version.
  */
 
+#include <linux/delay.h>
 #include <linux/input.h>
 #include <linux/input-polldev.h>
 #include <linux/module.h>
 #include <linux/of_gpio.h>
 #include <linux/platform_device.h>
 #include <linux/regmap.h>
-#include <linux/sched.h>
 #include <linux/input/matrix_keypad.h>
 #include <linux/mfd/syscon.h>
 #include <linux/mfd/syscon/clps711x.h>
@@ -54,9 +54,9 @@ static void clps711x_keypad_poll(struct input_polled_dev *dev)
 
 			/* Read twice for protection against fluctuations */
 			do {
-				state = gpiod_get_value_cansleep(data->desc);
-				cond_resched();
-				state1 = gpiod_get_value_cansleep(data->desc);
+				state = gpiod_get_value(data->desc);
+				udelay(5);
+				state1 = gpiod_get_value(data->desc);
 			} while (state != state1);
 
 			if (test_bit(col, data->last_state) != state) {
Signature · 1 line
1.8.5.5
maintainer
#1 lore raw

Hi Alexander,

Quoted 29 lines · Alexander Shiyan

cond_resched() is not works as expected for clps711x-keypad driver and cause runtime error.
This patch replaces this call with udelay().

---
 drivers/input/keyboard/clps711x-keypad.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/input/keyboard/clps711x-keypad.c +1 -1
index 552b65c..650205d 100644
@@ -9,13 +9,13 @@
  * (at your option) any later version.
  */
 
+#include <linux/delay.h>
 #include <linux/input.h>
 #include <linux/input-polldev.h>
 #include <linux/module.h>
 #include <linux/of_gpio.h>
 #include <linux/platform_device.h>
 #include <linux/regmap.h>
-#include <linux/sched.h>
 #include <linux/input/matrix_keypad.h>
 #include <linux/mfd/syscon.h>
 #include <linux/mfd/syscon/clps711x.h>

drivers/input/keyboard/clps711x-keypad.c static void clps711x_keypad_poll(struct input_polled_dev *dev) · line 59

Quoted 9 lines
drivers/input/keyboard/clps711x-keypad.c +3 -3
@@ -54,9 +54,9 @@ static void clps711x_keypad_poll(struct input_polled_dev *dev)
 
 			/* Read twice for protection against fluctuations */
 			do {
-				state = gpiod_get_value_cansleep(data->desc);
-				cond_resched();
-				state1 = gpiod_get_value_cansleep(data->desc);
+				state = gpiod_get_value(data->desc);
+				udelay(5);
+				state1 = gpiod_get_value(data->desc);

Why are you changing gpiod_get_value_cansleep() -> gpiod_get_value(). I am not saying it is incorrect, but could you give reasoning in the changelog?

Thanks.

Signature · 1 line
Dmitry