libusb compat: remove debug layer
This commit is contained in:
parent
7d076334a7
commit
c19cea25bb
@ -32,22 +32,6 @@
|
|||||||
static libusb_context *ctx = NULL;
|
static libusb_context *ctx = NULL;
|
||||||
static int usb_debug = 0;
|
static int usb_debug = 0;
|
||||||
|
|
||||||
#ifdef ENABLE_LOGGING
|
|
||||||
#define _usbi_log(level, ...) usbi_log(level, __FUNCTION__, __VA_ARGS__)
|
|
||||||
#else
|
|
||||||
#define _usbi_log(level, ...)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ENABLE_DEBUG_LOGGING
|
|
||||||
#define usbi_dbg(...) _usbi_log(LOG_LEVEL_DEBUG, __VA_ARGS__)
|
|
||||||
#else
|
|
||||||
#define usbi_dbg(...)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define usbi_info(...) _usbi_log(LOG_LEVEL_INFO, __VA_ARGS__)
|
|
||||||
#define usbi_warn(...) _usbi_log(LOG_LEVEL_WARNING, __VA_ARGS__)
|
|
||||||
#define usbi_err(...) _usbi_log(LOG_LEVEL_ERROR, __VA_ARGS__)
|
|
||||||
|
|
||||||
struct usb_bus *usb_busses = NULL;
|
struct usb_bus *usb_busses = NULL;
|
||||||
|
|
||||||
#define compat_err(e) -(errno=libusb_to_errno(e))
|
#define compat_err(e) -(errno=libusb_to_errno(e))
|
||||||
@ -96,13 +80,10 @@ static void _usb_finalize(void)
|
|||||||
|
|
||||||
void usb_init(void)
|
void usb_init(void)
|
||||||
{
|
{
|
||||||
usbi_dbg("");
|
|
||||||
|
|
||||||
if (!ctx) {
|
if (!ctx) {
|
||||||
int r;
|
int r;
|
||||||
r = libusb_init(&ctx);
|
r = libusb_init(&ctx);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
usbi_err("initialization failed!");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,7 +111,6 @@ static int find_busses(struct usb_bus **ret)
|
|||||||
|
|
||||||
r = libusb_get_device_list(ctx, &dev_list);
|
r = libusb_get_device_list(ctx, &dev_list);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
usbi_err("get_device_list failed with error %d", r);
|
|
||||||
return compat_err(r);
|
return compat_err(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,10 +180,8 @@ int usb_find_busses(void)
|
|||||||
if (!ctx)
|
if (!ctx)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
usbi_dbg("");
|
|
||||||
r = find_busses(&new_busses);
|
r = find_busses(&new_busses);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
usbi_err("find_busses failed with error %d", r);
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,7 +194,6 @@ int usb_find_busses(void)
|
|||||||
struct usb_bus *tbus = bus->next;
|
struct usb_bus *tbus = bus->next;
|
||||||
struct usb_bus *nbus = new_busses;
|
struct usb_bus *nbus = new_busses;
|
||||||
int found = 0;
|
int found = 0;
|
||||||
usbi_dbg("in loop");
|
|
||||||
|
|
||||||
while (nbus) {
|
while (nbus) {
|
||||||
struct usb_bus *tnbus = nbus->next;
|
struct usb_bus *tnbus = nbus->next;
|
||||||
@ -232,7 +209,6 @@ int usb_find_busses(void)
|
|||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
/* bus removed */
|
/* bus removed */
|
||||||
usbi_dbg("bus %d removed", bus->location);
|
|
||||||
changes++;
|
changes++;
|
||||||
LIST_DEL(usb_busses, bus);
|
LIST_DEL(usb_busses, bus);
|
||||||
free(bus);
|
free(bus);
|
||||||
@ -245,7 +221,6 @@ int usb_find_busses(void)
|
|||||||
bus = new_busses;
|
bus = new_busses;
|
||||||
while (bus) {
|
while (bus) {
|
||||||
struct usb_bus *tbus = bus->next;
|
struct usb_bus *tbus = bus->next;
|
||||||
usbi_dbg("bus %d added", bus->location);
|
|
||||||
LIST_DEL(new_busses, bus);
|
LIST_DEL(new_busses, bus);
|
||||||
LIST_ADD(usb_busses, bus);
|
LIST_ADD(usb_busses, bus);
|
||||||
changes++;
|
changes++;
|
||||||
@ -465,7 +440,6 @@ static int initialize_device(struct usb_device *dev)
|
|||||||
r = libusb_get_device_descriptor(newlib_dev,
|
r = libusb_get_device_descriptor(newlib_dev,
|
||||||
(struct libusb_device_descriptor *) &dev->descriptor);
|
(struct libusb_device_descriptor *) &dev->descriptor);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
usbi_err("error %d getting device descriptor", r);
|
|
||||||
return compat_err(r);
|
return compat_err(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -525,7 +499,6 @@ int usb_find_devices(void)
|
|||||||
if (!ctx)
|
if (!ctx)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
usbi_dbg("");
|
|
||||||
dev_list_len = libusb_get_device_list(ctx, &dev_list);
|
dev_list_len = libusb_get_device_list(ctx, &dev_list);
|
||||||
if (dev_list_len < 0)
|
if (dev_list_len < 0)
|
||||||
return compat_err(dev_list_len);
|
return compat_err(dev_list_len);
|
||||||
@ -561,8 +534,6 @@ int usb_find_devices(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
usbi_dbg("device %d.%d removed",
|
|
||||||
dev->bus->location, dev->devnum);
|
|
||||||
LIST_DEL(bus->devices, dev);
|
LIST_DEL(bus->devices, dev);
|
||||||
free_device(dev);
|
free_device(dev);
|
||||||
changes++;
|
changes++;
|
||||||
@ -577,12 +548,9 @@ int usb_find_devices(void)
|
|||||||
struct usb_device *tdev = dev->next;
|
struct usb_device *tdev = dev->next;
|
||||||
r = initialize_device(dev);
|
r = initialize_device(dev);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
usbi_err("couldn't initialize device %d.%d (error %d)",
|
|
||||||
dev->bus->location, dev->devnum, r);
|
|
||||||
dev = tdev;
|
dev = tdev;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
usbi_dbg("device %d.%d added", dev->bus->location, dev->devnum);
|
|
||||||
LIST_DEL(new_devices, dev);
|
LIST_DEL(new_devices, dev);
|
||||||
LIST_ADD(bus->devices, dev);
|
LIST_ADD(bus->devices, dev);
|
||||||
changes++;
|
changes++;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user