]> sigrok.org Git - libsigrok.git/commitdiff
hardware: Call libusb_error_name() in all USB-related error messages
authorPeter Stuge <redacted>
Tue, 4 Dec 2012 20:11:25 +0000 (21:11 +0100)
committerBert Vermeulen <redacted>
Wed, 5 Dec 2012 00:14:44 +0000 (01:14 +0100)
hardware/common/ezusb.c
hardware/common/usb.c
hardware/fx2lafw/command.c
hardware/fx2lafw/fx2lafw.c
hardware/hantek-dso/api.c
hardware/hantek-dso/dso.c
hardware/uni-t-dmm/protocol.c
hardware/victor-dmm/api.c
hardware/zeroplus-logic-cube/gl_usb.c
hardware/zeroplus-logic-cube/zeroplus.c

index 6b49645b63b2f9f52f440bf081567c624a8ad1de..947fe1f834c1d7662c3a791a153c2aabdaafe8b5 100644 (file)
@@ -50,7 +50,8 @@ SR_PRIV int ezusb_reset(struct libusb_device_handle *hdl, int set_clear)
        ret = libusb_control_transfer(hdl, LIBUSB_REQUEST_TYPE_VENDOR, 0xa0,
                                      0xe600, 0x0000, buf, 1, 100);
        if (ret < 0)
-               sr_err("Unable to send control request: %d", ret);
+               sr_err("Unable to send control request: %s",
+                               libusb_error_name(ret));
 
        return ret;
 }
@@ -79,8 +80,8 @@ SR_PRIV int ezusb_install_firmware(libusb_device_handle *hdl,
                                              LIBUSB_ENDPOINT_OUT, 0xa0, offset,
                                              0x0000, buf, chunksize, 100);
                if (ret < 0) {
-                       sr_err("Unable to send firmware to device: %d",
-                              ret);
+                       sr_err("Unable to send firmware to device: %s",
+                                       libusb_error_name(ret));
                        result = SR_ERR;
                        break;
                }
@@ -103,7 +104,8 @@ SR_PRIV int ezusb_upload_firmware(libusb_device *dev, int configuration,
                libusb_get_bus_number(dev), libusb_get_device_address(dev));
 
        if ((ret = libusb_open(dev, &hdl)) < 0) {
-               sr_err("failed to open device: %d", ret);
+               sr_err("ezusb: failed to open device: %s",
+                               libusb_error_name(ret));
                return SR_ERR;
        }
 
