diff mbox series

[libgpiod,v2,3/3] line-info: rename infobuf to uinfo

Message ID 20220315053220.102934-4-warthog618@gmail.com
State New
Headers show
Series api tweaks | expand

Commit Message

Kent Gibson March 15, 2022, 5:32 a.m. UTC
The infobuf variable in gpiod_line_info_from_kernel() refers to the
uAPI version of the info, and the "buf" suffix doesn't really
emphasise that, so rename it to uinfo.

Signed-off-by: Kent Gibson <warthog618@gmail.com>
---
 lib/line-info.c | 38 +++++++++++++++++++-------------------
 1 file changed, 19 insertions(+), 19 deletions(-)

Comments

Bartosz Golaszewski March 15, 2022, 12:14 p.m. UTC | #1
On Tue, Mar 15, 2022 at 6:33 AM Kent Gibson <warthog618@gmail.com> wrote:
>
> The infobuf variable in gpiod_line_info_from_kernel() refers to the
> uAPI version of the info, and the "buf" suffix doesn't really
> emphasise that, so rename it to uinfo.
>
> Signed-off-by: Kent Gibson <warthog618@gmail.com>
> ---

I don't entirely disagree with infobuf not being the best name but
uinfo is even less so. The 'u' prefix doesn't mean anything on its
own. If anything I would think it has something to do with udev,
udisks, upower etc. Or "mili" like useconds. How about info_kernel?
kernel_info? uapi_info?

Bart
Kent Gibson March 15, 2022, 12:24 p.m. UTC | #2
On Tue, Mar 15, 2022 at 01:14:33PM +0100, Bartosz Golaszewski wrote:
> On Tue, Mar 15, 2022 at 6:33 AM Kent Gibson <warthog618@gmail.com> wrote:
> >
> > The infobuf variable in gpiod_line_info_from_kernel() refers to the
> > uAPI version of the info, and the "buf" suffix doesn't really
> > emphasise that, so rename it to uinfo.
> >
> > Signed-off-by: Kent Gibson <warthog618@gmail.com>
> > ---
> 
> I don't entirely disagree with infobuf not being the best name but
> uinfo is even less so. The 'u' prefix doesn't mean anything on its
> own. If anything I would think it has something to do with udev,
> udisks, upower etc. Or "mili" like useconds. How about info_kernel?
> kernel_info? uapi_info?
> 

uapi_info works for me.

Cheers,
Kent.
diff mbox series

Patch

