1
0
mirror of https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git synced 2026-10-28 13:55:08 +03:00

112 Commits

Author SHA1 Message Date
Bartosz Golaszewski
1bdb669467 doc: improve the part about non-unique line names
The current comments for functions related to line lookups state that
"lines are not unique" but they're really supposed to say "line names
are not unqiue".

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
2020-09-15 17:31:44 +02:00
Alexander Stein
fc61e740fc doc: add @file to headers
It's necessary to have a file reference linked in the file list.
Also: strip the top_srcdir from paths

Signed-off-by: Alexander Stein <alexander.stein@mailbox.org>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
2020-08-13 21:06:52 +02:00
Alexander Stein
61c1557aa1 doc: fix doxygen warnings
Apparently __<name>__ is not supported for @defgroup commands anymore in
doxygen v1.8.19 (and possibly earlier versions). This results in the
following warning (printed multiple times):

gpiod.h:79: warning: group strong: ignoring title ">high_level</strong> High-level
API" that does not match old title ">common</strong> Common helper macros"

Also the module list is broken.

Fix this my removing the underscores.

Signed-off-by: Alexander Stein <alexander.stein@mailbox.org>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
2020-08-13 20:29:16 +02:00
Bartosz Golaszewski
a5cc6cc041 doc: document the reasons for deprecating interfaces
Use the @deprecated doxygen tag to mark deprecated functions and explain
why their usage is discouraged.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
2020-08-06 22:02:55 +02:00
Bartosz Golaszewski
9ffa2afd8c doc: document the caveat concerning line lookups
GPIO line names in the kernel aren't unique - neither globally nor
within a single chip. The current API doesn't take this into
consideration and simply returns the first matching line in
gpiod_line_find() and co.

This will be addressed in v2.0 but we can't fix it in v1.x without
introducing new interfaces and deprecating the ones that already exist.

Let's document this behavior in doxygen comments for all affected
routines.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
2020-08-06 21:55:37 +02:00
Kent Gibson
2efb0075a7 doc: fix comment mix up in gpiod.h
A couple of the doc comments for GPIOD_LINE_REQUEST_XX values document
the wrong value. Switch them so that they document the appropriate value.

Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
2020-05-27 14:05:59 +02:00
Bartosz Golaszewski
5f6d42a56d doc: improve the description of gpiod_line_event_read()
The description of gpiod_line_event_read() states that it reads the last
event that occurred for this line. This is not true: the kernel stores
the events in a FIFO and this function reads the next event from it.

Fix the confusing statement.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
2020-04-28 13:54:09 +02:00
Bartosz Golaszewski
ff4f2b965e doc: add descriptions for doxygen sub-sections
Add additional descriptions fox doxygen sub-sections under the line
section.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
2020-04-09 12:19:22 +02:00
Bartosz Golaszewski
44921ecc9a core: provide functions for reading multiple line events at once
The kernel allows us to read multiple (up to 16) line events with
a single read() call, but up to this point libgpiod only supported
reading one event at a time. Add two new functions that allow users
to read more events at the same time.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
2019-12-18 15:09:30 +01:00
Kent Gibson
da25df40dc doc: document gpiod_line_set_value_bulk NULL values behaviour
The handling of NULL values by gpiod_line_set_value_bulk has been changed
to interpret NULL as low values for all lines. This patch updates the
documentation of the function to describe that.

Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
2019-12-10 16:41:46 +01:00
Kent Gibson
12b73c7420 core: add support for SET_CONFIG
Extend the libgpiod API to support the setting line configuration using the
GPIO GPIOHANDLE_SET_CONFIG_IOCTL uAPI ioctl.

The core change is the addition of gpiod_line_set_config, which provides a
low level wrapper around the ioctl.

Additionally, higher level helper functions, gpiod_line_set_flags,
gpiod_line_set_direction_input, and gpiod_line_set_direction_output provide
slightly simplified APIs for common use cases.

Bulk forms of all functions are also provided.

Documented the fields of gpiod_line to better identify the purpose of
each where the field name alone is not sufficiently clear, and to
indicate which flags are applicable to each field.

Implementation includes a few helper functions that serve to keep the
code tidier and are consistent with similar helper functions already
present.

Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
2019-12-10 11:45:52 +01:00
Kent Gibson
26d8d8f0b7 core: add support for bias flags
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.

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>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
2019-12-09 17:45:41 +01:00
Bartosz Golaszewski
296444104b core: deprecate gpiod_needs_update()
This function and the logic behind have been introduced in an early
version of libgpiod for reasons that have been long forgotten.

When updating the line info after a line request fails, just propagate
the error out of the request function instead of setting the internal
needs_update variable. Drop the entire logic behind gpiod_needs_update(),
make this routine always return false and mark it as deprecated in the
header.

