Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb Consistently use the macros to get softc, dxfer, ...



details:   https://anonhg.NetBSD.org/src/rev/0f2dca447840
branches:  trunk
changeset: 785099:0f2dca447840
user:      skrll <skrll%NetBSD.org@localhost>
date:      Sat Feb 23 08:22:05 2013 +0000

description:
Consistently use the macros to get softc, dxfer, etc.

diffstat:

 sys/dev/usb/dwc_otg.c |  153 ++++++++++++++++++++++++-------------------------
 1 files changed, 74 insertions(+), 79 deletions(-)

diffs (truncated from 508 to 300 lines):

diff -r e8f9c54166ca -r 0f2dca447840 sys/dev/usb/dwc_otg.c
--- a/sys/dev/usb/dwc_otg.c     Fri Feb 22 15:59:14 2013 +0000
+++ b/sys/dev/usb/dwc_otg.c     Sat Feb 23 08:22:05 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dwc_otg.c,v 1.46 2013/02/15 17:07:09 skrll Exp $       */
+/*     $NetBSD: dwc_otg.c,v 1.47 2013/02/23 08:22:05 skrll Exp $       */
 
 /*-
  * Copyright (c) 2012 Hans Petter Selasky. All rights reserved.
@@ -60,7 +60,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dwc_otg.c,v 1.46 2013/02/15 17:07:09 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dwc_otg.c,v 1.47 2013/02/23 08:22:05 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -118,7 +118,9 @@
 
 #define        DWC_OTG_BUS2SC(bus)     ((bus)->hci_private)
 
-#define        DWC_OTG_XFER2SC(xfer)   DWC_OTG_BUS2SC((xfer)->pipe->device->bus)
+#define        DWC_OTG_PIPE2SC(pipe)   DWC_OTG_BUS2SC((pipe)->device->bus)
+
+#define        DWC_OTG_XFER2SC(xfer)   DWC_OTG_PIPE2SC((xfer)->pipe)
 
 #define        DWC_OTG_TD2SC(td)       DWC_OTG_XFER2SC((td)->xfer)
 
@@ -129,6 +131,8 @@
 
 #define        DWC_OTG_XFER2DPIPE(x) (struct dwc_otg_pipe *)(x)->pipe;
 
+#define        DWC_OTG_PIPE2DPIPE(p) (struct dwc_otg_pipe *)(p)
+
 #define usbd_copy_in(d, o, b, s) \
     memcpy(((char *)(d) + (o)), (b), (s))
 
@@ -339,7 +343,7 @@
 Static usbd_status
 dwc_otg_allocm(struct usbd_bus *bus, usb_dma_t *dma, uint32_t size)
 {
-       struct dwc_otg_softc *sc = bus->hci_private;
+       struct dwc_otg_softc *sc = DWC_OTG_BUS2SC(bus);
        usbd_status status;
 
        status = usb_allocmem(&sc->sc_bus, size, 0, dma);
@@ -351,7 +355,7 @@
 Static void
 dwc_otg_freem(struct usbd_bus *bus, usb_dma_t *dma)
 {
-       struct dwc_otg_softc *sc = bus->hci_private;
+       struct dwc_otg_softc *sc = DWC_OTG_BUS2SC(bus);
 
        DPRINTF("\n");
 
@@ -365,7 +369,7 @@
 usbd_xfer_handle
 dwc_otg_allocx(struct usbd_bus *bus)
 {
-       struct dwc_otg_softc *sc = bus->hci_private;
+       struct dwc_otg_softc *sc = DWC_OTG_BUS2SC(bus);
        struct dwc_otg_xfer *dxfer;
 
        DPRINTF("\n");
@@ -385,7 +389,7 @@
 void
 dwc_otg_freex(struct usbd_bus *bus, usbd_xfer_handle xfer)
 {
-       struct dwc_otg_softc *sc = bus->hci_private;
+       struct dwc_otg_softc *sc = DWC_OTG_BUS2SC(bus);
 
        DPRINTF("\n");
 
@@ -403,7 +407,7 @@
 Static void
 dwc_otg_get_lock(struct usbd_bus *bus, kmutex_t **lock)
 {
-       struct dwc_otg_softc *sc = bus->hci_private;
+       struct dwc_otg_softc *sc = DWC_OTG_BUS2SC(bus);
 
        *lock = &sc->sc_lock;
 }
@@ -412,7 +416,7 @@
 dwc_otg_softintr(void *v)
 {
        struct usbd_bus *bus = v;
-       struct dwc_otg_softc *sc = bus->hci_private;
+       struct dwc_otg_softc *sc = DWC_OTG_BUS2SC(bus);
        struct dwc_otg_xfer *dxfer;
 
        KASSERT(sc->sc_bus.use_polling || mutex_owned(&sc->sc_lock));
@@ -481,9 +485,9 @@
 Static void
 dwc_otg_timeout(void *addr)
 {
-       struct dwc_otg_xfer *dxfer = addr;
-       struct dwc_otg_pipe *dpipe = (struct dwc_otg_pipe *)dxfer->xfer.pipe;
-       struct dwc_otg_softc *sc = dpipe->pipe.device->bus->hci_private;
+       usbd_xfer_handle xfer = addr;
+       struct dwc_otg_xfer *dxfer = DWC_OTG_XFER2DXFER(xfer);
+       struct dwc_otg_softc *sc = DWC_OTG_XFER2SC(xfer);
 
        DPRINTF("dxfer=%p\n", dxfer);
 
@@ -505,7 +509,7 @@
 dwc_otg_timeout_task(void *addr)
 {
        usbd_xfer_handle xfer = addr;
-       struct dwc_otg_softc *sc = xfer->pipe->device->bus->hci_private;
+       struct dwc_otg_softc *sc = DWC_OTG_XFER2SC(xfer);
 
        DPRINTF("xfer=%p\n", xfer);
 
@@ -517,9 +521,10 @@
 usbd_status
 dwc_otg_open(usbd_pipe_handle pipe)
 {
+       struct dwc_otg_pipe *dpipe = DWC_OTG_PIPE2DPIPE(pipe);
+       struct dwc_otg_softc *sc = DWC_OTG_DPIPE2SC(dpipe);
+       usb_endpoint_descriptor_t *ed = pipe->endpoint->edesc;
        usbd_device_handle dev = pipe->device;
-       struct dwc_otg_softc *sc = dev->bus->hci_private;
-       usb_endpoint_descriptor_t *ed = pipe->endpoint->edesc;
        uint8_t addr = dev->address;
        uint8_t xfertype = UE_GET_XFERTYPE(ed->bmAttributes);
        usbd_status err;
@@ -581,7 +586,7 @@
 Static void
 dwc_otg_poll(struct usbd_bus *bus)
 {
-       struct dwc_otg_softc *sc = bus->hci_private;
+       struct dwc_otg_softc *sc = DWC_OTG_BUS2SC(bus);
 
        KASSERT(sc->sc_bus.use_polling || mutex_owned(&sc->sc_lock));
        mutex_spin_enter(&sc->sc_intr_lock);
@@ -596,8 +601,8 @@
 Static void
 dwc_otg_close_pipe(usbd_pipe_handle pipe)
 {
-       struct dwc_otg_pipe *dpipe = (struct dwc_otg_pipe *)pipe;
-       struct dwc_otg_softc *sc = pipe->device->bus->hci_private;
+       struct dwc_otg_pipe *dpipe = DWC_OTG_PIPE2DPIPE(pipe);
+       struct dwc_otg_softc *sc = DWC_OTG_DPIPE2SC(dpipe);
 
        dpipe = dpipe;
 
@@ -610,9 +615,8 @@
 Static void
 dwc_otg_abort_xfer(usbd_xfer_handle xfer, usbd_status status)
 {
-       struct dwc_otg_xfer *dxfer = (struct dwc_otg_xfer *)xfer;
-       struct dwc_otg_pipe *dpipe = (struct dwc_otg_pipe *)xfer->pipe;
-       struct dwc_otg_softc *sc = dpipe->pipe.device->bus->hci_private;
+       struct dwc_otg_xfer *dxfer = DWC_OTG_XFER2DXFER(xfer);
+       struct dwc_otg_softc *sc = DWC_OTG_XFER2SC(xfer);
        bool wake;
 
        DPRINTF("xfer=%p\n", xfer);
@@ -778,7 +782,7 @@
 Static usbd_status
 dwc_otg_root_ctrl_transfer(usbd_xfer_handle xfer)
 {
-       struct dwc_otg_softc *sc = xfer->pipe->device->bus->hci_private;
+       struct dwc_otg_softc *sc = DWC_OTG_XFER2SC(xfer);
        usbd_status err;
 
        mutex_enter(&sc->sc_lock);
@@ -793,7 +797,7 @@
 Static usbd_status
 dwc_otg_root_ctrl_start(usbd_xfer_handle xfer)
 {
-       struct dwc_otg_softc *sc = xfer->pipe->device->bus->hci_private;
+       struct dwc_otg_softc *sc = DWC_OTG_XFER2SC(xfer);
        usb_device_request_t *req;
        uint8_t *buf;
        int len, value, index, l, totlen;
@@ -1195,7 +1199,7 @@
 Static usbd_status
 dwc_otg_root_intr_transfer(usbd_xfer_handle xfer)
 {
-       struct dwc_otg_softc *sc = xfer->pipe->device->bus->hci_private;
+       struct dwc_otg_softc *sc = DWC_OTG_XFER2SC(xfer);
        usbd_status err;
 
        DPRINTF("\n");
@@ -1214,8 +1218,7 @@
 Static usbd_status
 dwc_otg_root_intr_start(usbd_xfer_handle xfer)
 {
-       usbd_pipe_handle pipe = xfer->pipe;
-       struct dwc_otg_softc *sc = pipe->device->bus->hci_private;
+       struct dwc_otg_softc *sc = DWC_OTG_XFER2SC(xfer);
 
        DPRINTF("\n");
 
@@ -1235,7 +1238,7 @@
 dwc_otg_root_intr_abort(usbd_xfer_handle xfer)
 {
 #ifdef DIAGNOSTIC
-       struct dwc_otg_softc *sc = xfer->pipe->device->bus->hci_private;
+       struct dwc_otg_softc *sc = DWC_OTG_XFER2SC(xfer);
 #endif
        DPRINTF("xfer=%p\n", xfer);
 
@@ -1252,7 +1255,7 @@
 Static void
 dwc_otg_root_intr_close(usbd_pipe_handle pipe)
 {
-       struct dwc_otg_softc *sc = pipe->device->bus->hci_private;
+       struct dwc_otg_softc *sc = DWC_OTG_PIPE2SC(pipe);
 
        DPRINTF("\n");
 
@@ -1272,7 +1275,7 @@
 Static usbd_status
 dwc_otg_device_ctrl_transfer(usbd_xfer_handle xfer)
 {
-       struct dwc_otg_softc *sc = xfer->pipe->device->bus->hci_private;
+       struct dwc_otg_softc *sc = DWC_OTG_XFER2SC(xfer);
        usbd_status err;
 
        DPRINTF("\n");
@@ -1294,7 +1297,7 @@
 Static usbd_status
 dwc_otg_device_ctrl_start(usbd_xfer_handle xfer)
 {
-       struct dwc_otg_softc *sc = xfer->pipe->device->bus->hci_private;
+       struct dwc_otg_softc *sc = DWC_OTG_XFER2SC(xfer);
 
        DPRINTF("\n");
 
@@ -1313,7 +1316,7 @@
 dwc_otg_device_ctrl_abort(usbd_xfer_handle xfer)
 {
 #ifdef DIAGNOSTIC
-       struct dwc_otg_softc *sc = xfer->pipe->device->bus->hci_private;
+       struct dwc_otg_softc *sc = DWC_OTG_XFER2SC(xfer);
 #endif
        KASSERT(mutex_owned(&sc->sc_lock));
 
@@ -1324,8 +1327,8 @@
 Static void
 dwc_otg_device_ctrl_close(usbd_pipe_handle pipe)
 {
-       struct dwc_otg_pipe *dpipe = (struct dwc_otg_pipe *)pipe;
-       struct dwc_otg_softc *sc = pipe->device->bus->hci_private;
+       struct dwc_otg_pipe *dpipe = DWC_OTG_PIPE2DPIPE(pipe);
+       struct dwc_otg_softc *sc = DWC_OTG_PIPE2SC(pipe);
 
        dpipe = dpipe;
        sc = sc;
@@ -1351,7 +1354,7 @@
 Static usbd_status
 dwc_otg_device_bulk_transfer(usbd_xfer_handle xfer)
 {
-       struct dwc_otg_softc *sc = xfer->pipe->device->bus->hci_private;
+       struct dwc_otg_softc *sc = DWC_OTG_XFER2SC(xfer);
        usbd_status err;
 
        DPRINTF("\n");
@@ -1378,7 +1381,7 @@
 Static usbd_status
 dwc_otg_device_bulk_start(usbd_xfer_handle xfer)
 {
-       struct dwc_otg_softc *sc = xfer->pipe->device->bus->hci_private;
+       struct dwc_otg_softc *sc = DWC_OTG_XFER2SC(xfer);
 
        DPRINTF("xfer=%p\n", xfer);
 
@@ -1397,7 +1400,7 @@
 dwc_otg_device_bulk_abort(usbd_xfer_handle xfer)
 {
 #ifdef DIAGNOSTIC
-       struct dwc_otg_softc *sc = xfer->pipe->device->bus->hci_private;
+       struct dwc_otg_softc *sc = DWC_OTG_XFER2SC(xfer);
 #endif
        KASSERT(mutex_owned(&sc->sc_lock));
 
@@ -1408,8 +1411,8 @@
 Static void
 dwc_otg_device_bulk_close(usbd_pipe_handle pipe)
 {
-       struct dwc_otg_pipe *dpipe = (struct dwc_otg_pipe *)pipe;
-       struct dwc_otg_softc *sc = pipe->device->bus->hci_private;
+       struct dwc_otg_pipe *dpipe = DWC_OTG_PIPE2DPIPE(pipe);
+       struct dwc_otg_softc *sc = DWC_OTG_PIPE2SC(pipe);
 
        DPRINTF("\n");
 
@@ -1422,7 +1425,7 @@
 Static void
 dwc_otg_device_bulk_done(usbd_xfer_handle xfer)
 {
-       struct dwc_otg_softc *sc = xfer->pipe->device->bus->hci_private;
+       struct dwc_otg_softc *sc = DWC_OTG_XFER2SC(xfer);
 
        DPRINTF("\n");
 
@@ -1435,7 +1438,7 @@



Home | Main Index | Thread Index | Old Index