qemu-gpiodev/libgpiod.git
8 years agocore: rename direction defines
Bartosz Golaszewski [Wed, 4 Jan 2017 16:55:26 +0000 (17:55 +0100)]
core: rename direction defines

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: remove redundant memset()
Bartosz Golaszewski [Wed, 4 Jan 2017 16:54:15 +0000 (17:54 +0100)]
core: remove redundant memset()

The request structure is already zeroed by zalloc().

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: put the line request configuration into a structure
Bartosz Golaszewski [Wed, 4 Jan 2017 16:52:26 +0000 (17:52 +0100)]
core: put the line request configuration into a structure

The base routine for line requesting should have all config parameters
packed in a single structure. Future request helpers will simplify
this.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: remove different gpiod_line_request() versions
Bartosz Golaszewski [Wed, 4 Jan 2017 16:42:32 +0000 (17:42 +0100)]
core: remove different gpiod_line_request() versions

Until the request API is considered stable, remove all the request
helpers.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: rename GPIOD_MAX_LINES
Bartosz Golaszewski [Wed, 4 Jan 2017 16:17:03 +0000 (17:17 +0100)]
core: rename GPIOD_MAX_LINES

This define specifies the maximum number of lines that can be
requested in a single operation. Make it clear with the new name.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: implement public line update routines
Bartosz Golaszewski [Wed, 4 Jan 2017 16:09:28 +0000 (17:09 +0100)]
core: implement public line update routines

Line info is retrieved from the kernel for the first time
automatically when gpiod_chip_get_line() is called. Then the line
is updated automatically on request/release. If the ioctl fails in the
latter case, the up_to_date flag is set to false.

Expose an interface allowing users to check if a line is up-to-date
and manually update it if needed.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agomisc: add a TODO file
Bartosz Golaszewski [Tue, 3 Jan 2017 21:29:35 +0000 (22:29 +0100)]
misc: add a TODO file

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: add input/output flavors of bulk request routines
Bartosz Golaszewski [Tue, 3 Jan 2017 17:25:05 +0000 (18:25 +0100)]
core: add input/output flavors of bulk request routines

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: merge the direction argument into flags for request routines
Bartosz Golaszewski [Tue, 3 Jan 2017 17:20:09 +0000 (18:20 +0100)]
core: merge the direction argument into flags for request routines

There's no reason to keep the direction as a separate argument if we
have polarity configured using the flags argument. We have separate
routines for input/output requests anyway.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agobuild: add dependencies to Makefile.am
Bartosz Golaszewski [Tue, 3 Jan 2017 10:22:44 +0000 (11:22 +0100)]
build: add dependencies to Makefile.am

This fixes the build with multiple make jobs.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: implement gpiod_line_polarity()
Bartosz Golaszewski [Tue, 3 Jan 2017 10:17:19 +0000 (11:17 +0100)]
core: implement gpiod_line_polarity()

Instead of returning a boolean value from gpiod_line_is_active_low(),
introduce two separate values as is done for direction and implement
gpiod_line_polarity(). This makes the code less confusing.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogpiodetect: use the correct gpiod_chip_open() flavor
Bartosz Golaszewski [Mon, 2 Jan 2017 17:05:19 +0000 (18:05 +0100)]
gpiodetect: use the correct gpiod_chip_open() flavor

gpiod_chip_iter_next() should use gpiod_chip_open_by_name() internally
when opening chips by dentry->d_name.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: code shrink
Bartosz Golaszewski [Mon, 2 Jan 2017 17:02:16 +0000 (18:02 +0100)]
core: code shrink

Reuse the bulk routines for single lines too. This unduplicates
a lot of code.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: coding style fix
Bartosz Golaszewski [Mon, 2 Jan 2017 16:51:04 +0000 (17:51 +0100)]
core: coding style fix

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: remove gpiod_simple_set_value()
Bartosz Golaszewski [Mon, 2 Jan 2017 16:49:35 +0000 (17:49 +0100)]
core: remove gpiod_simple_set_value()

This has been removed from gpiod.h and doesn't even work. Remove the
definition from core.c.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: add bulk operations
Bartosz Golaszewski [Mon, 2 Jan 2017 16:42:47 +0000 (17:42 +0100)]
core: add bulk operations

Add versions of the request/release and get/set value operations for
bundles of GPIO lines.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: update line info after a line request
Bartosz Golaszewski [Mon, 2 Jan 2017 15:23:24 +0000 (16:23 +0100)]
core: update line info after a line request

Currently the line information isn't updated after it's been
requested. Re-read the line info after requesting it.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: add libgpiod-specific error numbers
Bartosz Golaszewski [Mon, 2 Jan 2017 15:05:59 +0000 (16:05 +0100)]
core: add libgpiod-specific error numbers

