core: remove the active_low argument from line bulk requests
authorBartosz Golaszewski <bartekgola@gmail.com>
Thu, 13 Jul 2017 11:29:27 +0000 (13:29 +0200)
committerBartosz Golaszewski <bartekgola@gmail.com>
Thu, 13 Jul 2017 11:29:27 +0000 (13:29 +0200)
We previously removed this argument from routines dealing with single
line requests. Do the same for bulk requests.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
include/gpiod.h
src/lib/core.c
src/lib/simple.c
tests/tests-line.c

index c7a0335dfceea2854d0ee90d48fb319a01cf2c24..828f8245344151f21dd20d8fc396c385d6a72be2 100644 (file)
@@ -604,25 +604,45 @@ int gpiod_line_request_bulk(struct gpiod_line_bulk *bulk,
  * @brief Reserve a set of GPIO lines, set the direction to input.
  * @param bulk Set of GPIO lines to reserve.
  * @param consumer Name of the consumer.
- * @param active_low Active state of the lines (true if low).
  * @return 0 if the lines were properly reserved, -1 on failure.
  */
 int gpiod_line_request_bulk_input(struct gpiod_line_bulk *bulk,
-                                 const char *consumer,
-                                 bool active_low) GPIOD_API;
+                                 const char *consumer) GPIOD_API;
 
 /**
  * @brief Reserve a set of GPIO lines, set the direction to output.
  * @param bulk Set of GPIO lines to reserve.
  * @param consumer Name of the consumer.
- * @param active_low Active state of the lines (true if low).
  * @param default_vals Default line values.
  * @return 0 if the lines were properly reserved, -1 on failure.
  */
 int gpiod_line_request_bulk_output(struct gpiod_line_bulk *bulk,
-                                  const char *consumer, bool active_low,
+                                  const char *consumer,
                                   const int *default_vals) GPIOD_API;
 
