Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/usb Introduce usbd_clear_endpoint_feature(), and dedup.
details: https://anonhg.NetBSD.org/src/rev/1778568ca7d6
branches: trunk
changeset: 744620:1778568ca7d6
user: maxv <maxv%NetBSD.org@localhost>
date: Sat Feb 08 07:53:23 2020 +0000
description:
Introduce usbd_clear_endpoint_feature(), and dedup.
diffstat:
sys/dev/usb/u3g.c | 14 ++++----------
sys/dev/usb/uhmodem.c | 14 ++++----------
sys/dev/usb/usbdi.c | 22 ++++++----------------
sys/dev/usb/usbdi_util.c | 18 ++++++++++++++++--
sys/dev/usb/usbdi_util.h | 3 ++-
5 files changed, 32 insertions(+), 39 deletions(-)
diffs (200 lines):
diff -r 8d499e9eb3ee -r 1778568ca7d6 sys/dev/usb/u3g.c
--- a/sys/dev/usb/u3g.c Sat Feb 08 07:38:17 2020 +0000
+++ b/sys/dev/usb/u3g.c Sat Feb 08 07:53:23 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: u3g.c,v 1.38 2020/01/07 06:42:26 maxv Exp $ */
+/* $NetBSD: u3g.c,v 1.39 2020/02/08 07:53:23 maxv Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -50,7 +50,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: u3g.c,v 1.38 2020/01/07 06:42:26 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: u3g.c,v 1.39 2020/02/08 07:53:23 maxv Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -571,7 +571,6 @@
u3g_open(void *arg, int portno)
{
struct u3g_softc *sc = arg;
- usb_device_request_t req;
usb_endpoint_descriptor_t *ed;
usb_interface_descriptor_t *id;
struct usbd_interface *ih;
@@ -596,13 +595,8 @@
if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK &&
nin++ == portno) {
- /* Issue ENDPOINT_HALT request */
- req.bmRequestType = UT_WRITE_ENDPOINT;
- req.bRequest = UR_CLEAR_FEATURE;
- USETW(req.wValue, UF_ENDPOINT_HALT);
- USETW(req.wIndex, ed->bEndpointAddress);
- USETW(req.wLength, 0);
- err = usbd_do_request(sc->sc_udev, &req, 0);
+ err = usbd_clear_endpoint_feature(sc->sc_udev,
+ ed->bEndpointAddress, UF_ENDPOINT_HALT);
if (err)
return EIO;
}
diff -r 8d499e9eb3ee -r 1778568ca7d6 sys/dev/usb/uhmodem.c
--- a/sys/dev/usb/uhmodem.c Sat Feb 08 07:38:17 2020 +0000
+++ b/sys/dev/usb/uhmodem.c Sat Feb 08 07:53:23 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uhmodem.c,v 1.20 2019/05/27 03:08:13 maya Exp $ */
+/* $NetBSD: uhmodem.c,v 1.21 2020/02/08 07:53:23 maxv Exp $ */
/*
* Copyright (c) 2008 Yojiro UO <yuo%nui.org@localhost>.
@@ -71,7 +71,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uhmodem.c,v 1.20 2019/05/27 03:08:13 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhmodem.c,v 1.21 2020/02/08 07:53:23 maxv Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -506,7 +506,6 @@
static usbd_status
uhmodem_endpointhalt(struct ubsa_softc *sc, int iface)
{
- usb_device_request_t req;
usb_endpoint_descriptor_t *ed;
usb_interface_descriptor_t *id;
usbd_status err;
@@ -521,13 +520,8 @@
return EIO;
if (UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) {
- /* issue ENDPOINT_HALT request */
- req.bmRequestType = UT_WRITE_ENDPOINT;
- req.bRequest = UR_CLEAR_FEATURE;
- USETW(req.wValue, UF_ENDPOINT_HALT);
- USETW(req.wIndex, ed->bEndpointAddress);
- USETW(req.wLength, 0);
- err = usbd_do_request(sc->sc_udev, &req, 0);
+ err = usbd_clear_endpoint_feature(sc->sc_udev,
+ ed->bEndpointAddress, UF_ENDPOINT_HALT);
if (err) {
DPRINTF(("%s: ENDPOINT_HALT to EP:%d fail\n",
__func__, ed->bEndpointAddress));
diff -r 8d499e9eb3ee -r 1778568ca7d6 sys/dev/usb/usbdi.c
--- a/sys/dev/usb/usbdi.c Sat Feb 08 07:38:17 2020 +0000
+++ b/sys/dev/usb/usbdi.c Sat Feb 08 07:53:23 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: usbdi.c,v 1.187 2020/02/08 07:38:17 maxv Exp $ */
+/* $NetBSD: usbdi.c,v 1.188 2020/02/08 07:53:23 maxv Exp $ */
/*
* Copyright (c) 1998, 2012, 2015 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.187 2020/02/08 07:38:17 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.188 2020/02/08 07:53:23 maxv Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -677,7 +677,6 @@
usbd_clear_endpoint_stall(struct usbd_pipe *pipe)
{
struct usbd_device *dev = pipe->up_dev;
- usb_device_request_t req;
usbd_status err;
USBHIST_FUNC(); USBHIST_CALLED(usbdebug);
@@ -688,12 +687,8 @@
*/
pipe->up_methods->upm_cleartoggle(pipe);
- req.bmRequestType = UT_WRITE_ENDPOINT;
- req.bRequest = UR_CLEAR_FEATURE;
- USETW(req.wValue, UF_ENDPOINT_HALT);
- USETW(req.wIndex, pipe->up_endpoint->ue_edesc->bEndpointAddress);
- USETW(req.wLength, 0);
- err = usbd_do_request(dev, &req, 0);
+ err = usbd_clear_endpoint_feature(dev,
+ pipe->up_endpoint->ue_edesc->bEndpointAddress, UF_ENDPOINT_HALT);
#if 0
XXX should we do this?
if (!err) {
@@ -709,16 +704,11 @@
{
struct usbd_pipe *pipe = arg;
struct usbd_device *dev = pipe->up_dev;
- usb_device_request_t req;
pipe->up_methods->upm_cleartoggle(pipe);
- req.bmRequestType = UT_WRITE_ENDPOINT;
- req.bRequest = UR_CLEAR_FEATURE;
- USETW(req.wValue, UF_ENDPOINT_HALT);
- USETW(req.wIndex, pipe->up_endpoint->ue_edesc->bEndpointAddress);
- USETW(req.wLength, 0);
- (void)usbd_do_request(dev, &req, 0);
+ (void)usbd_clear_endpoint_feature(dev,
+ pipe->up_endpoint->ue_edesc->bEndpointAddress, UF_ENDPOINT_HALT);
}
void
diff -r 8d499e9eb3ee -r 1778568ca7d6 sys/dev/usb/usbdi_util.c
--- a/sys/dev/usb/usbdi_util.c Sat Feb 08 07:38:17 2020 +0000
+++ b/sys/dev/usb/usbdi_util.c Sat Feb 08 07:53:23 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: usbdi_util.c,v 1.75 2019/08/21 10:48:37 mrg Exp $ */
+/* $NetBSD: usbdi_util.c,v 1.76 2020/02/08 07:53:23 maxv Exp $ */
/*
* Copyright (c) 1998, 2012 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usbdi_util.c,v 1.75 2019/08/21 10:48:37 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi_util.c,v 1.76 2020/02/08 07:53:23 maxv Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -330,6 +330,20 @@
}
usbd_status
+usbd_clear_endpoint_feature(struct usbd_device *dev, int epaddr, int sel)
+{
+ USBHIST_FUNC();
+ 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_get_protocol(struct usbd_interface *iface, uint8_t *report)
{
usb_interface_descriptor_t *id = usbd_get_interface_descriptor(iface);
diff -r 8d499e9eb3ee -r 1778568ca7d6 sys/dev/usb/usbdi_util.h
--- a/sys/dev/usb/usbdi_util.h Sat Feb 08 07:38:17 2020 +0000
+++ b/sys/dev/usb/usbdi_util.h Sat Feb 08 07:53:23 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: usbdi_util.h,v 1.49 2019/02/07 13:20:41 skrll Exp $ */
+/* $NetBSD: usbdi_util.h,v 1.50 2020/02/08 07:53:23 maxv Exp $ */
/*
* Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
@@ -58,6 +58,7 @@
usbd_status usbd_clear_port_feature(struct usbd_device *, int, int);
usbd_status usbd_set_port_u1_timeout(struct usbd_device *, int, int);
usbd_status usbd_set_port_u2_timeout(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_protocol(struct usbd_interface *, uint8_t *);
Home |
Main Index |
Thread Index |
Old Index