core: group the line request code together
authorBartosz Golaszewski <bartekgola@gmail.com>
Thu, 13 Jul 2017 11:15:39 +0000 (13:15 +0200)
committerBartosz Golaszewski <bartekgola@gmail.com>
Thu, 13 Jul 2017 11:15:39 +0000 (13:15 +0200)
Put both the regular input & output requests as well as event requests
together in the same place in core.c.

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

index 7209351df3db2cd381eb19cd87c09fe6b21dc9c1..49efefaf8bacfa14a984bd4a36ffabcefa845f79 100644 (file)
@@ -389,64 +389,6 @@ int gpiod_line_update(struct gpiod_line *line)
        return 0;
 }
 
-int gpiod_line_request(struct gpiod_line *line,
-                      const struct gpiod_line_request_config *config,
-                      int default_val)
-{
-       struct gpiod_line_bulk bulk;
-
-       gpiod_line_bulk_init(&bulk);
-       gpiod_line_bulk_add(&bulk, line);
-
-       return gpiod_line_request_bulk(&bulk, config, &default_val);
-}
-
-int gpiod_line_request_input(struct gpiod_line *line, const char *consumer)
-{
-       struct gpiod_line_request_config config = {
-               .consumer = consumer,
-               .request_type = GPIOD_REQUEST_DIRECTION_INPUT,
-       };
-
-       return gpiod_line_request(line, &config, 0);
-}
-
-int gpiod_line_request_output(struct gpiod_line *line,
-                             const char *consumer, int default_val)
-{
-       struct gpiod_line_request_config config = {
-               .consumer = consumer,
-               .request_type = GPIOD_REQUEST_DIRECTION_OUTPUT,
-       };
-
-       return gpiod_line_request(line, &config, default_val);
-}
-
-int gpiod_line_request_input_flags(struct gpiod_line *line,
-                                  const char *consumer, int flags)
-{
-       struct gpiod_line_request_config config = {
-               .consumer = consumer,
-               .request_type = GPIOD_REQUEST_DIRECTION_INPUT,
-               .flags = flags,
-       };
-
-       return gpiod_line_request(line, &config, 0);
-}
-
-int gpiod_line_request_output_flags(struct gpiod_line *line,
-                                   const char *consumer, int flags,
-                                   int default_val)
-{
-       struct gpiod_line_request_config config = {
-               .consumer = consumer,
-               .request_type = GPIOD_REQUEST_DIRECTION_OUTPUT,
-               .flags = flags,
-       };
-
-       return gpiod_line_request(line, &config, default_val);
-}
-
 static bool verify_line_bulk(struct gpiod_line_bulk *bulk)
 {
        struct gpiod_line *line;
@@ -590,6 +532,120 @@ static int line_request_events(struct gpiod_line_bulk *bulk,
        return 0;
 }
 
+int gpiod_line_request(struct gpiod_line *line,
+                      const struct gpiod_line_request_config *config,
+                      int default_val)
+{
+       struct gpiod_line_bulk bulk;
+
+       gpiod_line_bulk_init(&bulk);
+       gpiod_line_bulk_add(&bulk, line);
+
+       return gpiod_line_request_bulk(&bulk, config, &default_val);
+}
+
+int gpiod_line_request_input(struct gpiod_line *line, const char *consumer)
+{
+       struct gpiod_line_request_config config = {
+               .consumer = consumer,
+               .request_type = GPIOD_REQUEST_DIRECTION_INPUT,
+       };
+
+       return gpiod_line_request(line, &config, 0);
+}
+
+int gpiod_line_request_output(struct gpiod_line *line,
+                             const char *consumer, int default_val)
+{
+       struct gpiod_line_request_config config = {
+               .consumer = consumer,
+               .request_type = GPIOD_REQUEST_DIRECTION_OUTPUT,
+       };
+
+       return gpiod_line_request(line, &config, default_val);
+}
+
+int gpiod_line_request_input_flags(struct gpiod_line *line,
+                                  const char *consumer, int flags)
+{
+       struct gpiod_line_request_config config = {
+               .consumer = consumer,
+               .request_type = GPIOD_REQUEST_DIRECTION_INPUT,
+               .flags = flags,
+       };
+
+       return gpiod_line_request(line, &config, 0);
+}
+
+int gpiod_line_request_output_flags(struct gpiod_line *line,
+                                   const char *consumer, int flags,
+                                   int default_val)
+{
+       struct gpiod_line_request_config config = {
+               .consumer = consumer,
+               .request_type = GPIOD_REQUEST_DIRECTION_OUTPUT,
+               .flags = flags,
+       };
+
+       return gpiod_line_request(line, &config, default_val);
+}
+
+static int line_event_request_type(struct gpiod_line *line,
+                                  const char *consumer, int flags, int type)
+{
+       struct gpiod_line_request_config config = {
+               .consumer = consumer,
+               .request_type = type,
+               .flags = flags,
+       };
+
+       return gpiod_line_request(line, &config, 0);
+}
+
+int gpiod_line_request_rising_edge_events(struct gpiod_line *line,
+                                         const char *consumer)
+{
+       return line_event_request_type(line, consumer, 0,
+                                      GPIOD_REQUEST_EVENT_RISING_EDGE);
+}
+
+int gpiod_line_request_falling_edge_events(struct gpiod_line *line,
+                                          const char *consumer)
+{
+       return line_event_request_type(line, consumer, 0,
+                                      GPIOD_REQUEST_EVENT_FALLING_EDGE);
+}
+
+int gpiod_line_request_both_edges_events(struct gpiod_line *line,
+                                        const char *consumer)
+{
+       return line_event_request_type(line, consumer, 0,
+                                      GPIOD_REQUEST_EVENT_BOTH_EDGES);
+}
+
+int gpiod_line_request_rising_edge_events_flags(struct gpiod_line *line,
+                                               const char *consumer,
+                                               int flags)
+{
+       return line_event_request_type(line, consumer, flags,
+                                      GPIOD_REQUEST_EVENT_RISING_EDGE);
+}
+
+int gpiod_line_request_falling_edge_events_flags(struct gpiod_line *line,
+                                                const char *consumer,
+                                                int flags)
+{
+       return line_event_request_type(line, consumer, flags,
+                                      GPIOD_REQUEST_EVENT_RISING_EDGE);
+}
+
+int gpiod_line_request_both_edges_events_flags(struct gpiod_line *line,
+                                              const char *consumer, int flags)
+{
+       return line_event_request_type(line, consumer, flags,
+                                      GPIOD_REQUEST_EVENT_RISING_EDGE);
+}
+
 int gpiod_line_request_bulk(struct gpiod_line_bulk *bulk,
                            const struct gpiod_line_request_config *config,
                            const int *default_vals)
@@ -791,62 +847,6 @@ struct gpiod_line * gpiod_line_find_by_name(const char *name)
        return NULL;
 }
 
