Source-Changes-HG archive

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

[src/nick-nhusb]: src/sys Consistently providei/use *_{XFER, PIPE, BUS}2SC, etc...



details:   https://anonhg.NetBSD.org/src/rev/d28c0942f83f
branches:  nick-nhusb
changeset: 804419:d28c0942f83f
user:      skrll <skrll%NetBSD.org@localhost>
date:      Tue Oct 20 15:31:21 2015 +0000

description:
Consistently providei/use *_{XFER,PIPE,BUS}2SC, etc macros

diffstat:

 sys/arch/mips/adm5120/dev/ahci.c    |   39 +++++----
 sys/dev/ic/sl811hs.c                |   46 ++++++-----
 sys/dev/usb/ehci.c                  |   88 ++++++++++-----------
 sys/dev/usb/motg.c                  |   52 ++++++------
 sys/dev/usb/motgvar.h               |    9 ++-
 sys/dev/usb/ohci.c                  |  142 ++++++++++++++++-------------------
 sys/dev/usb/ohcivar.h               |    9 ++-
 sys/dev/usb/uhci.c                  |  115 +++++++++++++---------------
 sys/dev/usb/uhcivar.h               |    9 +-
 sys/dev/usb/xhci.c                  |   68 ++++++++--------
 sys/dev/usb/xhcivar.h               |    9 ++-
 sys/rump/dev/lib/libugenhc/ugenhc.c |   30 ++++---
 12 files changed, 315 insertions(+), 301 deletions(-)

diffs (truncated from 2341 to 300 lines):

