Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/usb Remove usbd_do_request_async. It's callback was ...



details:   https://anonhg.NetBSD.org/src/rev/5013c1e8b509
branches:  trunk
changeset: 790204:5013c1e8b509
user:      skrll <skrll%NetBSD.org@localhost>
date:      Thu Sep 26 07:25:31 2013 +0000

description:
Remove usbd_do_request_async. It's callback was calling usbd_free_xfer
from softint context.

Adjust callers appropriately

        - usbd_clear_endpoint_stall_async is already triggered via a
          usb_task, so simply call usbd_do_request.

        - uhidev_set_report_async had one caller in ukbd_set_leds.
          Convert this usage to use usb_task as well.

Discussed with mrg@

diffstat:

 sys/dev/usb/uhidev.c     |  20 +----------------
 sys/dev/usb/uhidev.h     |   7 ++---
 sys/dev/usb/ukbd.c       |  26 +++++++++++++++++++----
 sys/dev/usb/usb_subr.c   |   6 ++--
 sys/dev/usb/usbdi.c      |  51 +++--------------------------------------------
 sys/dev/usb/usbdi.h      |   4 +-
 sys/dev/usb/usbdi_util.c |  24 +--------------------
 sys/dev/usb/usbdi_util.h |   4 +--
 8 files changed, 38 insertions(+), 104 deletions(-)

diffs (truncated from 337 to 300 lines):

