treewide: remove ctxless API
Subsystems (2)
PATCH 1/2 core: provide gpiod_line_bulk_clear()
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
Provide a helper function that allows to reset an existing bulk object.
--- include/gpiod.h | 6 ++++++ lib/core.c | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-)
include/gpiod.h +6 -0
@@ -649,6 +649,12 @@ gpiod_chip_find_lines(struct gpiod_chip *chip, const char **names) GPIOD_API;*/ struct gpiod_line_bulk *gpiod_line_bulk_new (unsigned int max_lines)GPIOD_API ; +/** +* @brief Reset a bulk object. Remove all lines and set size to 0. +* @param bulk Bulk object to reset. +*/ +void gpiod_line_bulk_clear(struct gpiod_line_bulk *bulk) GPIOD_API; +/** * @brief Release all resources allocated for this bulk object. * @param bulk Bulk object to free.
lib/core.c +7 -1
@@ -106,12 +106,18 @@ struct gpiod_line_bulk *gpiod_line_bulk_new(unsigned int max_lines)if (!bulk)return NULL ; -memset (bulk,0 , size); bulk->max_lines = max_lines; +gpiod_line_bulk_clear (bulk);return bulk; } +void gpiod_line_bulk_clear (struct gpiod_line_bulk *bulk) +{ + bulk->num_lines =0 ; +memset (bulk->lines,0 , bulk->max_lines *sizeof (struct line *)); +} +void gpiod_line_bulk_free (struct gpiod_line_bulk *bulk) {free (bulk);
Signature · 1 line
2.29.1
PATCH 2/2 ctxless: drop all context-less interfaces
In reply to Bartosz GolaszewskiFrom: Bartosz Golaszewski <[email protected]>
The context-less family of functions seems to be largely unused. Drop this part of the codebase and convert tools to using the regular low-level API.
--- include/gpiod.h | 406 --------------------------------- lib/Makefile.am | 2 +- lib/ctxless.c | 456 ------------------------------------- tests/Makefile.am | 1 - tests/tests-ctxless.c | 375 ------------------------------ tools/gpio-tools-test.bats | 12 +- tools/gpiofind.c | 25 +- tools/gpioget.c | 36 ++- tools/gpiomon.c | 177 +++++++------- tools/gpioset.c | 42 +++- tools/tools-common.c | 6 +- 11 files changed, 169 insertions(+), 1369 deletions(-) delete mode 100644 lib/ctxless.c delete mode 100644 tests/tests-ctxless.c
include/gpiod.h +0 -406
@@ -74,412 +74,6 @@ struct gpiod_line_bulk_iter;*/ #define GPIOD_BIT (nr) (1UL << (nr)) -/** -* @} -* -* @defgroup high_level High-level API -* @{ -* -* Simple high-level routines for straightforward GPIO manipulation without -* 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. -* @param offset Offset of the GPIO line. -* @param active_low The active state of this line - true if low. -* @param consumer Name of the consumer. -* @return 0 or 1 (GPIO value) if the operation succeeds, -1 on error. -*/ -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 consumer Name of the consumer. -* @param flags The flags for the line. -* @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, const char *consumer, - int flags) 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 the lines - true if low. -* @param consumer Name of the consumer. -* @return 0 if the operation succeeds, -1 on error. -*/ -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) 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 consumer Name of the consumer. -* @param flags The flags for the lines. -* @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, const char *consumer, - int flags) GPIOD_API; - -/** -* @brief Simple set value callback signature. -*/ -typedef void (*gpiod_ctxless_set_value_cb )(void *); - -/** -* @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 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(const char *device, unsigned int offset, int value, - bool active_low, const char *consumer, - 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 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. -* @param flags The flags for the line. -* @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, - const char *consumer, - gpiod_ctxless_set_value_cb cb, - void *data, int flags) 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 the lines - true if low. -* @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(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) 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 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. -* @param flags The flags for the lines. -* @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, -const char *consumer, -gpiod_ctxless_set_value_cb cb, - void *data, int flags) GPIOD_API; - -/** - * @brief Event types that the ctxless event monitor can wait for. - */ -enum { -/**< Wait for rising edge events only. */ -GPIOD_CTXLESS_EVENT_RISING_EDGE =1 , -/**< Wait for falling edge events only. */ -GPIOD_CTXLESS_EVENT_FALLING_EDGE , -/**< Wait for both types of events. */ - GPIOD_CTXLESS_EVENT_BOTH_EDGES, -}; - -/** -* @brief Event types that can be passed to the ctxless event callback. -*/ -enum { -GPIOD_CTXLESS_EVENT_CB_TIMEOUT =1 , -/**< Waiting for events timed out. */ -GPIOD_CTXLESS_EVENT_CB_RISING_EDGE , -/**< Rising edge event occured. */ -GPIOD_CTXLESS_EVENT_CB_FALLING_EDGE , -/**< Falling edge event occured. */ -}; - -/** -* @brief Return status values that the ctxless event callback can return. -*/ -enum { -GPIOD_CTXLESS_EVENT_CB_RET_ERR =-1 , -/**< Stop processing events and indicate an error. */ -GPIOD_CTXLESS_EVENT_CB_RET_OK =0 , -/**< Continue processing events. */ -GPIOD_CTXLESS_EVENT_CB_RET_STOP =1 , -/**< Stop processing events. */ -}; - -/** -* @brief Simple event callback signature. -* -* The callback function takes the following arguments: event type (int), -* GPIO line offset (unsigned int), event timestamp (const struct timespec *) -* and a pointer to user data (void *). -* -* This callback is called by the ctxless event loop functions for each GPIO -* event. If the callback returns ::GPIOD_CTXLESS_EVENT_CB_RET_ERR, it should -* also set errno. -*/ -typedef int (*gpiod_ctxless_event_handle_cb )(int ,unsigned int , -const struct timespec *,void *); - -/** -* @brief Return status values that the ctxless event poll callback can return. -* -* Positive value returned from the polling callback indicates the number of -* events that occurred on the set of monitored lines. -*/ -enum { -GPIOD_CTXLESS_EVENT_POLL_RET_STOP =-2 , -/**< The event loop should stop processing events. */ -GPIOD_CTXLESS_EVENT_POLL_RET_ERR =-1 , -/**< Polling error occurred (the polling function should set errno). */ -GPIOD_CTXLESS_EVENT_POLL_RET_TIMEOUT =0 , -/**< Poll timed out. */ -}; - -/** -* @brief Helper structure for the ctxless event loop poll callback. -*/ -struct gpiod_ctxless_event_poll_fd { -int fd; -/**< File descriptor number. */ -bool event; -/**< Indicates whether an event occurred on this file descriptor. */ -}; - -/** -* @brief Simple event poll callback signature. -* -* The poll callback function takes the following arguments: number of lines -* (unsigned int), an array of file descriptors on which input events should -* be monitored (struct gpiod_ctxless_event_poll_fd *), poll timeout -* (const struct timespec *) and a pointer to user data (void *). -* -* The callback should poll for input events on the set of descriptors and -* return an appropriate value that can be interpreted by the event loop -* routine. -*/ -typedef int (*gpiod_ctxless_event_poll_cb )(unsigned int , -struct gpiod_ctxless_event_poll_fd *, -const struct timespec *,void *); - -/** -* @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 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(const char *device, int event_type, - unsigned int offset, bool active_low, - 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 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 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. -* @param flags The flags for the line. -* @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, - const char *consumer, - const struct timespec *timeout, - gpiod_ctxless_event_poll_cb poll_cb, - gpiod_ctxless_event_handle_cb event_cb, - void *data, int flags) 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 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( - const char *device, int event_type, - const unsigned int *offsets, - unsigned int num_lines, bool active_low, - 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. -* @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 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. -* @param flags The flags for the lines. -* @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, - const char *consumer, const struct timespec *timeout, - gpiod_ctxless_event_poll_cb poll_cb, - gpiod_ctxless_event_handle_cb event_cb, - void *data, int flags) 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. -* @param chipname Buffer in which the name of the GPIO chip will be stored. -* @param chipname_size Size of the chip name buffer. -* @param offset Pointer to an integer in which the line offset will be stored. -* @return -1 on error, 0 if the line with given name doesn't exist and 1 if -* the line was found. In the first two cases the contents of chipname -* and offset remain unchanged. -* @note The chip name is truncated if the buffer can't hold its entire size. -* @attention GPIO line names are not unique in the linux kernel, neither -* globally nor within a single chip. This function finds the first -* line with given name. -*/ -int gpiod_ctxless_find_line(const char *name, char *chipname, - size_t chipname_size, - unsigned int *offset) GPIOD_API; -/** * @} *
lib/Makefile.am +1 -1
@@ -7,7 +7,7 @@ # lib_LTLIBRARIES = libgpiod.la -libgpiod_la_SOURCES = core.c ctxless.c helpers.c iter.c misc.c +libgpiod_la_SOURCES = core.c helpers.c iter.c misc.c libgpiod_la_CFLAGS = -Wall -Wextra -g -std=gnu89 libgpiod_la_CFLAGS += -fvisibility=hidden -I$(top_srcdir)/include/ libgpiod_la_CFLAGS += -include $(top_builddir)/config.h
lib/ctxless.c deleted +0 -456
456 lines not on this page · raw message
tests/Makefile.am +0 -1
@@ -24,7 +24,6 @@ gpiod_test_SOURCES = \ gpiod-test.h \ tests-bulk.c \ tests-chip.c \ - tests-ctxless.c \ tests-event.c \ tests-iter.c \ tests-line.c \
tests/tests-ctxless.c deleted +0 -375
375 lines not on this page · raw message
tools/gpio-tools-test.bats +6 -6
@@ -375,7 +375,7 @@ teardown() { run_tool gpioget "$(gpio_mockup_chip_name 1)" 0 1 2 3 4 test "$status" -eq "1" - output_regex_match ".*error reading GPIO values" + output_regex_match ".*unable to retrieve GPIO lines from chip" } @test "gpioget: same line twice" {
@@ -384,7 +384,7 @@ teardown() { run_tool gpioget "$(gpio_mockup_chip_name 1)" 0 0 test "$status" -eq "1" - output_regex_match ".*error reading GPIO values.*" + output_regex_match ".*unable to request lines.*" } @test "gpioget: invalid bias" {
@@ -583,7 +583,7 @@ teardown() { run_tool gpioset "$(gpio_mockup_chip_name 1)" 0=1 1=1 2=1 3=1 4=1 5=1 test "$status" -eq "1" - output_regex_match ".*error setting the GPIO line values" + output_regex_match ".*unable to retrieve GPIO lines from chip" } @test "gpioset: use --sec without --mode=time" {
@@ -664,7 +664,7 @@ teardown() { run_tool gpioset "$(gpio_mockup_chip_name 1)" 0=1 0=1 test "$status" -eq "1" - output_regex_match ".*error setting the GPIO line values.*" + output_regex_match ".*unable to request lines.*" } #
@@ -884,7 +884,7 @@ teardown() { run_tool gpiomon "$(gpio_mockup_chip_name 1)" 0 0 test "$status" -eq "1" - output_regex_match ".*error waiting for events.*" + output_regex_match ".*unable to request GPIO lines for events" } @test "gpiomon: no arguments" {
@@ -909,7 +909,7 @@ teardown() { run_tool gpiomon "$(gpio_mockup_chip_name 0)" 5 test "$status" -eq "1" - output_regex_match ".*error waiting for events" + output_regex_match ".*unable to retrieve GPIO lines from chip" } @test "gpiomon: invalid bias" {
tools/gpiofind.c +16 -9
@@ -5,6 +5,7 @@* Copyright (C) 2017-2018 Bartosz Golaszewski <[email protected]> */ +#include <errno.h> #include <getopt.h> #include <gpiod.h> #include <stdio.h>
@@ -33,9 +34,9 @@ static void print_help(void)int main (int argc,char **argv) { -unsigned int offset; -int optc, opti, rv; -char chip[32 ]; +int optc, opti, ret =EXIT_SUCCESS ; +struct gpiod_chip *chip; +struct gpiod_line *line;for (;;) { optc =getopt_long (argc, argv, shortopts, longopts, &opti);
@@ -62,13 +63,19 @@ int main(int argc, char **argv)if (argc !=1 )die ("exactly one GPIO line name must be specified" ); - rv =gpiod_ctxless_find_line (argv[0 ], chip,sizeof (chip), &offset); -if (rv <0 ) + line =gpiod_line_find (argv[0 ]); +if (!line) { +if (errno ==ENOENT ) +return EXIT_FAILURE ; +die_perror ("error performing the line lookup" ); -else if (rv ==0 ) -return EXIT_FAILURE ; + } + + chip =gpiod_line_get_chip (line); + +printf ("%s %u\n" ,gpiod_chip_name (chip),gpiod_line_offset (line)); -printf ("%s %u\n" , chip, offset); +gpiod_chip_close (chip); -return EXIT_SUCCESS ; +return ret; }
tools/gpioget.c +28 -8
@@ -42,10 +42,11 @@ static void print_help(void)int main (int argc,char **argv) { +struct gpiod_line_request_config config; +int *values, optc, opti, rv, flags =0 ;unsigned int *offsets, i, num_lines; -int *values, optc, opti, rv; -bool active_low = false; -int flags =0 ; +struct gpiod_line_bulk *lines; +struct gpiod_chip *chip;char *device, *end;for (;;) {
@@ -61,10 +62,10 @@ int main(int argc, char **argv)print_version ();return EXIT_SUCCESS ;case 'l' : - active_low = true; + flags |=GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW ;break ;case 'B' : - flags =bias_flags (optarg); + flags |=bias_flags (optarg);break ;case '?' :die ("try %s --help" ,get_progname ());
@@ -96,9 +97,25 @@ int main(int argc, char **argv)die ("invalid GPIO offset: %s" , argv[i +1 ]); } - rv =gpiod_ctxless_get_value_multiple_ext (device, offsets, values, - num_lines, active_low, -"gpioget" , flags); + chip =gpiod_chip_open_lookup (device); +if (!chip) +die_perror ("unable to open %s" , device); + + lines =gpiod_chip_get_lines (chip, offsets, num_lines); +if (!lines) +die_perror ("unable to retrieve GPIO lines from chip" ); + +memset (&config,0 ,sizeof (config)); + + config.consumer ="gpioget" ; + config.request_type =GPIOD_LINE_REQUEST_DIRECTION_INPUT ; + config.flags = flags; + + rv =gpiod_line_request_bulk (lines, &config,NULL ); +if (rv) +die_perror ("unable to request lines" ); + + rv =gpiod_line_get_value_bulk (lines, values);if (rv <0 )die_perror ("error reading GPIO values" );
@@ -109,6 +126,9 @@ int main(int argc, char **argv) }printf ("\n" ); +gpiod_line_release_bulk (lines); +gpiod_chip_close (chip); +gpiod_line_bulk_free (lines);free (values);free (offsets);
tools/gpiomon.c +85 -92
252 lines not on this page · raw message
tools/gpioset.c +30 -12
76 lines not on this page · raw message
tools/tools-common.c +3 -3
@@ -63,11 +63,11 @@ void print_version(void)int bias_flags (const char *option) {if (strcmp (option,"pull-down" ) ==0 ) -return GPIOD_CTXLESS_FLAG_BIAS_PULL_DOWN ; +return GPIOD_LINE_REQUEST_FLAG_BIAS_PULL_DOWN ;if (strcmp (option,"pull-up" ) ==0 ) -return GPIOD_CTXLESS_FLAG_BIAS_PULL_UP ; +return GPIOD_LINE_REQUEST_FLAG_BIAS_PULL_UP ;if (strcmp (option,"disable" ) ==0 ) -return GPIOD_CTXLESS_FLAG_BIAS_DISABLE ; +return GPIOD_LINE_REQUEST_FLAG_BIAS_DISABLE ;if (strcmp (option,"as-is" ) !=0 )die ("invalid bias: %s" , option);return 0 ;
Signature · 1 line
2.29.1
cover treewide: remove ctxless API
From: Bartosz Golaszewski <[email protected]>
As I mentioned in another thread: the context-less API seems to be unused outside the gpio-tools. There's no reason to keep it in v2 then. Let's remove it and convert gpio-tools to regular API.
The tools are converted in a rather quick and dirty way because I don't want to spend a lot of time on something that'll be modified soon once we convert the library to using uAPI v2.
All tests still pass.
Bartosz Golaszewski (2):
core: provide gpiod_line_bulk_clear()
ctxless: drop all context-less interfaces
include/gpiod.h | 412 +-------------------------------- lib/Makefile.am | 2 +- lib/core.c | 8 +- lib/ctxless.c | 456 ------------------------------------- tests/Makefile.am | 1 - tests/tests-ctxless.c | 375 ------------------------------ tools/gpio-tools-test.bats | 12 +- tools/gpiofind.c | 25 +- tools/gpioget.c | 36 ++- tools/gpiomon.c | 177 +++++++------- tools/gpioset.c | 42 +++- tools/tools-common.c | 6 +- 12 files changed, 182 insertions(+), 1370 deletions(-) delete mode 100644 lib/ctxless.c delete mode 100644 tests/tests-ctxless.c
Signature · 1 line
2.29.1
Re: [libgpiod][PATCH 1/2] core: provide gpiod_line_bulk_clear()
In reply to Bartosz GolaszewskiQuoted 7 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Provide a helper function that allows to reset an existing bulk object.
Signed-off-by Bartosz Golaszewski <[email protected]>---
Looking at it now - it should have probably been called gpiod_line_bulk_reset(). I can change it when applying.
Bart
Quoted 33 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
As I mentioned in another thread: the context-less API seems to be unused outside the gpio-tools. There's no reason to keep it in v2 then. Let's remove it and convert gpio-tools to regular API.
The tools are converted in a rather quick and dirty way because I don't want to spend a lot of time on something that'll be modified soon once we convert the library to using uAPI v2.
All tests still pass.
Bartosz Golaszewski (2):
core: providegpiod_line_bulk_clear()
ctxless: drop all context-less interfacesinclude/gpiod.h | 412 +-------------------------------- lib/Makefile.am | 2 +- lib/core.c | 8 +- lib/ctxless.c | 456 ------------------------------------- tests/Makefile.am | 1 - tests/tests-ctxless.c | 375 ------------------------------ tools/gpio-tools-test.bats | 12 +- tools/gpiofind.c | 25 +- tools/gpioget.c | 36 ++- tools/gpiomon.c | 177 +++++++------- tools/gpioset.c | 42 +++- tools/tools-common.c | 6 +- 12 files changed, 182 insertions(+), 1370 deletions(-) delete mode 100644 lib/ctxless.c delete mode 100644 tests/tests-ctxless.c
Quoted 3 lines
--
2.29.1
If there are no objections, I intend to apply this tomorrow.
Bartosz