FreeBSD/sys/dev/usb/net/uhso.c
/*
 * Attach a multiplexed serial port
 * Data is read/written with requests on the default control pipe. An interrupt
 * endpoint returns when there is new data to be read.
 */
Attach a multiplexed serial port
Data is read/written with requests on the default control pipe. An interrupt
endpoint returns when there is new data to be read.
Attach a multiplexed serial port Data is read / written with requests on the default control pipe . An interrupt endpoint returns when there is new data to be read .
static int
uhso_attach_muxserial(struct uhso_softc *sc, struct usb_interface *iface,
    int type)
{
	struct usb_descriptor *desc;
	int i, port, tty;
	usb_error_t uerr;
	desc = usbd_find_descriptor(sc->sc_udev, NULL,
	    iface->idesc->bInterfaceNumber, UDESC_CS_INTERFACE, 0xff, 0, 0);
	if (desc == NULL) {
		UHSO_DPRINTF(0, "Failed to find UDESC_CS_INTERFACE\n");
		return (ENXIO);
	}
	UHSO_DPRINTF(1, "Mux port mask %x\n", desc->bDescriptorSubtype);
	if (desc->bDescriptorSubtype == 0)
		return (ENXIO);
	for (i = 0; i < 8; i++) {
		port = (1 << i);
		if ((port & desc->bDescriptorSubtype) == port) {
			UHSO_DPRINTF(2, "Found mux port %x (%d)\n", port, i);
			tty = uhso_alloc_tty(sc);
			if (tty < 0)
				return (ENOMEM);
			sc->sc_tty[tty].ht_muxport = i;
			uerr = usbd_transfer_setup(sc->sc_udev,	
			    &sc->sc_iface_index, sc->sc_tty[tty].ht_xfer,
			    uhso_ctrl_config, UHSO_CTRL_MAX, sc, &sc->sc_mtx);
			if (uerr) {
				device_printf(sc->sc_dev,
				    "Failed to setup control pipe: %s\n",
				    usbd_errstr(uerr));
				return (ENXIO);
			}
		}
	}
	uerr = usbd_transfer_setup(sc->sc_udev,
	    &iface->idesc->bInterfaceNumber, sc->sc_xfer,
	    uhso_mux_config, 1, sc, &sc->sc_mtx);
	if (uerr)
		return (ENXIO);
	return (0);
}
static int uhso_attach_muxserial ( struct uhso_softc * sc , struct usb_interface * iface , int type ) { struct usb_descriptor * desc ; int i , port , tty ; usb_error_t uerr ; desc = usbd_find_descriptor ( sc -> sc_udev , NULL , iface -> idesc -> bInterfaceNumber , UDESC_CS_INTERFACE , 0xff , 0 , 0 ) ; if ( desc == NULL ) { UHSO_DPRINTF ( 0 , " \n " ) ; return ( ENXIO ) ; } UHSO_DPRINTF ( 1 , " \n " , desc -> bDescriptorSubtype ) ; if ( desc -> bDescriptorSubtype == 0 ) return ( ENXIO ) ; for ( i = 0 ; i < 8 ; i ++ ) { port = ( 1 << i ) ; if ( ( port & desc -> bDescriptorSubtype ) == port ) { UHSO_DPRINTF ( 2 , " \n " , port , i ) ; tty = uhso_alloc_tty ( sc ) ; if ( tty < 0 ) return ( ENOMEM ) ; sc -> sc_tty [ tty ] . ht_muxport = i ; uerr = usbd_transfer_setup ( sc -> sc_udev , & sc -> sc_iface_index , sc -> sc_tty [ tty ] . ht_xfer , uhso_ctrl_config , UHSO_CTRL_MAX , sc , & sc -> sc_mtx ) ; if ( uerr ) { device_printf ( sc -> sc_dev , " \n " , usbd_errstr ( uerr ) ) ; return ( ENXIO ) ; } } } uerr = usbd_transfer_setup ( sc -> sc_udev , & iface -> idesc -> bInterfaceNumber , sc -> sc_xfer , uhso_mux_config , 1 , sc , & sc -> sc_mtx ) ; if ( uerr ) return ( ENXIO ) ; return ( 0 ) ; }
Attach a multiplexed serial port
 Data is read/written with requests on the default control pipe.
Attach a multiplexed serial port Data is read / written with requests on the default control pipe .
/*
	 * The class specific interface (type 0x24) descriptor subtype field
	 * contains a bitmask that specifies which (and how many) ports that
	 * are available through this multiplexed serial port.
 	 */ /*
	 * The bitmask is one octet, loop through the number of
	 * bits that are set and create a TTY for each.
	 */ /* Setup the intr. endpoint */