From: Bartosz Golaszewski Date: Thu, 5 Jan 2017 16:48:53 +0000 (+0100) Subject: core: naming convention tweaks X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=07edb8314025c0f1ff83695f68a5be003151b4be;p=qemu-gpiodev%2Flibgpiod.git core: naming convention tweaks Change naming of some routines and variables dealing with line requests. This makes their purpose more obvious. Signed-off-by: Bartosz Golaszewski --- diff --git a/core.c b/core.c index 4fa9d0d..a5a201b 100644 --- a/core.c +++ b/core.c @@ -135,8 +135,8 @@ int gpiod_simple_get_value(const char *device, unsigned int offset) } struct gpiod_line { - bool requested; - bool event_requested; + bool reserved; + bool event_configured; bool up_to_date; struct gpiod_chip *chip; struct gpioline_info info; @@ -298,7 +298,7 @@ int gpiod_line_request_bulk(struct gpiod_line_bulk *line_bulk, line = line_bulk->lines[i]; line->req = req; - line->requested = true; + line->reserved = true; /* * Update line info to include the changes after the * request. @@ -334,7 +334,7 @@ void gpiod_line_release_bulk(struct gpiod_line_bulk *line_bulk) line = line_bulk->lines[i]; line->req = NULL; - line->requested = false; + line->reserved = false; status = gpiod_line_update(line); if (status < 0) @@ -342,9 +342,9 @@ void gpiod_line_release_bulk(struct gpiod_line_bulk *line_bulk) } } -bool gpiod_line_is_requested(struct gpiod_line *line) +bool gpiod_line_is_reserved(struct gpiod_line *line) { - return line->requested; + return line->reserved; } static bool line_bulk_is_requested(struct gpiod_line_bulk *line_bulk) @@ -352,7 +352,7 @@ static bool line_bulk_is_requested(struct gpiod_line_bulk *line_bulk) unsigned int i; for (i = 0; i < line_bulk->num_lines; i++) { - if (!gpiod_line_is_requested(line_bulk->lines[i])) + if (!gpiod_line_is_reserved(line_bulk->lines[i])) return false; } @@ -439,7 +439,7 @@ int gpiod_line_event_request(struct gpiod_line *line, struct gpiod_chip *chip; int status, fd; - if (line->event_requested) + if (line->event_configured) return -EBUSY; req = &line->event; @@ -472,7 +472,7 @@ int gpiod_line_event_request(struct gpiod_line *line, if (status < 0) return -1; - line->event_requested = true; + line->event_configured = true; return 0; } @@ -480,12 +480,12 @@ int gpiod_line_event_request(struct gpiod_line *line, void gpiod_line_event_release(struct gpiod_line *line) { close(line->event.fd); - line->event_requested = false; + line->event_configured = false; } -bool gpiod_line_event_is_requested(struct gpiod_line *line) +bool gpiod_line_event_configured(struct gpiod_line *line) { - return line->event_requested; + return line->event_configured; } int gpiod_line_event_wait(struct gpiod_line *line, @@ -553,7 +553,7 @@ int gpiod_line_event_wait_bulk(struct gpiod_line_bulk *bulk, int gpiod_line_event_get_fd(struct gpiod_line *line) { - return line->event_requested ? line->event.fd : -1; + return line->event_configured ? line->event.fd : -1; } struct gpiod_chip @@ -650,7 +650,7 @@ void gpiod_chip_close(struct gpiod_chip *chip) unsigned int i; for (i = 0; i < chip->cinfo.lines; i++) { - if (chip->lines[i].requested) + if (chip->lines[i].reserved) gpiod_line_release(&chip->lines[i]); } diff --git a/gpiod.h b/gpiod.h index 59ca33c..ed8da70 100644 --- a/gpiod.h +++ b/gpiod.h @@ -304,21 +304,24 @@ struct gpiod_line_request_config { }; /** - * @brief Request a single line. + * @brief Reserve a single line. * @param line GPIO line object. * @param config Request options. * @param default_val Default line value - only relevant if we're setting * the direction to output. - * @return 0 if the line was properly requested. In case of an error this + * @return 0 if the line was properly reserved. In case of an error this * routine returns -1 and sets the last error number. + * + * Is this routine succeeds, the caller takes posession of the GPIO line until + * it's released. */ int gpiod_line_request(struct gpiod_line *line, const struct gpiod_line_request_config *config, int default_val) GPIOD_API; /** - * @brief Request a set of GPIO lines. - * @param line_bulk Set of GPIO lines to request. + * @brief Reserve a set of GPIO lines. + * @param line_bulk Set of GPIO lines to reserve. * @param config Request options. * @param default_vals Default line values - only relevant if we're setting * the direction to output. @@ -330,23 +333,23 @@ int gpiod_line_request_bulk(struct gpiod_line_bulk *line_bulk, int *default_vals) GPIOD_API; /** - * @brief Release a previously requested line. + * @brief Release a previously reserved line. * @param line GPIO line object. */ void gpiod_line_release(struct gpiod_line *line) GPIOD_API; /** - * @brief Release a set of previously requested lines. + * @brief Release a set of previously reserved lines. * @param line_bulk Set of GPIO lines to release. */ void gpiod_line_release_bulk(struct gpiod_line_bulk *line_bulk) GPIOD_API; /** - * @brief Check if the line was requested. + * @brief Check if the line is reserved by the calling user. * @param line GPIO line object. * @return True if given line was requested, false otherwise. */ -bool gpiod_line_is_requested(struct gpiod_line *line) GPIOD_API; +bool gpiod_line_is_reserved(struct gpiod_line *line) GPIOD_API; int gpiod_line_get_value(struct gpiod_line *line) GPIOD_API; @@ -390,7 +393,7 @@ int gpiod_line_event_request(struct gpiod_line *line, void gpiod_line_event_release(struct gpiod_line *line) GPIOD_API; -bool gpiod_line_event_is_requested(struct gpiod_line *line) GPIOD_API; +bool gpiod_line_event_configured(struct gpiod_line *line) GPIOD_API; int gpiod_line_event_wait(struct gpiod_line *line, const struct timespec *timeout,