Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb replace the hack to pass USBD_SYNCHRONOUS down w...



details:   https://anonhg.NetBSD.org/src/rev/b1d7e54cd495
branches:  trunk
changeset: 777777:b1d7e54cd495
user:      mrg <mrg%NetBSD.org@localhost>
date:      Sun Mar 04 00:21:20 2012 +0000

description:
replace the hack to pass USBD_SYNCHRONOUS down when called with
XS_CTL_POLL with one that doesn't modify global-to-softc state.

diffstat:

 sys/dev/usb/umass.c        |  28 ++++++++++++++--------------
 sys/dev/usb/umass_isdata.c |   8 ++++----
 sys/dev/usb/umass_scsipi.c |  13 ++++++-------
 sys/dev/usb/umassvar.h     |   5 ++---
 4 files changed, 26 insertions(+), 28 deletions(-)

diffs (233 lines):

diff -r 169a314e0338 -r b1d7e54cd495 sys/dev/usb/umass.c
--- a/sys/dev/usb/umass.c       Sun Mar 04 00:07:44 2012 +0000
+++ b/sys/dev/usb/umass.c       Sun Mar 04 00:21:20 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: umass.c,v 1.142 2012/02/24 06:48:26 mrg Exp $  */
+/*     $NetBSD: umass.c,v 1.143 2012/03/04 00:21:20 mrg Exp $  */
 
 /*
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -124,7 +124,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: umass.c,v 1.142 2012/02/24 06:48:26 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: umass.c,v 1.143 2012/03/04 00:21:20 mrg Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_umass.h"
@@ -212,7 +212,7 @@
 
 /* Bulk-Only related functions */
 Static void umass_bbb_transfer(struct umass_softc *, int, void *, int, void *,
-                              int, int, u_int, umass_callback, void *);
+                              int, int, u_int, int, umass_callback, void *);
 Static void umass_bbb_reset(struct umass_softc *, int);
 Static void umass_bbb_state(usbd_xfer_handle, usbd_private_handle, usbd_status);
 
@@ -220,11 +220,11 @@
 
 /* CBI related functions */
 Static void umass_cbi_transfer(struct umass_softc *, int, void *, int, void *,
-                              int, int, u_int, umass_callback, void *);
+                              int, int, u_int, int, umass_callback, void *);
 Static void umass_cbi_reset(struct umass_softc *, int);
 Static void umass_cbi_state(usbd_xfer_handle, usbd_private_handle, usbd_status);
 
-Static int umass_cbi_adsc(struct umass_softc *, char *, int, usbd_xfer_handle);
+Static int umass_cbi_adsc(struct umass_softc *, char *, int, int, usbd_xfer_handle);
 
 const struct umass_wire_methods umass_bbb_methods = {
        umass_bbb_transfer,
@@ -761,12 +761,12 @@
        /* Initialiase a USB transfer and then schedule it */
 
        usbd_setup_xfer(xfer, pipe, (void *)sc, buffer, buflen,
-           flags | sc->sc_xfer_flags, sc->timeout, sc->sc_methods->wire_state);
+           flags, sc->timeout, sc->sc_methods->wire_state);
 
        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->sc_xfer_flags, sc->timeout));
