libftdi Archives

Subject: Re: (Corrected)In linusb-1.0, libusb_detach_kernel_driver is available unconditional

From: Xiaofan Chen <xiaofanc@xxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Tue, 18 May 2010 21:29:57 +0800
On Tue, May 18, 2010 at 8:46 PM, Xiaofan Chen <xiaofanc@xxxxxxxxx> wrote:
> On Tue, May 18, 2010 at 8:37 PM, Uwe Bonnes
> <bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
>
>> libftdi stores the result of usb_detach_kernel_driver_np and checks and
>> reports EPERM with usb_set_configuration() and usb_claim_interface(). The
>> messages seem quite hintfull for plain users.
>
> I was also thinking the codes in libftdi is better. But then I am not
> sure why the they are enclosed by the __WIN32__ ifdef. In
> this case, the code does not really help.

This is not correct. The codes following __WIN32__ ifdef is
correct. Sorry about that.

> On the other hand,
> Windows user will probably puzzled by the error message
> about permission and ftdi_sio. ;-)
>
> So I think the codes in libftdi also needs to be changed.

I think this is still correct.

For Windows libusb-win32, LIBUSB_HAS_GET_DRIVER_NP
is not defined. So detach_errno will stay at zero.

The following lines will not be reachable for Windows.

            if (detach_errno == EPERM)
            {
                ftdi_error_return(-8, "inappropriate permissions on device!");
            }
            else
            {
                ftdi_error_return(-3, "unable to set usb
configuration. Make sure ftdi_sio is unloaded!");
            }

Here is the proposed patch.

diff --git a/src/ftdi.c b/src/ftdi.c
index ac56d08..4500c8b 100644
--- a/src/ftdi.c
+++ b/src/ftdi.c
@@ -491,13 +491,7 @@ int ftdi_usb_open_dev(struct ftdi_context *ftdi,
struct usb_device *dev)
             errno != EBUSY)
         {
             ftdi_usb_close_internal (ftdi);
-            if (detach_errno == EPERM)
-            {
-                ftdi_error_return(-8, "inappropriate permissions on device!");
-            }
-            else
-            {
-                ftdi_error_return(-3, "unable to set usb
configuration. Make sure ftdi_sio is unloaded!");
+            ftdi_error_return(-3, "unable to set usb configuration.
Make sure libusb-win32 is installed properly");
             }
         }
     }


-- 
Xiaofan http://mcuee.blogspot.com

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx   

Current Thread