diff libuwrap/claim_if.c @ 44:5160f6717903

libuwrap: implement function to claim/unbind all interfaces
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 11 Sep 2023 02:27:11 +0000
parents f5847be43d35
children 5cbde3c80c24
line wrap: on
line diff
--- 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 <stdio.h>
@@ -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);
+}