@@ -111,14 +113,16 @@ SR_PRIV int ezusb_upload_firmware(libusb_device *dev, int configuration,
 #if !defined(_WIN32) && !defined(__APPLE__)
        if (libusb_kernel_driver_active(hdl, 0)) {
                if ((ret = libusb_detach_kernel_driver(hdl, 0)) < 0) {
-                       sr_err("failed to detach kernel driver: %d", ret);
+                       sr_err("failed to detach kernel driver: %s",
+                                       libusb_error_name(ret));
                        return SR_ERR;
                }
        }
 #endif
 
        if ((ret = libusb_set_configuration(hdl, configuration)) < 0) {
-               sr_err("Unable to set configuration: %d", ret);
+               sr_err("Unable to set configuration: %s",
+                               libusb_error_name(ret));
                return SR_ERR;
        }
 
index 4c0c5b031069a0e10af1de091ffba7dc9488a4ad..2e90b7ccae80c20832cdbb2ea5320f44055e5b2e 100644 (file)
@@ -123,7 +123,8 @@ SR_PRIV GSList *sr_usb_find(libusb_context *usb_ctx, const char *conn)
        libusb_get_device_list(usb_ctx, &devlist);
        for (i = 0; devlist[i]; i++) {
                if ((ret = libusb_get_device_descriptor(devlist[i], &des))) {
-                       sr_err("Failed to get device descriptor: %d.", ret);
+                       sr_err("Failed to get device descriptor: %s.",
+                              libusb_error_name(ret));
                        continue;
                }
 
index a1c2109c120d08d83ab568e97f598611f2a52cbc..6c72c8d035d4855cf41c6911548a4f69f22d722c 100644 (file)
@@ -33,7 +33,8 @@ SR_PRIV int command_get_fw_version(libusb_device_handle *devhdl,
                (unsigned char *)vi, sizeof(struct version_info), 100);
 
        if (ret < 0) {
-               sr_err("fx2lafw: Unable to get version info: %d.", ret);
+               sr_err("fx2lafw: Unable to get version info: %s.",
+                      libusb_error_name(ret));
                return SR_ERR;
        }
 
@@ -50,7 +51,8 @@ SR_PRIV int command_get_revid_version(libusb_device_handle *devhdl,
                revid, 1, 100);
 
        if (ret < 0) {
-               sr_err("fx2lafw: Unable to get REVID: %d.", ret);
+               sr_err("fx2lafw: Unable to get REVID: %s.",
+                      libusb_error_name(ret));
                return SR_ERR;
        }
 
@@ -103,7 +105,8 @@ SR_PRIV int command_start_acquisition(libusb_device_handle *devhdl,
                        LIBUSB_ENDPOINT_OUT, CMD_START, 0x0000, 0x0000,
                        (unsigned char *)&cmd, sizeof(cmd), 100);
        if (ret < 0) {
-               sr_err("fx2lafw: Unable to send start command: %d.", ret);
+               sr_err("fx2lafw: Unable to send start command: %s.",
+                      libusb_error_name(ret));
                return SR_ERR;
        }
 
index d3fd85f20782ec3f355be0d78c3d2e8806a53331..648b13f48cb0361712a59b8bf032f778b1503280 100644 (file)
@@ -216,8 +216,8 @@ static int fx2lafw_dev_open(struct sr_dev_inst *sdi)
 
        for (i = 0; i < device_count; i++) {
                if ((ret = libusb_get_device_descriptor(devlist[i], &des))) {
-                       sr_err("fx2lafw: Failed to get device descriptor: %d.",
-                              ret);
+                       sr_err("fx2lafw: Failed to get device descriptor: %s.",
+                              libusb_error_name(ret));
                        continue;
                }
 
@@ -250,7 +250,8 @@ static int fx2lafw_dev_open(struct sr_dev_inst *sdi)
                                 */
                                devc->usb->address = libusb_get_device_address(devlist[i]);
                } else {
-                       sr_err("fx2lafw: Failed to open device: %d.", ret);
+                       sr_err("fx2lafw: Failed to open device: %s.",
+                              libusb_error_name(ret));
                        break;
                }
 
@@ -442,7 +443,8 @@ static GSList *hw_scan(GSList *options)
 
                if ((ret = libusb_get_device_descriptor(
                     devlist[i], &des)) != 0) {
-                       sr_warn("fx2lafw: Failed to get device descriptor: %d.", ret);
+                       sr_warn("fx2lafw: Failed to get device descriptor: %s.",
+                               libusb_error_name(ret));
                        continue;
                }
 
@@ -564,7 +566,8 @@ static int hw_dev_open(struct sr_dev_inst *sdi)
                        break;
 
                default:
-                       sr_err("fx2lafw: Unable to claim interface: %d.", ret);
+                       sr_err("fx2lafw: Unable to claim interface: %s.",
+                              libusb_error_name(ret));
                        break;
                }
 
@@ -750,12 +753,15 @@ static void free_transfer(struct libusb_transfer *transfer)
 
 static void resubmit_transfer(struct libusb_transfer *transfer)
 {
-       if (libusb_submit_transfer(transfer) != 0) {
-               free_transfer(transfer);
-               /* TODO: Stop session? */
-               /* TODO: Better error message. */
-               sr_err("fx2lafw: %s: libusb_submit_transfer error.", __func__);
-       }
+       int ret = libusb_submit_transfer(transfer);
+
+       if (LIBUSB_SUCCESS == ret)
+               return;
+
+       free_transfer(transfer);
+       /* TODO: Stop session? */
+
+       sr_err("fx2lafw: %s: %s", __func__, libusb_error_name(ret));
 }
 
 static void receive_transfer(struct libusb_transfer *transfer)
@@ -984,7 +990,9 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
                libusb_fill_bulk_transfer(transfer, devc->usb->devhdl,
                                2 | LIBUSB_ENDPOINT_IN, buf, size,
                                receive_transfer, devc, timeout);
-               if (libusb_submit_transfer(transfer) != 0) {
+               if ((ret = libusb_submit_transfer(transfer)) != 0) {
+                       sr_err("fx2lafw: %s: libusb_submit_transfer: %s.",
+                              __func__, libusb_error_name(ret));
                        libusb_free_transfer(transfer);
                        g_free(buf);
                        abort_acquisition(devc);
index 8d9a8b08cefbd0aa5860e791689a88b023fc7f22..01a080017e2eae8339a828e0c295e97adf3467d1 100644 (file)
@@ -292,7 +292,8 @@ static GSList *hw_scan(GSList *options)
        libusb_get_device_list(drvc->sr_ctx->libusb_ctx, &devlist);
        for (i = 0; devlist[i]; i++) {
                if ((ret = libusb_get_device_descriptor(devlist[i], &des))) {
-                       sr_err("Failed to get device descriptor: %d.", ret);
+                       sr_err("Failed to get device descriptor: %s.",
+                              libusb_error_name(ret));
                        continue;
                }
 
@@ -390,7 +391,8 @@ static int hw_dev_open(struct sr_dev_inst *sdi)
 
        err = libusb_claim_interface(devc->usb->devhdl, USB_INTERFACE);
        if (err != 0) {
-               sr_err("Unable to claim interface: %d.", err);
+               sr_err("Unable to claim interface: %s.",
+                      libusb_error_name(err));
                return SR_ERR;
        }
 
index 0167f9636397646ff9fbd47ad43661884bed69c7..853bab340146ce2bb34eefa4cb3d12b5de203fcd 100644 (file)
@@ -39,7 +39,8 @@ static int send_begin(struct dev_context *devc)
        if ((ret = libusb_control_transfer(devc->usb->devhdl,
                        LIBUSB_REQUEST_TYPE_VENDOR, CTRL_BEGINCOMMAND,
                        0, 0, buffer, sizeof(buffer), 200)) != sizeof(buffer)) {
-               sr_err("Failed to send begincommand: %d.", ret);
+               sr_err("Failed to send begincommand: %s.",
+                      libusb_error_name(ret));
                return SR_ERR;
        }
 
@@ -119,7 +120,8 @@ SR_PRIV int dso_open(struct sr_dev_inst *sdi)
        libusb_get_device_list(drvc->sr_ctx->libusb_ctx, &devlist);
        for (i = 0; devlist[i]; i++) {
                if ((err = libusb_get_device_descriptor(devlist[i], &des))) {
-                       sr_err("Failed to get device descriptor: %d.", err);
+                       sr_err("Failed to get device descriptor: %s.",
+                              libusb_error_name(err));
                        continue;
                }
 
@@ -161,7 +163,8 @@ SR_PRIV int dso_open(struct sr_dev_inst *sdi)
                                        devc->usb->address, USB_INTERFACE);
                        }
                } else {
-                       sr_err("Failed to open device: %d.", err);
+                       sr_err("Failed to open device: %s.",
+                              libusb_error_name(err));
                }
 
                /* If we made it here, we handled the device (somehow). */
@@ -206,7 +209,8 @@ static int get_channel_offsets(struct dev_context *devc)
                        (unsigned char *)&devc->channel_levels,
                        sizeof(devc->channel_levels), 200);
        if (ret != sizeof(devc->channel_levels)) {
-               sr_err("Failed to get channel offsets: %d.", ret);
+               sr_err("Failed to get channel offsets: %s.",
+                      libusb_error_name(ret));
                return SR_ERR;
        }
 
@@ -349,7 +353,8 @@ SR_PRIV int dso_set_trigger_samplerate(struct dev_context *devc)
                        DSO_EP_OUT | LIBUSB_ENDPOINT_OUT,
                        cmdstring, sizeof(cmdstring),
                        &tmp, 100)) != 0) {
-               sr_err("Failed to set trigger/samplerate: %d.", ret);
+               sr_err("Failed to set trigger/samplerate: %s.",
+                      libusb_error_name(ret));
                return SR_ERR;
        }
        sr_dbg("Sent CMD_SET_TRIGGER_SAMPLERATE.");
