From d6d3599dbc0aa04884ef6f62daba043614d35f3c Mon Sep 17 00:00:00 2001 From: mglocker Date: Mon, 25 Jan 2021 14:05:57 +0000 Subject: [PATCH] Add the new function usbd_clear_endpoint_feature() which allows to issue an UR_CLEAR_FEATURE request on a specific endpoint address without the need to have a pipe open to that endpoint. From NetBSD, ok mpi@ --- sys/dev/usb/usbdi_util.c | 15 ++++++++++++++- sys/dev/usb/usbdi_util.h | 3 ++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/sys/dev/usb/usbdi_util.c b/sys/dev/usb/usbdi_util.c index 5c067c1f4a1..4b2cdc5f8b6 100644 --- a/sys/dev/usb/usbdi_util.c +++ b/sys/dev/usb/usbdi_util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: usbdi_util.c,v 1.44 2019/10/06 17:11:51 mpi Exp $ */ +/* $OpenBSD: usbdi_util.c,v 1.45 2021/01/25 14:05:57 mglocker Exp $ */ /* $NetBSD: usbdi_util.c,v 1.40 2002/07/11 21:14:36 augustss Exp $ */ /* $FreeBSD: src/sys/dev/usb/usbdi_util.c,v 1.14 1999/11/17 22:33:50 n_hibma Exp $ */ @@ -191,6 +191,19 @@ usbd_clear_port_feature(struct usbd_device *dev, int port, int sel) return (usbd_do_request(dev, &req, 0)); } +usbd_status +usbd_clear_endpoint_feature(struct usbd_device *dev, int epaddr, int sel) +{ + usb_device_request_t req; + + req.bmRequestType = UT_WRITE_ENDPOINT; + req.bRequest = UR_CLEAR_FEATURE; + USETW(req.wValue, sel); + USETW(req.wIndex, epaddr); + USETW(req.wLength, 0); + return (usbd_do_request(dev, &req, 0)); +} + usbd_status usbd_set_port_feature(struct usbd_device *dev, int port, int sel) { diff --git a/sys/dev/usb/usbdi_util.h b/sys/dev/usb/usbdi_util.h index 81a468503b4..04c149bd51a 100644 --- a/sys/dev/usb/usbdi_util.h +++ b/sys/dev/usb/usbdi_util.h @@ -1,4 +1,4 @@ -/* $OpenBSD: usbdi_util.h,v 1.29 2014/12/08 22:00:11 mpi Exp $ */ +/* $OpenBSD: usbdi_util.h,v 1.30 2021/01/25 14:05:57 mglocker Exp $ */ /* $NetBSD: usbdi_util.h,v 1.28 2002/07/11 21:14:36 augustss Exp $ */ /* $FreeBSD: src/sys/dev/usb/usbdi_util.h,v 1.9 1999/11/17 22:33:50 n_hibma Exp $ */ @@ -41,6 +41,7 @@ usbd_status usbd_set_hub_feature(struct usbd_device *dev, int); usbd_status usbd_clear_hub_feature(struct usbd_device *, int); usbd_status usbd_set_port_feature(struct usbd_device *dev, int, int); usbd_status usbd_clear_port_feature(struct usbd_device *, int, int); +usbd_status usbd_clear_endpoint_feature(struct usbd_device *, int, int); usbd_status usbd_get_device_status(struct usbd_device *, usb_status_t *); usbd_status usbd_get_hub_status(struct usbd_device *, usb_hub_status_t *); usbd_status usbd_get_hub_descriptor(struct usbd_device *, -- 2.20.1