Module: xenomai-3
Branch: wip/drivers
Commit: 1f56f78877e3999f357d9467c18d94b391b72d55
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=1f56f78877e3999f357d9467c18d94b391b72d55

Author: Philippe Gerum <r...@xenomai.org>
Date:   Tue Jul 12 09:53:37 2016 +0200

drivers/gpio: add blocking read()

---

 include/rtdm/uapi/gpio.h        |    2 --
 kernel/drivers/gpio/gpio-core.c |    7 +++++++
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/include/rtdm/uapi/gpio.h b/include/rtdm/uapi/gpio.h
index 307e190..f846f48 100644
--- a/include/rtdm/uapi/gpio.h
+++ b/include/rtdm/uapi/gpio.h
@@ -18,8 +18,6 @@
 #ifndef _RTDM_UAPI_GPIO_H
 #define _RTDM_UAPI_GPIO_H
 
-#include <linux/types.h>
-
 #define GPIO_RTIOC_DIR_OUT             _IOW(RTDM_CLASS_GPIO, 0, int)
 #define GPIO_RTIOC_DIR_IN              _IO(RTDM_CLASS_GPIO, 1)
 #define GPIO_RTIOC_IRQEN               _IOW(RTDM_CLASS_GPIO, 2, int) /* GPIO 
trigger */
diff --git a/kernel/drivers/gpio/gpio-core.c b/kernel/drivers/gpio/gpio-core.c
index 6c1f351..f18d571 100644
--- a/kernel/drivers/gpio/gpio-core.c
+++ b/kernel/drivers/gpio/gpio-core.c
@@ -155,6 +155,13 @@ static ssize_t gpio_pin_read_rt(struct rtdm_fd *fd,
                return -EINVAL;
 
        pin = container_of(dev, struct rtdm_gpio_pin, dev);
+
+       if (!(fd->oflags & O_NONBLOCK)) {
+               ret = rtdm_event_wait(&pin->event);
+               if (ret)
+                       return ret;
+       }
+
        value = gpiod_get_raw_value(pin->desc);
        ret = rtdm_safe_copy_to_user(fd, buf, &value, sizeof(value));
        


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git

Reply via email to