Hi Jean-René,
Am 21.01.2016 um 19:15 schrieb Jean-René David:
> enum ftdi_module_detach_mode
> {
> AUTO_DETACH_SIO_MODULE = 0,
> DONT_DETACH_SIO_MODULE = 1
> };
>
> I wonder if ftdi_usb_close() should re-attach the driver like so:
>
> ..
>
> diff --git src/ftdi.c src/ftdi.c
> index aa4b4ec..7891b91 100644
> --- src/ftdi.c
> +++ src/ftdi.c
> @@ -995,6 +995,9 @@ int ftdi_usb_close(struct ftdi_context *ftdi)
> if (libusb_release_interface(ftdi->usb_dev, ftdi->interface) < 0)
> rtn = -1;
>
> + if (ftdi->module_detach_mode == AUTO_DETACH_SIO_MODULE)
> + libusb_attach_kernel_driver(ftdi->usb_dev, ftdi->interface);
> +
> ftdi_usb_close_internal (ftdi);
>
> return rtn;
>
> Maybe creating a new flag to re-attach would be safer, to avoid breaking
> existing programs.
yes, a new flag would be the way to go.
I also think we should put it into ftdi_usb_close_internal()
since that's the one used by a few other libftdi functions.
Another question is how the system reacts if the kernel module
gets detached and re-attached a few times, f.e. if you call
ftdi_get_usb_strings() since that one currently closes the device.
Do you care to develop a patch for it?
I'll review it then :)
Cheers,
Thomas
--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx
|