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

94 Commits

Author SHA1 Message Date
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
Bartosz Golaszewski
b3eb355472 simple-api: modify the order of arguments in get value routines
Move the consumer string to the end of the argument list as the least
significant option.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-10-11 17:53:32 +02:00
Bartosz Golaszewski
9cbe16952f simple-api: allow the simple event loop callback to indicate an error
Add a new return value for the simple event loop callback which, when
returned, makes the loop function return a negative value indicating
an error.

Include new test cases.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-10-11 17:40:50 +02:00
Bartosz Golaszewski
b96ddf1635 simple-api: improve documentation
Mention the meaning of a positive value returned from the polling
callback of the simple event loop routines.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-10-11 17:01:04 +02:00
Bartosz Golaszewski
07698f9950 simple-api: handle receiving multiple events
Make the simple event loop poll callback capable of signalling to the
caller that more than one event occurred. Make the event loop routine
for multiple lines aware of that so that it reads all the event data
queued up instead of needlessly polling in that case.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-10-11 16:47:12 +02:00
Bartosz Golaszewski
23f7bc07f3 simple-api: use correct prefixes for callback typedefs
We want to have all simple-api-related symbols prefixed with
gpiod_simple_.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-10-11 14:20:54 +02:00
Bartosz Golaszewski
ac2891d920 event: rework gpiod_line_event_wait_bulk()
When monitoring more than one line, it's possible for two or more
events to be queued at the same time in the kernel, so the internal
call to ppoll() will return a value greater than 1. If we always only
read one event at most, we end up calling ppoll() needlessly, as we
already know more events are pending.

Allow gpiod_line_event_wait_bulk() to pass a list of all lines on
which events occurred via a line bulk object.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-10-11 11:31:54 +02:00
Bartosz Golaszewski
5f20e77479 line: provide gpiod_line_bulk_foreach_line()
Add a macro allowing to easily iterate over all lines held by a line
bulk object.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-10-04 09:07:44 +02:00
Bartosz Golaszewski
404968c9f5 core: provide gpiod_line_bulk_num_lines()
Add an inline routine allowing to retrieve the number of lines held by
a line bulk object.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-10-02 15:16:44 +02:00
Bartosz Golaszewski
8eb243de96 doc: split the documentation for GPIO lines into smaller chunks
Create separate sections for bulk, info, requests, values, events and
misc routines and data structures for GPIO lines.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-10-02 15:04:12 +02:00
Bartosz Golaszewski
9f2b813ed0 core: group the GCC attributes together
Put the defines wrapping the gcc attributes in the same place
in gpiod.h.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-10-02 14:48:03 +02:00
Bartosz Golaszewski
69facaaf0e iter: improve the naming of line iterator constants
These three constants define the possible line iterator states. Make
their names reflect that.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-10-02 14:46:17 +02:00
Bartosz Golaszewski
9f856266ea line: rename the constant defining the max size of a bulk line object
Stay in line with other prefixes and change it to
GPIOD_LINE_BULK_MAX_LINES.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-10-02 14:41:49 +02:00
Bartosz Golaszewski
944d44339d line: use a common prefix for all line defines
Prefix all constants used by line functions with GPIOD_LINE_.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-10-02 14:40:26 +02:00
Bartosz Golaszewski
be50e25235 simple-api: provide gpiod_simple_find_line()
Implement a simple API function for looking up GPIO lines. Include
a set of test cases.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-09-29 19:17:37 +02:00
Bartosz Golaszewski
1cef8332ae core: provide gpiod_line_get()
Provide a routine which simplifies the process of getting the handle
for a single GPIO line by encapsulating the calls opening the chip and
retrieving the line handle in a single function.

Implement test cases as well.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-09-29 18:47:51 +02:00
Bartosz Golaszewski
d477b96778 core: rework gpiod_line_find()
Use gpiod_chip_find_line() internally for smaller code. Return NULL
if an error occurrs during the lookup. Update the documentation.

While we're at it: update the tests for line lookups.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-09-29 18:35:28 +02:00
Bartosz Golaszewski
f147847391 core: rename gpiod_line_find_by_name()
Shorten the name of the line lookup routine as any other type of
lookup wouldn't make sense anyway.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-09-29 18:20:30 +02:00
Bartosz Golaszewski
1a6a61cbe1 core: implement gpiod_chip_find_line()
The low-level line lookup should be more fine-grained. As the first
step: introduce a routine performing a line lookup for specific chip.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-09-29 17:15:36 +02:00