linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
To: Kent Gibson <warthog618@gmail.com>
Cc: linux-gpio <linux-gpio@vger.kernel.org>
Subject: Re: [libgpiod] [PATCH 02/19] API: add support for bias flags
Date: Mon, 18 Nov 2019 14:51:06 +0100	[thread overview]
Message-ID: <CAMpxmJXRuRmE9-9mk9uv47kviMUO=+oEgPO0KtVB77JW8M_AYg@mail.gmail.com> (raw)
In-Reply-To: <20191115144355.975-3-warthog618@gmail.com>

pt., 15 lis 2019 o 15:44 Kent Gibson <warthog618@gmail.com> napisał(a):
>
> Extend the libgpiod API to support the bias flags recently added to the
> kernel GPIO uAPI.  The core change is the addition of
> GPIOD_LINE_REQUEST_FLAG_BIAS_DISABLE, GPIOD_LINE_REQUEST_FLAG_BIAS_PULL_UP
> and GPIOD_LINE_REQUEST_FLAG_BIAS_PULL_DOWN flags to be passed into
> line_request functions, and the addition of gpiod_line_bias to return the
> bias state of lines.
>
> Extended variants of the ctxless functions that accept an active_low flag
> are added to also accept other flags. The variant names add a "_ext"
> suffix to the name of the original function.
>
> Based on initial work by Drew Fustini <drew@pdp7.com>.
>
> Signed-off-by: Kent Gibson <warthog618@gmail.com>

Hi Kent,

this looks good, just a couple nits. I'd change the subject line to
"core: add support for bias flags". Also: how about moving the flags
argument to the last position in all the ctxless extended variants, so
that they keep the same signature *except* for the appended new
argument?

Bart



