1 // SPDX-License-Identifier: GPL-2.0-or-later
8 struct gpiod_line_request *request_input_line(const char *chip_path,
11 struct gpiod_line_settings *settings) {
12 struct gpiod_line_request *request = NULL;
13 struct gpiod_request_config *req_cfg = NULL;
14 struct gpiod_line_config *line_cfg;
15 struct gpiod_chip *chip;
19 settings = gpiod_line_settings_new();
21 chip = gpiod_chip_open(chip_path);
25 line_cfg = gpiod_line_config_new();
29 ret = gpiod_line_config_add_line_settings(line_cfg, &offset, 1,
32 goto free_line_config;
35 req_cfg = gpiod_request_config_new();
37 goto free_line_config;
39 gpiod_request_config_set_consumer(req_cfg, consumer);
42 request = gpiod_chip_request_lines(chip, req_cfg, line_cfg);
44 gpiod_request_config_free(req_cfg);
47 gpiod_line_config_free(line_cfg);
50 gpiod_chip_close(chip);
53 gpiod_line_settings_free(settings);
58 struct gpiod_edge_event * read_event(struct gpiod_line_request *request,
59 struct gpiod_edge_event_buffer *event_buffer) {
62 err = gpiod_line_request_read_edge_events(request, event_buffer, 1);
64 fprintf(stderr, "error reading edge events: %s\n",
68 return gpiod_edge_event_buffer_get_event(event_buffer, 0);