@@ -388,7 +393,8 @@ SR_PRIV int dso_set_filters(struct dev_context *devc)
                        DSO_EP_OUT | LIBUSB_ENDPOINT_OUT,
                        cmdstring, sizeof(cmdstring),
                        &tmp, 100)) != 0) {
-               sr_err("Failed to set filters: %d", ret);
+               sr_err("Failed to set filters: %s",
+                      libusb_error_name(ret));
                return SR_ERR;
        }
        sr_dbg("Sent CMD_SET_FILTERS.");
@@ -455,7 +461,8 @@ SR_PRIV int dso_set_voltage(struct dev_context *devc)
                        DSO_EP_OUT | LIBUSB_ENDPOINT_OUT,
                        cmdstring, sizeof(cmdstring),
                        &tmp, 100)) != 0) {
-               sr_err("Failed to set voltage: %d.", ret);
+               sr_err("Failed to set voltage: %s.",
+                      libusb_error_name(ret));
                return SR_ERR;
        }
        sr_dbg("Sent CMD_SET_VOLTAGE.");
@@ -507,7 +514,8 @@ SR_PRIV int dso_set_relays(struct dev_context *devc)
        if ((ret = libusb_control_transfer(devc->usb->devhdl,
                        LIBUSB_REQUEST_TYPE_VENDOR, CTRL_SETRELAYS,
                        0, 0, relays, 17, 100)) != sizeof(relays)) {
-               sr_err("Failed to set relays: %d.", ret);
+               sr_err("Failed to set relays: %s.",
+                      libusb_error_name(ret));
                return SR_ERR;
        }
        sr_dbg("Sent CTRL_SETRELAYS.");
