From: Bartosz Golaszewski Date: Mon, 9 Jan 2017 12:23:00 +0000 (+0100) Subject: core: new error number X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=76ad46ef425c70e25ab797c4db93f85c20a173c6;p=qemu-gpiodev%2Flibgpiod.git core: new error number 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 --- diff --git a/core.c b/core.c index a55de83..2ccd6ad 100644 --- 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 c4f08c7..f490671 100644 --- 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. */ };