+           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)));
@@ -884,7 +884,7 @@
 Static void
 umass_bbb_transfer(struct umass_softc *sc, int lun, void *cmd, int cmdlen,
                   void *data, int datalen, int dir, u_int timeout,
-                  umass_callback cb, void *priv)
+                  int flags, umass_callback cb, void *priv)
 {
        static int dCBWtag = 42;        /* unique for CBW of transfer */
 
@@ -991,7 +991,7 @@
 
        /* Send the CBW from host to device via bulk-out endpoint. */
        if (umass_setup_transfer(sc, sc->sc_pipe[UMASS_BULKOUT],
-                       &sc->cbw, UMASS_BBB_CBW_SIZE, 0,
+                       &sc->cbw, UMASS_BBB_CBW_SIZE, flags,
                        sc->transfer_xfer[XFER_BBB_CBW])) {
                umass_bbb_reset(sc, STATUS_WIRE_FAILED);
        }
@@ -1314,7 +1314,7 @@
  */
 
 Static int
-umass_cbi_adsc(struct umass_softc *sc, char *buffer, int buflen,
+umass_cbi_adsc(struct umass_softc *sc, char *buffer, int buflen, int flags,
               usbd_xfer_handle xfer)
 {
        KASSERTMSG(sc->sc_wire & (UMASS_WPROTO_CBI|UMASS_WPROTO_CBI_I),
@@ -1333,7 +1333,7 @@
        USETW(sc->sc_req.wIndex, sc->sc_ifaceno);
        USETW(sc->sc_req.wLength, buflen);
        return umass_setup_ctrl_transfer(sc, &sc->sc_req, buffer,
-                                        buflen, 0, xfer);
+                                        buflen, flags, xfer);
 }
 
 
@@ -1385,7 +1385,7 @@
        for (i = 2; i < SEND_DIAGNOSTIC_CMDLEN; i++)
                sc->cbl[i] = 0xff;
 
-       umass_cbi_adsc(sc, sc->cbl, SEND_DIAGNOSTIC_CMDLEN,
+       umass_cbi_adsc(sc, sc->cbl, SEND_DIAGNOSTIC_CMDLEN, 0,
                       sc->transfer_xfer[XFER_CBI_RESET1]);
        /* XXX if the command fails we should reset the port on the bub */
 }
@@ -1393,7 +1393,7 @@
 Static void
 umass_cbi_transfer(struct umass_softc *sc, int lun,
                   void *cmd, int cmdlen, void *data, int datalen, int dir,
-                  u_int timeout, umass_callback cb, void *priv)
+                  u_int timeout, int flags, umass_callback cb, void *priv)
 {
        DPRINTF(UDMASS_CBI,("%s: umass_cbi_transfer cmd=0x%02x, len=%d\n",
                device_xname(sc->sc_dev), *(u_char *)cmd, datalen));
@@ -1445,7 +1445,7 @@
        sc->transfer_state = TSTATE_CBI_COMMAND;
 
        /* Send the Command Block from host to device via control endpoint. */
-       if (umass_cbi_adsc(sc, cmd, cmdlen, sc->transfer_xfer[XFER_CBI_CB]))
+       if (umass_cbi_adsc(sc, cmd, cmdlen, flags, sc->transfer_xfer[XFER_CBI_CB]))
                umass_cbi_reset(sc, STATUS_WIRE_FAILED);
 }
 
diff -r 169a314e0338 -r b1d7e54cd495 sys/dev/usb/umass_isdata.c
--- a/sys/dev/usb/umass_isdata.c        Sun Mar 04 00:07:44 2012 +0000
+++ b/sys/dev/usb/umass_isdata.c        Sun Mar 04 00:21:20 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: umass_isdata.c,v 1.21 2011/08/24 11:28:50 mbalmer Exp $        */
+/*     $NetBSD: umass_isdata.c,v 1.22 2012/03/04 00:21:20 mrg Exp $    */
 
 /*
  * TODO:
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: umass_isdata.c,v 1.21 2011/08/24 11:28:50 mbalmer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: umass_isdata.c,v 1.22 2012/03/04 00:21:20 mrg Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_umass.h"
@@ -361,7 +361,7 @@
                 ata_bio->bcount, drv->drive));
        sc->sc_methods->wire_xfer(sc, drv->drive, &ata, sizeof ata,
                                  ata_bio->databuf + scbus->sc_skip, nbytes,
-                                 dir, ATA_DELAY, uisdata_bio_cb, ata_bio);
+                                 dir, ATA_DELAY, 0, uisdata_bio_cb, ata_bio);
 
        while (ata_bio->flags & ATA_POLL) {
                DPRINTF(("%s: tsleep %p\n", __func__, ata_bio));
@@ -455,7 +455,7 @@
                 ata.ac_command, drv->drive));
        sc->sc_methods->wire_xfer(sc, drv->drive, &ata,
                                  sizeof ata, cmd->data, cmd->bcount, dir,
-                                 cmd->timeout, uisdata_exec_cb, cmd);
+                                 cmd->timeout, 0, uisdata_exec_cb, cmd);
        if (cmd->flags & (AT_POLL | AT_WAIT)) {
 #if 0
                if (cmd->flags & AT_POLL)
diff -r 169a314e0338 -r b1d7e54cd495 sys/dev/usb/umass_scsipi.c
--- a/sys/dev/usb/umass_scsipi.c        Sun Mar 04 00:07:44 2012 +0000
+++ b/sys/dev/usb/umass_scsipi.c        Sun Mar 04 00:21:20 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: umass_scsipi.c,v 1.40 2012/02/23 13:31:13 he Exp $     */
+/*     $NetBSD: umass_scsipi.c,v 1.41 2012/03/04 00:21:20 mrg Exp $    */
 
 /*
  * Copyright (c) 2001, 2003 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: umass_scsipi.c,v 1.40 2012/02/23 13:31:13 he Exp $");
+__KERNEL_RCSID(0, "$NetBSD: umass_scsipi.c,v 1.41 2012/03/04 00:21:20 mrg Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_umass.h"
@@ -282,13 +282,12 @@
                        /* Use sync transfer. XXX Broken! */
                        DPRINTF(UDMASS_SCSI,
                            ("umass_scsi_cmd: sync dir=%d\n", dir));
-                       sc->sc_xfer_flags = USBD_SYNCHRONOUS;
                        scbus->sc_sync_status = USBD_INVAL;
                        sc->sc_methods->wire_xfer(sc, periph->periph_lun, cmd,
                                                  cmdlen, xs->data,
                                                  xs->datalen, dir,
-                                                 xs->timeout, 0, xs);
-                       sc->sc_xfer_flags = 0;
+                                                 xs->timeout, USBD_SYNCHRONOUS,
+                                                 0, xs);
                        DPRINTF(UDMASS_SCSI, ("umass_scsi_cmd: done err=%d\n",
                                              scbus->sc_sync_status));
                        switch (scbus->sc_sync_status) {
@@ -311,7 +310,7 @@
                        sc->sc_methods->wire_xfer(sc, periph->periph_lun, cmd,
                                                  cmdlen, xs->data,
                                                  xs->datalen, dir,
-                                                 xs->timeout,
+                                                 xs->timeout, 0,
                                                  umass_scsipi_cb, xs);
                        return;
                }
