Source-Changes-HG archive

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

[src/netbsd-6]: src/sys/dev/usb Pull up following revision(s) (requested by n...



details:   https://anonhg.NetBSD.org/src/rev/74026634856f
branches:  netbsd-6
changeset: 775741:74026634856f
user:      riz <riz%NetBSD.org@localhost>
date:      Sat Mar 30 23:03:19 2013 +0000

description:
Pull up following revision(s) (requested by nick in ticket #847):
        sys/dev/usb/dwc_otg.c: revision 1.47
        sys/dev/usb/dwc_otg.c: revision 1.48
Consistently use the macros to get softc, dxfer, etc.
Fix misunderstanding of how to handle wMaxPacketSize.
The *_host_{setup,data}_[tr]x routines already split transfers into < mps
units, so there no reason to do it in *_setup_{ctrl,data}_chain. Fix
short_pkt handling in the process.
This gives urtwn a fighting change to Tx large packets.

diffstat:

 sys/dev/usb/dwc_otg.c |  176 +++++++++++++++++++++----------------------------
 1 files changed, 76 insertions(+), 100 deletions(-)

diffs (truncated from 499 to 300 lines):

diff -r 8b91a1ddc8c7 -r 74026634856f sys/dev/usb/dwc_otg.c
--- a/sys/dev/usb/dwc_otg.c     Fri Mar 29 00:50:32 2013 +0000
+++ b/sys/dev/usb/dwc_otg.c     Sat Mar 30 23:03:19 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dwc_otg.c,v 1.45.2.4 2013/02/18 18:13:05 riz Exp $     */
+/*     $NetBSD: dwc_otg.c,v 1.45.2.5 2013/03/30 23:03:19 riz 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.45.2.4 2013/02/18 18:13:05 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dwc_otg.c,v 1.45.2.5 2013/03/30 23:03:19 riz Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -119,7 +119,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)
 
@@ -130,6 +132,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))
 
@@ -337,7 +341,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);
@@ -349,7 +353,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");
 
@@ -363,7 +367,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");
@@ -383,7 +387,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");
 
@@ -402,7 +406,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;
 
        DOTG_EVCNT_INCR(sc->sc_ev_soft_intr);
@@ -466,9 +470,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);
 
@@ -496,9 +500,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;
@@ -560,7 +565,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);
 
        mutex_spin_enter(&sc->sc_intr_lock);
        dwc_otg_interrupt(sc);
@@ -583,9 +588,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;
        int s;
 
@@ -764,7 +768,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;
@@ -1182,8 +1186,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");
 
@@ -1213,7 +1216,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");
 
@@ -1250,7 +1253,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");
 
@@ -1274,8 +1277,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;
@@ -1325,7 +1328,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);
 
@@ -1349,8 +1352,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");
 
@@ -1363,7 +1366,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");
 
@@ -1395,9 +1398,7 @@
 Static usbd_status
 dwc_otg_device_intr_start(usbd_xfer_handle xfer)
 {
-       struct dwc_otg_pipe *dpipe = (struct dwc_otg_pipe *)xfer->pipe;
-       usbd_device_handle dev = dpipe->pipe.device;
-       struct dwc_otg_softc *sc = dev->bus->hci_private;
+       struct dwc_otg_softc *sc = DWC_OTG_XFER2SC(xfer);
 
        DPRINTF("\n");
 
@@ -1427,8 +1428,8 @@
 Static void
 dwc_otg_device_intr_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;
@@ -1483,9 +1484,9 @@
 void
 dwc_otg_device_isoc_enter(usbd_xfer_handle xfer)
 {
-       struct dwc_otg_pipe *dpipe = (struct dwc_otg_pipe *)xfer->pipe;
+       struct dwc_otg_pipe *dpipe = DWC_OTG_XFER2DPIPE(xfer);
        usbd_device_handle dev = dpipe->pipe.device;
-       struct dwc_otg_softc *sc = dev->bus->hci_private;
+       struct dwc_otg_softc *sc = DWC_OTG_XFER2SC(xfer);
 
        DPRINTF("\n");
 
@@ -1496,8 +1497,7 @@
 usbd_status
 dwc_otg_device_isoc_start(usbd_xfer_handle 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_softc *sc = DWC_OTG_XFER2SC(xfer);
 
        sc = sc;
        DPRINTF("\n");
@@ -1508,8 +1508,7 @@
 void
 dwc_otg_device_isoc_abort(usbd_xfer_handle 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_softc *sc = DWC_OTG_XFER2SC(xfer);
 
        sc = sc;
        DPRINTF("\n");
@@ -1520,8 +1519,8 @@
 usbd_status
 dwc_otg_setup_isoc(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;
@@ -1534,8 +1533,8 @@
 void
 dwc_otg_device_isoc_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;
@@ -2914,7 +2913,7 @@
                                        return 0;       /* complete */
 
                                /*
-                                * Else we need to transmit a short
+                                * Else we need to transmit a 0 length
                                 * packet:
                                 */
                        }
@@ -3085,7 +3084,7 @@
 static uint8_t
 dwc_otg_xfer_do_fifo(usbd_xfer_handle xfer)
 {
-       struct dwc_otg_xfer *dxfer = (struct dwc_otg_xfer *)xfer;
+       struct dwc_otg_xfer *dxfer = DWC_OTG_XFER2DXFER(xfer);
        struct dwc_otg_td *td;
        uint8_t toggle;



Home | Main Index | Thread Index | Old Index