diff -r 3c1270a7c173 -r d28c0942f83f sys/arch/mips/adm5120/dev/ahci.c
--- a/sys/arch/mips/adm5120/dev/ahci.c  Tue Oct 20 15:17:54 2015 +0000
+++ b/sys/arch/mips/adm5120/dev/ahci.c  Tue Oct 20 15:31:21 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ahci.c,v 1.12.6.13 2015/10/11 09:17:50 skrll Exp $     */
+/*     $NetBSD: ahci.c,v 1.12.6.14 2015/10/20 15:31:21 skrll Exp $     */
 
 /*-
  * Copyright (c) 2007 Ruslan Ermilov and Vsevolod Lobko.
@@ -64,7 +64,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ahci.c,v 1.12.6.13 2015/10/11 09:17:50 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ahci.c,v 1.12.6.14 2015/10/20 15:31:21 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -409,6 +409,11 @@
        DPRINTF(D_TRACE, ("%s()", __func__));
 }
 
+#define AHCI_BUS2SC(bus)       ((bus)->ub_hcpriv)
+#define AHCI_PIPE2SC(pipe)     AHCI_BUS2SC((pipe)->up_dev->ud_bus)
+#define AHCI_XFER2SC(xfer)     AHCI_PIPE2SC((xfer)->ux_pipe)
+#define AHCI_APIPE2SC(ap)      AHCI_BUS2SC((d)->pipe.up_dev->ud_bus)
+
 /*
  * Emulation of interrupt transfer for status change endpoint
  * of root hub.
@@ -417,8 +422,7 @@
 ahci_poll_hub(void *arg)
 {
        struct usbd_xfer *xfer = arg;
-       struct usbd_pipe *pipe = xfer->ux_pipe;
-       struct ahci_softc *sc = (struct ahci_softc *)pipe->up_dev->ud_bus;
+       struct ahci_softc *sc = AHCI_XFER2SC(xfer);
        u_char *p;
        static int p0_state=0;
        static int p1_state=0;
@@ -453,7 +457,7 @@
 struct usbd_xfer *
 ahci_allocx(struct usbd_bus *bus, unsigned int nframes)
 {
-       struct ahci_softc *sc = (struct ahci_softc *)bus;
+       struct ahci_softc *sc = AHCI_BUS2SC(bus);
        struct usbd_xfer *xfer;
 
        DPRINTF(D_MEM, ("SLallocx"));
@@ -484,7 +488,7 @@
 void
 ahci_freex(struct usbd_bus *bus, struct usbd_xfer *xfer)
 {
-       struct ahci_softc *sc = (struct ahci_softc *)bus;
+       struct ahci_softc *sc = AHCI_BUS2SC(bus);
 
        DPRINTF(D_MEM, ("SLfreex"));
 
@@ -502,7 +506,7 @@
 static void
 ahci_get_lock(struct usbd_bus *bus, kmutex_t **lock)
 {
-       struct ahci_softc *sc = bus->ub_hcpriv;
+       struct ahci_softc *sc = AHCI_BUS2SC(bus);
 
        *lock = &sc->sc_lock;
 }
@@ -521,7 +525,7 @@
 ahci_roothub_ctrl(struct usbd_bus *bus, usb_device_request_t *req,
     void *buf, int buflen)
 {
-       struct ahci_softc *sc = bus->ub_hcpriv;
+       struct ahci_softc *sc = AHCI_BUS2SC(bus);
        uint16_t len, value, index;
        usb_port_status_t ps;
        int totlen = 0;
@@ -700,7 +704,7 @@
 static usbd_status
 ahci_root_intr_transfer(struct usbd_xfer *xfer)
 {
-       struct ahci_softc *sc = (struct ahci_softc *)xfer->ux_pipe->up_dev->ud_bus;
+       struct ahci_softc *sc = AHCI_XFER2SC(xfer);
        usbd_status error;
 
        DPRINTF(D_TRACE, ("SLRItransfer "));
@@ -722,8 +726,7 @@
 static usbd_status
 ahci_root_intr_start(struct usbd_xfer *xfer)
 {
-       struct usbd_pipe *pipe = xfer->ux_pipe;
-       struct ahci_softc *sc = (struct ahci_softc *)pipe->up_dev->ud_bus;
+       struct ahci_softc *sc = AHCI_XFER2SC(xfer);
 
        DPRINTF(D_TRACE, ("SLRIstart "));
 
@@ -742,7 +745,7 @@
 static void
 ahci_root_intr_close(struct usbd_pipe *pipe)
 {
-       struct ahci_softc *sc = (struct ahci_softc *)pipe->up_dev->ud_bus;
+       struct ahci_softc *sc = AHCI_PIPE2SC(pipe);
 
        DPRINTF(D_TRACE, ("SLRIclose "));
 
@@ -759,7 +762,7 @@
 static usbd_status
 ahci_device_ctrl_transfer(struct usbd_xfer *xfer)
 {
-       struct ahci_softc *sc = (struct ahci_softc *)xfer->ux_pipe->up_dev->ud_bus;
+       struct ahci_softc *sc = AHCI_XFER2SC(xfer);
        usbd_status error;
 
        DPRINTF(D_TRACE, ("C"));
@@ -783,7 +786,7 @@
        static usb_dma_t reqdma;
        struct usbd_pipe *pipe = xfer->ux_pipe;
        usb_device_request_t *req = &xfer->ux_request;
-       struct ahci_softc *sc = (struct ahci_softc *)pipe->up_dev->ud_bus;
+       struct ahci_softc *sc = AHCI_XFER2SC(xfer);
        int len, isread;
 
 
@@ -946,7 +949,7 @@
 static usbd_status
 ahci_device_intr_transfer(struct usbd_xfer *xfer)
 {
-       struct ahci_softc *sc = (struct ahci_softc *)xfer->ux_pipe->up_dev->ud_bus;
+       struct ahci_softc *sc = AHCI_XFER2SC(xfer);
        usbd_status error;
 
        DPRINTF(D_TRACE, ("INTRtrans "));
@@ -994,7 +997,7 @@
        struct ahci_xfer *sx = (struct ahci_xfer *)arg;
        struct usbd_xfer *xfer = sx->sx_xfer;
        struct usbd_pipe *pipe = xfer->ux_pipe;
-       struct ahci_softc *sc = (struct ahci_softc *)pipe->up_dev->ud_bus;
+       struct ahci_softc *sc = AHCI_XFER2SC(xfer);
        void *buf;
        int pid;
        int r;
@@ -1090,7 +1093,7 @@
 static usbd_status
 ahci_device_bulk_transfer(struct usbd_xfer *xfer)
 {
-       struct ahci_softc *sc = (struct ahci_softc *)xfer->ux_pipe->up_dev->ud_bus;
+       struct ahci_softc *sc = AHCI_XFER2SC(xfer);
        usbd_status error;
 
        DPRINTF(D_TRACE, ("B"));
@@ -1114,7 +1117,7 @@
        static struct admhcd_ed ep_v __attribute__((aligned(16))), *ep;
        static struct admhcd_td td_v[NBULK_TDS] __attribute__((aligned(16))), *td[NBULK_TDS];
        struct usbd_pipe *pipe = xfer->ux_pipe;
-       struct ahci_softc *sc = (struct ahci_softc *)pipe->up_dev->ud_bus;
+       struct ahci_softc *sc = AHCI_XFER2SC(xfer);
        int endpt, i, len, tlen, segs, offset, isread, toggle, short_ok;
        struct ahci_pipe *apipe = (struct ahci_pipe *)xfer->ux_pipe;
 
diff -r 3c1270a7c173 -r d28c0942f83f sys/dev/ic/sl811hs.c
--- a/sys/dev/ic/sl811hs.c      Tue Oct 20 15:17:54 2015 +0000
+++ b/sys/dev/ic/sl811hs.c      Tue Oct 20 15:31:21 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sl811hs.c,v 1.47.6.13 2015/10/11 09:17:51 skrll Exp $  */
+/*     $NetBSD: sl811hs.c,v 1.47.6.14 2015/10/20 15:31:21 skrll Exp $  */
 
 /*
  * Not (c) 2007 Matthew Orgass
@@ -68,7 +68,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sl811hs.c,v 1.47.6.13 2015/10/11 09:17:51 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sl811hs.c,v 1.47.6.14 2015/10/20 15:31:21 skrll Exp $");
 
 #include "opt_slhci.h"
 
@@ -292,6 +292,12 @@
        uint8_t         ptype;          /* Pipe type */
 };
 
