[PATCH 3/4] input: gpio_keys: limit poll rate

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

 



GPIOs a sometimes slow to read out, for example when they are provided
by I2C GPIO expanders. Limit the poll rate so that we do not slow down
barebox more than necessary in these cases.

Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
---
 drivers/input/gpio_keys.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/drivers/input/gpio_keys.c b/drivers/input/gpio_keys.c
index 77013be133..fd3995d01f 100644
--- a/drivers/input/gpio_keys.c
+++ b/drivers/input/gpio_keys.c
@@ -29,20 +29,14 @@ struct gpio_keys {
 	struct gpio_key *buttons;
 	int nbuttons;
 
-	struct poller_struct poller;
+	struct poller_async poller;
 	struct input_device input;
 	struct device *dev;
 };
 
-static inline struct gpio_keys *
-poller_to_gk_pdata(struct poller_struct *poller)
+static void gpio_key_poller(void *data)
 {
-	return container_of(poller, struct gpio_keys, poller);
-}
-
-static void gpio_key_poller(struct poller_struct *poller)
-{
-	struct gpio_keys *gk = poller_to_gk_pdata(poller);
+	struct gpio_keys *gk = data;
 	struct gpio_key *gb;
 	int i, val;
 
@@ -64,6 +58,8 @@ static void gpio_key_poller(struct poller_struct *poller)
 			gb->previous_state = val;
 		}
 	}
+
+	poller_call_async(&gk->poller, 10 * MSECOND, gpio_key_poller, gk);
 }
 
 static int gpio_keys_probe_pdata(struct gpio_keys *gk, struct device *dev)
@@ -159,16 +155,16 @@ static int __init gpio_keys_probe(struct device *dev)
 		gk->buttons[i].previous_state = gk->buttons[i].active_low;
 	}
 
-	gk->poller.func = gpio_key_poller;
-
 	ret = input_device_register(&gk->input);
 	if (ret)
 		return ret;
 
-	ret = poller_register(&gk->poller, dev_name(dev));
+	ret = poller_async_register(&gk->poller, dev_name(dev));
 	if (ret)
 		return ret;
 
+	poller_call_async(&gk->poller, 10 * MSECOND, gpio_key_poller, gk);
+
 	return 0;
 }
 
-- 
2.39.2





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux