Remove log_libusb_error()

This helper did not help a lot, and prevented the client to choose the
log level and the prefix error message.
This commit is contained in:
Romain Vimont 2022-02-07 12:56:25 +01:00
parent 137d2c9791
commit b0e04aa327
2 changed files with 9 additions and 20 deletions

View file

@ -45,11 +45,6 @@ sc_hid_event_destroy(struct sc_hid_event *hid_event) {
free(hid_event->buffer); free(hid_event->buffer);
} }
static inline void
log_libusb_error(enum libusb_error errcode) {
LOGW("libusb error: %s", libusb_strerror(errcode));
}
bool bool
sc_aoa_init(struct sc_aoa *aoa, struct sc_usb *usb, sc_aoa_init(struct sc_aoa *aoa, struct sc_usb *usb,
struct sc_acksync *acksync) { struct sc_acksync *acksync) {
@ -99,7 +94,7 @@ sc_aoa_register_hid(struct sc_aoa *aoa, uint16_t accessory_id,
request, value, index, buffer, length, request, value, index, buffer, length,
DEFAULT_TIMEOUT); DEFAULT_TIMEOUT);
if (result < 0) { if (result < 0) {
log_libusb_error((enum libusb_error) result); LOGE("REGISTER_HID: libusb error: %s", libusb_strerror(result));
return false; return false;
} }
@ -135,7 +130,7 @@ sc_aoa_set_hid_report_desc(struct sc_aoa *aoa, uint16_t accessory_id,
request, value, index, buffer, length, request, value, index, buffer, length,
DEFAULT_TIMEOUT); DEFAULT_TIMEOUT);
if (result < 0) { if (result < 0) {
log_libusb_error((enum libusb_error) result); LOGE("SET_HID_REPORT_DESC: libusb error: %s", libusb_strerror(result));
return false; return false;
} }
@ -177,7 +172,7 @@ sc_aoa_send_hid_event(struct sc_aoa *aoa, const struct sc_hid_event *event) {
request, value, index, buffer, length, request, value, index, buffer, length,
DEFAULT_TIMEOUT); DEFAULT_TIMEOUT);
if (result < 0) { if (result < 0) {
log_libusb_error((enum libusb_error) result); LOGE("SEND_HID_EVENT: libusb error: %s", libusb_strerror(result));
return false; return false;
} }
@ -199,7 +194,7 @@ sc_aoa_unregister_hid(struct sc_aoa *aoa, const uint16_t accessory_id) {
request, value, index, buffer, length, request, value, index, buffer, length,
DEFAULT_TIMEOUT); DEFAULT_TIMEOUT);
if (result < 0) { if (result < 0) {
log_libusb_error((enum libusb_error) result); LOGE("UNREGISTER_HID: libusb error: %s", libusb_strerror(result));
return false; return false;
} }

View file

@ -4,11 +4,6 @@
#include "util/log.h" #include "util/log.h"
static inline void
log_libusb_error(enum libusb_error errcode) {
LOGW("libusb error: %s", libusb_strerror(errcode));
}
static char * static char *
read_string(libusb_device_handle *handle, uint8_t desc_index) { read_string(libusb_device_handle *handle, uint8_t desc_index) {
char buffer[128]; char buffer[128];
@ -96,7 +91,7 @@ sc_usb_find_devices(struct sc_usb *usb, const char *serial,
libusb_device **list; libusb_device **list;
ssize_t count = libusb_get_device_list(usb->context, &list); ssize_t count = libusb_get_device_list(usb->context, &list);
if (count < 0) { if (count < 0) {
log_libusb_error((enum libusb_error) count); LOGE("List USB devices: libusb error: %s", libusb_strerror(count));
return -1; return -1;
} }
@ -118,7 +113,7 @@ sc_usb_open_handle(libusb_device *device) {
libusb_device_handle *handle; libusb_device_handle *handle;
int result = libusb_open(device, &handle); int result = libusb_open(device, &handle);
if (result < 0) { if (result < 0) {
log_libusb_error((enum libusb_error) result); LOGE("Open device: libusb error: %s", libusb_strerror(result));
return NULL; return NULL;
} }
return handle; return handle;
@ -183,8 +178,7 @@ sc_usb_register_callback(struct sc_usb *usb) {
struct libusb_device_descriptor desc; struct libusb_device_descriptor desc;
int result = libusb_get_device_descriptor(device, &desc); int result = libusb_get_device_descriptor(device, &desc);
if (result < 0) { if (result < 0) {
log_libusb_error((enum libusb_error) result); LOGE("Device descriptor: libusb error: %s", libusb_strerror(result));
LOGW("Could not read USB device descriptor");
return false; return false;
} }
@ -198,8 +192,8 @@ sc_usb_register_callback(struct sc_usb *usb) {
sc_usb_libusb_callback, usb, sc_usb_libusb_callback, usb,
&usb->callback_handle); &usb->callback_handle);
if (result < 0) { if (result < 0) {
log_libusb_error((enum libusb_error) result); LOGE("Register hotplog callback: libusb error: %s",
LOGW("Could not register USB callback"); libusb_strerror(result));
return false; return false;
} }