core: move struct definitions to the top of core.c
authorBartosz Golaszewski <bartekgola@gmail.com>
Fri, 6 Jan 2017 09:54:20 +0000 (10:54 +0100)
committerBartosz Golaszewski <bartekgola@gmail.com>
Fri, 6 Jan 2017 09:54:20 +0000 (10:54 +0100)
We will need to access the chip data from the line-related code.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
core.c

diff --git a/core.c b/core.c
index a5a201b7edb55d2a7858e01901852fea0a8524d1..f6019cdd1d2149b43aab71813165fc20ab1bbad7 100644 (file)
--- a/core.c
+++ b/core.c
 #include <sys/poll.h>
 #include <linux/gpio.h>
 
+struct gpiod_chip
+{
+       int fd;
+       struct gpiochip_info cinfo;
+       struct gpiod_line *lines;
+};
+
+struct gpiod_line {
+       bool reserved;
+       bool event_configured;
+       bool up_to_date;
+       struct gpiod_chip *chip;
+       struct gpioline_info info;
+       struct gpiohandle_request *req;
+       struct gpioevent_request event;
+};
+
+struct gpiod_chip_iter
+{
+       DIR *dir;
+       struct gpiod_chip *current;
+};
+
 static const char dev_dir[] = "/dev/";
 static const char cdev_prefix[] = "gpiochip";
 static const char libgpiod_consumer[] = "libgpiod";
@@ -134,16 +157,6 @@ int gpiod_simple_get_value(const char *device, unsigned int offset)
        return value;
 }
 
-struct gpiod_line {
-       bool reserved;
-       bool event_configured;
-       bool up_to_date;
-       struct gpiod_chip *chip;
-       struct gpioline_info info;
-       struct gpiohandle_request *req;
-       struct gpioevent_request event;
-};
-
 static void line_set_offset(struct gpiod_line *line, unsigned int offset)
 {
        line->info.line_offset = offset;
@@ -556,13 +569,6 @@ int gpiod_line_event_get_fd(struct gpiod_line *line)
        return line->event_configured ? line->event.fd : -1;
 }
 
-struct gpiod_chip
-{
-       int fd;
-       struct gpiochip_info cinfo;
-       struct gpiod_line *lines;
-};
-
 struct gpiod_chip * gpiod_chip_open(const char *path)
 {
        struct gpiod_chip *chip;
@@ -707,12 +713,6 @@ struct gpiod_chip * gpiod_line_get_chip(struct gpiod_line *line)
        return line->chip;
 }
 
-struct gpiod_chip_iter
-{
-       DIR *dir;
-       struct gpiod_chip *current;
-};
-
 struct gpiod_chip_iter * gpiod_chip_iter_new(void)
 {
        struct gpiod_chip_iter *new;