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

169 Commits

Author SHA1 Message Date
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
Bartosz Golaszewski
7a9dae7e32 core: implement gpiod_line_close_chip()
This function works nicely with gpiod_line_find_by_name() which
returns a line object whose owning chip must be later freed by the
caller. With this routine the caller can skip creating a temporary
chip object.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-09-28 09:54:10 +02:00
Bartosz Golaszewski
699e747b1a simple-api: improve the naming convention
Discern between the callback arguments and return values by renaming
relevant defines.

Also: prefix all simple API defines with GPIOD_SIMPLE_.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-09-27 11:44:09 +02:00
Bartosz Golaszewski
2eff5f51e6 core: new public macro
Export GPIOD_UNUSED in gpiod.h as it may be useful for users not
using all arguments in certain callback functions.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-09-27 11:10:38 +02:00
Bartosz Golaszewski
a7ee495b12 simple: rework the event loop
Implement a new routine for monitoring multiple lines with the simple
event loop and extend the simple loop interface with custom polling
capabilities.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-09-27 10:01:12 +02:00
Bartosz Golaszewski
52bfc4f2aa core: add gpiod_line_bulk_get_line()
Add a getter function for retrieving line handles from bulk objects.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-09-24 22:06:31 +02:00
Bartosz Golaszewski
57fb030d30 core: rename gpiod_line_is_used_by_kernel()
The UAPI flag checked by this routine is called GPIOLINE_FLAG_KERNEL
but its name may be a bit misleading. When set, it can mean that the
line is used by the kernel or by another user space process.

Use a more general name: gpiod_line_is_used().

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-09-24 10:48:14 +02:00
Bartosz Golaszewski
986612c331 gpiod.h: improve the documentation for gpiod_line_iter_last_offset()
Mention the undefined behavior if gpiod_line_iter_last_offset() is
ever called before gpiod_line_iter_next().

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-07-14 13:25:40 +02:00
Bartosz Golaszewski
b88b5c99b7 gpiod.h: extend the introduction to the simple API
Add more info on the simple API functions.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-07-14 12:58:47 +02:00
Bartosz Golaszewski
83040631d6 gpiod.h: move the mainpage doxygen comment down
Move it to where the libgpiod declarations begin.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-07-14 12:45:51 +02:00
Bartosz Golaszewski
5571ba17ce core: add the offset argument to the simple event loop callback
In preparation for introducing a multiple lines variant of the simple
event loop routine, add the offset argument to the callback prototype.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-07-13 18:09:17 +02:00
Bartosz Golaszewski
3a903b5abb core: add bulk event requests
Add functions for requesting events for line bulk objects. Both with
and without additional flags.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-07-13 13:54:27 +02:00
Bartosz Golaszewski
abec0c89e5 core: remove the active_low argument from line bulk requests
We previously removed this argument from routines dealing with single
line requests. Do the same for bulk requests.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-07-13 13:29:27 +02:00
Bartosz Golaszewski
47d97c70ac core: remove the active_low boolean argument from single-line requests
Remove the separate argument for setting the active-state to low in
helper functions doing the single GPIO line requests.

Introduce new variants of these helpers that allow to pass
a combination of all available flags to the request.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-07-12 20:41:09 +02:00
Bartosz Golaszewski
8e164e9926 core: set the active state using the request flags
Having to always set the active state in the line request config
structure makes users create unnecessary boilerplate code. Remove the
active state field from the config structure and add a new flag, which
when set, sets the active state to low, while high is the default.

This patch updates the main request function and all the callers - we
still need to update all the helper request routines.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-07-12 20:17:01 +02:00
Bartosz Golaszewski
59bfd579eb gpiod.h: remove the separate doxygen group for events
Much of the event functionality has been merged with regular GPIO line
definitions. We no longer need a separate group for events in the
documentation.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-07-12 19:18:24 +02:00
Bartosz Golaszewski
9c5c2ad29f gpiod.h: move the chip operations before line definitions
Chip operations should come earlier in the public header.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-07-12 19:15:40 +02:00
Bartosz Golaszewski
091d36e360 libgpiod: unify the header comments
Make the header comment look the same in every file. Move additional
descriptions of files' contents below the header.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-07-12 17:22:09 +02:00
Bartosz Golaszewski
54dba79b42 event: rename event requests routines
The event request functionality is now merged with the regular
requests. Change the naming pattern for event requests and move the
prototypes under the input and output requests.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-07-10 10:27:40 +02:00
Bartosz Golaszewski
fb1700c470 core: merge event requests with regular line requests
Requesting the lines both for reading/setting values as well as for
watching events will now be done using the gpiod_line_request_*()
family of functions.

This is the first part of changes required to fully convert the API.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-07-06 11:11:36 +02:00
Bartosz Golaszewski
27a58a919f simple-api: reposition the prototypes in the public header
Move the 'multiple' variants below the single value ones.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-07-06 11:11:36 +02:00
Bartosz Golaszewski
0799d0b934 core: kill gpiod_line_event_release()
We can (and already do in gpiod_chip_close()) easily figure out if
a GPIO line was configured for events or values, so there's no need
to have a separate release function for events.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-07-06 11:11:36 +02:00
Bartosz Golaszewski
67ce942331 simple API: un-inline simple API routines
Try to avoid inline functions in the public header wherever possible.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-07-06 11:11:36 +02:00
Bartosz Golaszewski
cc0b3fac72 core: kill custom error handling
The libgpiod-specific error codes are not really necessary and can be
easily replaced with regular libc error numbers defined in errno.h.

Remove all routines and definitions dealing with error numbers and
switch to using errnos in the library code.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-07-06 11:11:36 +02:00
Bartosz Golaszewski
d15edb03d1 core: remove doxygen hack
Keep gpiod.h clean - pull _gpiod_line_event_request_type() into
core.c and un-inline the gpiod_line_event_request_*() routines.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-03-01 22:16:56 +01:00
Bartosz Golaszewski
47b7f3cb24 core: don't expose designated initializers in the library header
We don't know who might want to include gpiod.h, so let's try to avoid
any C99 extensions in the header.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-03-01 17:51:26 +01:00