# HG changeset patch # User Mychaela Falconia # Date 1694399231 0 # Node ID 5160f67179039df2a233b6c67f3acfe35392d978 # Parent dbaf239436cf4106b36fa0378bf0c6ab313e344c libuwrap: implement function to claim/unbind all interfaces diff -r dbaf239436cf -r 5160f6717903 libuwrap/claim_if.c --- a/libuwrap/claim_if.c Mon Sep 11 01:06:03 2023 +0000 +++ b/libuwrap/claim_if.c Mon Sep 11 02:27:11 2023 +0000 @@ -1,10 +1,15 @@ /* - * When we are reprogramming the EEPROM on DUART28 or possibly other devices - * in the future where we know that we are operating on a multichannel FTDI - * chip (or perhaps a multichannel chip from some other vendor), it is most - * philosophically correct to bump off ftdi_sio from both interfaces, - * removing both ttyUSB devices. Here we implement a function for claiming - * one interface, easily callable for multiple interfaces in a row. + * The operation of programming an FTDI EEPROM *can* be done without ever + * claiming any of the chip's interfaces and without unbinding ttyUSB from + * any channel, even if we are doing the special magic sequence for FT232R. + * However, given the identity-altering nature of EEPROM programming it is + * generally a good idea to claim all interfaces and unbind all ttyUSB + * devices, and in the case of FT232R the magic sequence breaks normal + * UART operation. + * + * This library module provides building block functions: a function for + * claiming one interface and a higher-level function claiming all interfaces + * of a multichannel device. */ #include @@ -21,3 +26,11 @@ exit(1); } } + +void usbwrap_claim_all_ifs(usb_dev_handle *usbh, unsigned nchannels) +{ + unsigned n; + + for (n = 0; n < nchannels; n++) + usbwrap_claim_interface(usbh, n, 1); +} diff -r dbaf239436cf -r 5160f6717903 libuwrap/open_close.h --- a/libuwrap/open_close.h Mon Sep 11 01:06:03 2023 +0000 +++ b/libuwrap/open_close.h Mon Sep 11 02:27:11 2023 +0000 @@ -3,3 +3,4 @@ extern void usbwrap_claim_interface(usb_dev_handle *usbh, int ifnum, int detach); +extern void usbwrap_claim_all_ifs(usb_dev_handle *usbh, unsigned nchannels);