view libuwrap/claim_if.c @ 41:940cde8a99b6

fteeprom-prog: we don't need to claim the interface
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 10 Sep 2023 21:22:20 +0000
parents f5847be43d35
children 5160f6717903
line wrap: on
line source

/*
 * 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.
 */

#include <stdio.h>
#include <stdlib.h>
#include <usb.h>
#include "open_close.h"

void usbwrap_claim_interface(usb_dev_handle *usbh, int ifnum, int detach)
{
	if (detach)
		usb_detach_kernel_driver_np(usbh, ifnum);
	if (usb_claim_interface(usbh, ifnum) != 0) {
		fprintf(stderr, "error: usb_claim_interface() failed\n");
		exit(1);
	}
}