All of lore.kernel.org
 help / color / mirror / Atom feed
* [libgpiod v2][PATCH 0/3] doc tweak corrections and renaming
@ 2022-03-16  2:04 Kent Gibson
  2022-03-16  2:04 ` [libgpiod v2][PATCH 1/3] doc: API documentation tweaks corrections Kent Gibson
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Kent Gibson @ 2022-03-16  2:04 UTC (permalink / raw)
  To: linux-gpio, brgl; +Cc: Kent Gibson

Another small series of patches following up on the two recent series.

The first patch is the corrections for patch 6 of the original series,
after omitting patches 2 and 4 and fixing conflicts and some other renaming.
This brings the conflicted sections into line with the rest of the docs.
There are also a few lines unrelated to the conflicts that differ between
my tree and yours.  Not sure if you have issues with them and dropped them,
or something else happened along the way.  I don't see anything terribly
contraversial so I've kept them in here.
And there is an unrelated indentation fix as well.

The second is using num_values more consistently.
These may actually be more corrections for doc tweaks, that slipped
through because they didn't conflict, and could be squashed into patch 1,
but kept them separate just in case.  And there is a corresponding code
rename as well, so it isn't purely documentation.

The final one is completing the renaming of "buf" variables to a name
more clearly indicating that they refer to uAPI types.
And renaming the conversion functions to match.

I think that is everything for the core for now.  Hopefully.

Cheers,
Kent.

Kent Gibson (3):
  doc: API documentation tweaks corrections
  core: use num_values rather than num_lines when dealing with subsets
    of values
  core: rename uAPI related variables and functions to uapi.

 include/gpiod.h      | 51 +++++++++++++++++++++++---------------------
 lib/chip-info.c      |  2 +-
 lib/chip.c           | 24 ++++++++++-----------
 lib/info-event.c     | 18 ++++++++--------
 lib/internal.h       | 20 ++++++++---------
 lib/line-config.c    | 24 ++++++++++-----------
 lib/line-info.c      |  2 +-
 lib/line-request.c   | 50 +++++++++++++++++++++----------------------
 lib/request-config.c | 12 +++++------
 9 files changed, 103 insertions(+), 100 deletions(-)


base-commit: 9d5112d0448fb2436e926a36842ff5ca365303c3
-- 
2.35.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [libgpiod v2][PATCH 1/3] doc: API documentation tweaks corrections
  2022-03-16  2:04 [libgpiod v2][PATCH 0/3] doc tweak corrections and renaming Kent Gibson
@ 2022-03-16  2:04 ` Kent Gibson
  2022-03-17 15:49   ` Bartosz Golaszewski
  2022-03-16  2:04 ` [libgpiod v2][PATCH 2/3] core: use num_values rather than num_lines when dealing with subsets of values Kent Gibson
  2022-03-16  2:04 ` [libgpiod v2][PATCH 3/3] core: rename uAPI related variables and functions to uapi Kent Gibson
  2 siblings, 1 reply; 7+ messages in thread
From: Kent Gibson @ 2022-03-16  2:04 UTC (permalink / raw)
  To: linux-gpio, brgl; +Cc: Kent Gibson

The corrections to the doc tweaks patch 6, allowing for the omission
of patches 2 and 4.

Signed-off-by: Kent Gibson <warthog618@gmail.com>
---
 include/gpiod.h | 37 ++++++++++++++++++++-----------------
 1 file changed, 20 insertions(+), 17 deletions(-)

diff --git a/include/gpiod.h b/include/gpiod.h
index 883c327..1f90be5 100644
--- a/include/gpiod.h
+++ b/include/gpiod.h
@@ -731,7 +731,7 @@ int gpiod_line_config_get_bias_default(struct gpiod_line_config *config);
  *	   in a request.
  */
 int gpiod_line_config_get_bias_offset(struct gpiod_line_config *config,
-			       unsigned int offset);
+				      unsigned int offset);
 
 /**
  * @brief Set the default drive setting.
@@ -986,12 +986,13 @@ gpiod_line_config_set_output_value_override(struct gpiod_line_config *config,
 					    unsigned int offset, int value);
 
 /**
- * @brief Override the output values for multiple offsets.
+ * @brief Override the output values for multiple lines.
  * @param config Line config object.
- * @param num_values Number of offsets for which to override values.
- * @param offsets Array of line offsets to override values for.
- * @param values Array of output values associated with the offsets passed in
- *               the previous argument.
+ * @param num_values Number of lines for which to override values.
+ * @param offsets Array of offsets identifying the lines for which to override
+ *		  values,  containing \p num_values entries.
+ * @param values Array of output values corresponding to the lines identified in
+ *		 \p offsets, also containing \p num_values entries.
  */
 void gpiod_line_config_set_output_values(struct gpiod_line_config *config,
 					 size_t num_values,
@@ -1125,18 +1126,18 @@ void gpiod_request_config_set_consumer(struct gpiod_request_config *config,
 				       const char *consumer);
 
 /**
- * @brief Get the consumer string.
+ * @brief Get the consumer name configured in the request config.
  * @param config Request config object.
- * @return Current consumer string stored in this request config.
+ * @return Consumer name stored in the request config.
  */
 const char *
 gpiod_request_config_get_consumer(struct gpiod_request_config *config);
 
 /**
- * @brief Set line offsets for this request.
+ * @brief Set the offsets of the lines to be requested.
  * @param config Request config object.
- * @param num_offsets Number of offsets.
- * @param offsets Array of line offsets.
+ * @param num_offsets Number of offsets to set.
+ * @param offsets Array of offsets, containing \p num_offsets entries.
  * @note If too many offsets were specified, the offsets above the limit
  *       accepted by the kernel (64 lines) are silently dropped.
  */
@@ -1153,29 +1154,31 @@ size_t
 gpiod_request_config_get_num_offsets(struct gpiod_request_config *config);
 
 /**
- * @brief Get the hardware offsets of lines in this request config.
+ * @brief Get the offsets of lines in the request config.
  * @param config Request config object.
- * @param offsets Array to store offsets. Must hold at least the number of
- *                lines returned by ::gpiod_request_config_get_num_offsets.
+ * @param offsets Array to store offsets. Must be sized to hold the number of
+ *		  lines returned by ::gpiod_request_config_get_num_offsets.
  */
 void gpiod_request_config_get_offsets(struct gpiod_request_config *config,
 				      unsigned int *offsets);
 
 /**
- * @brief Set the size of the kernel event buffer.
+ * @brief Set the size of the kernel event buffer for the request.
  * @param config Request config object.
  * @param event_buffer_size New event buffer size.
  * @note The kernel may adjust the value if it's too high. If set to 0, the
  *       default value will be used.
+ * @note The kernel buffer is distinct from and independent of the user space
+ *	 buffer (::gpiod_edge_event_buffer_new).
  */
 void
 gpiod_request_config_set_event_buffer_size(struct gpiod_request_config *config,
 					   size_t event_buffer_size);
 
 /**
- * @brief Get the edge event buffer size from this request config.
+ * @brief Get the edge event buffer size for the request config.
  * @param config Request config object.
- * @return Current edge event buffer size setting.
+ * @return Edge event buffer size setting from the request config.
  */
 size_t
 gpiod_request_config_get_event_buffer_size(struct gpiod_request_config *config);
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [libgpiod v2][PATCH 2/3] core: use num_values rather than num_lines when dealing with subsets of values
  2022-03-16  2:04 [libgpiod v2][PATCH 0/3] doc tweak corrections and renaming Kent Gibson
  2022-03-16  2:04 ` [libgpiod v2][PATCH 1/3] doc: API documentation tweaks corrections Kent Gibson