-static int line_event_request_type(struct gpiod_line *line,
-                                  const char *consumer, int flags, int type)
-{
-       struct gpiod_line_request_config config = {
-               .consumer = consumer,
-               .request_type = type,
-               .flags = flags,
-       };
-
-       return gpiod_line_request(line, &config, 0);
-}
-
-int gpiod_line_request_rising_edge_events(struct gpiod_line *line,
-                                         const char *consumer)
-{
-       return line_event_request_type(line, consumer, 0,
-                                      GPIOD_REQUEST_EVENT_RISING_EDGE);
-}
-
-int gpiod_line_request_falling_edge_events(struct gpiod_line *line,
-                                          const char *consumer)
-{
-       return line_event_request_type(line, consumer, 0,
-                                      GPIOD_REQUEST_EVENT_FALLING_EDGE);
-}
-
-int gpiod_line_request_both_edges_events(struct gpiod_line *line,
-                                        const char *consumer)
-{
-       return line_event_request_type(line, consumer, 0,
-                                      GPIOD_REQUEST_EVENT_BOTH_EDGES);
-}
-
-int gpiod_line_request_rising_edge_events_flags(struct gpiod_line *line,
-                                               const char *consumer,
-                                               int flags)
-{
-       return line_event_request_type(line, consumer, flags,
-                                      GPIOD_REQUEST_EVENT_RISING_EDGE);
-}
-
-int gpiod_line_request_falling_edge_events_flags(struct gpiod_line *line,
-                                                const char *consumer,
-                                                int flags)
-{
-       return line_event_request_type(line, consumer, flags,
-                                      GPIOD_REQUEST_EVENT_RISING_EDGE);
-}
-
-int gpiod_line_request_both_edges_events_flags(struct gpiod_line *line,
-                                              const char *consumer, int flags)
-{
-       return line_event_request_type(line, consumer, flags,
-                                      GPIOD_REQUEST_EVENT_RISING_EDGE);
-}
-
 int gpiod_line_event_wait(struct gpiod_line *line,
                          const struct timespec *timeout)
 {