From 154e4f4b6161d9561712dc107e3baff88b49b264 Mon Sep 17 00:00:00 2001 From: Kano Date: Wed, 13 Mar 2013 11:04:05 +1100 Subject: [PATCH] usbutils allow call of usb_all() from other code --- usbutils.c | 12 ++++++------ usbutils.h | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/usbutils.c b/usbutils.c index 93d918ca..e7567ef2 100644 --- a/usbutils.c +++ b/usbutils.c @@ -411,7 +411,7 @@ static bool setgetdes(ssize_t count, libusb_device *dev, struct libusb_device_ha return true; } -static void usb_full(ssize_t count, libusb_device *dev, char **buf, size_t *off, size_t *len) +static void usb_full(ssize_t count, libusb_device *dev, char **buf, size_t *off, size_t *len, int level) { struct libusb_device_descriptor desc; uint8_t bus_number; @@ -437,7 +437,7 @@ static void usb_full(ssize_t count, libusb_device *dev, char **buf, size_t *off, bus_number = libusb_get_bus_number(dev); device_address = libusb_get_device_address(dev); - if (opt_usbdump == 0) { + if (level == 0) { sprintf(tmp, EOL ".USB dev %d: Bus %d Device %d ID: %04x:%04x", (int)count, (int)bus_number, (int)device_address, desc.idVendor, desc.idProduct); @@ -471,7 +471,7 @@ static void usb_full(ssize_t count, libusb_device *dev, char **buf, size_t *off, if (err < 0) sprintf((char *)prod, "** err(%d)", err); - if (opt_usbdump == 0) { + if (level == 0) { libusb_close(handle); sprintf(tmp, EOL " Manufacturer: '%s'" EOL " Product: '%s'", man, prod); append(buf, tmp, off, len); @@ -556,7 +556,7 @@ static void usb_full(ssize_t count, libusb_device *dev, char **buf, size_t *off, } // Function to dump all USB devices -static void usb_all() +void usb_all(int level) { libusb_device **list; ssize_t count, i; @@ -581,7 +581,7 @@ static void usb_all() off = strlen(buf); for (i = 0; i < count; i++) - usb_full(i, list[i], &buf, &off, &len); + usb_full(i, list[i], &buf, &off, &len, level); applog(LOG_WARNING, "%s", buf); @@ -599,7 +599,7 @@ static void cgusb_check_init() // N.B. environment LIBUSB_DEBUG also sets libusb_set_debug() if (opt_usbdump >= 0) { libusb_set_debug(NULL, opt_usbdump); - usb_all(); + usb_all(opt_usbdump); } usb_commands = malloc(sizeof(*usb_commands) * C_MAX); diff --git a/usbutils.h b/usbutils.h index 8a364c9b..de79312e 100644 --- a/usbutils.h +++ b/usbutils.h @@ -129,6 +129,7 @@ enum usb_cmds { struct device_drv; struct cgpu_info; +void usb_all(int level); void usb_uninit(struct cgpu_info *cgpu); bool usb_init(struct cgpu_info *cgpu, struct libusb_device *dev, struct usb_find_devices *found); void usb_detect(struct device_drv *drv, bool (*device_detect)(struct libusb_device *, struct usb_find_devices *));