Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb Convert umass(4) to usbhist.



details:   https://anonhg.NetBSD.org/src/rev/1ecb0b37dde7
branches:  trunk
changeset: 816352:1ecb0b37dde7
user:      skrll <skrll%NetBSD.org@localhost>
date:      Fri Jul 01 12:16:35 2016 +0000

description:
Convert umass(4) to usbhist.

diffstat:

 sys/dev/usb/umass.c        |  267 ++++++++++++++++++++------------------------
 sys/dev/usb/umass_quirks.c |   15 +-
 sys/dev/usb/umass_scsipi.c |   79 ++++++-------
 sys/dev/usb/umassvar.h     |   12 +-
 4 files changed, 176 insertions(+), 197 deletions(-)

diffs (truncated from 974 to 300 lines):

diff -r c3485b497915 -r 1ecb0b37dde7 sys/dev/usb/umass.c
--- a/sys/dev/usb/umass.c       Fri Jul 01 12:12:06 2016 +0000
+++ b/sys/dev/usb/umass.c       Fri Jul 01 12:16:35 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: umass.c,v 1.152 2016/04/29 07:11:32 skrll Exp $        */
+/*     $NetBSD: umass.c,v 1.153 2016/07/01 12:16:35 skrll Exp $        */
 
 /*
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -124,7 +124,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: umass.c,v 1.152 2016/04/29 07:11:32 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: umass.c,v 1.153 2016/07/01 12:16:35 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -322,6 +322,7 @@
 void
 umass_attach(device_t parent, device_t self, void *aux)
 {
+       UMASSHIST_FUNC(); UMASSHIST_CALLED();
        struct umass_softc *sc = device_private(self);
        struct usbif_attach_arg *uiaa = aux;
        const struct umass_quirk *quirk;
@@ -377,10 +378,8 @@
                        sc->sc_wire = UMASS_WPROTO_BBB;
                        break;
                default:
-                       DPRINTF(UDMASS_GEN,
-                               ("%s: Unsupported wire protocol %u\n",
-                               device_xname(sc->sc_dev),
-                               uiaa->uiaa_proto));
+                       DPRINTFM(UDMASS_GEN, "Unsupported wire protocol %u",
+                           uiaa->uiaa_proto, 0, 0, 0);
                        return;
                }
        }
@@ -402,10 +401,8 @@
                        sc->sc_cmd = UMASS_CPROTO_RBC;
                        break;
                default:
-                       DPRINTF(UDMASS_GEN,
-                               ("%s: Unsupported command protocol %u\n",
-                               device_xname(sc->sc_dev),
-                               uiaa->uiaa_subclass));
+                       DPRINTFM(UDMASS_GEN, "Unsupported command protocol %u",
+                           uiaa->uiaa_subclass, 0, 0, 0);
                        return;
                }
        }
@@ -488,9 +485,8 @@
                        sc->sc_epaddr[UMASS_INTRIN] = ed->bEndpointAddress;
 #ifdef UMASS_DEBUG
                        if (UGETW(ed->wMaxPacketSize) > 2) {
-                               DPRINTF(UDMASS_CBI, ("%s: intr size is %d\n",
-                                       device_xname(sc->sc_dev),
-                                       UGETW(ed->wMaxPacketSize)));
+                               DPRINTFM(UDMASS_CBI, "sc %p intr size is %d",
+                                   sc, UGETW(ed->wMaxPacketSize), 0, 0);
                        }
 #endif
                }
@@ -525,9 +521,8 @@
        }
 
        /* Open the bulk-in and -out pipe */
-       DPRINTF(UDMASS_USB, ("%s: opening iface %p epaddr %d for BULKOUT\n",
-               device_xname(sc->sc_dev), sc->sc_iface,
-               sc->sc_epaddr[UMASS_BULKOUT]));
+       DPRINTFM(UDMASS_USB, "sc %p: opening iface %p epaddr %d for BULKOUT",
+           sc, sc->sc_iface, sc->sc_epaddr[UMASS_BULKOUT], 0);
        err = usbd_open_pipe(sc->sc_iface, sc->sc_epaddr[UMASS_BULKOUT],
                                USBD_EXCLUSIVE_USE,
                                &sc->sc_pipe[UMASS_BULKOUT]);
@@ -537,9 +532,8 @@
                umass_disco(sc);
                return;
        }
