From a0bbbd7d32150ab6ed25f466cce05169fbbbaead Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Sat, 5 Nov 2016 00:10:17 +0100 Subject: [PATCH] drivers: Print USB error when libusb_claim_interface() fails https://bugs.freedesktop.org/show_bug.cgi?id=98594 --- libfprint/drivers/aes1610.c | 2 +- libfprint/drivers/aes1660.c | 2 +- libfprint/drivers/aes2501.c | 2 +- libfprint/drivers/aes2550.c | 2 +- libfprint/drivers/aes2660.c | 2 +- libfprint/drivers/aes3500.c | 2 +- libfprint/drivers/aes4000.c | 2 +- libfprint/drivers/etes603.c | 3 +-- libfprint/drivers/fdu2000.c | 6 ++++-- libfprint/drivers/upeke2.c | 4 +++- libfprint/drivers/upeksonly.c | 2 +- libfprint/drivers/upektc.c | 2 +- libfprint/drivers/upektc_img.c | 2 +- libfprint/drivers/upekts.c | 4 +++- libfprint/drivers/uru4000.c | 2 +- libfprint/drivers/vcom5s.c | 2 +- libfprint/drivers/vfs101.c | 2 +- libfprint/drivers/vfs301.c | 2 +- libfprint/drivers/vfs5011.c | 2 +- 19 files changed, 26 insertions(+), 21 deletions(-) diff --git a/libfprint/drivers/aes1610.c b/libfprint/drivers/aes1610.c index 5661753..50bc483 100644 --- a/libfprint/drivers/aes1610.c +++ b/libfprint/drivers/aes1610.c @@ -811,7 +811,7 @@ static int dev_init(struct fp_img_dev *dev, unsigned long driver_data) r = libusb_claim_interface(dev->udev, 0); if (r < 0) { - fp_err("could not claim interface 0"); + fp_err("could not claim interface 0: %s", libusb_error_name(r)); return r; } diff --git a/libfprint/drivers/aes1660.c b/libfprint/drivers/aes1660.c index 8e63fe3..32bea4e 100644 --- a/libfprint/drivers/aes1660.c +++ b/libfprint/drivers/aes1660.c @@ -53,7 +53,7 @@ static int dev_init(struct fp_img_dev *dev, unsigned long driver_data) r = libusb_claim_interface(dev->udev, 0); if (r < 0) { - fp_err("could not claim interface 0"); + fp_err("could not claim interface 0: %s", libusb_error_name(r)); return r; } diff --git a/libfprint/drivers/aes2501.c b/libfprint/drivers/aes2501.c index 6c852a5..f6e3edf 100644 --- a/libfprint/drivers/aes2501.c +++ b/libfprint/drivers/aes2501.c @@ -850,7 +850,7 @@ static int dev_init(struct fp_img_dev *dev, unsigned long driver_data) r = libusb_claim_interface(dev->udev, 0); if (r < 0) { - fp_err("could not claim interface 0"); + fp_err("could not claim interface 0: %s", libusb_error_name(r)); return r; } diff --git a/libfprint/drivers/aes2550.c b/libfprint/drivers/aes2550.c index 965bdb0..387967e 100644 --- a/libfprint/drivers/aes2550.c +++ b/libfprint/drivers/aes2550.c @@ -622,7 +622,7 @@ static int dev_init(struct fp_img_dev *dev, unsigned long driver_data) r = libusb_claim_interface(dev->udev, 0); if (r < 0) { - fp_err("could not claim interface 0"); + fp_err("could not claim interface 0: %s", libusb_error_name(r)); return r; } diff --git a/libfprint/drivers/aes2660.c b/libfprint/drivers/aes2660.c index 7cae59c..efe9670 100644 --- a/libfprint/drivers/aes2660.c +++ b/libfprint/drivers/aes2660.c @@ -53,7 +53,7 @@ static int dev_init(struct fp_img_dev *dev, unsigned long driver_data) r = libusb_claim_interface(dev->udev, 0); if (r < 0) { - fp_err("could not claim interface 0"); + fp_err("could not claim interface 0: %s", libusb_error_name(r)); return r; } diff --git a/libfprint/drivers/aes3500.c b/libfprint/drivers/aes3500.c index 6f4d6b0..05c204a 100644 --- a/libfprint/drivers/aes3500.c +++ b/libfprint/drivers/aes3500.c @@ -131,7 +131,7 @@ static int dev_init(struct fp_img_dev *dev, unsigned long driver_data) r = libusb_claim_interface(dev->udev, 0); if (r < 0) - fp_err("could not claim interface 0"); + fp_err("could not claim interface 0: %s", libusb_error_name(r)); aesdev = dev->priv = g_malloc0(sizeof(struct aes3k_dev)); diff --git a/libfprint/drivers/aes4000.c b/libfprint/drivers/aes4000.c index b849651..f1a9d06 100644 --- a/libfprint/drivers/aes4000.c +++ b/libfprint/drivers/aes4000.c @@ -128,7 +128,7 @@ static int dev_init(struct fp_img_dev *dev, unsigned long driver_data) r = libusb_claim_interface(dev->udev, 0); if (r < 0) - fp_err("could not claim interface 0"); + fp_err("could not claim interface 0: %s", libusb_error_name(r)); aesdev = dev->priv = g_malloc0(sizeof(struct aes3k_dev)); diff --git a/libfprint/drivers/etes603.c b/libfprint/drivers/etes603.c index aae0f0f..44cacbc 100644 --- a/libfprint/drivers/etes603.c +++ b/libfprint/drivers/etes603.c @@ -1465,8 +1465,7 @@ static int dev_open(struct fp_img_dev *idev, unsigned long driver_data) ret = libusb_claim_interface(idev->udev, 0); if (ret != LIBUSB_SUCCESS) { - fp_err("libusb_claim_interface failed on interface 0 " - "(err=%d)", ret); + fp_err("libusb_claim_interface failed on interface 0: %s", libusb_error_name(r)); return ret; } diff --git a/libfprint/drivers/fdu2000.c b/libfprint/drivers/fdu2000.c index ebd7103..e14b860 100644 --- a/libfprint/drivers/fdu2000.c +++ b/libfprint/drivers/fdu2000.c @@ -264,8 +264,10 @@ gint dev_init(struct fp_img_dev *dev, unsigned long driver_data) //if ( (r = usb_set_configuration(dev->udev, 1)) < 0 ) // goto out; - if ( (r = libusb_claim_interface(dev->udev, 0)) < 0 ) - goto out; + if ( (r = libusb_claim_interface(dev->udev, 0)) < 0 ) { + fp_err("could not claim interface 0: %s", libusb_error_name(r)); + return r; + } //if ( (r = usb_set_altinterface(dev->udev, 1)) < 0 ) // goto out; diff --git a/libfprint/drivers/upeke2.c b/libfprint/drivers/upeke2.c index f685205..3f05e80 100644 --- a/libfprint/drivers/upeke2.c +++ b/libfprint/drivers/upeke2.c @@ -864,8 +864,10 @@ static int dev_init(struct fp_dev *dev, unsigned long driver_data) int r; r = libusb_claim_interface(dev->udev, 0); - if (r < 0) + if (r < 0) { + fp_err("could not claim interface 0: %s", libusb_error_name(r)); return r; + } upekdev = g_malloc(sizeof(*upekdev)); upekdev->seq = 0xf0; /* incremented to 0x00 before first cmd */ diff --git a/libfprint/drivers/upeksonly.c b/libfprint/drivers/upeksonly.c index 22ada5e..5048a5c 100644 --- a/libfprint/drivers/upeksonly.c +++ b/libfprint/drivers/upeksonly.c @@ -1359,7 +1359,7 @@ static int dev_init(struct fp_img_dev *dev, unsigned long driver_data) r = libusb_claim_interface(dev->udev, 0); if (r < 0) { - fp_err("could not claim interface 0"); + fp_err("could not claim interface 0: %s", libusb_error_name(r)); return r; } diff --git a/libfprint/drivers/upektc.c b/libfprint/drivers/upektc.c index 271cffb..f3d9b8a 100644 --- a/libfprint/drivers/upektc.c +++ b/libfprint/drivers/upektc.c @@ -441,7 +441,7 @@ static int dev_init(struct fp_img_dev *dev, unsigned long driver_data) r = libusb_claim_interface(dev->udev, 0); if (r < 0) { - fp_err("could not claim interface 0"); + fp_err("could not claim interface 0: %s", libusb_error_name(r)); return r; } diff --git a/libfprint/drivers/upektc_img.c b/libfprint/drivers/upektc_img.c index 31eddff..18e271b 100644 --- a/libfprint/drivers/upektc_img.c +++ b/libfprint/drivers/upektc_img.c @@ -651,7 +651,7 @@ static int dev_init(struct fp_img_dev *dev, unsigned long driver_data) r = libusb_claim_interface(dev->udev, 0); if (r < 0) { - fp_err("could not claim interface 0"); + fp_err("could not claim interface 0: %s", libusb_error_name(r)); return r; } diff --git a/libfprint/drivers/upekts.c b/libfprint/drivers/upekts.c index c191a2d..b297127 100644 --- a/libfprint/drivers/upekts.c +++ b/libfprint/drivers/upekts.c @@ -875,8 +875,10 @@ static int dev_init(struct fp_dev *dev, unsigned long driver_data) int r; r = libusb_claim_interface(dev->udev, 0); - if (r < 0) + if (r < 0) { + fp_err("could not claim interface 0: %s", libusb_error_name(r)); return r; + } upekdev = g_malloc(sizeof(*upekdev)); upekdev->seq = 0xf0; /* incremented to 0x00 before first cmd */ diff --git a/libfprint/drivers/uru4000.c b/libfprint/drivers/uru4000.c index ccaa87f..462b86a 100644 --- a/libfprint/drivers/uru4000.c +++ b/libfprint/drivers/uru4000.c @@ -1285,7 +1285,7 @@ static int dev_init(struct fp_img_dev *dev, unsigned long driver_data) r = libusb_claim_interface(dev->udev, iface_desc->bInterfaceNumber); if (r < 0) { - fp_err("interface claim failed"); + fp_err("interface claim failed: %s", libusb_error_name(r)); goto out; } diff --git a/libfprint/drivers/vcom5s.c b/libfprint/drivers/vcom5s.c index 4b442b2..1f127a8 100644 --- a/libfprint/drivers/vcom5s.c +++ b/libfprint/drivers/vcom5s.c @@ -348,7 +348,7 @@ static int dev_init(struct fp_img_dev *dev, unsigned long driver_data) r = libusb_claim_interface(dev->udev, 0); if (r < 0) - fp_err("could not claim interface 0"); + fp_err("could not claim interface 0: %s", libusb_error_name(r)); if (r == 0) fpi_imgdev_open_complete(dev, 0); diff --git a/libfprint/drivers/vfs101.c b/libfprint/drivers/vfs101.c index 062bc42..3ee13e3 100644 --- a/libfprint/drivers/vfs101.c +++ b/libfprint/drivers/vfs101.c @@ -1504,7 +1504,7 @@ static int dev_open(struct fp_img_dev *dev, unsigned long driver_data) if (r < 0) { /* Interface not claimed, return error */ - fp_err("could not claim interface 0"); + fp_err("could not claim interface 0: %s", libusb_error_name(r)); return r; } diff --git a/libfprint/drivers/vfs301.c b/libfprint/drivers/vfs301.c index 04db05e..833c05b 100644 --- a/libfprint/drivers/vfs301.c +++ b/libfprint/drivers/vfs301.c @@ -240,7 +240,7 @@ static int dev_open(struct fp_img_dev *dev, unsigned long driver_data) r = libusb_claim_interface(dev->udev, 0); if (r < 0) { /* Interface not claimed, return error */ - fp_err("could not claim interface 0"); + fp_err("could not claim interface 0: %s", libusb_error_name(r)); return r; } diff --git a/libfprint/drivers/vfs5011.c b/libfprint/drivers/vfs5011.c index efa3df2..fa1dcab 100644 --- a/libfprint/drivers/vfs5011.c +++ b/libfprint/drivers/vfs5011.c @@ -849,7 +849,7 @@ static int dev_open(struct fp_img_dev *dev, unsigned long driver_data) r = libusb_claim_interface(dev->udev, 0); if (r != 0) { - fp_err("Failed to claim interface"); + fp_err("Failed to claim interface: %s", libusb_error_name(r)); return r; }