@@ -550,7 +558,8 @@ SR_PRIV int dso_set_voffsets(struct dev_context *devc)
        if ((ret = libusb_control_transfer(devc->usb->devhdl,
                        LIBUSB_REQUEST_TYPE_VENDOR, CTRL_SETOFFSET,
                        0, 0, offsets, sizeof(offsets), 100)) != sizeof(offsets)) {
-               sr_err("Failed to set offsets: %d.", ret);
+               sr_err("Failed to set offsets: %s.",
+                      libusb_error_name(ret));
                return SR_ERR;
        }
        sr_dbg("Sent CTRL_SETOFFSET.");
@@ -576,7 +585,8 @@ SR_PRIV int dso_enable_trigger(struct dev_context *devc)
                        DSO_EP_OUT | LIBUSB_ENDPOINT_OUT,
                        cmdstring, sizeof(cmdstring),
                        &tmp, 100)) != 0) {
-               sr_err("Failed to enable trigger: %d.", ret);
+               sr_err("Failed to enable trigger: %s.",
+                      libusb_error_name(ret));
                return SR_ERR;
        }
 
@@ -601,7 +611,8 @@ SR_PRIV int dso_force_trigger(struct dev_context *devc)
                        DSO_EP_OUT | LIBUSB_ENDPOINT_OUT,
                        cmdstring, sizeof(cmdstring),
                        &tmp, 100)) != 0) {
-               sr_err("Failed to force trigger: %d.", ret);
+               sr_err("Failed to force trigger: %s.",
+                      libusb_error_name(ret));
                return SR_ERR;
        }
 