diff -r caaf8bb90442 -r 5013c1e8b509 sys/dev/usb/uhidev.c
--- a/sys/dev/usb/uhidev.c      Thu Sep 26 00:41:51 2013 +0000
+++ b/sys/dev/usb/uhidev.c      Thu Sep 26 07:25:31 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uhidev.c,v 1.56 2012/06/10 06:15:54 mrg Exp $  */
+/*     $NetBSD: uhidev.c,v 1.57 2013/09/26 07:25:31 skrll Exp $        */
 
 /*
  * Copyright (c) 2001, 2012 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uhidev.c,v 1.56 2012/06/10 06:15:54 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhidev.c,v 1.57 2013/09/26 07:25:31 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -670,22 +670,6 @@
        return retstat;
 }
 
-void
-uhidev_set_report_async(struct uhidev *scd, int type, void *data, int len)
-{
-       /* XXX */
-       char buf[100];
-       if (scd->sc_report_id) {
-               buf[0] = scd->sc_report_id;
-               memcpy(buf+1, data, len);
-               len++;
-               data = buf;
-       }
-
-       usbd_set_report_async(scd->sc_parent->sc_iface, type,
-                             scd->sc_report_id, data, len);
-}
-
 usbd_status
 uhidev_get_report(struct uhidev *scd, int type, void *data, int len)
 {
diff -r caaf8bb90442 -r 5013c1e8b509 sys/dev/usb/uhidev.h
--- a/sys/dev/usb/uhidev.h      Thu Sep 26 00:41:51 2013 +0000
+++ b/sys/dev/usb/uhidev.h      Thu Sep 26 07:25:31 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uhidev.h,v 1.13 2012/06/10 06:15:54 mrg Exp $  */
+/*     $NetBSD: uhidev.h,v 1.14 2013/09/26 07:25:31 skrll Exp $        */
 
 /*
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -79,7 +79,6 @@
 void uhidev_get_report_desc(struct uhidev_softc *, void **, int *);
 int uhidev_open(struct uhidev *);
 void uhidev_close(struct uhidev *);
-usbd_status uhidev_set_report(struct uhidev *scd, int type, void *data,int len);
-void uhidev_set_report_async(struct uhidev *scd, int type, void *data, int len);
-usbd_status uhidev_get_report(struct uhidev *scd, int type, void *data,int len);
+usbd_status uhidev_set_report(struct uhidev *, int, void *, int);
+usbd_status uhidev_get_report(struct uhidev *, int, void *, int);
 usbd_status uhidev_write(struct uhidev_softc *, void *, int);
diff -r caaf8bb90442 -r 5013c1e8b509 sys/dev/usb/ukbd.c
--- a/sys/dev/usb/ukbd.c        Thu Sep 26 00:41:51 2013 +0000
+++ b/sys/dev/usb/ukbd.c        Thu Sep 26 07:25:31 2013 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: ukbd.c,v 1.128 2013/09/15 15:44:53 martin Exp $        */
+/*      $NetBSD: ukbd.c,v 1.129 2013/09/26 07:25:31 skrll Exp $        */
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ukbd.c,v 1.128 2013/09/15 15:44:53 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ukbd.c,v 1.129 2013/09/26 07:25:31 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ukbd.h"
@@ -271,6 +271,7 @@
        struct hid_location sc_scroloc;
        struct hid_location sc_compose;
        int sc_leds;
+       struct usb_task sc_ledtask;
        device_t sc_wskbddev;
 
 #if defined(WSDISPLAY_COMPAT_RAWKBD)
@@ -341,6 +342,7 @@
 
 Static int     ukbd_enable(void *, int);
 Static void    ukbd_set_leds(void *, int);
+Static void    ukbd_set_leds_task(void *);
 
 Static int     ukbd_ioctl(void *, u_long, void *, int, struct lwp *);
 #if  defined(WSDISPLAY_COMPAT_RAWKBD) && defined(UKBD_REPEAT)
@@ -476,6 +478,9 @@
 
        callout_init(&sc->sc_delay, 0);
 
+       usb_init_task(&sc->sc_ledtask, ukbd_set_leds_task, sc,
+           USB_TASKQ_MPSAFE);
+
        /* Flash the leds; no real purpose, just shows we're alive. */
        ukbd_set_leds(sc, WSKBD_LED_SCROLL | WSKBD_LED_NUM | WSKBD_LED_CAPS
                        | WSKBD_LED_COMPOSE);
@@ -884,7 +889,7 @@
 ukbd_set_leds(void *v, int leds)
 {
        struct ukbd_softc *sc = v;
-       u_int8_t res;
+       usbd_device_handle udev = sc->sc_hdev.sc_parent->sc_udev;
 
        DPRINTF(("ukbd_set_leds: sc=%p leds=%d, sc_leds=%d\n",
                 sc, leds, sc->sc_leds));
@@ -894,8 +899,18 @@
 
        if (sc->sc_leds == leds)
                return;
+
        sc->sc_leds = leds;
-       res = 0;
+       usb_add_task(udev, &sc->sc_ledtask, USB_TASKQ_DRIVER);
+}
+
+void
+ukbd_set_leds_task(void *v)
+{
+       struct ukbd_softc *sc = v;
+       int leds = sc->sc_leds;
+       uint8_t res = 0;
+
        /* XXX not really right */
        if ((leds & WSKBD_LED_COMPOSE) && sc->sc_compose.size == 1)
                res |= 1 << sc->sc_compose.pos;
@@ -905,7 +920,8 @@
                res |= 1 << sc->sc_numloc.pos;
        if ((leds & WSKBD_LED_CAPS) && sc->sc_capsloc.size == 1)
                res |= 1 << sc->sc_capsloc.pos;
-       uhidev_set_report_async(&sc->sc_hdev, UHID_OUTPUT_REPORT, &res, 1);
+
+       uhidev_set_report(&sc->sc_hdev, UHID_OUTPUT_REPORT, &res, 1);
 }
 
 #if defined(WSDISPLAY_COMPAT_RAWKBD) && defined(UKBD_REPEAT)
diff -r caaf8bb90442 -r 5013c1e8b509 sys/dev/usb/usb_subr.c
--- a/sys/dev/usb/usb_subr.c    Thu Sep 26 00:41:51 2013 +0000
+++ b/sys/dev/usb/usb_subr.c    Thu Sep 26 07:25:31 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usb_subr.c,v 1.193 2013/09/14 00:40:31 jakllsch Exp $  */
+/*     $NetBSD: usb_subr.c,v 1.194 2013/09/26 07:25:31 skrll Exp $     */
 /*     $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $   */
 
 /*
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.193 2013/09/14 00:40:31 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.194 2013/09/26 07:25:31 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -770,7 +770,7 @@
                free(p, M_USB);
                return (err);
        }
-       usb_init_task(&p->async_task, usbd_clear_endpoint_stall_async_cb, p,
+       usb_init_task(&p->async_task, usbd_clear_endpoint_stall_task, p,
            USB_TASKQ_MPSAFE);
        *pipe = p;
        return (USBD_NORMAL_COMPLETION);
diff -r caaf8bb90442 -r 5013c1e8b509 sys/dev/usb/usbdi.c
--- a/sys/dev/usb/usbdi.c       Thu Sep 26 00:41:51 2013 +0000
+++ b/sys/dev/usb/usbdi.c       Thu Sep 26 07:25:31 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usbdi.c,v 1.155 2013/08/22 20:00:43 aymeric Exp $      */
+/*     $NetBSD: usbdi.c,v 1.156 2013/09/26 07:25:31 skrll Exp $        */
 
 /*
  * Copyright (c) 1998, 2012 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.155 2013/08/22 20:00:43 aymeric Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.156 2013/09/26 07:25:31 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -608,7 +608,7 @@
 }
 
 void
-usbd_clear_endpoint_stall_async_cb(void *arg)
+usbd_clear_endpoint_stall_task(void *arg)
 {
        usbd_pipe_handle pipe = arg;
        usbd_device_handle dev = pipe->device;
@@ -621,7 +621,7 @@
        USETW(req.wValue, UF_ENDPOINT_HALT);
        USETW(req.wIndex, pipe->endpoint->edesc->bEndpointAddress);
        USETW(req.wLength, 0);
-       (void)usbd_do_request_async(dev, &req, 0);
+       (void)usbd_do_request(dev, &req, 0);
 }
 
 void
@@ -1085,49 +1085,6 @@
        return (err);
 }
 
-void
-usbd_do_request_async_cb(usbd_xfer_handle xfer,
-    usbd_private_handle priv, usbd_status status)
-{
-#if defined(USB_DEBUG) || defined(DIAGNOSTIC)
-       if (xfer->actlen > xfer->length) {
-               DPRINTF(("usbd_do_request: overrun addr=%d type=0x%02x req=0x"
-                        "%02x val=%d index=%d rlen=%d length=%d actlen=%d\n",
-                        xfer->pipe->device->address,
-                        xfer->request.bmRequestType,
-                        xfer->request.bRequest, UGETW(xfer->request.wValue),
-                        UGETW(xfer->request.wIndex),
-                        UGETW(xfer->request.wLength),
-                        xfer->length, xfer->actlen));
-       }
-#endif
-       usbd_free_xfer(xfer);
-}
-
-/*
- * Execute a request without waiting for completion.
- * Can be used from interrupt context.
- */
-usbd_status
-usbd_do_request_async(usbd_device_handle dev, usb_device_request_t *req,
-                     void *data)
-{
-       usbd_xfer_handle xfer;
-       usbd_status err;
-
-       xfer = usbd_alloc_xfer(dev);
-       if (xfer == NULL)
-               return (USBD_NOMEM);
-       usbd_setup_default_xfer(xfer, dev, 0, USBD_DEFAULT_TIMEOUT, req,
-           data, UGETW(req->wLength), 0, usbd_do_request_async_cb);
-       err = usbd_transfer(xfer);
-       if (err != USBD_IN_PROGRESS) {
-               usbd_free_xfer(xfer);
-               return (err);
-       }
-       return (USBD_NORMAL_COMPLETION);
-}
-
 const struct usbd_quirks *
 usbd_get_quirks(usbd_device_handle dev)
 {
diff -r caaf8bb90442 -r 5013c1e8b509 sys/dev/usb/usbdi.h
--- a/sys/dev/usb/usbdi.h       Thu Sep 26 00:41:51 2013 +0000
+++ b/sys/dev/usb/usbdi.h       Thu Sep 26 07:25:31 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usbdi.h,v 1.88 2013/09/07 16:47:23 skrll Exp $ */
+/*     $NetBSD: usbdi.h,v 1.89 2013/09/26 07:25:31 skrll Exp $ */
 /*     $FreeBSD: src/sys/dev/usb/usbdi.h,v 1.18 1999/11/17 22:33:49 n_hibma Exp $      */
 
 /*
@@ -190,7 +190,7 @@
 const usb_descriptor_t *usb_desc_iter_next(usbd_desc_iter_t *);
 
 /* Used to clear endpoint stalls from the softint */
-void usbd_clear_endpoint_stall_async_cb(void *);
+void usbd_clear_endpoint_stall_task(void *);
 
 /*
  * The usb_task structs form a queue of things to run in the USB event
diff -r caaf8bb90442 -r 5013c1e8b509 sys/dev/usb/usbdi_util.c
--- a/sys/dev/usb/usbdi_util.c  Thu Sep 26 00:41:51 2013 +0000
+++ b/sys/dev/usb/usbdi_util.c  Thu Sep 26 07:25:31 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usbdi_util.c,v 1.61 2013/08/30 12:59:19 skrll Exp $    */
+/*     $NetBSD: usbdi_util.c,v 1.62 2013/09/26 07:25:31 skrll 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.61 2013/08/30 12:59:19 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi_util.c,v 1.62 2013/09/26 07:25:31 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -273,26 +273,6 @@
 }
 
 usbd_status
-usbd_set_report_async(usbd_interface_handle iface, int type, int id, void *data,
-                     int len)
-{
-       usb_interface_descriptor_t *ifd = usbd_get_interface_descriptor(iface);



Home | Main Index | Thread Index | Old Index