core: naming convention tweaks
authorBartosz Golaszewski <bartekgola@gmail.com>
Thu, 5 Jan 2017 16:48:53 +0000 (17:48 +0100)
committerBartosz Golaszewski <bartekgola@gmail.com>
Thu, 5 Jan 2017 16:48:53 +0000 (17:48 +0100)
Change naming of some routines and variables dealing with line
requests. This makes their purpose more obvious.

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

diff --git a/core.c b/core.c
index 4fa9d0db485c55c08966cfdac62ae7b7c949a16c..a5a201b7edb55d2a7858e01901852fea0a8524d1 100644 (file)
--- 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 59ca33c86676c07d33153e4c34c9c2849eba26c6..ed8da70bc826e7447c6a2101e8107d24542e5eb6 100644 (file)
--- 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,