@ 2022-03-16  2:04 ` Kent Gibson
  2022-03-17 16:22   ` Bartosz Golaszewski
  2022-03-16  2:04 ` [libgpiod v2][PATCH 3/3] core: rename uAPI related variables and functions to uapi Kent Gibson
  2 siblings, 1 reply; 7+ messages in thread
From: Kent Gibson @ 2022-03-16  2:04 UTC (permalink / raw)
  To: linux-gpio, brgl; +Cc: Kent Gibson

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@gmail.com>
---
 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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [libgpiod v2][PATCH 3/3] core: rename uAPI related variables and functions to uapi.
  2022-03-16  2:04 [libgpiod v2][PATCH 0/3] doc tweak corrections and renaming Kent Gibson
  2022-03-16  2:04 ` [libgpiod v2][PATCH 1/3] doc: API documentation tweaks corrections Kent Gibson
  2022-03-16  2:04 ` [libgpiod v2][PATCH 2/3] core: use num_values rather than num_lines when dealing with subsets of values Kent Gibson
@ 2022-03-16  2:04 ` Kent Gibson
  2022-03-17 16:23   ` Bartosz Golaszewski
  2 siblings, 1 reply; 7+ messages in thread
From: Kent Gibson @ 2022-03-16  2:04 UTC (permalink / raw)
  To: linux-gpio, brgl; +Cc: Kent Gibson

Rename variables using the "buf" suffix to a "uapi_" prefix to identify
them as being uAPI types.
Similarly, rename the corresponding uAPI conversion functions from
"kernel" to "uapi".

Signed-off-by: Kent Gibson <warthog618@gmail.com>
---
 lib/chip-info.c      |  2 +-
 lib/chip.c           | 24 ++++++++++++------------
 lib/info-event.c     | 18 +++++++++---------
 lib/internal.h       | 20 ++++++++++----------
 lib/line-config.c    | 24 ++++++++++++------------
 lib/line-info.c      |  2 +-
 lib/line-request.c   | 38 +++++++++++++++++++-------------------
 lib/request-config.c | 12 ++++++------
 8 files changed, 70 insertions(+), 70 deletions(-)

diff --git a/lib/chip-info.c b/lib/chip-info.c
index 1ab9b5e..584c9d4 100644
--- a/lib/chip-info.c
+++ b/lib/chip-info.c
@@ -37,7 +37,7 @@ GPIOD_API size_t gpiod_chip_info_get_num_lines(struct gpiod_chip_info *info)
 }
 
 struct gpiod_chip_info *
-gpiod_chip_info_from_kernel(struct gpiochip_info *uapi_info)
+gpiod_chip_info_from_uapi(struct gpiochip_info *uapi_info)
 {
 	struct gpiod_chip_info *info;
 
diff --git a/lib/chip.c b/lib/chip.c
index b1435e2..edb2dfd 100644
--- a/lib/chip.c
+++ b/lib/chip.c
@@ -82,7 +82,7 @@ GPIOD_API struct gpiod_chip_info *gpiod_chip_get_info(struct gpiod_chip *chip)
 	if (ret < 0)
 		return NULL;
 
-	return gpiod_chip_info_from_kernel(&info);
+	return gpiod_chip_info_from_uapi(&info);
 }
 
 GPIOD_API const char *gpiod_chip_get_path(struct gpiod_chip *chip)
@@ -118,7 +118,7 @@ chip_get_line_info(struct gpiod_chip *chip, unsigned int offset, bool watch)
 	if (ret)
 		return NULL;
 
-	return gpiod_line_info_from_kernel(&info);
+	return gpiod_line_info_from_uapi(&info);
 }
 
 GPIOD_API struct gpiod_line_info *
@@ -202,34 +202,34 @@ gpiod_chip_request_lines(struct gpiod_chip *chip,
 			 struct gpiod_request_config *req_cfg,
 			 struct gpiod_line_config *line_cfg)
 {
-	struct gpio_v2_line_request reqbuf;
+	struct gpio_v2_line_request uapi_req;
 	struct gpiod_line_request *request;
 	int ret;
 
-	memset(&reqbuf, 0, sizeof(reqbuf));
+	memset(&uapi_req, 0, sizeof(uapi_req));
 
-	ret = gpiod_request_config_to_kernel(req_cfg, &reqbuf);
+	ret = gpiod_request_config_to_uapi(req_cfg, &uapi_req);
 	if (ret)
 		return NULL;
 
-	ret = gpiod_line_config_to_kernel(line_cfg, &reqbuf.config,
-					  reqbuf.num_lines, reqbuf.offsets);
+	ret = gpiod_line_config_to_uapi(line_cfg, &uapi_req.config,
+					uapi_req.num_lines, uapi_req.offsets);
 	if (ret)
 		return NULL;
 
-	ret = ioctl(chip->fd, GPIO_V2_GET_LINE_IOCTL, &reqbuf);
+	ret = ioctl(chip->fd, GPIO_V2_GET_LINE_IOCTL, &uapi_req);
 	if (ret < 0)
 		return NULL;
 
-	ret = set_fd_noblock(reqbuf.fd);
+	ret = set_fd_noblock(uapi_req.fd);
 	if (ret) {
-		close(reqbuf.fd);
+		close(uapi_req.fd);
 		return NULL;
 	}
 
-	request = gpiod_line_request_from_kernel(&reqbuf);
+	request = gpiod_line_request_from_uapi(&uapi_req);
 	if (!request) {
-		close(reqbuf.fd);
+		close(uapi_req.fd);
 		return NULL;
 	}
 
diff --git a/lib/info-event.c b/lib/info-event.c
index 1776d82..4abed57 100644
--- a/lib/info-event.c
+++ b/lib/info-event.c
@@ -15,7 +15,7 @@ struct gpiod_info_event {
 };
 
 struct gpiod_info_event *
-gpiod_info_event_from_kernel(struct gpio_v2_line_info_changed *evbuf)
+gpiod_info_event_from_uapi(struct gpio_v2_line_info_changed *uapi_evt)
 {
 	struct gpiod_info_event *event;
 
@@ -24,9 +24,9 @@ gpiod_info_event_from_kernel(struct gpio_v2_line_info_changed *evbuf)
 		return NULL;
 
 	memset(event, 0, sizeof(*event));
-	event->timestamp = evbuf->timestamp_ns;
+	event->timestamp = uapi_evt->timestamp_ns;
 
-	switch (evbuf->event_type) {
+	switch (uapi_evt->event_type) {
 	case GPIOLINE_CHANGED_REQUESTED:
 		event->event_type = GPIOD_INFO_EVENT_LINE_REQUESTED;
 		break;
@@ -43,7 +43,7 @@ gpiod_info_event_from_kernel(struct gpio_v2_line_info_changed *evbuf)
 		return NULL;
 	}
 
-	event->info = gpiod_line_info_from_kernel(&evbuf->info);
+	event->info = gpiod_line_info_from_uapi(&uapi_evt->info);
 	if (!event->info) {
 		free(event);
 		return NULL;
@@ -80,18 +80,18 @@ gpiod_info_event_get_line_info(struct gpiod_info_event *event)
 
 struct gpiod_info_event *gpiod_info_event_read_fd(int fd)
 {
-	struct gpio_v2_line_info_changed evbuf;
+	struct gpio_v2_line_info_changed uapi_evt;
 	ssize_t rd;
 
-	memset(&evbuf, 0, sizeof(evbuf));
+	memset(&uapi_evt, 0, sizeof(uapi_evt));
 
-	rd = read(fd, &evbuf, sizeof(evbuf));
+	rd = read(fd, &uapi_evt, sizeof(uapi_evt));
 	if (rd < 0) {
 		return NULL;
-	} else if ((unsigned int)rd < sizeof(evbuf)) {
+	} else if ((unsigned int)rd < sizeof(uapi_evt)) {
 		errno = EIO;
 		return NULL;
 	}
 
-	return gpiod_info_event_from_kernel(&evbuf);
+	return gpiod_info_event_from_uapi(&uapi_evt);
 }
diff --git a/lib/internal.h b/lib/internal.h
index ffef578..c87df91 100644
--- a/lib/internal.h
+++ b/lib/internal.h
@@ -19,21 +19,21 @@
 #define GPIOD_BIT(nr)	(1UL << (nr))
 
 struct gpiod_chip_info *
-gpiod_chip_info_from_kernel(struct gpiochip_info *infobuf);
+gpiod_chip_info_from_uapi(struct gpiochip_info *uapi_info);
 struct gpiod_line_info *
-gpiod_line_info_from_kernel(struct gpio_v2_line_info *infobuf);
-int gpiod_request_config_to_kernel(struct gpiod_request_config *config,
-				   struct gpio_v2_line_request *reqbuf);
-int gpiod_line_config_to_kernel(struct gpiod_line_config *config,
-				struct gpio_v2_line_config *cfgbuf,
-				unsigned int num_lines,
-				const unsigned int *offsets);
+gpiod_line_info_from_uapi(struct gpio_v2_line_info *uapi_info);
+int gpiod_request_config_to_uapi(struct gpiod_request_config *config,
+				 struct gpio_v2_line_request *uapi_req);
+int gpiod_line_config_to_uapi(struct gpiod_line_config *config,
+			      struct gpio_v2_line_config *uapi_cfg,
+			      unsigned int num_lines,
+			      const unsigned int *offsets);
 struct gpiod_line_request *
-gpiod_line_request_from_kernel(struct gpio_v2_line_request *reqbuf);
+gpiod_line_request_from_uapi(struct gpio_v2_line_request *uapi_req);
 int gpiod_edge_event_buffer_read_fd(int fd, struct gpiod_edge_event_buffer *buffer,
 				    size_t max_events);
 struct gpiod_info_event *
-gpiod_info_event_from_kernel(struct gpio_v2_line_info_changed *evbuf);
+gpiod_info_event_from_uapi(struct gpio_v2_line_info_changed *uapi_evt);
 struct gpiod_info_event *gpiod_info_event_read_fd(int fd);
 
 int gpiod_poll_fd(int fd, uint64_t timeout);
diff --git a/lib/line-config.c b/lib/line-config.c
index b7e154f..f9cd6ac 100644
--- a/lib/line-config.c
+++ b/lib/line-config.c
@@ -1062,7 +1062,7 @@ static void set_kernel_attr_mask(uint64_t *out, const uint64_t *in,
 }
 
 static int process_overrides(struct gpiod_line_config *config,
-			     struct gpio_v2_line_config *cfgbuf,
+			     struct gpio_v2_line_config *uapi_cfg,
 			     unsigned int *attr_idx,
 			     unsigned int num_lines,
 			     const unsigned int *offsets,
@@ -1113,7 +1113,7 @@ static int process_overrides(struct gpiod_line_config *config,
 			}
 		}
 
-		attr = &cfgbuf->attrs[(*attr_idx)++];
+		attr = &uapi_cfg->attrs[(*attr_idx)++];
 
 		set_kernel_attr_mask(&mask, &marked,
 				     num_lines, offsets, config);
@@ -1142,10 +1142,10 @@ static bool has_at_least_one_output_direction(struct gpiod_line_config *config)
 	return false;
 }
 
-int gpiod_line_config_to_kernel(struct gpiod_line_config *config,
-				struct gpio_v2_line_config *cfgbuf,
-				unsigned int num_lines,
-				const unsigned int *offsets)
+int gpiod_line_config_to_uapi(struct gpiod_line_config *config,
+			      struct gpio_v2_line_config *uapi_cfg,
+			      unsigned int num_lines,
+			      const unsigned int *offsets)
 {
 	struct gpio_v2_line_config_attribute *attr;
 	unsigned int attr_idx = 0;
@@ -1160,7 +1160,7 @@ int gpiod_line_config_to_kernel(struct gpiod_line_config *config,
 	 * If so, let's take one attribute for the default values.
 	 */
 	if (has_at_least_one_output_direction(config)) {
-		attr = &cfgbuf->attrs[attr_idx++];
+		attr = &uapi_cfg->attrs[attr_idx++];
 		attr->attr.id = GPIO_V2_LINE_ATTR_ID_OUTPUT_VALUES;
 
 		set_kernel_output_values(&mask, &values, config,
@@ -1173,7 +1173,7 @@ int gpiod_line_config_to_kernel(struct gpiod_line_config *config,
 
 	/* If we have a default debounce period - use another attribute. */
 	if (config->defaults.debounce_period_us) {
-		attr = &cfgbuf->attrs[attr_idx++];
+		attr = &uapi_cfg->attrs[attr_idx++];
 		attr->attr.id = GPIO_V2_LINE_ATTR_ID_DEBOUNCE;
 		attr->attr.debounce_period_us =
 				config->defaults.debounce_period_us;
@@ -1193,22 +1193,22 @@ int gpiod_line_config_to_kernel(struct gpiod_line_config *config,
 	 * further processing.
 	 */
 
-	ret = process_overrides(config, cfgbuf, &attr_idx, num_lines, offsets,
+	ret = process_overrides(config, uapi_cfg, &attr_idx, num_lines, offsets,
 				base_config_flags_are_equal,
 				override_config_flags_are_equal,
 				set_base_config_flags);
 	if (ret)
 		return -1;
 
-	ret = process_overrides(config, cfgbuf, &attr_idx, num_lines, offsets,
+	ret = process_overrides(config, uapi_cfg, &attr_idx, num_lines, offsets,
 				base_debounce_period_is_equal,
 				override_config_debounce_period_is_equal,
 				set_base_config_debounce_period);
 	if (ret)
 		return -1;
 
-	cfgbuf->flags = make_kernel_flags(&config->defaults);
-	cfgbuf->num_attrs = attr_idx;
+	uapi_cfg->flags = make_kernel_flags(&config->defaults);
+	uapi_cfg->num_attrs = attr_idx;
 
 	return 0;
 
diff --git a/lib/line-info.c b/lib/line-info.c
index 0724120..65eca48 100644
--- a/lib/line-info.c
+++ b/lib/line-info.c
@@ -106,7 +106,7 @@ gpiod_line_info_get_debounce_period_us(struct gpiod_line_info *info)
 }
 
 struct gpiod_line_info *
-gpiod_line_info_from_kernel(struct gpio_v2_line_info *uapi_info)
+gpiod_line_info_from_uapi(struct gpio_v2_line_info *uapi_info)
 {
 	struct gpio_v2_line_attribute *attr;
 	struct gpiod_line_info *info;
diff --git a/lib/line-request.c b/lib/line-request.c
index 31e82f8..33f7f67 100644
--- a/lib/line-request.c
+++ b/lib/line-request.c
@@ -17,7 +17,7 @@ struct gpiod_line_request {
 };
 
 struct gpiod_line_request *
-gpiod_line_request_from_kernel(struct gpio_v2_line_request *reqbuf)
+gpiod_line_request_from_uapi(struct gpio_v2_line_request *uapi_req)
 {
 	struct gpiod_line_request *request;
 
@@ -26,9 +26,9 @@ gpiod_line_request_from_kernel(struct gpio_v2_line_request *reqbuf)
 		return NULL;
 
 	memset(request, 0, sizeof(*request));
-	request->fd = reqbuf->fd;
-	request->num_lines = reqbuf->num_lines;
-	memcpy(request->offsets, reqbuf->offsets,
+	request->fd = uapi_req->fd;
+	request->num_lines = uapi_req->num_lines;
+	memcpy(request->offsets, uapi_req->offsets,
 	       sizeof(*request->offsets) * request->num_lines);
 
 	return request;
@@ -88,12 +88,12 @@ gpiod_line_request_get_values_subset(struct gpiod_line_request *request,
 				     size_t num_values,
 				     const unsigned int *offsets, int *values)
 {
-	struct gpio_v2_line_values buf;
+	struct gpio_v2_line_values uapi_values;
 	uint64_t mask = 0, bits = 0;
 	size_t i;
 	int bit, ret;
 
-	buf.bits = 0;
+	uapi_values.bits = 0;
 
 	for (i = 0; i < num_values; i++) {
 		bit = offset_to_bit(request, offsets[i]);
@@ -105,13 +105,13 @@ gpiod_line_request_get_values_subset(struct gpiod_line_request *request,
 		gpiod_line_mask_set_bit(&mask, bit);
 	}
 
-	buf.mask = mask;
+	uapi_values.mask = mask;
 
-	ret = ioctl(request->fd, GPIO_V2_LINE_GET_VALUES_IOCTL, &buf);
+	ret = ioctl(request->fd, GPIO_V2_LINE_GET_VALUES_IOCTL, &uapi_values);
 	if (ret)
 		return -1;
 
-	bits = buf.bits;
+	bits = uapi_values.bits;
 	memset(values, 0, sizeof(*values) * num_values);
 
 	for (i = 0; i < num_values; i++) {
@@ -142,7 +142,7 @@ gpiod_line_request_set_values_subset(struct gpiod_line_request *request,
 				     const unsigned int *offsets,
 				     const int *values)
 {
-	struct gpio_v2_line_values buf;
+	struct gpio_v2_line_values uapi_values;
 	uint64_t mask = 0, bits = 0;
 	size_t i;
 	int bit;
@@ -158,11 +158,11 @@ gpiod_line_request_set_values_subset(struct gpiod_line_request *request,
 		gpiod_line_mask_assign_bit(&bits, bit, values[i]);
 	}
 
-	memset(&buf, 0, sizeof(buf));
-	buf.mask = mask;
-	buf.bits = bits;
+	memset(&uapi_values, 0, sizeof(uapi_values));
+	uapi_values.mask = mask;
+	uapi_values.bits = bits;
 
-	return ioctl(request->fd, GPIO_V2_LINE_SET_VALUES_IOCTL, &buf);
+	return ioctl(request->fd, GPIO_V2_LINE_SET_VALUES_IOCTL, &uapi_values);
 }
 
 GPIOD_API int gpiod_line_request_set_values(struct gpiod_line_request *request,
@@ -176,17 +176,17 @@ GPIOD_API int
 gpiod_line_request_reconfigure_lines(struct gpiod_line_request *request,
 				     struct gpiod_line_config *config)
 {
-	struct gpio_v2_line_config cfgbuf;
+	struct gpio_v2_line_config uapi_cfg;
 	int ret;
 
-	memset(&cfgbuf, 0, sizeof(cfgbuf));
+	memset(&uapi_cfg, 0, sizeof(uapi_cfg));
 
-	ret = gpiod_line_config_to_kernel(config, &cfgbuf,
-					  request->num_lines, request->offsets);
+	ret = gpiod_line_config_to_uapi(config, &uapi_cfg,
+					request->num_lines, request->offsets);
 	if (ret)
 		return ret;
 
-	ret = ioctl(request->fd, GPIO_V2_LINE_SET_CONFIG_IOCTL, &cfgbuf);
+	ret = ioctl(request->fd, GPIO_V2_LINE_SET_CONFIG_IOCTL, &uapi_cfg);
 	if (ret)
 		return ret;
 
diff --git a/lib/request-config.c b/lib/request-config.c
index d22af80..3a84106 100644
--- a/lib/request-config.c
+++ b/lib/request-config.c
@@ -91,8 +91,8 @@ gpiod_request_config_get_event_buffer_size(struct gpiod_request_config *config)
 	return config->event_buffer_size;
 }
 
-int gpiod_request_config_to_kernel(struct gpiod_request_config *config,
-				   struct gpio_v2_line_request *reqbuf)
+int gpiod_request_config_to_uapi(struct gpiod_request_config *config,
+				 struct gpio_v2_line_request *uapi_req)
 {
 	size_t i;
 
@@ -102,11 +102,11 @@ int gpiod_request_config_to_kernel(struct gpiod_request_config *config,
 	}
 
 	for (i = 0; i < config->num_offsets; i++)
-		reqbuf->offsets[i] = config->offsets[i];
+		uapi_req->offsets[i] = config->offsets[i];
 
-	reqbuf->num_lines = config->num_offsets;
-	strcpy(reqbuf->consumer, config->consumer);
-	reqbuf->event_buffer_size = config->event_buffer_size;
+	uapi_req->num_lines = config->num_offsets;
+	strcpy(uapi_req->consumer, config->consumer);
+	uapi_req->event_buffer_size = config->event_buffer_size;
 
 	return 0;
 }
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [libgpiod v2][PATCH 1/3] doc: API documentation tweaks corrections
  2022-03-16  2:04 ` [libgpiod v2][PATCH 1/3] doc: API documentation tweaks corrections Kent Gibson