+#define SLHCI_BUS2SC(bus)      ((bus)->ub_hcpriv)
+#define SLHCI_PIPE2SC(pipe)    SLHCI_BUS2SC((pipe)->up_dev->ud_bus)
+#define SLHCI_XFER2SC(xfer)    SLHCI_PIPE2SC((xfer)->ux_pipe)
+
+#define SLHCI_PIPE2SPIPE(pipe) ((struct slhci_pipe *)(pipe))
+
 #ifdef SLHCI_PROFILE_TRANSFER
 #if defined(__mips__)
 /*
@@ -786,7 +792,7 @@
 #endif
 #ifdef DIAGNOSTIC
        if (xfer->ux_state != XFER_BUSY) {
-               struct slhci_softc *sc = bus->ub_hcpriv;
+               struct slhci_softc *sc = SLHCI_BUS2SC(bus);
                printf("%s: slhci_freex: xfer=%p not busy, %#08x halted\n",
                    SC_NAME(sc), xfer, xfer->ux_state);
                DDOLOG("%s: slhci_freex: xfer=%p not busy, %#08x halted\n",
@@ -803,7 +809,7 @@
 static void
 slhci_get_lock(struct usbd_bus *bus, kmutex_t **lock)
 {
-       struct slhci_softc *sc = bus->ub_hcpriv;
+       struct slhci_softc *sc = SLHCI_BUS2SC(bus);
 
        *lock = &sc->sc_lock;
 }
@@ -811,7 +817,7 @@
 usbd_status
 slhci_transfer(struct usbd_xfer *xfer)
 {
-       struct slhci_softc *sc = xfer->ux_pipe->up_dev->ud_bus->ub_hcpriv;
+       struct slhci_softc *sc = SLHCI_XFER2SC(xfer);
        usbd_status error;
 
        DLOG(D_TRACE, "%s transfer xfer %p spipe %p ",
@@ -845,9 +851,9 @@
 usbd_status
 slhci_start(struct usbd_xfer *xfer)
 {
-       struct slhci_softc *sc = xfer->ux_pipe->up_dev->ud_bus->ub_hcpriv;
+       struct slhci_softc *sc = SLHCI_XFER2SC(xfer);
        struct usbd_pipe *pipe = xfer->ux_pipe;
-       struct slhci_pipe *spipe = (struct slhci_pipe *)pipe;
+       struct slhci_pipe *spipe = SLHCI_PIPE2SPIPE(pipe);
        struct slhci_transfers *t = &sc->sc_transfers;
        usb_endpoint_descriptor_t *ed = pipe->up_endpoint->ue_edesc;
        unsigned int max_packet;
@@ -980,8 +986,8 @@
        struct slhci_softc *sc;
        struct slhci_pipe *spipe;
 
-       spipe = (struct slhci_pipe *)xfer->ux_pipe;
-       sc = xfer->ux_pipe->up_dev->ud_bus->ub_hcpriv;
+       spipe = SLHCI_PIPE2SPIPE(xfer->ux_pipe);
+       sc = SLHCI_XFER2SC(xfer);
 
        return slhci_lock_call(sc, &slhci_root, spipe, xfer);
 }
@@ -997,8 +1003,8 @@
        uint8_t rhaddr;
 
        dev = pipe->up_dev;
-       sc = dev->ud_bus->ub_hcpriv;
-       spipe = (struct slhci_pipe *)pipe;
+       sc = SLHCI_PIPE2SC(pipe);
+       spipe = SLHCI_PIPE2SPIPE(pipe);
        ed = pipe->up_endpoint->ue_edesc;
        rhaddr = dev->ud_bus->ub_rhaddr;
 
@@ -1289,12 +1295,12 @@
        struct slhci_softc *sc;
        struct slhci_pipe *spipe;
 
-       spipe = (struct slhci_pipe *)xfer->ux_pipe;
+       spipe = SLHCI_PIPE2SPIPE(xfer->ux_pipe);
 
        if (spipe == NULL)
                goto callback;
 
-       sc = spipe->pipe.up_dev->ud_bus->ub_hcpriv;
+       sc = SLHCI_XFER2SC(xfer);
 
        KASSERT(mutex_owned(&sc->sc_lock));
 
@@ -1315,8 +1321,8 @@
        struct slhci_softc *sc;
        struct slhci_pipe *spipe;
 
-       sc = pipe->up_dev->ud_bus->ub_hcpriv;
-       spipe = (struct slhci_pipe *)pipe;
+       sc = SLHCI_PIPE2SC(pipe);
+       spipe = SLHCI_PIPE2SPIPE(pipe);
 
        DLOG(D_TRACE, "%s close spipe %p spipe->xfer %p",
            pnames(spipe->ptype), spipe, spipe->xfer, 0);
@@ -1329,7 +1335,7 @@
 {
        struct slhci_pipe *spipe;
 
-       spipe = (struct slhci_pipe *)pipe;
+       spipe = SLHCI_PIPE2SPIPE(pipe);
 
        DLOG(D_TRACE, "%s toggle spipe %p", pnames(spipe->ptype),
            spipe,0,0);
@@ -1355,7 +1361,7 @@
 {
        struct slhci_softc *sc;
 
-       sc = bus->ub_hcpriv;
+       sc = SLHCI_BUS2SC(bus);
 
        DLOG(D_TRACE, "slhci_poll", 0,0,0,0);
 
@@ -1377,7 +1383,7 @@
 void
 slhci_mem_use(struct usbd_bus *bus, int val)
 {
-       struct slhci_softc *sc = bus->ub_hcpriv;
+       struct slhci_softc *sc = SLHCI_BUS2SC(bus);



Home | Main Index | Thread Index | Old Index