Suggested-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
2019-11-23 15:48:56 +01:00
Kent Gibson
bb3dc9eb2e treewide: change "correspond with" to "correspond to"
Trivial grammar fix. "correspond with" can mean either being in agreement
with, happening at the same time, or communication between parties.
"correspond to" is used to mean equivalance, which is the intended use
throughout the documentation.

Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
2019-11-18 15:46:12 +01:00
Kent Gibson
065c2a8b45 core: fix misspelling of parameter
Trivial fix to bring gpiod_ctxless_event_monitor_multiple() documentation
into line with gpiod_ctxless_event_monitor_multiple_ext().

Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
2019-11-18 15:25:36 +01:00
Bartosz Golaszewski
9462caf743 core: rename up_to_date to needs_update in struct gpiod_line
This variable is called up_to_date which can lead readers to the wrong
conclusion that libgpiod can somehow know when external actors (such as
a different process or a kernel driver) change the state of a GPIO line.

This is not the case and libgpiod only ever knows if a line needs info
update when a previous internal call to gpiod_line_update() fails.

The kernel does not provide any notification mechanism currently.

For that reason: rename the variable to needs_update.

While at it: clarify the documentation for gpiod_line_needs_update().

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
2019-09-10 10:43:24 +02:00
Bartosz Golaszewski
937ded4dbc treewide: order includes alphabetically
Unify the header includes by ordering them alphabetically and always
having local headers in a second group below the global ones (separated
by a newline).

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
2019-02-21 09:38:57 +01:00
Gasper Zejn
3599d34aee doc: C API documentation fixes
Fix a couple problems in doxygen documentation of the C API.

(Unfortunately no Signed-off-by tag from the submitter...)
[Bartosz: added a proper commit message]
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2018-11-13 18:41:04 +01:00
Bartosz Golaszewski
5095bdd01a API: mark context-less event loop functions as deprecated
Mark gpiod_ctxless_event_loop() and gpiod_ctxless_event_loop_multiple()
as deprecated. Those functions suffer from an issue where HW may not
allow setting up both rising and falling egde interrupts. All users
have been converted to using the new event monitor helpers.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2018-10-07 11:00:15 +02:00
Bartosz Golaszewski
99bc2260bd API: add a macro for marking deprecated functions
We want to deprecate the badly designed event loop functions. Introduce
a macro that allows marking API routines as deprecated.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2018-10-07 10:59:48 +02:00
Bartosz Golaszewski
61498a0ee5 ctxless: provide new event monitor
Current implementation of gpiod_ctxless_event_loop() (and its variant
for multiple lines) always requests GPIO lines for listening for both
rising and falling edge events. This causes a problem when the
underlying hardware doesn't allow this.

It can e.g. result in the following error raised by the interrupt
controller:

  genirq: Setting trigger mode 3 for irq 107 failed (kempld_irq_set_type+0x0/0x130 [gpio_kempld])

For the sake of backward compatibility we're leaving the old
implementation in place and provide two new routines that that take an
additional parameter allowing users to specify the events libgpiod
should listen for.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2018-10-07 10:34:26 +02:00
Bartosz Golaszewski
6639fb7709 doc: tweak the comment for gpiod_version_string()
Make it clear that this function returns the API version as we now have
separate API and ABI versions.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2018-05-16 10:11:57 +02:00
Bartosz Golaszewski
5da2e8d790 helpers: provide gpiod_chip_find_lines()
Implement a new helper that allows to look-up multiple GPIO lines by
their names. Include a set of test cases.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2018-05-14 12:00:24 +02:00
Bartosz Golaszewski
9616fa5cc9 include: use SPDX license identifier
Use the SPDX license identifier for LGPLv2.1 or later in the public
API header and the corresponding Makefile.am.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2018-03-04 10:50:11 +01:00
Bartosz Golaszewski
6b6bed27cc API: provide new line accessors
Add two new public functions that allow to retrieve multiple lines from
GPIO chips at once. Include test cases.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2018-02-22 21:15:43 +01:00
Bartosz Golaszewski
783ff2e3c7 API: start certain enums from 1
For enums describing direction & active state, event types etc. use 1
as the first value as it's easier to debug when all valid values are
different than in a zero-initialized data structure.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2018-02-19 10:06:07 +01:00
Bartosz Golaszewski
610a8111bc core: constify *values in gpiod_line_set_value_bulk()
The values in the array passed as argument to this routine are never
modified.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2018-02-03 16:06:47 +01:00
Bartosz Golaszewski
7b493a5019 doc: improve the doxygen description of default_val(s)
Users report being confused by the name 'default_val(s)' for function
parameters. Because it's in line with the kernel uAPI, we'll leave it
like this, but let's improve the documentation a bit by stating
explicitly that this parameter represents the initial values for
requested GPIO lines.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2018-01-29 17:10:54 +01:00
Bartosz Golaszewski
f27f85f607 doc: consistently break lines in @param's descriptions
When breaking the line in doxygen's @param descriptions, start the
next one after the param's name.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2018-01-26 11:02:37 +01:00
Bartosz Golaszewski
45c5fbf7c9 doc: explicitly state that the ctxless event poll callback can be NULL
This is mentioned later in the text, but state it in the argument's
description too.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2018-01-26 10:58:18 +01:00
Bartosz Golaszewski
3eb0c52ad5 doc: clarify that the high-level set value callback is optional
Users have reported it as confusing so make it clear.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2018-01-26 10:53:23 +01:00
Bartosz Golaszewski
7bddc61ae5 API: use gpiod_ctxless_ as prefix for the high-level API
As suggested by Linus Walleij: the word 'simple' is generally
subjective and the high-level routines provided by libgpiod are not
necessarily simple, but rather contextless, as they don't require any
resource managemend. Use 'gpiod_ctxless_' as prefix for all high-level
symbols.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2018-01-26 10:36:04 +01:00
Bartosz Golaszewski
7222ec048e all: fix various coding style issues
Make the entire code base more consistent with the linux kernel
coding style.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2018-01-19 11:40:37 +01:00
Bartosz Golaszewski
0704bcdbbf all: update the copyright notice
All these files have been updated in 2018.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2018-01-13 23:16:31 +01:00
Bartosz Golaszewski
7df216bf4d all: modify the license preamble in files
This project contains both a library and executables so it's better to
use an umbrella term "This program ..." than "This library ..." in all
the source files.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2018-01-10 01:50:36 +01:00
Bartosz Golaszewski
65f52d059d doc: minor documentation tweaks
Fix/tweak the in-code API documentation in a couple places.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2018-01-10 01:00:15 +01:00
SZ Lin
7d61309458 all: make license type consistent between source files and COPYING file
The license type of COPYING file is "LGPL-2.1+", but it is declared
as "LGPL-2.1" in the preamble of source files.