@ 2022-03-17 15:49   ` Bartosz Golaszewski
  0 siblings, 0 replies; 7+ messages in thread
From: Bartosz Golaszewski @ 2022-03-17 15:49 UTC (permalink / raw)
  To: Kent Gibson; +Cc: open list:GPIO SUBSYSTEM

On Wed, Mar 16, 2022 at 3:05 AM Kent Gibson <warthog618@gmail.com> wrote:
>
> The corrections to the doc tweaks patch 6, allowing for the omission
> of patches 2 and 4.
>
> Signed-off-by: Kent Gibson <warthog618@gmail.com>
> ---

Applied, thanks!

Bart

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [libgpiod v2][PATCH 2/3] core: use num_values rather than num_lines when dealing with subsets of values
  2022-03-16  2:04 ` [libgpiod v2][PATCH 2/3] core: use num_values rather than num_lines when dealing with subsets of values Kent Gibson
@ 2022-03-17 16:22   ` Bartosz Golaszewski
  0 siblings, 0 replies; 7+ messages in thread
From: Bartosz Golaszewski @ 2022-03-17 16:22 UTC (permalink / raw)
  To: Kent Gibson; +Cc: open list:GPIO SUBSYSTEM

On Wed, Mar 16, 2022 at 3:05 AM Kent Gibson <warthog618@gmail.com> wrote:
>
> 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@gmail.com>
> ---

Applied, thanks!

Bart

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [libgpiod v2][PATCH 3/3] core: rename uAPI related variables and functions to uapi.
  2022-03-16  2:04 ` [libgpiod v2][PATCH 3/3] core: rename uAPI related variables and functions to uapi Kent Gibson