+/**
+ * @brief Reserve a set of GPIO lines, set the direction to input.
+ * @param bulk Set of GPIO lines to reserve.
+ * @param consumer Name of the consumer.
+ * @param flags Additional request flags.
+ * @return 0 if the lines were properly reserved, -1 on failure.
+ */
+int gpiod_line_request_bulk_input_flags(struct gpiod_line_bulk *bulk,
+                                       const char *consumer,
+                                       int flags) GPIOD_API;
+
+/**
+ * @brief Reserve a set of GPIO lines, set the direction to output.
+ * @param bulk Set of GPIO lines to reserve.
+ * @param consumer Name of the consumer.
+ * @param flags Additional request flags.
+ * @param default_vals Default line values.
+ * @return 0 if the lines were properly reserved, -1 on failure.
+ */
+int gpiod_line_request_bulk_output_flags(struct gpiod_line_bulk *bulk,
+                                        const char *consumer, int flags,
+                                        const int *default_vals) GPIOD_API;
+
 /**
  * @brief Release a previously reserved line.
  * @param line GPIO line object.
index 49efefaf8bacfa14a984bd4a36ffabcefa845f79..96b0d2cc789620a0b542555e890ae0d88113c13d 100644 (file)
@@ -668,25 +668,48 @@ int gpiod_line_request_bulk(struct gpiod_line_bulk *bulk,
 }
 
 int gpiod_line_request_bulk_input(struct gpiod_line_bulk *bulk,
-                                 const char *consumer, bool active_low)
+                                 const char *consumer)
 {
        struct gpiod_line_request_config config = {
                .consumer = consumer,
                .request_type = GPIOD_REQUEST_DIRECTION_INPUT,
-               .flags = active_low ? GPIOD_REQUEST_ACTIVE_LOW : 0,
        };
 
        return gpiod_line_request_bulk(bulk, &config, 0);
 }
 
 int gpiod_line_request_bulk_output(struct gpiod_line_bulk *bulk,
-                                  const char *consumer, bool active_low,
+                                  const char *consumer,
                                   const int *default_vals)
 {
        struct gpiod_line_request_config config = {
                .consumer = consumer,
                .request_type = GPIOD_REQUEST_DIRECTION_OUTPUT,
-               .flags = active_low ? GPIOD_REQUEST_ACTIVE_LOW: 0,
+       };
+
+       return gpiod_line_request_bulk(bulk, &config, default_vals);
+}
+
+int gpiod_line_request_bulk_input_flags(struct gpiod_line_bulk *bulk,
+                                       const char *consumer, int flags)
+{
+       struct gpiod_line_request_config config = {
+               .consumer = consumer,
+               .request_type = GPIOD_REQUEST_DIRECTION_INPUT,
+               .flags = flags,
+       };
+
+       return gpiod_line_request_bulk(bulk, &config, 0);
+}
+
+int gpiod_line_request_bulk_output_flags(struct gpiod_line_bulk *bulk,
+                                        const char *consumer, int flags,
+                                        const int *default_vals)
+{
+       struct gpiod_line_request_config config = {
+               .consumer = consumer,
+               .request_type = GPIOD_REQUEST_DIRECTION_OUTPUT,
+               .flags = flags,
        };
 
        return gpiod_line_request_bulk(bulk, &config, default_vals);
index 0f81d1c8e913d2fd3394d02e16b4af790b335604..90ea6ed8952c6613b04a03f9a8a58fcec09af918 100644 (file)
@@ -35,8 +35,8 @@ int gpiod_simple_get_value_multiple(const char *consumer, const char *device,
        struct gpiod_line_bulk bulk;
        struct gpiod_chip *chip;
        struct gpiod_line *line;
+       int status, flags;
        unsigned int i;
-       int status;
 
        if (num_lines > GPIOD_REQUEST_MAX_LINES) {
                errno = EINVAL;
@@ -59,7 +59,9 @@ int gpiod_simple_get_value_multiple(const char *consumer, const char *device,
                gpiod_line_bulk_add(&bulk, line);
        }
 
-       status = gpiod_line_request_bulk_input(&bulk, consumer, active_low);
+       flags = active_low ? GPIOD_REQUEST_ACTIVE_LOW : 0;
+
+       status = gpiod_line_request_bulk_input_flags(&bulk, consumer, flags);
        if (status < 0) {
                gpiod_chip_close(chip);
                return -1;
@@ -92,8 +94,8 @@ int gpiod_simple_set_value_multiple(const char *consumer, const char *device,
        struct gpiod_line_bulk bulk;
        struct gpiod_chip *chip;
        struct gpiod_line *line;
+       int status, flags;
        unsigned int i;
-       int status;
 
        if (num_lines > GPIOD_REQUEST_MAX_LINES) {
                errno = EINVAL;
@@ -116,8 +118,10 @@ int gpiod_simple_set_value_multiple(const char *consumer, const char *device,
                gpiod_line_bulk_add(&bulk, line);
        }
 
-       status = gpiod_line_request_bulk_output(&bulk, consumer,
-                                               active_low, values);
+       flags = active_low ? GPIOD_REQUEST_ACTIVE_LOW : 0;
+
+       status = gpiod_line_request_bulk_output_flags(&bulk, consumer,
+                                                     flags, values);
        if (status < 0) {
                gpiod_chip_close(chip);
                return -1;
index 368275e56f13789e2286048a854b161615a0cdaa..596cbb59e4ad8b9cfa393cc82a4d2d48022c26ef 100644 (file)
@@ -173,16 +173,14 @@ static void line_request_bulk_output(void)
        valA[1] = 0;
        valA[2] = 0;
        valA[3] = 1;
-       status = gpiod_line_request_bulk_output(&bulkA, TEST_CONSUMER,
-                                               false, valA);
+       status = gpiod_line_request_bulk_output(&bulkA, TEST_CONSUMER, valA);
        TEST_ASSERT_RET_OK(status);
 
        valB[0] = 0;
        valB[1] = 1;
        valB[2] = 0;
        valB[3] = 1;
-       status = gpiod_line_request_bulk_output(&bulkB, TEST_CONSUMER,
-                                               false, valB);
+       status = gpiod_line_request_bulk_output(&bulkB, TEST_CONSUMER, valB);
        TEST_ASSERT_RET_OK(status);
 
        memset(valA, 0, sizeof(valA));