This patch fixes license type inconsistency issue in each source file.

Signed-off-by: SZ Lin <sz.lin@moxa.com>
[Bartosz: tweaked the commit message]
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-12-01 18:43:54 +01:00
Bartosz Golaszewski
57ecc14c4d core: change the prefix for line request flags
Make it clear that these are flags and that more than one can be used
simultaneously.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-11-17 17:51:45 +01:00
Bartosz Golaszewski
48c0caf08a core: coding style tweak
Remove one tab from the GPIOD_LINE_BULK_MAX_LINES definition.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-11-17 17:43:15 +01:00
Bartosz Golaszewski
dfe98084e2 iter: rework line iterator API
The changes roughly correspond with what we did for chip iterators.

Only perform operations that can fail in gpiod_line_iter_new(), so
that there's no need to check for errors after every call to
gpiod_line_iter_next().

Make gpiod_line_iter an opaque pointer and provide 'new' and 'free'
functions.

Update all users and relevant test cases. Extend the test API with
a new cleanup function.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-11-05 20:57:25 +01:00
Bartosz Golaszewski
1039b1cfb4 doc: update the descriptions for chip iterators
The 'next' routines for chip iterators can no longer fail. Update
the docs accordingly. Also: turn the extended description into a note
for the noclose variant.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-11-05 20:34:49 +01:00
Bartosz Golaszewski
230868dcfa iter: rework chip iterators
We can significantly simplify the chip iterators by performing all
actions that can yield an error in gpiod_chip_iter_new(). Instead of
opening each subsequent chip in gpiod_chip_iter_next(), open them all
in the new function and make next just return an active handle.

Fix relevant test cases and macros, remove related routines that are
no longer needed.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-11-04 23:18:26 +01:00
Bartosz Golaszewski
64daf40829 doc: update the documentation for events and iterators
Various documentation updates for iterator and event routines.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-11-03 18:12:50 +01:00
Bartosz Golaszewski
1439359dac doc: minor fix for line bulk loop macros
Make it clear in the @brief section what the difference is between the
two variants.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-10-24 14:48:54 +02:00
Bartosz Golaszewski
878b4f676b doc: improvements for the chip operations
Tweak the docs for the low-level chip API a bit.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-10-24 14:46:24 +02:00
Bartosz Golaszewski
5808092cbc doc: extend the documentation of the simple API
Fix some minor issues and tweak the style and doxygen markup.

Describe in detail the way the simple event loop works.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-10-24 11:31:16 +02:00
Bartosz Golaszewski
e567cb14f0 doc: extend the introduction
Add some additional info about the way the API is logically ordered
and a note on error handling.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-10-24 10:20:47 +02:00
Bartosz Golaszewski
5ba624dd69 core: implement gpiod_line_bulk_foreach_line_off()
Implement a variant of gpiod_line_bulk_foreach_line() which allows to
store the loop state in an integer counter variable.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-10-23 12:55:10 +02:00
Bartosz Golaszewski
996e9c37c4 simple-api: modify the order of arguments in simple loop routines
Move the consumer string after the active_low property.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-10-11 18:33:03 +02:00
Bartosz Golaszewski
b493015722 simple-api: modify the order of arguments in set value routines
Move the consumer string after the active_low property.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-10-11 18:10:31 +02:00