@ 2022-03-17 16:23   ` Bartosz Golaszewski
  0 siblings, 0 replies; 7+ messages in thread
From: Bartosz Golaszewski @ 2022-03-17 16:23 UTC (permalink / raw)
  To: Kent Gibson; +Cc: open list:GPIO SUBSYSTEM

On Wed, Mar 16, 2022 at 3:05 AM Kent Gibson <warthog618@gmail.com> wrote:
>
> Rename variables using the "buf" suffix to a "uapi_" prefix to identify
> them as being uAPI types.
> Similarly, rename the corresponding uAPI conversion functions from
> "kernel" to "uapi".
>
> Signed-off-by: Kent Gibson <warthog618@gmail.com>
> ---

Applied, thanks!

Bart

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-03-17 16:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-16  2:04 [libgpiod v2][PATCH 0/3] doc tweak corrections and renaming Kent Gibson
2022-03-16  2:04 ` [libgpiod v2][PATCH 1/3] doc: API documentation tweaks corrections Kent Gibson
2022-03-17 15:49   ` Bartosz Golaszewski
2022-03-16  2:04 ` [libgpiod v2][PATCH 2/3] core: use num_values rather than num_lines when dealing with subsets of values Kent Gibson
2022-03-17 16:22   ` Bartosz Golaszewski
2022-03-16  2:04 ` [libgpiod v2][PATCH 3/3] core: rename uAPI related variables and functions to uapi Kent Gibson
2022-03-17 16:23   ` Bartosz Golaszewski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.