From b60809a4da23f52c1efaebc2813d3a45d97a8ca5 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Mon, 7 Feb 2022 13:01:49 +0100 Subject: [PATCH] Inline USB device opening Such a separate function was useless. --- app/src/usb/usb.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/app/src/usb/usb.c b/app/src/usb/usb.c index 143bca04..1b5f4a5d 100644 --- a/app/src/usb/usb.c +++ b/app/src/usb/usb.c @@ -108,17 +108,6 @@ sc_usb_find_devices(struct sc_usb *usb, const char *serial, return idx; } -static libusb_device_handle * -sc_usb_open_handle(libusb_device *device) { - libusb_device_handle *handle; - int result = libusb_open(device, &handle); - if (result < 0) { - LOGE("Open device: libusb error: %s", libusb_strerror(result)); - return NULL; - } - return handle; - } - bool sc_usb_init(struct sc_usb *usb) { usb->handle = NULL; @@ -204,8 +193,9 @@ sc_usb_register_callback(struct sc_usb *usb) { bool sc_usb_connect(struct sc_usb *usb, libusb_device *device, const struct sc_usb_callbacks *cbs, void *cbs_userdata) { - usb->handle = sc_usb_open_handle(device); - if (!usb->handle) { + int result = libusb_open(device, &usb->handle); + if (result < 0) { + LOGE("Open device: libusb error: %s", libusb_strerror(result)); return false; }