sys/bus/u4b/usb_util.c
void
device_set_usb_desc(device_t dev)
{
	struct usb_attach_arg *uaa;
	struct usb_device *udev;
	struct usb_interface *iface;
	char *temp_p;
	usb_error_t err;

	if (dev == NULL) {
		/* should not happen */
		return;
	}
	uaa = device_get_ivars(dev);
	if (uaa == NULL) {
		/* can happen if called at the wrong time */
		return;
	}
	udev = uaa->device;
	iface = uaa->iface;

	if ((iface == NULL) ||
	    (iface->idesc == NULL) ||
	    (iface->idesc->iInterface == 0)) {
		err = USB_ERR_INVAL;
	} else {
		err = 0;
	}

	temp_p = (char *)udev->bus->scratch[0].data;

	if (!err) {
		/* try to get the interface string ! */
		err = usbd_req_get_string_any
		    (udev, NULL, temp_p,
		    sizeof(udev->bus->scratch), iface->idesc->iInterface);
	}
	if (err) {
		/* use default description */
		usb_devinfo(udev, temp_p,
		    sizeof(udev->bus->scratch));
	}
	device_set_desc_copy(dev, temp_p);
	device_printf(dev, "<%s> on %s\n", temp_p,
	    device_get_nameunit(udev->bus->bdev));
}
/*------------------------------------------------------------------------*
 *	device_set_usb_desc
 *
 * This function can be called at probe or attach to set the USB
 * device supplied textual description for the given device.
 *------------------------------------------------------------------------*/
device_set_usb_desc
This function can be called at probe or attach to set the USB
device supplied textual description for the given device.
device_set_usb_desc This function can be called at probe or attach to set the USB device supplied textual description for the given device .
void
device_set_usb_desc(device_t dev)
{
	struct usb_attach_arg *uaa;
	struct usb_device *udev;
	struct usb_interface *iface;
	char *temp_p;
	usb_error_t err;
	if (dev == NULL) {
		return;
	}
	uaa = device_get_ivars(dev);
	if (uaa == NULL) {
		return;
	}
	udev = uaa->device;
	iface = uaa->iface;
	if ((iface == NULL) ||
	    (iface->idesc == NULL) ||
	    (iface->idesc->iInterface == 0)) {
		err = USB_ERR_INVAL;
	} else {
		err = 0;
	}
	temp_p = (char *)udev->bus->scratch[0].data;
	if (!err) {
		err = usbd_req_get_string_any
		    (udev, NULL, temp_p,
		    sizeof(udev->bus->scratch), iface->idesc->iInterface);
	}
	if (err) {
		usb_devinfo(udev, temp_p,
		    sizeof(udev->bus->scratch));
	}
	device_set_desc_copy(dev, temp_p);
	device_printf(dev, "<%s> on %s\n", temp_p,
	    device_get_nameunit(udev->bus->bdev));
}
void device_set_usb_desc ( device_t dev ) { struct usb_attach_arg * uaa ; struct usb_device * udev ; struct usb_interface * iface ; char * temp_p ; usb_error_t err ; if ( dev == NULL ) { return ; } uaa = device_get_ivars ( dev ) ; if ( uaa == NULL ) { return ; } udev = uaa -> device ; iface = uaa -> iface ; if ( ( iface == NULL ) || ( iface -> idesc == NULL ) || ( iface -> idesc -> iInterface == 0 ) ) { err = USB_ERR_INVAL ; } else { err = 0 ; } temp_p = ( char * ) udev -> bus -> scratch [ 0 ] . data ; if ( ! err ) { err = usbd_req_get_string_any ( udev , NULL , temp_p , sizeof ( udev -> bus -> scratch ) , iface -> idesc -> iInterface ) ; } if ( err ) { usb_devinfo ( udev , temp_p , sizeof ( udev -> bus -> scratch ) ) ; } device_set_desc_copy ( dev , temp_p ) ; device_printf ( dev , " \n " , temp_p , device_get_nameunit ( udev -> bus -> bdev ) ) ; }
device_set_usb_desc
 This function can be called at probe or attach to set the USB
 device supplied textual description for the given device.
device_set_usb_desc This function can be called at probe or attach to set the USB device supplied textual description for the given device .
/* should not happen */ /* can happen if called at the wrong time */ /* try to get the interface string ! */ /* use default description */