> ---
>  include/gpiod.h | 184 ++++++++++++++++++++++++++++++++++++++++++++++++
>  lib/core.c      |  32 ++++++---
>  lib/ctxless.c   | 115 +++++++++++++++++++++++++++---
>  3 files changed, 313 insertions(+), 18 deletions(-)
>
> diff --git a/include/gpiod.h b/include/gpiod.h
> index 9860ea8..0f01cab 100644
> --- a/include/gpiod.h
> +++ b/include/gpiod.h
> @@ -84,6 +84,22 @@ struct gpiod_line_bulk;
>   * the need to use the gpiod_* structures or to keep track of resources.
>   */
>
> +/**
> + * @brief Miscellaneous GPIO flags.
> + */
> +enum {
> +       GPIOD_CTXLESS_FLAG_OPEN_DRAIN           = GPIOD_BIT(0),
> +       /**< The line is an open-drain port. */
> +       GPIOD_CTXLESS_FLAG_OPEN_SOURCE          = GPIOD_BIT(1),
> +       /**< The line is an open-source port. */
> +       GPIOD_CTXLESS_FLAG_BIAS_DISABLE         = GPIOD_BIT(2),
> +       /**< The line has neither either pull-up nor pull-down resistor */
> +       GPIOD_CTXLESS_FLAG_BIAS_PULL_DOWN       = GPIOD_BIT(3),
> +       /**< The line has pull-down resistor enabled */
> +       GPIOD_CTXLESS_FLAG_BIAS_PULL_UP         = GPIOD_BIT(4),
> +       /**< The line has pull-up resistor enabled */
> +};
> +
>  /**
>   * @brief Read current value from a single GPIO line.
>   * @param device Name, path, number or label of the gpiochip.
> @@ -95,6 +111,19 @@ struct gpiod_line_bulk;
>  int gpiod_ctxless_get_value(const char *device, unsigned int offset,
>                             bool active_low, const char *consumer) GPIOD_API;
>
> +/**
> + * @brief Read current value from a single GPIO line.
> + * @param device Name, path, number or label of the gpiochip.
> + * @param offset Offset of the GPIO line.
> + * @param active_low The active state of this line - true if low.
> + * @param flags The flags for the line.
> + * @param consumer Name of the consumer.
> + * @return 0 or 1 (GPIO value) if the operation succeeds, -1 on error.
> + */
> +int gpiod_ctxless_get_value_ext(const char *device, unsigned int offset,
> +                               bool active_low, int flags,
> +                               const char *consumer) GPIOD_API;
> +
>  /**
>   * @brief Read current values from a set of GPIO lines.
>   * @param device Name, path, number or label of the gpiochip.
> @@ -110,6 +139,24 @@ int gpiod_ctxless_get_value_multiple(const char *device,
>                                      unsigned int num_lines, bool active_low,
>                                      const char *consumer) GPIOD_API;
>
> +/**
> + * @brief Read current values from a set of GPIO lines.
> + * @param device Name, path, number or label of the gpiochip.
> + * @param offsets Array of offsets of lines whose values should be read.
> + * @param values Buffer in which the values will be stored.
> + * @param num_lines Number of lines, must be > 0.
> + * @param active_low The active state of this line - true if low.
> + * @param flags The flags for the lines.
> + * @param consumer Name of the consumer.
> + * @return 0 if the operation succeeds, -1 on error.
> + */
> +int gpiod_ctxless_get_value_multiple_ext(const char *device,
> +                                        const unsigned int *offsets,
> +                                        int *values,
> +                                        unsigned int num_lines,
> +                                        bool active_low, int flags,
> +                                        const char *consumer) GPIOD_API;
> +
>  /**
>   * @brief Simple set value callback signature.
>   */
> @@ -133,6 +180,26 @@ int gpiod_ctxless_set_value(const char *device, unsigned int offset, int value,
>                             gpiod_ctxless_set_value_cb cb,
>                             void *data) GPIOD_API;
>
> +/**
> + * @brief Set value of a single GPIO line.
> + * @param device Name, path, number or label of the gpiochip.
> + * @param offset The offset of the GPIO line.
> + * @param value New value (0 or 1).
> + * @param active_low The active state of this line - true if low.
> + * @param flags The flags for the line.
> + * @param consumer Name of the consumer.
> + * @param cb Optional callback function that will be called right after setting
> + *           the value. Users can use this, for example, to pause the execution
> + *           after toggling a GPIO.
> + * @param data Optional user data that will be passed to the callback function.
> + * @return 0 if the operation succeeds, -1 on error.
> + */
> +int gpiod_ctxless_set_value_ext(const char *device, unsigned int offset,
> +                               int value, bool active_low, int flags,
> +                               const char *consumer,
> +                               gpiod_ctxless_set_value_cb cb,
> +                               void *data) GPIOD_API;
> +
>  /**
>   * @brief Set values of multiple GPIO lines.
>   * @param device Name, path, number or label of the gpiochip.
> @@ -153,6 +220,29 @@ int gpiod_ctxless_set_value_multiple(const char *device,
>                                      gpiod_ctxless_set_value_cb cb,
>                                      void *data) GPIOD_API;
>
> +/**
> + * @brief Set values of multiple GPIO lines.
> + * @param device Name, path, number or label of the gpiochip.
> + * @param offsets Array of offsets of lines the values of which should be set.
> + * @param values Array of integers containing new values.
> + * @param num_lines Number of lines, must be > 0.
> + * @param active_low The active state of this line - true if low.
> + * @param flags The flags for the lines.
> + * @param consumer Name of the consumer.
> + * @param cb Optional callback function that will be called right after setting
> + *           all values. Works the same as in ::gpiod_ctxless_set_value.
> + * @param data Optional user data that will be passed to the callback function.
> + * @return 0 if the operation succeeds, -1 on error.
> + */
> +int gpiod_ctxless_set_value_multiple_ext(const char *device,
> +                                        const unsigned int *offsets,
> +                                        const int *values,
> +                                        unsigned int num_lines,
> +                                        bool active_low, int flags,
> +                                        const char *consumer,
> +                                        gpiod_ctxless_set_value_cb cb,
> +                                        void *data) GPIOD_API;
> +
>  /**
>   * @brief Event types that the ctxless event monitor can wait for.
>   */
> @@ -327,6 +417,31 @@ int gpiod_ctxless_event_monitor(const char *device, int event_type,
>                                 gpiod_ctxless_event_handle_cb event_cb,
>                                 void *data) GPIOD_API;
>
> +/**
> + * @brief Wait for events on a single GPIO line.
> + * @param device Name, path, number or label of the gpiochip.
> + * @param event_type Type of events to listen for.
> + * @param offset GPIO line offset to monitor.
> + * @param active_low The active state of this line - true if low.
> + * @param flags The flags for the line.
> + * @param consumer Name of the consumer.
> + * @param timeout Maximum wait time for each iteration.
> + * @param poll_cb Callback function to call when waiting for events.
> + * @param event_cb Callback function to call for each line event.
> + * @param data User data passed to the callback.
> + * @return 0 if no errors were encountered, -1 if an error occurred.
> + * @note The way the ctxless event loop works is described in detail in
> + *       ::gpiod_ctxless_event_monitor_multiple - this is just a wrapper aound
> + *       this routine which calls it for a single GPIO line.
> + */
> +int gpiod_ctxless_event_monitor_ext(const char *device, int event_type,
> +                                   unsigned int offset, bool active_low,
> +                                   int flags, const char *consumer,
> +                                   const struct timespec *timeout,
> +                                   gpiod_ctxless_event_poll_cb poll_cb,
> +                                   gpiod_ctxless_event_handle_cb event_cb,
> +                                   void *data) GPIOD_API;
> +
>  /**
>   * @brief Wait for events on multiple GPIO lines.
>   * @param device Name, path, number or label of the gpiochip.
> @@ -366,6 +481,47 @@ int gpiod_ctxless_event_monitor_multiple(
>                         gpiod_ctxless_event_handle_cb event_cb,
>                         void *data) GPIOD_API;
>
> +/**
> + * @brief Wait for events on multiple GPIO lines.
> + * @param device Name, path, number or label of the gpiochip.
> + * @param event_type Type of events to listen for.
> + * @param offsets Array of GPIO line offsets to monitor.
> + * @param num_lines Number of lines to monitor.
> + * @param active_low The active state of this line - true if low.
> + * @param flags The flags for the lines.
> + * @param consumer Name of the consumer.
> + * @param timeout Maximum wait time for each iteration.
> + * @param poll_cb Callback function to call when waiting for events. Can
> + *                be NULL.
> + * @param event_cb Callback function to call on event occurrence.
> + * @param data User data passed to the callback.
> + * @return 0 no errors were encountered, -1 if an error occurred.
> + * @note The poll callback can be NULL in which case the routine will fall
> + *       back to a basic, ppoll() based callback.
> + *
> + * Internally this routine opens the GPIO chip, requests the set of lines for
> + * the type of events specified in the event_type parameter and calls the
> + * polling callback in a loop. The role of the polling callback is to detect
> + * input events on a set of file descriptors and notify the caller about the
> + * fds ready for reading.
> + *
> + * The ctxless event loop then reads each queued event from marked descriptors
> + * and calls the event callback. Both callbacks can stop the loop at any
> + * point.
> + *
> + * The poll_cb argument can be NULL in which case the function falls back to
> + * a default, ppoll() based callback.
> + */
> +int gpiod_ctxless_event_monitor_multiple_ext(
> +                       const char *device, int event_type,
> +                       const unsigned int *offsets,
> +                       unsigned int num_lines, bool active_low, int flags,
> +                       const char *consumer, const struct timespec *timeout,
> +                       gpiod_ctxless_event_poll_cb poll_cb,
> +                       gpiod_ctxless_event_handle_cb event_cb,
> +                       void *data) GPIOD_API;
> +
> +
>  /**
>   * @brief Determine the chip name and line offset of a line with given name.
>   * @param name The name of the GPIO line to lookup.
> @@ -658,6 +814,20 @@ enum {
>         /**< The active state of a GPIO is active-low. */
>  };
>
> +/**
> + * @brief Possible internal bias settings.
> + */
> +enum {
> +       GPIOD_LINE_BIAS_AS_IS = 1,
> +       /**< The internal bias state is unknown. */
> +       GPIOD_LINE_BIAS_DISABLE,
> +       /**< The internal bias is disabled. */
> +       GPIOD_LINE_BIAS_PULL_UP,
> +       /**< The internal pull-up bias is enabled. */
> +       GPIOD_LINE_BIAS_PULL_DOWN,
> +       /**< The internal pull-down bias is enabled. */
> +};
> +
>  /**
>   * @brief Read the GPIO line offset.
>   * @param line GPIO line object.
> @@ -697,6 +867,14 @@ int gpiod_line_direction(struct gpiod_line *line) GPIOD_API;
>   */
>  int gpiod_line_active_state(struct gpiod_line *line) GPIOD_API;
>
> +/**
> + * @brief Read the GPIO line bias setting.
> + * @param line GPIO line object.
> + * @return Returns GPIOD_LINE_BIAS_PULL_UP, GPIOD_LINE_BIAS_PULL_DOWN,
> + *         GPIOD_LINE_BIAS_DISABLE or GPIOD_LINE_BIAS_AS_IS.
> + */
> +int gpiod_line_bias(struct gpiod_line *line) GPIOD_API;
> +
>  /**
>   * @brief Check if the line is currently in use.
>   * @param line GPIO line object.
> @@ -792,6 +970,12 @@ enum {
>         /**< The line is an open-source port. */
>         GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW      = GPIOD_BIT(2),
>         /**< The active state of the line is low (high is the default). */
> +       GPIOD_LINE_REQUEST_FLAG_BIAS_DISABLE    = GPIOD_BIT(3),
> +       /**< The line has neither either pull-up nor pull-down resistor */
> +       GPIOD_LINE_REQUEST_FLAG_BIAS_PULL_DOWN  = GPIOD_BIT(4),
> +       /**< The line has pull-down resistor enabled */
> +       GPIOD_LINE_REQUEST_FLAG_BIAS_PULL_UP    = GPIOD_BIT(5),
> +       /**< The line has pull-up resistor enabled */
>  };
>
>  /**
> diff --git a/lib/core.c b/lib/core.c
> index f05e595..9b7d88f 100644
> --- a/lib/core.c
> +++ b/lib/core.c
> @@ -36,9 +36,7 @@ struct gpiod_line {
>         unsigned int offset;
>         int direction;
>         int active_state;
> -       bool used;
> -       bool open_source;
> -       bool open_drain;
> +       __u32 flags;
>
>         int state;
>         bool needs_update;
> @@ -359,19 +357,31 @@ int gpiod_line_active_state(struct gpiod_line *line)
>         return line->active_state;
>  }
>
> +int gpiod_line_bias(struct gpiod_line *line)
> +{
> +       if (line->flags & GPIOLINE_FLAG_BIAS_DISABLE)
> +               return GPIOD_LINE_BIAS_DISABLE;
> +       if (line->flags & GPIOLINE_FLAG_BIAS_PULL_UP)
> +               return GPIOD_LINE_BIAS_PULL_UP;
> +       if (line->flags & GPIOLINE_FLAG_BIAS_PULL_DOWN)
> +               return GPIOD_LINE_BIAS_PULL_DOWN;
> +
> +       return GPIOD_LINE_BIAS_AS_IS;
> +}
> +
>  bool gpiod_line_is_used(struct gpiod_line *line)
>  {
> -       return line->used;
> +       return line->flags & GPIOLINE_FLAG_KERNEL;
>  }
>
>  bool gpiod_line_is_open_drain(struct gpiod_line *line)
>  {
> -       return line->open_drain;
> +       return line->flags & GPIOLINE_FLAG_OPEN_DRAIN;
>  }
>
>  bool gpiod_line_is_open_source(struct gpiod_line *line)
>  {
> -       return line->open_source;
> +       return line->flags & GPIOLINE_FLAG_OPEN_SOURCE;
>  }
>
>  bool gpiod_line_needs_update(struct gpiod_line *line)
> @@ -398,9 +408,7 @@ int gpiod_line_update(struct gpiod_line *line)
>                                                 ? GPIOD_LINE_ACTIVE_STATE_LOW
>                                                 : GPIOD_LINE_ACTIVE_STATE_HIGH;
>
> -       line->used = info.flags & GPIOLINE_FLAG_KERNEL;
> -       line->open_drain = info.flags & GPIOLINE_FLAG_OPEN_DRAIN;
> -       line->open_source = info.flags & GPIOLINE_FLAG_OPEN_SOURCE;
> +       line->flags = info.flags;
>
>         strncpy(line->name, info.name, sizeof(line->name));
>         strncpy(line->consumer, info.consumer, sizeof(line->consumer));
> @@ -473,6 +481,12 @@ static __u32 line_request_flag_to_gpio_handleflag(int flags)
>                 hflags |= GPIOHANDLE_REQUEST_OPEN_SOURCE;
>         if (flags & GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW)
>                 hflags |= GPIOHANDLE_REQUEST_ACTIVE_LOW;
> +       if (flags & GPIOD_LINE_REQUEST_FLAG_BIAS_DISABLE)
> +               hflags |= GPIOHANDLE_REQUEST_BIAS_DISABLE;
> +       if (flags & GPIOD_LINE_REQUEST_FLAG_BIAS_PULL_DOWN)
> +               hflags |= GPIOHANDLE_REQUEST_BIAS_PULL_DOWN;
> +       if (flags & GPIOD_LINE_REQUEST_FLAG_BIAS_PULL_UP)
> +               hflags |= GPIOHANDLE_REQUEST_BIAS_PULL_UP;
>
>         return hflags;
>  }
> diff --git a/lib/ctxless.c b/lib/ctxless.c
> index ba85018..44f1872 100644
> --- a/lib/ctxless.c
> +++ b/lib/ctxless.c
> @@ -14,6 +14,26 @@
>  #include <stdio.h>
>  #include <string.h>
>
> +static int ctxless_flags_to_line_request_flags(bool active_low, int flags)
> +{
> +       int lflags = 0;
> +
> +       if (active_low)
> +               lflags |= GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW;
> +       if (flags & GPIOD_CTXLESS_FLAG_OPEN_DRAIN)
> +               lflags |= GPIOD_LINE_REQUEST_FLAG_OPEN_DRAIN;
> +       if (flags & GPIOD_CTXLESS_FLAG_OPEN_SOURCE)
> +               lflags |= GPIOD_LINE_REQUEST_FLAG_OPEN_SOURCE;
> +       if (flags & GPIOD_CTXLESS_FLAG_BIAS_DISABLE)
> +               lflags |= GPIOD_LINE_REQUEST_FLAG_BIAS_DISABLE;
> +       if (flags & GPIOD_CTXLESS_FLAG_BIAS_PULL_UP)
> +               lflags |= GPIOD_LINE_REQUEST_FLAG_BIAS_PULL_UP;
> +       if (flags & GPIOD_CTXLESS_FLAG_BIAS_PULL_DOWN)
> +               lflags |= GPIOD_LINE_REQUEST_FLAG_BIAS_PULL_DOWN;
> +
> +       return lflags;
> +}
> +
>  int gpiod_ctxless_get_value(const char *device, unsigned int offset,
>                             bool active_low, const char *consumer)
>  {
> @@ -27,16 +47,45 @@ int gpiod_ctxless_get_value(const char *device, unsigned int offset,
>         return value;
>  }
>
> +int gpiod_ctxless_get_value_ext(const char *device, unsigned int offset,
> +                               bool active_low, int flags,
> +                               const char *consumer)
> +{
> +       int value, rv;
> +
> +       rv = gpiod_ctxless_get_value_multiple_ext(device, &offset, &value, 1,
> +                                                 active_low, flags, consumer);
> +       if (rv < 0)
> +               return rv;
> +
> +       return value;
> +}
> +
>  int gpiod_ctxless_get_value_multiple(const char *device,
>                                      const unsigned int *offsets, int *values,
>                                      unsigned int num_lines, bool active_low,
>                                      const char *consumer)
> +{
> +       int rv;
> +
> +       rv = gpiod_ctxless_get_value_multiple_ext(device, offsets, values,
> +                                                 num_lines, active_low, 0,
> +                                                 consumer);
> +       return rv;
> +}
> +
> +int gpiod_ctxless_get_value_multiple_ext(const char *device,
> +                                        const unsigned int *offsets,
> +                                        int *values,
> +                                        unsigned int num_lines,
> +                                        bool active_low, int flags,
> +                                        const char *consumer)
>  {
>         struct gpiod_line_bulk bulk;
>         struct gpiod_chip *chip;
>         struct gpiod_line *line;
>         unsigned int i;
> -       int rv, flags;
> +       int rv, lflags;
>
>         if (!num_lines || num_lines > GPIOD_LINE_BULK_MAX_LINES) {
>                 errno = EINVAL;
> @@ -59,9 +108,8 @@ int gpiod_ctxless_get_value_multiple(const char *device,
>                 gpiod_line_bulk_add(&bulk, line);
>         }
>
> -       flags = active_low ? GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW : 0;
> -
> -       rv = gpiod_line_request_bulk_input_flags(&bulk, consumer, flags);
> +       lflags = ctxless_flags_to_line_request_flags(active_low, flags);
> +       rv = gpiod_line_request_bulk_input_flags(&bulk, consumer, lflags);
>         if (rv < 0) {
>                 gpiod_chip_close(chip);
>                 return -1;
> @@ -83,17 +131,39 @@ int gpiod_ctxless_set_value(const char *device, unsigned int offset, int value,
>                                                 active_low, consumer, cb, data);
>  }
>
> +int gpiod_ctxless_set_value_ext(const char *device, unsigned int offset,
> +                               int value, bool active_low, int flags,
> +                               const char *consumer,
> +                               gpiod_ctxless_set_value_cb cb, void *data)
> +{
> +       return gpiod_ctxless_set_value_multiple_ext(device, &offset, &value,
> +                                                   1, active_low, flags,
> +                                                   consumer, cb, data);
> +}
> +
>  int gpiod_ctxless_set_value_multiple(const char *device,
>                                      const unsigned int *offsets,
>                                      const int *values, unsigned int num_lines,
>                                      bool active_low, const char *consumer,
>                                      gpiod_ctxless_set_value_cb cb, void *data)
> +{
> +       return gpiod_ctxless_set_value_multiple_ext(device, offsets, values,
> +                                                   num_lines, active_low,
> +                                                   0, consumer, cb, data);
> +}
> +
> +int gpiod_ctxless_set_value_multiple_ext(
> +                       const char *device,
> +                       const unsigned int *offsets,
> +                       const int *values, unsigned int num_lines,
> +                       bool active_low, int flags, const char *consumer,
> +                       gpiod_ctxless_set_value_cb cb, void *data)
>  {
>         struct gpiod_line_bulk bulk;
>         struct gpiod_chip *chip;
>         struct gpiod_line *line;
>         unsigned int i;
> -       int rv, flags;
> +       int rv, lflags;
>
>         if (!num_lines || num_lines > GPIOD_LINE_BULK_MAX_LINES) {
>                 errno = EINVAL;
> @@ -116,10 +186,9 @@ int gpiod_ctxless_set_value_multiple(const char *device,
>                 gpiod_line_bulk_add(&bulk, line);
>         }
>
> -       flags = active_low ? GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW : 0;
> -
> +       lflags = ctxless_flags_to_line_request_flags(active_low, flags);
>         rv = gpiod_line_request_bulk_output_flags(&bulk, consumer,
> -                                                 flags, values);
> +                                                 lflags, values);
>         if (rv < 0) {
>                 gpiod_chip_close(chip);
>                 return -1;
> @@ -216,6 +285,19 @@ int gpiod_ctxless_event_monitor(const char *device, int event_type,
>                                                     poll_cb, event_cb, data);
>  }
>
> +int gpiod_ctxless_event_monitor_ext(const char *device, int event_type,
> +                                   unsigned int offset, bool active_low,
> +                                   int flags, const char *consumer,
> +                                   const struct timespec *timeout,
> +                                   gpiod_ctxless_event_poll_cb poll_cb,
> +                                   gpiod_ctxless_event_handle_cb event_cb,
> +                                   void *data)
> +{
> +       return gpiod_ctxless_event_monitor_multiple_ext(
> +                       device, event_type, &offset, 1, active_low,
> +                       flags, consumer, timeout, poll_cb, event_cb, data);
> +}
> +
>  int gpiod_ctxless_event_monitor_multiple(
>                         const char *device, int event_type,
>                         const unsigned int *offsets,
> @@ -225,6 +307,21 @@ int gpiod_ctxless_event_monitor_multiple(
>                         gpiod_ctxless_event_poll_cb poll_cb,
>                         gpiod_ctxless_event_handle_cb event_cb,
>                         void *data)
> +{
> +       return gpiod_ctxless_event_monitor_multiple_ext(
> +                       device, event_type, offsets,
> +                       num_lines, active_low, 0, consumer, timeout,
> +                       poll_cb, event_cb, data);
> +}
> +
> +int gpiod_ctxless_event_monitor_multiple_ext(
> +                       const char *device, int event_type,
> +                       const unsigned int *offsets,
> +                       unsigned int num_lines, bool active_low, int flags,
> +                       const char *consumer, const struct timespec *timeout,
> +                       gpiod_ctxless_event_poll_cb poll_cb,
> +                       gpiod_ctxless_event_handle_cb event_cb,
> +                       void *data)
>  {
>         struct gpiod_ctxless_event_poll_fd fds[GPIOD_LINE_BULK_MAX_LINES];
>         struct gpiod_line_request_config conf;
> @@ -259,7 +356,7 @@ int gpiod_ctxless_event_monitor_multiple(
>                 gpiod_line_bulk_add(&bulk, line);
>         }
>
> -       conf.flags = active_low ? GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW : 0;
> +       conf.flags = ctxless_flags_to_line_request_flags(active_low, flags);
>         conf.consumer = consumer;
>
>         if (event_type == GPIOD_CTXLESS_EVENT_RISING_EDGE) {
> --
> 2.24.0
>

  reply	other threads:[~2019-11-18 13:51 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-15 14:43 [libgpiod] [PATCH 00/19] Add support for bias flags and SET_CONFIG Kent Gibson
2019-11-15 14:43 ` [libgpiod] [PATCH 01/19] core: move request flag to handle flag conversion into a separate function Kent Gibson
2019-11-15 14:43 ` [libgpiod] [PATCH 02/19] API: add support for bias flags Kent Gibson
2019-11-18 13:51   ` Bartosz Golaszewski [this message]
2019-11-18 14:12     ` Kent Gibson
2019-11-15 14:43 ` [libgpiod] [PATCH 03/19] core: fix misspelling of parameter Kent Gibson
2019-11-15 14:43 ` [libgpiod] [PATCH 04/19] tests: add tests for bias flags Kent Gibson
2019-11-18 13:51   ` Bartosz Golaszewski
2019-11-18 14:14     ` Kent Gibson
2019-11-15 14:43 ` [libgpiod] [PATCH 05/19] bindings: cxx: drop noexcept from direction and active_state Kent Gibson
2019-11-15 14:43 ` [libgpiod] [PATCH 06/19] bindings: cxx: initialise bitset with integer instead of string Kent Gibson
2019-11-18 13:51   ` Bartosz Golaszewski
2019-11-18 14:17     ` Kent Gibson
2019-11-15 14:43 ` [libgpiod] [PATCH 07/19] bindings: cxx: add support for bias flags Kent Gibson
2019-11-15 14:43 ` [libgpiod] [PATCH 08/19] bindings: cxx: tests: add tests " Kent Gibson
2019-11-15 14:43 ` [libgpiod] [PATCH 09/19] bindings: python: add support " Kent Gibson
2019-11-15 14:43 ` [libgpiod] [PATCH 10/19] bindings: python: tests: add tests " Kent Gibson
2019-11-15 14:43 ` [libgpiod] [PATCH 11/19] API: add support for SET_CONFIG Kent Gibson
2019-11-18 13:52   ` Bartosz Golaszewski
2019-11-18 14:48     ` Kent Gibson
2019-11-19 15:52       ` Kent Gibson
2019-11-20 11:00         ` Bartosz Golaszewski
2019-11-20 13:58           ` Kent Gibson
2019-11-20 14:08             ` Bartosz Golaszewski
2019-11-20 14:13               ` Kent Gibson
2019-11-20 14:18                 ` Bartosz Golaszewski
2019-11-20 14:36                   ` Kent Gibson
2019-11-20 15:18                     ` Bartosz Golaszewski
2019-11-21  0:34                       ` Kent Gibson
2019-11-21  7:13                         ` Bartosz Golaszewski
2019-11-21  7:46                           ` Kent Gibson
2019-11-21  8:46                             ` Bartosz Golaszewski
2019-11-21  9:30                               ` Kent Gibson
2019-11-21 10:03                                 ` Bartosz Golaszewski
2019-11-21 10:18                                   ` Kent Gibson
2019-11-21 10:27                                     ` Bartosz Golaszewski
2019-11-21 10:31                                       ` Bartosz Golaszewski
2019-11-21 11:07                                         ` Kent Gibson
2019-11-21 15:22                                           ` Bartosz Golaszewski
2019-11-21 10:59                                       ` Kent Gibson
2019-11-21 15:20                                         ` Bartosz Golaszewski
2019-11-15 14:43 ` [libgpiod] [PATCH 12/19] tests: add tests " Kent Gibson
2019-11-15 14:43 ` [libgpiod] [PATCH 13/19] core: allow gpiod_line_set_value_bulk to accept null values Kent Gibson
2019-11-15 14:43 ` [libgpiod] [PATCH 14/19] bindings: cxx: add support for SET_CONFIG Kent Gibson
2019-11-15 14:43 ` [libgpiod] [PATCH 15/19] bindings: cxx: tests: add tests for SET_CONFIG methods Kent Gibson
2019-11-15 14:43 ` [libgpiod] [PATCH 16/19] bindings: python: add support for SET_CONFIG Kent Gibson
2019-11-15 14:43 ` [libgpiod] [PATCH 17/19] bindings: python: tests: add tests for SET_CONFIG methods Kent Gibson
2019-11-15 14:43 ` [libgpiod] [PATCH 18/19] tools: add support for bias flags Kent Gibson
2019-11-16 15:40   ` Kent Gibson
2019-11-17 12:18     ` Bartosz Golaszewski
2019-11-17 12:28       ` Kent Gibson
2019-11-17 13:12         ` Kent Gibson
2019-11-15 14:43 ` [libgpiod] [PATCH 19/19] treewide: change "correspond with" to "correspond to" Kent Gibson
2019-11-18 13:52   ` Bartosz Golaszewski
2019-11-18 15:01     ` Kent Gibson
2019-11-18 13:50 ` [libgpiod] [PATCH 00/19] Add support for bias flags and SET_CONFIG Bartosz Golaszewski
2019-11-18 14:09   ` Kent Gibson
2019-11-18 14:55     ` Bartosz Golaszewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAMpxmJXRuRmE9-9mk9uv47kviMUO=+oEgPO0KtVB77JW8M_AYg@mail.gmail.com' \
    --to=bgolaszewski@baylibre.com \
    --cc=linux-gpio@vger.kernel.org \
    --cc=warthog618@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).