FreeBSD/sys/dev/usb/net/uhso.c
/*
 * Probe the interface type by querying the device. The elements
 * of an array indicates the capabilities of a particular interface.
 * Returns a bit mask with the interface capabilities.
 */
Probe the interface type by querying the device. The elements
of an array indicates the capabilities of a particular interface.
Returns a bit mask with the interface capabilities.
Probe the interface type by querying the device . The elements of an array indicates the capabilities of a particular interface . Returns a bit mask with the interface capabilities .
static int
uhso_probe_iface_auto(struct usb_device *udev, int index)
{
	struct usb_device_request req;
	usb_error_t uerr;
	uint16_t actlen = 0;
	char port;
	char buf[17] = {0};
	req.bmRequestType = UT_READ_VENDOR_DEVICE;
	req.bRequest = 0x86;
	USETW(req.wValue, 0);
	USETW(req.wIndex, 0);
	USETW(req.wLength, 17);
	uerr = usbd_do_request_flags(udev, NULL, &req, buf,
	    0, &actlen, USB_MS_HZ);
	if (uerr != 0) {
		printf("%s: usbd_do_request_flags failed, %s\n",
		    __func__, usbd_errstr(uerr));
		return (0);
	}
	UHSO_DPRINTF(1, "actlen=%d\n", actlen);
	UHSO_HEXDUMP(buf, 17);
	if (index < 0 || index > 16) {
		UHSO_DPRINTF(0, "Index %d out of range\n", index);
		return (0);
	}
	UHSO_DPRINTF(1, "index=%d, type=%x[%s]\n", index, buf[index],
	    uhso_port_type[(int)uhso_port_map[(int)buf[index]]]);
	if (buf[index] >= uhso_port_map_max)
		port = 0;
	else
		port = uhso_port_map[(int)buf[index]];
	switch (port) {
	case UHSO_PORT_TYPE_NETWORK:
		return (UHSO_IFACE_SPEC(UHSO_IF_NET | UHSO_IF_MUX,
		    UHSO_PORT_SERIAL | UHSO_PORT_NETWORK, port));
	case UHSO_PORT_TYPE_DIAG:
	case UHSO_PORT_TYPE_DIAG2:
	case UHSO_PORT_TYPE_GPS:
	case UHSO_PORT_TYPE_GPSCTL:
	case UHSO_PORT_TYPE_CTL:
	case UHSO_PORT_TYPE_APP:
	case UHSO_PORT_TYPE_APP2:
	case UHSO_PORT_TYPE_MODEM:
		return (UHSO_IFACE_SPEC(UHSO_IF_BULK,
		    UHSO_PORT_SERIAL, port));
	case UHSO_PORT_TYPE_MSD:
		return (0);
	case UHSO_PORT_TYPE_UNKNOWN:
	default:
		return (0);
	}
	return (0);
}
static int uhso_probe_iface_auto ( struct usb_device * udev , int index ) { struct usb_device_request req ; usb_error_t uerr ; uint16_t actlen = 0 ; char port ; char buf [ 17 ] = { 0 } ; req . bmRequestType = UT_READ_VENDOR_DEVICE ; req . bRequest = 0x86 ; USETW ( req . wValue , 0 ) ; USETW ( req . wIndex , 0 ) ; USETW ( req . wLength , 17 ) ; uerr = usbd_do_request_flags ( udev , NULL , & req , buf , 0 , & actlen , USB_MS_HZ ) ; if ( uerr != 0 ) { printf ( " \n " , __func__ , usbd_errstr ( uerr ) ) ; return ( 0 ) ; } UHSO_DPRINTF ( 1 , " \n " , actlen ) ; UHSO_HEXDUMP ( buf , 17 ) ; if ( index < 0 || index > 16 ) { UHSO_DPRINTF ( 0 , " \n " , index ) ; return ( 0 ) ; } UHSO_DPRINTF ( 1 , " \n " , index , buf [ index ] , uhso_port_type [ ( int ) uhso_port_map [ ( int ) buf [ index ] ] ] ) ; if ( buf [ index ] >= uhso_port_map_max ) port = 0 ; else port = uhso_port_map [ ( int ) buf [ index ] ] ; switch ( port ) { case UHSO_PORT_TYPE_NETWORK : return ( UHSO_IFACE_SPEC ( UHSO_IF_NET | UHSO_IF_MUX , UHSO_PORT_SERIAL | UHSO_PORT_NETWORK , port ) ) ; case UHSO_PORT_TYPE_DIAG : case UHSO_PORT_TYPE_DIAG2 : case UHSO_PORT_TYPE_GPS : case UHSO_PORT_TYPE_GPSCTL : case UHSO_PORT_TYPE_CTL : case UHSO_PORT_TYPE_APP : case UHSO_PORT_TYPE_APP2 : case UHSO_PORT_TYPE_MODEM : return ( UHSO_IFACE_SPEC ( UHSO_IF_BULK , UHSO_PORT_SERIAL , port ) ) ; case UHSO_PORT_TYPE_MSD : return ( 0 ) ; case UHSO_PORT_TYPE_UNKNOWN : default : return ( 0 ) ; } return ( 0 ) ; }
Probe the interface type by querying the device.
Probe the interface type by querying the device .