In order to better report error conditions to users, we need a set
of libgpiod-specific errnos. Extend the previous API to be able to
use both regular errno and GPIO-related error numbers together.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: clamp GPIO values to either 1 or 0
Bartosz Golaszewski [Mon, 2 Jan 2017 14:55:30 +0000 (15:55 +0100)]
core: clamp GPIO values to either 1 or 0

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogpioset: drop the call to gpiod_line_set_value()
Bartosz Golaszewski [Mon, 2 Jan 2017 14:50:28 +0000 (15:50 +0100)]
gpioset: drop the call to gpiod_line_set_value()

This is not needed as we already pass the default value to
gpiod_line_request_dout();

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: fix a default value bug when requesting a GPIO line
Bartosz Golaszewski [Mon, 2 Jan 2017 14:49:31 +0000 (15:49 +0100)]
core: fix a default value bug when requesting a GPIO line

The direction is stored in the 'direction' argument, not in flags.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogpiod.h: remove GPIOD_ARRAY_SIZE()
Bartosz Golaszewski [Mon, 2 Jan 2017 14:02:50 +0000 (15:02 +0100)]
gpiod.h: remove GPIOD_ARRAY_SIZE()

This macro is only used by gpioinfo and is not relevant for the GPIO
API. Remove it from gpiod.h and define it directly in gpioinfo.c.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: don't set the error number if zalloc() fails
Bartosz Golaszewski [Mon, 2 Jan 2017 13:56:46 +0000 (14:56 +0100)]
core: don't set the error number if zalloc() fails

zalloc() is implemented locally and already sets the error number on
failure.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: release all lines in gpiod_chip_close()
Bartosz Golaszewski [Mon, 2 Jan 2017 13:55:25 +0000 (14:55 +0100)]
core: release all lines in gpiod_chip_close()

This fixes a memory leak if the user forgets to explicitly release
requested lines.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: dynamically allocate memory for GPIO line request data
Bartosz Golaszewski [Mon, 2 Jan 2017 13:51:01 +0000 (14:51 +0100)]
core: dynamically allocate memory for GPIO line request data

For bulk requests, the lines will share the struct gpiohandle_request
object. Instead of it being a part of struct gpiod_line, allocate its
memory dynamically and only store the pointer in the line context
structure.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: rename two fields of struct gpiod_line
Bartosz Golaszewski [Mon, 2 Jan 2017 13:27:35 +0000 (14:27 +0100)]
core: rename two fields of struct gpiod_line

Drop the 'l' prefix - it's clear the fields are part of a GPIO line
structure.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agocore: ioctl() code shrink
Bartosz Golaszewski [Mon, 2 Jan 2017 13:06:03 +0000 (14:06 +0100)]
core: ioctl() code shrink

Wrap GPIO ioctl() calls in a routine setting the libgpiod errno in
case of an error.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agoerror: add internal wrappers for setting libgpiod errno
Bartosz Golaszewski [Mon, 2 Jan 2017 13:01:13 +0000 (14:01 +0100)]
error: add internal wrappers for setting libgpiod errno

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agodocumentation: add Doxyfile
Bartosz Golaszewski [Mon, 2 Jan 2017 11:41:52 +0000 (12:41 +0100)]
documentation: add Doxyfile

Add doxygen configuration and a new target to Makefile.am to generate
documentation. Also: update gitignore.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agolibgpiod: use a per-thread variable for storing errors
Bartosz Golaszewski [Mon, 2 Jan 2017 12:31:58 +0000 (13:31 +0100)]
libgpiod: use a per-thread variable for storing errors

The kernel-like trick with embedding error numbers in pointers can't
be guaranteed to work on all architectures. Use a per-thread variable
instead and add corresponding routines to access it.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agobuild: define _GNU_SOURCE for .c files
Bartosz Golaszewski [Mon, 2 Jan 2017 12:30:58 +0000 (13:30 +0100)]
build: define _GNU_SOURCE for .c files

This is needed for asprintf().

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agolibgpiod: add a simple README
Bartosz Golaszewski [Mon, 2 Jan 2017 10:44:35 +0000 (11:44 +0100)]
libgpiod: add a simple README

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agogitignore: ignore files generated by autotools
Bartosz Golaszewski [Mon, 2 Jan 2017 10:25:52 +0000 (11:25 +0100)]
gitignore: ignore files generated by autotools

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agobuild: add autotools configuration
Bartosz Golaszewski [Mon, 2 Jan 2017 10:23:20 +0000 (11:23 +0100)]
build: add autotools configuration

This allows to build the library and programs using autotools.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
8 years agolibgpiod: initial commit
Bartosz Golaszewski [Mon, 26 Dec 2016 21:54:01 +0000 (22:54 +0100)]
libgpiod: initial commit

This adds four basic tools and implements core functionalities.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>