Esempio n. 1
0
File: usb.c Progetto: Zuph/mchck
static int
usb_tx_string_desc(int idx, int reqlen)
{
	const struct usb_desc_string_t * const *d;

	for (d = usb.identity->string_descs; idx != 0 && *d != NULL; ++d)
		--idx;
	switch ((uintptr_t)*d) {
	case (uintptr_t)NULL:
		return (-1);
	case (uintptr_t)USB_DESC_STRING_SERIALNO:
		return (usb_tx_serialno(reqlen));
	default:
		usb_ep0_tx_cp(*d, (*d)->bLength, reqlen, NULL, NULL);
		return (0);
	}
}
Esempio n. 2
0
File: usb.c Progetto: koson/mchck-os
static int
usb_tx_string_desc(int idx, int reqlen)
{
	const struct usbd_string_entry *d;

	for (d = usb.identity->string_descs; d->string != NULL; ++d)
		if (d->index == idx)
			break;
	if (!d->string)
		return (-1);

	switch ((uintptr_t)d->string) {
	case (uintptr_t)NULL:
		return (-1);
	case (uintptr_t)USB_DESC_STRING_SERIALNO:
		return (usb_tx_serialno(reqlen));
	default:
		usb_ep0_tx(d->string, d->string->bLength, reqlen, NULL, NULL);
		return (0);
	}
}