FreeCalypso > hg > fc-usbser-tools
annotate libuwrap/claim_if.c @ 40:f5847be43d35
fc-duart28-conf: bump off both ttyUSB devices on set operation
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 10 Sep 2023 21:13:58 +0000 |
parents | libuwrap/open_close.c@80e521d6609c |
children | 5160f6717903 |
rev | line source |
---|---|
12
80e521d6609c
libuwrap: implement USB device open and close
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
40
f5847be43d35
fc-duart28-conf: bump off both ttyUSB devices on set operation
Mychaela Falconia <falcon@freecalypso.org>
parents:
12
diff
changeset
|
2 * When we are reprogramming the EEPROM on DUART28 or possibly other devices |
f5847be43d35
fc-duart28-conf: bump off both ttyUSB devices on set operation
Mychaela Falconia <falcon@freecalypso.org>
parents:
12
diff
changeset
|
3 * in the future where we know that we are operating on a multichannel FTDI |
f5847be43d35
fc-duart28-conf: bump off both ttyUSB devices on set operation
Mychaela Falconia <falcon@freecalypso.org>
parents:
12
diff
changeset
|
4 * chip (or perhaps a multichannel chip from some other vendor), it is most |
f5847be43d35
fc-duart28-conf: bump off both ttyUSB devices on set operation
Mychaela Falconia <falcon@freecalypso.org>
parents:
12
diff
changeset
|
5 * philosophically correct to bump off ftdi_sio from both interfaces, |
f5847be43d35
fc-duart28-conf: bump off both ttyUSB devices on set operation
Mychaela Falconia <falcon@freecalypso.org>
parents:
12
diff
changeset
|
6 * removing both ttyUSB devices. Here we implement a function for claiming |
f5847be43d35
fc-duart28-conf: bump off both ttyUSB devices on set operation
Mychaela Falconia <falcon@freecalypso.org>
parents:
12
diff
changeset
|
7 * one interface, easily callable for multiple interfaces in a row. |
12
80e521d6609c
libuwrap: implement USB device open and close
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 */ |
80e521d6609c
libuwrap: implement USB device open and close
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 |
80e521d6609c
libuwrap: implement USB device open and close
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <stdio.h> |
80e521d6609c
libuwrap: implement USB device open and close
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <stdlib.h> |
80e521d6609c
libuwrap: implement USB device open and close
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include <usb.h> |
80e521d6609c
libuwrap: implement USB device open and close
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include "open_close.h" |
80e521d6609c
libuwrap: implement USB device open and close
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 |
40
f5847be43d35
fc-duart28-conf: bump off both ttyUSB devices on set operation
Mychaela Falconia <falcon@freecalypso.org>
parents:
12
diff
changeset
|
15 void usbwrap_claim_interface(usb_dev_handle *usbh, int ifnum, int detach) |
12
80e521d6609c
libuwrap: implement USB device open and close
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 { |
80e521d6609c
libuwrap: implement USB device open and close
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 if (detach) |
40
f5847be43d35
fc-duart28-conf: bump off both ttyUSB devices on set operation
Mychaela Falconia <falcon@freecalypso.org>
parents:
12
diff
changeset
|
18 usb_detach_kernel_driver_np(usbh, ifnum); |
f5847be43d35
fc-duart28-conf: bump off both ttyUSB devices on set operation
Mychaela Falconia <falcon@freecalypso.org>
parents:
12
diff
changeset
|
19 if (usb_claim_interface(usbh, ifnum) != 0) { |
12
80e521d6609c
libuwrap: implement USB device open and close
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 fprintf(stderr, "error: usb_claim_interface() failed\n"); |
80e521d6609c
libuwrap: implement USB device open and close
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 exit(1); |
80e521d6609c
libuwrap: implement USB device open and close
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 } |
80e521d6609c
libuwrap: implement USB device open and close
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 } |