libftdi-git Archives

Subject: port libftdi to libusb-1.0 branch, master, updated. v0.17-195-ga3d86bd

From: libftdi-git@xxxxxxxxxxxxxxxxxxxxxxx
To: libftdi-git@xxxxxxxxxxxxxxxxxxxxxxx
Date: Tue, 14 Jun 2011 15:30:48 +0200 (CEST)
The branch, master has been updated
       via  a3d86bdb9327e787644255d5e96e016fe4289225 (commit)
      from  e375e6cb72af68379ae42c536728a992df0046e5 (commit)


- Log -----------------------------------------------------------------
commit a3d86bdb9327e787644255d5e96e016fe4289225
Author: Thomas Jarosch <thomas.jarosch@xxxxxxxxxxxxx>
Date:   Tue Jun 14 15:30:33 2011 +0200

    Forward port flexible module unload behavior

-----------------------------------------------------------------------

Summary of changes:
 src/ftdi.c |    9 +++++++--
 src/ftdi.h |   10 ++++++++++
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/src/ftdi.c b/src/ftdi.c
index 08b4010..e3201d1 100644
--- a/src/ftdi.c
+++ b/src/ftdi.c
@@ -105,6 +105,8 @@ int ftdi_init(struct ftdi_context *ftdi)
     memset(eeprom, 0, sizeof(struct ftdi_eeprom));
     ftdi->eeprom = eeprom;
 
+    ftdi->module_detach_mode = AUTO_DETACH_SIO_MODULE;
+
     /* All fine. Now allocate the readbuffer */
     return ftdi_read_data_set_chunksize(ftdi, 4096);
 }
@@ -498,8 +500,11 @@ int ftdi_usb_open_dev(struct ftdi_context *ftdi, 
libusb_device *dev)
     // if usb_set_configuration() or usb_claim_interface() fails as the
     // detach operation might be denied and everything still works fine.
     // Likely scenario is a static ftdi_sio kernel module.
-    if (libusb_detach_kernel_driver(ftdi->usb_dev, ftdi->interface) !=0)
-        detach_errno = errno;
+    if (ftdi->module_detach_mode == AUTO_DETACH_SIO_MODULE)
+    {
+        if (libusb_detach_kernel_driver(ftdi->usb_dev, ftdi->interface) !=0)
+            detach_errno = errno;
+    }
 
     if (libusb_get_configuration (ftdi->usb_dev, &cfg) < 0)
         ftdi_error_return(-12, "libusb_get_configuration () failed");
diff --git a/src/ftdi.h b/src/ftdi.h
index b7c0113..b43f6ec 100644
--- a/src/ftdi.h
+++ b/src/ftdi.h
@@ -57,6 +57,13 @@ enum ftdi_interface
     INTERFACE_D   = 4
 };
 
+/** Automatic loading / unloading of kernel modules */
+enum ftdi_module_detach_mode
+{
+    AUTO_DETACH_SIO_MODULE = 0,
+    DONT_DETACH_SIO_MODULE = 1
+};
+
 /* Shifting commands IN MPSSE Mode*/
 #define MPSSE_WRITE_NEG 0x01   /* Write TDI/DO on negative TCK/SK edge*/
 #define MPSSE_BITMODE   0x02   /* Write bits, not bytes */
@@ -313,6 +320,9 @@ struct ftdi_context
 
     /** String representation of last error */
     char *error_str;
+
+    /** Defines behavior in case a kernel module is already attached to the 
device */
+    enum ftdi_module_detach_mode module_detach_mode;
 };
 
 /**


hooks/post-receive
-- 
port libftdi to libusb-1.0

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

Current Thread
  • port libftdi to libusb-1.0 branch, master, updated. v0.17-195-ga3d86bd, libftdi-git <=