[libgpiod v2][PATCH 2/3] core: use num_values rather than num_lines when dealing with subsets of values

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



To be consistent with other usage, when getting or setting a subset of
requested line values, the array sizes should be named after the values
being accessed, not "lines" as that could be confused with the number of
lines in the request, not the subset.

Signed-off-by: Kent Gibson <warthog618@xxxxxxxxx>
---
 include/gpiod.h    | 14 +++++++-------
 lib/line-request.c | 12 ++++++------
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/include/gpiod.h b/include/gpiod.h
index 1f90be5..eaf6334 100644
--- a/include/gpiod.h
+++ b/include/gpiod.h
@@ -1226,16 +1226,16 @@ int gpiod_line_request_get_value(struct gpiod_line_request *request,
 /**
  * @brief Get the values of a subset of requested lines.
  * @param request GPIO line request.
- * @param num_lines Number of lines for which to read values.
+ * @param num_values Number of lines for which to read values.
  * @param offsets Array of offsets identifying the subset of requested lines
  *		  from which to read values.
  * @param values Array in which the values will be stored.  Must be sized
- *		 to hold \p num_lines entries.  Each value is associated with the
+ *		 to hold \p num_values entries.  Each value is associated with the
  *		 line identified by the corresponding entry in \p offsets.
  * @return 0 on success, -1 on failure.
  */
 int gpiod_line_request_get_values_subset(struct gpiod_line_request *request,
-					 size_t num_lines,
+					 size_t num_values,
 					 const unsigned int *offsets,
 					 int *values);
 
@@ -1265,17 +1265,17 @@ int gpiod_line_request_set_value(struct gpiod_line_request *request,
 /**
  * @brief Set the values of a subset of requested lines.
  * @param request GPIO line request.
- * @param num_lines Number of lines for which to set values.
+ * @param num_values Number of lines for which to set values.
  * @param offsets Array of offsets, containing the number of entries specified
- *		  by \p num_lines, identifying the requested lines for
+ *		  by \p num_values, identifying the requested lines for
  *		  which to set values.
  * @param values Array of values to set, containing the number of entries
- *		 specified by \p num_lines.  Each value is associated with the
+ *		 specified by \p num_values.  Each value is associated with the
  *		 line identified by the corresponding entry in \p offsets.
  * @return 0 on success, -1 on failure.
  */
 int gpiod_line_request_set_values_subset(struct gpiod_line_request *request,
-					 size_t num_lines,
+					 size_t num_values,
 					 const unsigned int *offsets,
 					 const int *values);
 
diff --git a/lib/line-request.c b/lib/line-request.c
index 51b4ac1..31e82f8 100644
--- a/lib/line-request.c
+++ b/lib/line-request.c
@@ -85,7 +85,7 @@ static int offset_to_bit(struct gpiod_line_request *request,
 
 GPIOD_API int
 gpiod_line_request_get_values_subset(struct gpiod_line_request *request,
-				     size_t num_lines,
+				     size_t num_values,
 				     const unsigned int *offsets, int *values)
 {
 	struct gpio_v2_line_values buf;
@@ -95,7 +95,7 @@ gpiod_line_request_get_values_subset(struct gpiod_line_request *request,
 
 	buf.bits = 0;
 
-	for (i = 0; i < num_lines; i++) {
+	for (i = 0; i < num_values; i++) {
 		bit = offset_to_bit(request, offsets[i]);
 		if (bit < 0) {
 			errno = EINVAL;
@@ -112,9 +112,9 @@ gpiod_line_request_get_values_subset(struct gpiod_line_request *request,
 		return -1;
 
 	bits = buf.bits;
-	memset(values, 0, sizeof(*values) * num_lines);
+	memset(values, 0, sizeof(*values) * num_values);
 
-	for (i = 0; i < num_lines; i++) {
+	for (i = 0; i < num_values; i++) {
 		bit = offset_to_bit(request, offsets[i]);
 		values[i] = gpiod_line_mask_test_bit(&bits, bit) ? 1 : 0;
 	}
@@ -138,7 +138,7 @@ GPIOD_API int gpiod_line_request_set_value(struct gpiod_line_request *request,
 
 GPIOD_API int
 gpiod_line_request_set_values_subset(struct gpiod_line_request *request,
-				     size_t num_lines,
+				     size_t num_values,
 				     const unsigned int *offsets,
 				     const int *values)
 {
@@ -147,7 +147,7 @@ gpiod_line_request_set_values_subset(struct gpiod_line_request *request,
 	size_t i;
 	int bit;
 
-	for (i = 0; i < num_lines; i++) {
+	for (i = 0; i < num_values; i++) {
 		bit = offset_to_bit(request, offsets[i]);
 		if (bit < 0) {
 			errno = EINVAL;
-- 
2.35.1




[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux