core: new error number
authorBartosz Golaszewski <bartekgola@gmail.com>
Mon, 9 Jan 2017 12:23:00 +0000 (13:23 +0100)
committerBartosz Golaszewski <bartekgola@gmail.com>
Mon, 9 Jan 2017 12:23:00 +0000 (13:23 +0100)
Add an error number indicating that a bulk operation was requested
on a set of lines not belonging to the same gpiochip.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
core.c
gpiod.h

diff --git a/core.c b/core.c
index a55de83870d4b972624ec30159fd43d32b899c03..2ccd6adec83d550d10a41f161b224aa4c2b477ea 100644 (file)
--- a/core.c
+++ b/core.c
@@ -67,6 +67,7 @@ static __thread char errmsg[ERRSTR_MAX];
 static const char *const error_descr[] = {
        "success",
        "GPIO line not requested",
+       "GPIO lines in bulk don't belong to the same gpiochip",
 };
 
 static void set_last_error(int errnum)
@@ -345,9 +346,10 @@ int gpiod_line_request_bulk(struct gpiod_line_bulk *line_bulk,
        int status, fd;
        unsigned int i;
 
-       /* Paranoia: verify that all lines are from the same gpiochip. */
-       if (!verify_line_bulk(line_bulk))
+       if (!verify_line_bulk(line_bulk)) {
+               set_last_error(GPIOD_EBULKINCOH);
                return -1;
+       }
 
        req = zalloc(sizeof(*req));
        if (!req)
diff --git a/gpiod.h b/gpiod.h
index c4f08c7ae0a2165a3cc97db3e8d2fe18a1076cfa..f4906712be9a637f4b03149bbb8e40d954ccc6e1 100644 (file)
--- a/gpiod.h
+++ b/gpiod.h
@@ -79,6 +79,8 @@ enum {
        /**< No error. */
        GPIOD_EREQUEST,
        /**< The caller has no ownership of this line. */
+       GPIOD_EBULKINCOH,
+       /**< Not all lines in bulk belong to the same GPIO chip. */
        __GPIOD_MAX_ERR,
        /**< Private: number of libgpiod-specific error numbers. */
 };