FreeCalypso > hg > fc-usbser-tools
comparison 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 |
comparison
equal
deleted
inserted
replaced
43:dbaf239436cf | 44:5160f6717903 |
---|---|
1 /* | 1 /* |
2 * When we are reprogramming the EEPROM on DUART28 or possibly other devices | 2 * The operation of programming an FTDI EEPROM *can* be done without ever |
3 * in the future where we know that we are operating on a multichannel FTDI | 3 * claiming any of the chip's interfaces and without unbinding ttyUSB from |
4 * chip (or perhaps a multichannel chip from some other vendor), it is most | 4 * any channel, even if we are doing the special magic sequence for FT232R. |
5 * philosophically correct to bump off ftdi_sio from both interfaces, | 5 * However, given the identity-altering nature of EEPROM programming it is |
6 * removing both ttyUSB devices. Here we implement a function for claiming | 6 * generally a good idea to claim all interfaces and unbind all ttyUSB |
7 * one interface, easily callable for multiple interfaces in a row. | 7 * devices, and in the case of FT232R the magic sequence breaks normal |
8 * UART operation. | |
9 * | |
10 * This library module provides building block functions: a function for | |
11 * claiming one interface and a higher-level function claiming all interfaces | |
12 * of a multichannel device. | |
8 */ | 13 */ |
9 | 14 |
10 #include <stdio.h> | 15 #include <stdio.h> |
11 #include <stdlib.h> | 16 #include <stdlib.h> |
12 #include <usb.h> | 17 #include <usb.h> |
19 if (usb_claim_interface(usbh, ifnum) != 0) { | 24 if (usb_claim_interface(usbh, ifnum) != 0) { |
20 fprintf(stderr, "error: usb_claim_interface() failed\n"); | 25 fprintf(stderr, "error: usb_claim_interface() failed\n"); |
21 exit(1); | 26 exit(1); |
22 } | 27 } |
23 } | 28 } |
29 | |
30 void usbwrap_claim_all_ifs(usb_dev_handle *usbh, unsigned nchannels) | |
31 { | |
32 unsigned n; | |
33 | |
34 for (n = 0; n < nchannels; n++) | |
35 usbwrap_claim_interface(usbh, n, 1); | |
36 } |