@@ -651,14 +662,16 @@ SR_PRIV int dso_get_capturestate(struct dev_context *devc,
        cmdstring[1] = 0;
 
        if ((ret = send_bulkcmd(devc, cmdstring, sizeof(cmdstring))) != SR_OK) {
-               sr_dbg("Failed to send get_capturestate command: %d.", ret);
+               sr_dbg("Failed to send get_capturestate command: %s.",
+                      libusb_error_name(ret));
                return SR_ERR;
        }
 
        if ((ret = libusb_bulk_transfer(devc->usb->devhdl,
                        DSO_EP_IN | LIBUSB_ENDPOINT_IN,
                        inbuf, 512, &tmp, 100)) != 0) {
-               sr_dbg("Failed to get capturestate: %d.", ret);
+               sr_dbg("Failed to get capturestate: %s.",
+                      libusb_error_name(ret));
                return SR_ERR;
        }
        *capturestate = inbuf[0];
@@ -692,7 +705,8 @@ SR_PRIV int dso_capture_start(struct dev_context *devc)
        cmdstring[1] = 0;
 
        if ((ret = send_bulkcmd(devc, cmdstring, sizeof(cmdstring))) != SR_OK) {
-               sr_err("Failed to send capture_start command: %d.", ret);
+               sr_err("Failed to send capture_start command: %s.",
+                      libusb_error_name(ret));
                return SR_ERR;
        }
 
@@ -712,7 +726,8 @@ SR_PRIV int dso_get_channeldata(struct dev_context *devc, libusb_transfer_cb_fn
        cmdstring[1] = 0;
 
        if ((ret = send_bulkcmd(devc, cmdstring, sizeof(cmdstring))) != SR_OK) {
-               sr_err("Failed to get channel data: %d.", ret);
+               sr_err("Failed to get channel data: %s.",
+                      libusb_error_name(ret));
                return SR_ERR;
        }
 
@@ -730,7 +745,8 @@ SR_PRIV int dso_get_channeldata(struct dev_context *devc, libusb_transfer_cb_fn
                                DSO_EP_IN | LIBUSB_ENDPOINT_IN, buf,
                                devc->epin_maxpacketsize, cb, devc, 40);
                if ((ret = libusb_submit_transfer(transfer)) != 0) {
-                       sr_err("Failed to submit transfer: %d.", ret);
+                       sr_err("Failed to submit transfer: %s.",
+                              libusb_error_name(ret));
                        /* TODO: Free them all. */
                        libusb_free_transfer(transfer);
                        g_free(buf);
index 96d26a65085e302f2751ed30b874d5b4e71f47a5..a4b69403f878e5c625295a04ce08fd3d72d0d513 100644 (file)
@@ -106,7 +106,8 @@ static int hid_chip_init(struct dev_context *devc, uint16_t baudrate)
        if (libusb_kernel_driver_active(devc->usb->devhdl, 0) == 1) {
                ret = libusb_detach_kernel_driver(devc->usb->devhdl, 0);
                if (ret < 0) {
-                       sr_err("Failed to detach kernel driver: %d.", ret);
+                       sr_err("Failed to detach kernel driver: %s.",
+                              libusb_error_name(ret));
                        return SR_ERR;
                }
                sr_dbg("Successfully detached kernel driver.");
@@ -116,7 +117,8 @@ static int hid_chip_init(struct dev_context *devc, uint16_t baudrate)
 
        /* Claim interface 0. */
        if ((ret = libusb_claim_interface(devc->usb->devhdl, 0)) < 0) {
-               sr_err("Failed to claim interface 0: %d.", ret);
+               sr_err("Failed to claim interface 0: %s.",
+                      libusb_error_name(ret));
                return SR_ERR;
        }
        sr_dbg("Successfully claimed interface 0.");
@@ -145,7 +147,7 @@ static int hid_chip_init(struct dev_context *devc, uint16_t baudrate)
                1000 /* timeout (ms) */);
 
        if (ret < 0) {
-               sr_err("HID feature report error: %d.", ret);
+               sr_err("HID feature report error: %s.", libusb_error_name(ret));
                return SR_ERR;
        }
 
@@ -216,7 +218,7 @@ static int uni_t_dmm_receive_data(int fd, int revents, int dmm, void *cb_data)
                1000 /* timeout (ms) */);
 
        if (ret < 0) {
-               sr_err("USB receive error: %d.", ret);
+               sr_err("USB receive error: %s.", libusb_error_name(ret));
                return FALSE;
        }
 
index a389b0794799932f62ee0aeb803ff286b603faa0..46e8c1d5b35c61124b5dd42b03bbf334928f3c44 100644 (file)
@@ -194,8 +194,9 @@ static int hw_dev_open(struct sr_dev_inst *sdi)
        /* The device reports as HID class, so the kernel would have
         * claimed it. */
        if (libusb_kernel_driver_active(devc->usb->devhdl, 0) == 1) {
-               if (libusb_detach_kernel_driver(devc->usb->devhdl, 0) < 0) {
-                       sr_err("Failed to detach kernel driver.");
+               if ((ret = libusb_detach_kernel_driver(devc->usb->devhdl, 0)) < 0) {
+                       sr_err("Failed to detach kernel driver: %s.",
+                              libusb_error_name(ret));
                        return SR_ERR;
                }
        }
index 6b894da91cd994d0601412d535e2079f97771f2f..cd7d97a81f043fd62594a5b8f90e42f2b524dc7b 100644 (file)
@@ -58,8 +58,7 @@ static int gl_write_address(libusb_device_handle *devh, unsigned int address)
        ret = libusb_control_transfer(devh, CTRL_OUT, 0xc, REQ_WRITEADDR,
                                         0, packet, 1, TIMEOUT);
        if (ret != 1)
-               sr_err("zp: %s: libusb_control_transfer returned %d.",
-                      __func__, ret);
+               sr_err("zp: %s: %s.", __func__, libusb_error_name(ret));
        return ret;
 }
 
@@ -71,8 +70,7 @@ static int gl_write_data(libusb_device_handle *devh, unsigned int val)
        ret = libusb_control_transfer(devh, CTRL_OUT, 0xc, REQ_WRITEDATA,
                                      0, packet, 1, TIMEOUT);
        if (ret != 1)
-               sr_err("zp: %s: libusb_control_transfer returned %d.",
-                      __func__, ret);
+               sr_err("zp: %s: %s.", __func__, libusb_error_name(ret));
        return ret;
 }
 
@@ -84,8 +82,8 @@ static int gl_read_data(libusb_device_handle *devh)
        ret = libusb_control_transfer(devh, CTRL_IN, 0xc, REQ_READDATA,
                                      0, packet, 1, TIMEOUT);
        if (ret != 1)
-               sr_err("zp: %s: libusb_control_transfer returned %d, "
-                      "val=%hhx.", __func__, ret, packet[0]);
+               sr_err("zp: %s: %s, val=%hhx.", __func__,
+                      libusb_error_name(ret), packet[0]);
        return (ret == 1) ? packet[0] : ret;
 }
 
