Inline USB device opening
Such a separate function was useless.
This commit is contained in:
parent
b0e04aa327
commit
b60809a4da
1 changed files with 3 additions and 13 deletions
|
@ -108,17 +108,6 @@ sc_usb_find_devices(struct sc_usb *usb, const char *serial,
|
||||||
return idx;
|
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
|
bool
|
||||||
sc_usb_init(struct sc_usb *usb) {
|
sc_usb_init(struct sc_usb *usb) {
|
||||||
usb->handle = NULL;
|
usb->handle = NULL;
|
||||||
|
@ -204,8 +193,9 @@ sc_usb_register_callback(struct sc_usb *usb) {
|
||||||
bool
|
bool
|
||||||
sc_usb_connect(struct sc_usb *usb, libusb_device *device,
|
sc_usb_connect(struct sc_usb *usb, libusb_device *device,
|
||||||
const struct sc_usb_callbacks *cbs, void *cbs_userdata) {
|
const struct sc_usb_callbacks *cbs, void *cbs_userdata) {
|
||||||
usb->handle = sc_usb_open_handle(device);
|
int result = libusb_open(device, &usb->handle);
|
||||||
if (!usb->handle) {
|
if (result < 0) {
|
||||||
|
LOGE("Open device: libusb error: %s", libusb_strerror(result));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue