am7xxx: add comment about detaching kernel drivers before setting configuration
[libam7xxx.git] / src / am7xxx.c
index ecec7d7..6595ccf 100644 (file)
@@ -34,7 +34,7 @@
  * taken from: http://unixwiz.net/techtips/gnu-c-attributes.html)
  */
 #ifndef __GNUC__
-#  define  __attribute__(x)  /*NOTHING*/
+#  define  __attribute__(x)  /* NOTHING */
 #endif
 
 /* Control shared library symbols visibility */
@@ -704,7 +704,7 @@ static am7xxx_device *find_device(am7xxx_context *ctx,
 
 static int open_device(am7xxx_context *ctx,
                       unsigned int device_index,
-                      libusb_deviceusb_dev,
+                      libusb_device *usb_dev,
                       am7xxx_device **dev)
 {
        int ret;
@@ -736,6 +736,15 @@ static int open_device(am7xxx_context *ctx,
        current_configuration = -1;
        libusb_get_configuration((*dev)->usb_device, &current_configuration);
        if (current_configuration != (*dev)->desc->configuration) {
+               /*
+                * In principle kernel drivers bound to each interface should
+                * be detached before setting the configuration, but in
+                * practice this is not necessary for most devices.
+                *
+                * For example something like the following function would be
+                * called:
+                *      libusb_detach_all_kernel_drivers((*dev)->usb_device);
+                */
                ret = libusb_set_configuration((*dev)->usb_device,
                                               (*dev)->desc->configuration);
                if (ret < 0) {
@@ -806,7 +815,7 @@ static int scan_devices(am7xxx_context *ctx, scan_op op,
                        unsigned int open_device_index, am7xxx_device **dev)
 {
        ssize_t num_devices;
-       libusb_device** list;
+       libusb_device **list;
        unsigned int current_index;
        int i;
        int ret;