@@ -100,13 +98,14 @@ SR_PRIV int gl_read_bulk(libusb_device_handle *devh, void *buffer,
        ret = libusb_control_transfer(devh, CTRL_OUT, 0x4, REQ_READBULK,
                                      0, packet, 8, TIMEOUT);
        if (ret != 8)
-               sr_err("zp: %s: libusb_control_transfer returned %d.",
-                      __func__, ret);
+               sr_err("zp: %s: libusb_control_transfer: %s.", __func__,
+                      libusb_error_name(ret));
 
        ret = libusb_bulk_transfer(devh, EP1_BULK_IN, buffer, size,
                                   &transferred, TIMEOUT);
        if (ret < 0)
-               sr_err("zp: Bulk read error %d.", ret);
+               sr_err("zp: %s: libusb_bulk_transfer: %s.", __func__,
+                      libusb_error_name(ret));
        return transferred;
 }
 
index 70d90fe6c632f51f83f6e084c778ddfb071bc5fd..56b020228bbf2251308a797b17b663df86f7679f 100644 (file)
@@ -341,7 +341,8 @@ static GSList *hw_scan(GSList *options)
        for (i = 0; devlist[i]; i++) {
                ret = libusb_get_device_descriptor(devlist[i], &des);
                if (ret != 0) {
-                       sr_err("zp: failed to get device descriptor: %d", ret);
+                       sr_err("zp: failed to get device descriptor: %s",
+                              libusb_error_name(ret));
                        continue;
                }
 
@@ -436,8 +437,8 @@ static int hw_dev_open(struct sr_dev_inst *sdi)
        dev = NULL;
        for (i = 0; i < device_count; i++) {
                if ((ret = libusb_get_device_descriptor(devlist[i], &des))) {
-                       sr_err("fx2lafw: Failed to get device descriptor: %d.",
-                              ret);
+                       sr_err("zp: Failed to get device descriptor: %s.",
+                              libusb_error_name(ret));
                        continue;
                }
                if (libusb_get_bus_number(devlist[i]) == devc->usb->bus
@@ -458,20 +459,21 @@ static int hw_dev_open(struct sr_dev_inst *sdi)
                        sdi->index, devc->usb->bus,
                        devc->usb->address, USB_INTERFACE);
        } else {
-               sr_err("zp: failed to open device: %d", ret);
+               sr_err("zp: failed to open device: %s", libusb_error_name(ret));
                return SR_ERR;
        }
 
        ret = libusb_set_configuration(devc->usb->devhdl, USB_CONFIGURATION);
        if (ret < 0) {
-               sr_err("zp: Unable to set USB configuration %d: %d",
-                      USB_CONFIGURATION, ret);
+               sr_err("zp: Unable to set USB configuration %d: %s",
+                      USB_CONFIGURATION, libusb_error_name(ret));
                return SR_ERR;
        }
 
        ret = libusb_claim_interface(devc->usb->devhdl, USB_INTERFACE);
        if (ret != 0) {
-               sr_err("zp: Unable to claim interface: %d", ret);
+               sr_err("zp: Unable to claim interface: %s",
+                      libusb_error_name(ret));
                return SR_ERR;
        }