From: Bartosz Golaszewski <bartekgola@gmail.com>
Date: Thu, 13 Jul 2017 11:29:27 +0000 (+0200)
Subject: core: remove the active_low argument from line bulk requests
X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=abec0c89e57179a75382b53f2649eb32f05df159;p=qemu-gpiodev%2Flibgpiod.git

core: remove the active_low argument from line bulk requests

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>
---

diff --git a/include/gpiod.h b/include/gpiod.h
index c7a0335..828f824 100644
--- a/include/gpiod.h
+++ b/include/gpiod.h
@@ -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.
diff --git a/src/lib/core.c b/src/lib/core.c
index 49efefa..96b0d2c 100644
--- a/src/lib/core.c
+++ b/src/lib/core.c
@@ -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);
diff --git a/src/lib/simple.c b/src/lib/simple.c
index 0f81d1c..90ea6ed 100644
--- a/src/lib/simple.c
+++ b/src/lib/simple.c
@@ -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;
diff --git a/tests/tests-line.c b/tests/tests-line.c
index 368275e..596cbb5 100644
--- a/tests/tests-line.c
+++ b/tests/tests-line.c
@@ -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));