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