@@ -435,7 +434,7 @@
                sc->sc_methods->wire_xfer(sc, periph->periph_lun,
                                          &scbus->sc_sense_cmd, cmdlen,
                                          &xs->sense, sizeof(xs->sense),
-                                         DIR_IN, xs->timeout,
+                                         DIR_IN, xs->timeout, 0,
                                          umass_scsipi_sense_cb, xs);
                return;
 
diff -r 169a314e0338 -r b1d7e54cd495 sys/dev/usb/umassvar.h
--- a/sys/dev/usb/umassvar.h    Sun Mar 04 00:07:44 2012 +0000
+++ b/sys/dev/usb/umassvar.h    Sun Mar 04 00:21:20 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: umassvar.h,v 1.31 2011/07/31 16:32:02 jakllsch Exp $   */
+/*     $NetBSD: umassvar.h,v 1.32 2012/03/04 00:21:20 mrg Exp $        */
 /*-
  * Copyright (c) 1999 MAEKAWA Masahide <bishop%rr.iij4u.or.jp@localhost>,
  *                   Nick Hibma <n_hibma%freebsd.org@localhost>
@@ -133,7 +133,7 @@
 #define STATUS_WIRE_FAILED     3       /* couldn't even get command across */
 
 typedef void (*umass_wire_xfer)(struct umass_softc *, int, void *, int, void *,
-                               int, int, u_int, umass_callback, void *);
+                               int, int, u_int, int, umass_callback, void *);
 typedef void (*umass_wire_reset)(struct umass_softc *, int);
 typedef void (*umass_wire_state)(usbd_xfer_handle, usbd_private_handle,
                                 usbd_status);
@@ -262,7 +262,6 @@
        struct timeval tv;
 #endif
 
-       int                     sc_xfer_flags;
        char                    sc_dying;
        int                     sc_refcnt;
        int                     sc_sense;



Home | Main Index | Thread Index | Old Index