diff --git a/lib/line-info.c b/lib/line-info.c
index fc656f9..168fc86 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 *infobuf)
+gpiod_line_info_from_kernel(struct gpio_v2_line_info *uinfo)
 {
 	struct gpio_v2_line_attribute *attr;
 	struct gpiod_line_info *info;
@@ -118,47 +118,47 @@  gpiod_line_info_from_kernel(struct gpio_v2_line_info *infobuf)
 
 	memset(info, 0, sizeof(*info));
 
-	info->offset = infobuf->offset;
-	strncpy(info->name, infobuf->name, GPIO_MAX_NAME_SIZE);
+	info->offset = uinfo->offset;
+	strncpy(info->name, uinfo->name, GPIO_MAX_NAME_SIZE);
 
-	info->used = !!(infobuf->flags & GPIO_V2_LINE_FLAG_USED);
-	strncpy(info->consumer, infobuf->consumer, GPIO_MAX_NAME_SIZE);
+	info->used = !!(uinfo->flags & GPIO_V2_LINE_FLAG_USED);
+	strncpy(info->consumer, uinfo->consumer, GPIO_MAX_NAME_SIZE);
 
-	if (infobuf->flags & GPIO_V2_LINE_FLAG_OUTPUT)
+	if (uinfo->flags & GPIO_V2_LINE_FLAG_OUTPUT)
 		info->direction = GPIOD_LINE_DIRECTION_OUTPUT;
 	else
 		info->direction = GPIOD_LINE_DIRECTION_INPUT;
 
-	if (infobuf->flags & GPIO_V2_LINE_FLAG_ACTIVE_LOW)
+	if (uinfo->flags & GPIO_V2_LINE_FLAG_ACTIVE_LOW)
 		info->active_low = true;
 
-	if (infobuf->flags & GPIO_V2_LINE_FLAG_BIAS_PULL_UP)
+	if (uinfo->flags & GPIO_V2_LINE_FLAG_BIAS_PULL_UP)
 		info->bias = GPIOD_LINE_BIAS_PULL_UP;
-	else if (infobuf->flags & GPIO_V2_LINE_FLAG_BIAS_PULL_DOWN)
+	else if (uinfo->flags & GPIO_V2_LINE_FLAG_BIAS_PULL_DOWN)
 		info->bias = GPIOD_LINE_BIAS_PULL_DOWN;
-	else if (infobuf->flags & GPIO_V2_LINE_FLAG_BIAS_DISABLED)
+	else if (uinfo->flags & GPIO_V2_LINE_FLAG_BIAS_DISABLED)
 		info->bias = GPIOD_LINE_BIAS_DISABLED;
 	else
 		info->bias = GPIOD_LINE_BIAS_UNKNOWN;
 
-	if (infobuf->flags & GPIO_V2_LINE_FLAG_OPEN_DRAIN)
+	if (uinfo->flags & GPIO_V2_LINE_FLAG_OPEN_DRAIN)
 		info->drive = GPIOD_LINE_DRIVE_OPEN_DRAIN;
-	else if (infobuf->flags & GPIO_V2_LINE_FLAG_OPEN_SOURCE)
+	else if (uinfo->flags & GPIO_V2_LINE_FLAG_OPEN_SOURCE)
 		info->drive = GPIOD_LINE_DRIVE_OPEN_SOURCE;
 	else
 		info->drive = GPIOD_LINE_DRIVE_PUSH_PULL;
 
-	if ((infobuf->flags & GPIO_V2_LINE_FLAG_EDGE_RISING) &&
-	    (infobuf->flags & GPIO_V2_LINE_FLAG_EDGE_FALLING))
+	if ((uinfo->flags & GPIO_V2_LINE_FLAG_EDGE_RISING) &&
+	    (uinfo->flags & GPIO_V2_LINE_FLAG_EDGE_FALLING))
 		info->edge = GPIOD_LINE_EDGE_BOTH;
-	else if (infobuf->flags & GPIO_V2_LINE_FLAG_EDGE_RISING)
+	else if (uinfo->flags & GPIO_V2_LINE_FLAG_EDGE_RISING)
 		info->edge = GPIOD_LINE_EDGE_RISING;
-	else if (infobuf->flags & GPIO_V2_LINE_FLAG_EDGE_FALLING)
+	else if (uinfo->flags & GPIO_V2_LINE_FLAG_EDGE_FALLING)
 		info->edge = GPIOD_LINE_EDGE_FALLING;
 	else
 		info->edge = GPIOD_LINE_EDGE_NONE;
 
-	if (infobuf->flags & GPIO_V2_LINE_FLAG_EVENT_CLOCK_REALTIME)
+	if (uinfo->flags & GPIO_V2_LINE_FLAG_EVENT_CLOCK_REALTIME)
 		info->event_clock = GPIOD_LINE_EVENT_CLOCK_REALTIME;
 	else
 		info->event_clock = GPIOD_LINE_EVENT_CLOCK_MONOTONIC;
@@ -167,8 +167,8 @@  gpiod_line_info_from_kernel(struct gpio_v2_line_info *infobuf)
 	 * We assume that the kernel returns correct configuration and that no
 	 * attributes repeat.
 	 */
-	for (i = 0; i < infobuf->num_attrs; i++) {
-		attr = &infobuf->attrs[i];
+	for (i = 0; i < uinfo->num_attrs; i++) {
+		attr = &uinfo->attrs[i];
 
 		if (attr->id == GPIO_V2_LINE_ATTR_ID_DEBOUNCE) {
 			info->debounced = true;