simple API: un-inline simple API routines
authorBartosz Golaszewski <bartekgola@gmail.com>
Sat, 24 Jun 2017 10:54:20 +0000 (12:54 +0200)
committerBartosz Golaszewski <bartekgola@gmail.com>
Thu, 6 Jul 2017 09:11:36 +0000 (11:11 +0200)
Try to avoid inline functions in the public header wherever possible.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
include/gpiod.h
src/lib/simple.c

index e1bfa78be50b02465a174fed20f727f5ad58aa9d..9a0863b932930465198034b53941ed70c4420396 100644 (file)
@@ -83,19 +83,8 @@ int gpiod_simple_get_value_multiple(const char *consumer, const char *device,
  * @param active_low The active state of this line - true if low.
  * @return 0 or 1 (GPIO value) if the operation succeeds, -1 on error.
  */
-static inline int gpiod_simple_get_value(const char *consumer,
-                                        const char *device,
-                                        unsigned int offset, bool active_low)
-{
-       int value, status;
-
-       status = gpiod_simple_get_value_multiple(consumer, device, &offset,
-                                                &value, 1, active_low);
-       if (status < 0)
-               return status;
-
-       return value;
-}
+int gpiod_simple_get_value(const char *consumer, const char *device,
+                          unsigned int offset, bool active_low) GPIOD_API;
 
 /**
  * @brief Simple set value callback signature.
@@ -134,16 +123,9 @@ int gpiod_simple_set_value_multiple(const char *consumer, const char *device,
  * @param data User data that will be passed to the callback function.
  * @return 0 if the operation succeeds, -1 on error.
  */
-static inline int gpiod_simple_set_value(const char *consumer,
-                                        const char *device,
-                                        unsigned int offset, int value,
-                                        bool active_low,
-                                        gpiod_set_value_cb cb, void *data)
-{
-       return gpiod_simple_set_value_multiple(consumer, device, &offset,
-                                              &value, 1, active_low,
-                                              cb, data);
-}
+int gpiod_simple_set_value(const char *consumer, const char *device,
+                          unsigned int offset, int value, bool active_low,
+                          gpiod_set_value_cb cb, void *data) GPIOD_API;
 
 /**
  * @brief Event types that can be passed to the simple event callback.
index ff86a3af3e1aa000857e000b7513cc2d2daa0bbf..88d879d083a9bc1e5f829981fbc9fd4f14fa6088 100644 (file)
 #include <string.h>
 #include <errno.h>
 
+int gpiod_simple_get_value(const char *consumer, const char *device,
+                          unsigned int offset, bool active_low)
+{
+       int value, status;
+
+       status = gpiod_simple_get_value_multiple(consumer, device, &offset,
+                                                &value, 1, active_low);
+       if (status < 0)
+               return status;
+
+       return value;
+}
+
 int gpiod_simple_get_value_multiple(const char *consumer, const char *device,
                                    const unsigned int *offsets, int *values,
                                    unsigned int num_lines, bool active_low)
@@ -59,6 +72,15 @@ int gpiod_simple_get_value_multiple(const char *consumer, const char *device,
        return status;
 }
 
+int gpiod_simple_set_value(const char *consumer, const char *device,
+                          unsigned int offset, int value, bool active_low,
+                          gpiod_set_value_cb cb, void *data)
+{
+       return gpiod_simple_set_value_multiple(consumer, device, &offset,
+                                              &value, 1, active_low,
+                                              cb, data);
+}
+
 int gpiod_simple_set_value_multiple(const char *consumer, const char *device,
                                    const unsigned int *offsets,
                                    const int *values, unsigned int num_lines,