From 67ce94233177c511b2202661c824aed7d9787307 Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Sat, 24 Jun 2017 12:54:20 +0200 Subject: [PATCH] simple API: un-inline simple API routines Try to avoid inline functions in the public header wherever possible. Signed-off-by: Bartosz Golaszewski --- include/gpiod.h | 28 +++++----------------------- src/lib/simple.c | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/include/gpiod.h b/include/gpiod.h index e1bfa78..9a0863b 100644 --- a/include/gpiod.h +++ b/include/gpiod.h @@ -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. diff --git a/src/lib/simple.c b/src/lib/simple.c index ff86a3a..88d879d 100644 --- a/src/lib/simple.c +++ b/src/lib/simple.c @@ -13,6 +13,19 @@ #include #include +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, -- 2.30.2