-       DPRINTF(UDMASS_USB, ("%s: opening iface %p epaddr %d for BULKIN\n",
-               device_xname(sc->sc_dev), sc->sc_iface,
-               sc->sc_epaddr[UMASS_BULKIN]));
+       DPRINTFM(UDMASS_USB, "sc %p: opening iface %p epaddr %d for BULKIN",
+           sc, sc->sc_iface, sc->sc_epaddr[UMASS_BULKIN], 0);
        err = usbd_open_pipe(sc->sc_iface, sc->sc_epaddr[UMASS_BULKIN],
                                USBD_EXCLUSIVE_USE, &sc->sc_pipe[UMASS_BULKIN]);
        if (err) {
@@ -561,9 +555,8 @@
         * arriving concurrently.
         */
        if (sc->sc_wire == UMASS_WPROTO_CBI_I) {
-               DPRINTF(UDMASS_USB, ("%s: opening iface %p epaddr %d for INTRIN\n",
-                       device_xname(sc->sc_dev), sc->sc_iface,
-                       sc->sc_epaddr[UMASS_INTRIN]));
+               DPRINTFM(UDMASS_USB, "sc %p: opening iface %p epaddr %d for INTRIN",
+                   sc, sc->sc_iface, sc->sc_epaddr[UMASS_INTRIN], 0);
                err = usbd_open_pipe(sc->sc_iface, sc->sc_epaddr[UMASS_INTRIN],
                                USBD_EXCLUSIVE_USE, &sc->sc_pipe[UMASS_INTRIN]);
                if (err) {
@@ -776,7 +769,7 @@
        if (!pmf_device_register(self, NULL, NULL))
                aprint_error_dev(self, "couldn't establish power handler\n");
 
-       DPRINTF(UDMASS_GEN, ("%s: Attach finished\n", device_xname(sc->sc_dev)));
+       DPRINTFM(UDMASS_GEN, "sc %p: Attach finished", sc, 0, 0, 0);
 
        return;
 }
@@ -794,11 +787,12 @@
 int
 umass_detach(device_t self, int flags)
 {
+       UMASSHIST_FUNC(); UMASSHIST_CALLED();
        struct umass_softc *sc = device_private(self);
        struct umassbus_softc *scbus;
        int rv = 0, i;
 
-       DPRINTF(UDMASS_USB, ("%s: detached\n", device_xname(sc->sc_dev)));
+       DPRINTFM(UDMASS_USB, "sc %p detached", sc, 0, 0, 0);
 
        pmf_device_deregister(self);
 
@@ -844,10 +838,10 @@
 int
 umass_activate(device_t dev, enum devact act)
 {
+       UMASSHIST_FUNC(); UMASSHIST_CALLED();
        struct umass_softc *sc = device_private(dev);
 
-       DPRINTF(UDMASS_USB, ("%s: umass_activate: %d\n",
-           device_xname(dev), act));
+       DPRINTFM(UDMASS_USB, "sc %p act %d", sc, act, 0, 0);
 
        switch (act) {
        case DVACT_DEACTIVATE:
@@ -861,10 +855,9 @@
 Static void
 umass_disco(struct umass_softc *sc)
 {
+       UMASSHIST_FUNC(); UMASSHIST_CALLED();
        int i;
 
-       DPRINTF(UDMASS_GEN, ("umass_disco\n"));
-
        /* Remove all the pipes. */
        for (i = 0 ; i < UMASS_NEP ; i++) {
                if (sc->sc_pipe[i] != NULL) {
@@ -901,10 +894,9 @@
                        void *buffer, int buflen, int flags,
                        struct usbd_xfer *xfer)
 {
+       UMASSHIST_FUNC(); UMASSHIST_CALLED();
        usbd_status err;
 
-       USBHIST_FUNC(); USBHIST_CALLED(umassdebug);
-
        if (sc->sc_dying)
                return USBD_IOERROR;
 
@@ -913,15 +905,12 @@
        usbd_setup_xfer(xfer, sc, buffer, buflen, flags, sc->timeout,
            sc->sc_methods->wire_state);
 
-       USBHIST_LOG(umassdebug, "xfer %p, flags %d", xfer, flags, 0, 0);
-
        err = usbd_transfer(xfer);
-       DPRINTF(UDMASS_XFER,("%s: start xfer buffer=%p buflen=%d flags=0x%x "
-           "timeout=%d\n", device_xname(sc->sc_dev),
-           buffer, buflen, flags, sc->timeout));
+       DPRINTFM(UDMASS_XFER, "start xfer buffer=%p buflen=%d flags=0x%x "
+           "timeout=%d", buffer, buflen, flags, sc->timeout);
        if (err && err != USBD_IN_PROGRESS) {
-               DPRINTF(UDMASS_BBB, ("%s: failed to setup transfer, %s\n",
-                       device_xname(sc->sc_dev), usbd_errstr(err)));
+               DPRINTFM(UDMASS_BBB, "failed to setup transfer... err=%d",
+                   err, 0, 0, 0);
                return err;
        }
 
@@ -933,6 +922,7 @@
 umass_setup_ctrl_transfer(struct umass_softc *sc, usb_device_request_t *req,
         void *buffer, int buflen, int flags, struct usbd_xfer *xfer)
 {
+       UMASSHIST_FUNC(); UMASSHIST_CALLED();
        usbd_status err;
 
        if (sc->sc_dying)
@@ -945,8 +935,8 @@
 
        err = usbd_transfer(xfer);
        if (err && err != USBD_IN_PROGRESS) {
-               DPRINTF(UDMASS_BBB, ("%s: failed to setup ctrl transfer, %s\n",
-                        device_xname(sc->sc_dev), usbd_errstr(err)));
+               DPRINTFM(UDMASS_BBB, "failed to setup ctrl transfer... err=%d",
+                   err, 0, 0, 0);
 
                /* do not reset, as this would make us loop */
                return err;
@@ -959,11 +949,13 @@
 umass_clear_endpoint_stall(struct umass_softc *sc, int endpt,
        struct usbd_xfer *xfer)
 {
+       UMASSHIST_FUNC(); UMASSHIST_CALLED();
+
        if (sc->sc_dying)
                return;
 
-       DPRINTF(UDMASS_BBB, ("%s: Clear endpoint 0x%02x stall\n",
-               device_xname(sc->sc_dev), sc->sc_epaddr[endpt]));
+       DPRINTFM(UDMASS_BBB, "Clear endpoint 0x%02x stall",
+           sc->sc_epaddr[endpt], 0, 0, 0);
 
        usbd_clear_endpoint_toggle(sc->sc_pipe[endpt]);
 
@@ -994,6 +986,7 @@
 Static void
 umass_bbb_reset(struct umass_softc *sc, int status)
 {
+       UMASSHIST_FUNC(); UMASSHIST_CALLED();
        KASSERTMSG(sc->sc_wire & UMASS_WPROTO_BBB,
                   "sc->sc_wire == 0x%02x wrong for umass_bbb_reset\n",
                   sc->sc_wire);
@@ -1017,8 +1010,7 @@
         * If the reset doesn't succeed, the device should be port reset.
         */
 
-       DPRINTF(UDMASS_BBB, ("%s: Bulk Reset\n",
-               device_xname(sc->sc_dev)));
+       DPRINTFM(UDMASS_BBB, "Bulk Reset", 0, 0, 0, 0);
 
        sc->transfer_state = TSTATE_BBB_RESET1;
        sc->transfer_status = status;
@@ -1038,10 +1030,10 @@
                   void *data, int datalen, int dir, u_int timeout,
                   int flags, umass_callback cb, void *priv)
 {
+       UMASSHIST_FUNC(); UMASSHIST_CALLED();
        static int dCBWtag = 42;        /* unique for CBW of transfer */
 
-       DPRINTF(UDMASS_BBB,("%s: umass_bbb_transfer cmd=0x%02x\n",
-               device_xname(sc->sc_dev), *(u_char *)cmd));
+       DPRINTFM(UDMASS_BBB, "sc %p cmd=0x%02x", sc, *(u_char *)cmd, 0, 0);
 
        KASSERTMSG(sc->sc_wire & UMASS_WPROTO_BBB,
                   "sc->sc_wire == 0x%02x wrong for umass_bbb_transfer\n",
@@ -1154,12 +1146,11 @@
 umass_bbb_state(struct usbd_xfer *xfer, void *priv,
                usbd_status err)
 {
+       UMASSHIST_FUNC(); UMASSHIST_CALLED();
        struct umass_softc *sc = (struct umass_softc *) priv;
        struct usbd_xfer *next_xfer;
        int residue;
 
-       USBHIST_FUNC(); USBHIST_CALLED(umassdebug);
-
        KASSERTMSG(sc->sc_wire & UMASS_WPROTO_BBB,
                   "sc->sc_wire == 0x%02x wrong for umass_bbb_state\n",
                   sc->sc_wire);
@@ -1178,12 +1169,8 @@
         * has been submitted you will find a 'return;'.
         */
 
-       DPRINTF(UDMASS_BBB, ("%s: Handling BBB state %d (%s), xfer=%p, %s\n",
-               device_xname(sc->sc_dev), sc->transfer_state,
-               states[sc->transfer_state], xfer, usbd_errstr(err)));
-
-       USBHIST_LOG(umassdebug, "xfer %p, transfer_state %d dir %d", xfer,
-           sc->transfer_state, sc->transfer_dir, 0);
+       DPRINTFM(UDMASS_BBB, "sc %p xfer %p, transfer_state %d dir %d", sc,
+           xfer, sc->transfer_state, sc->transfer_dir);
 
        switch (sc->transfer_state) {
 
@@ -1191,8 +1178,8 @@
        case TSTATE_BBB_COMMAND:
                /* Command transport phase, error handling */
                if (err) {
-                       DPRINTF(UDMASS_BBB, ("%s: failed to send CBW\n",
-                               device_xname(sc->sc_dev)));
+                       DPRINTFM(UDMASS_BBB, "sc %p failed to send CBW", sc,
+                           0, 0, 0);
                        /* If the device detects that the CBW is invalid, then
                         * the device may STALL both bulk endpoints and require
                         * a Bulk-Reset
@@ -1222,8 +1209,8 @@
 
                        return;
                } else {
-                       DPRINTF(UDMASS_BBB, ("%s: no data phase\n",
-                               device_xname(sc->sc_dev)));
+                       DPRINTFM(UDMASS_BBB, "sc %p: no data phase", sc, 0, 0,
+                           0);
                }
 
                /* FALLTHROUGH if no data phase, err == 0 */
@@ -1234,14 +1221,13 @@
                        /* retrieve the length of the transfer that was done */
                        usbd_get_xfer_status(xfer, NULL, NULL,



Home | Main Index | Thread Index | Old Index