In case we are using CUSE faked device, it can't provide dedicated file
descriptor. Use chip fd instead.
Signed-off-by: Nikita Shubin <nikita.shubin@maquefel.me>
struct gpio_v2_line_request uapi_req;
struct gpiod_line_request *request;
struct gpiochip_info info;
+ bool close_uapi_fd = true;
int ret;
assert(chip);
if (ret)
return NULL;
+ if (uapi_req.fd == 0) {
+ close_uapi_fd = true;
+ uapi_req.fd = chip->fd;
+ }
+
request = gpiod_line_request_from_uapi(&uapi_req, info.name);
if (!request) {
- close(uapi_req.fd);
+ if (close_uapi_fd)
+ close(uapi_req.fd);
+
return NULL;
}
pollfds[i].fd = gpiod_line_request_get_fd(requests[i]);
pollfds[i].events = POLLIN;
- gpiod_chip_close(chip);
}
gpiod_request_config_free(req_cfg);
}
done:
+ gpiod_chip_close(chip);
+
for (i = 0; i < resolver->num_chips; i++)
gpiod_line_request_release(requests[i]);