From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] gpio: iopoll: implement gpio_poll_timeout_us
Date: Thu, 29 Aug 2019 14:43:18 +0200 [thread overview]
Message-ID: <20190829124318.30339-1-a.fatoum@pengutronix.de> (raw)
Sometimes we need to wait for state change on a GPIO,
provide a helper to do this.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
include/gpio.h | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/include/gpio.h b/include/gpio.h
index 1926edeca757..89cb306a195c 100644
--- a/include/gpio.h
+++ b/include/gpio.h
@@ -3,6 +3,7 @@
#include <linux/types.h>
#include <linux/list.h>
+#include <linux/iopoll.h>
#ifdef CONFIG_GENERIC_GPIO
void gpio_set_value(unsigned gpio, int value);
@@ -31,6 +32,13 @@ static inline int gpio_direction_input(unsigned gpio)
void gpio_set_active(unsigned gpio, bool state);
int gpio_is_active(unsigned gpio);
int gpio_direction_active(unsigned gpio, bool state);
+
+#define gpio_poll_timeout_us(gpio, active, timeout_us) \
+ ({ \
+ int __state; \
+ readx_poll_timeout(gpio_is_active, gpio, __state, \
+ __state == (active), timeout_us); \
+ })
#else
static inline void gpio_set_active(unsigned gpio, int value)
{
@@ -43,6 +51,8 @@ static inline int gpio_direction_active(unsigned gpio, int value)
{
return -EINVAL;
}
+
+#define gpio_poll_timeout_us(gpio, val, timeout_us) (-ENOSYS)
#endif
#if defined(CONFIG_ARCH_NR_GPIO) && CONFIG_ARCH_NR_GPIO > 0
--
2.23.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next reply other threads:[~2019-08-29 12:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-29 12:43 Ahmad Fatoum [this message]
2019-08-30 4:18 ` Oleksij Rempel
2019-08-30 8:55 ` Ahmad Fatoum
2019-09-02 7:16 ` Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190829124318.30339-1-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox