From 7e0ed6b79f2f5dbbb5843ed836ea07ba675e731d Mon Sep 17 00:00:00 2001 From: Dave Chapman Date: Sat, 15 Sep 2007 22:47:42 +0000 Subject: Add a call to usb_set_configuration() (apparently required for both Windows and Linux, but Linux didn't seem to mind) and also add some more error checking/reporting. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14721 a1c6a512-1295-4272-9138-f99709370657 --- rbutil/e200rpatcher/e200rpatcher.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/rbutil/e200rpatcher/e200rpatcher.c b/rbutil/e200rpatcher/e200rpatcher.c index eff6dc136b..8d0c674a5e 100644 --- a/rbutil/e200rpatcher/e200rpatcher.c +++ b/rbutil/e200rpatcher/e200rpatcher.c @@ -106,6 +106,7 @@ void do_patching(void) struct usb_device *tmp_dev; struct usb_device *dev = NULL; usb_dev_handle *dh; + int err; fprintf(stderr,"[INFO] Searching for E200R\n"); @@ -148,13 +149,21 @@ found: return; } - /* "must be called" written in the libusb documentation */ - if (usb_claim_interface(dh, dev->config->interface->altsetting->bInterfaceNumber)) { - fprintf(stderr, "[ERR] Device is busy. (I was unable to claim its interface.)\n"); + err = usb_set_configuration(dh, 1); + + if (err < 0) { + fprintf(stderr, "[ERR] usb_set_configuration failed (%d)\n", err); usb_close(dh); return; } + /* "must be called" written in the libusb documentation */ + err = usb_claim_interface(dh, dev->config->interface->altsetting->bInterfaceNumber); + if (err < 0) { + fprintf(stderr, "[ERR] Unable to claim interface (%d)\n", err); + usb_close(dh); + return; + } fprintf(stderr,"[INFO] Found E200R, uploading patching application.\n"); -- cgit v1.2.3