Source-Changes-HG archive

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

[src/nick-nhusb]: src/sys/dev/usb Cache the usbd_bus pointer in the usbd_xfer...



details:   https://anonhg.NetBSD.org/src/rev/71a9771751be
branches:  nick-nhusb
changeset: 804420:71a9771751be
user:      skrll <skrll%NetBSD.org@localhost>
date:      Wed Oct 21 07:36:31 2015 +0000

description:
Cache the usbd_bus pointer in the usbd_xfer struct for memory allocation
and softc access.  This removes a level of indirection for memory
allocation.

Also cache the xfer pipe methods for later (temporary?) use.

diffstat:

 sys/dev/usb/usbdi.c    |  25 +++++++++++++------------
 sys/dev/usb/usbdivar.h |   8 +++++---
 2 files changed, 18 insertions(+), 15 deletions(-)

diffs (118 lines):

diff -r d28c0942f83f -r 71a9771751be sys/dev/usb/usbdi.c
--- a/sys/dev/usb/usbdi.c       Tue Oct 20 15:31:21 2015 +0000
+++ b/sys/dev/usb/usbdi.c       Wed Oct 21 07:36:31 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usbdi.c,v 1.162.2.32 2015/10/12 10:18:54 skrll Exp $   */
+/*     $NetBSD: usbdi.c,v 1.162.2.33 2015/10/21 07:36:31 skrll 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.162.2.32 2015/10/12 10:18:54 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.162.2.33 2015/10/21 07:36:31 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -380,7 +380,7 @@
 
        xfer->ux_bufsize = 0;
 #if NUSB_DMA > 0
-       struct usbd_bus *bus = xfer->ux_dev->ud_bus;
+       struct usbd_bus *bus = xfer->ux_bus;
 
        if (bus->ub_usedma) {
                usb_dma_t *dmap = &xfer->ux_dmabuf;
@@ -395,7 +395,7 @@
                return xfer->ux_buf;
        }
 #endif
-       KASSERT(xfer->ux_dev->ud_bus->ub_usedma == false);
+       KASSERT(xfer->ux_bus->ub_usedma == false);
        xfer->ux_buf = kmem_alloc(size, KM_SLEEP);
 
        if (xfer->ux_buf != NULL) {
@@ -418,7 +418,7 @@
        xfer->ux_bufsize = 0;
 
 #if NUSB_DMA > 0
-       struct usbd_bus *bus = xfer->ux_dev->ud_bus;
+       struct usbd_bus *bus = xfer->ux_bus;
 
        if (bus->ub_usedma) {
                usb_dma_t *dmap = &xfer->ux_dmabuf;
@@ -427,7 +427,7 @@
                return;
        }
 #endif
-       KASSERT(xfer->ux_dev->ud_bus->ub_usedma == false);
+       KASSERT(xfer->ux_bus->ub_usedma == false);
 
        kmem_free(buf, size);
 }
@@ -457,7 +457,7 @@
        xfer = dev->ud_bus->ub_methods->ubm_allocx(dev->ud_bus, nframes);
        if (xfer == NULL)
                return NULL;
-       xfer->ux_dev = dev;
+       xfer->ux_bus = dev->ud_bus;
        callout_init(&xfer->ux_callout, CALLOUT_MPSAFE);
        cv_init(&xfer->ux_cv, "usbxfer");
        cv_init(&xfer->ux_hccv, "usbhcxfer");
@@ -484,7 +484,7 @@
 #endif
        cv_destroy(&xfer->ux_cv);
        cv_destroy(&xfer->ux_hccv);
-       xfer->ux_dev->ud_bus->ub_methods->ubm_freex(xfer->ux_dev->ud_bus, xfer);
+       xfer->ux_bus->ub_methods->ubm_freex(xfer->ux_bus, xfer);
        return USBD_NORMAL_COMPLETION;
 }
 
@@ -509,9 +509,10 @@
        xfer->ux_pipe = pipe;
        xfer->ux_flags = flags;
        xfer->ux_nframes = nframes;
+       xfer->ux_methods = pipe->up_methods;
 
-       if (xfer->ux_pipe->up_methods->upm_init) {
-               int err = xfer->ux_pipe->up_methods->upm_init(xfer);
+       if (xfer->ux_methods->upm_init) {
+               int err = xfer->ux_methods->upm_init(xfer);
                if (err) {
                        if (buf)
                                usbd_free_buffer(xfer);
@@ -527,8 +528,8 @@
 void usbd_destroy_xfer(struct usbd_xfer *xfer)
 {
 
-       if (xfer->ux_pipe->up_methods->upm_fini) {
-               xfer->ux_pipe->up_methods->upm_fini(xfer);
+       if (xfer->ux_methods->upm_fini) {
+               xfer->ux_methods->upm_fini(xfer);
        }
 
        usbd_free_xfer(xfer);
diff -r d28c0942f83f -r 71a9771751be sys/dev/usb/usbdivar.h
--- a/sys/dev/usb/usbdivar.h    Tue Oct 20 15:31:21 2015 +0000
+++ b/sys/dev/usb/usbdivar.h    Wed Oct 21 07:36:31 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usbdivar.h,v 1.109.2.19 2015/10/12 10:18:54 skrll Exp $        */
+/*     $NetBSD: usbdivar.h,v 1.109.2.20 2015/10/21 07:36:31 skrll Exp $        */
 
 /*
  * Copyright (c) 1998, 2012 The NetBSD Foundation, Inc.
@@ -260,8 +260,10 @@
        uint16_t                *ux_frlengths;
        int                     ux_nframes;
 
-       /* For memory allocation */
-       struct usbd_device     *ux_dev;
+       const struct usbd_pipe_methods *ux_methods;
+
+       /* For memory allocation and softc */
+       struct usbd_bus        *ux_bus;
        usb_dma_t               ux_dmabuf;
        void                   *ux_buf;
        uint32_t                ux_bufsize;



Home | Main Index | Thread Index | Old Index