Author: thompsa
Date: Fri Jan 29 02:35:50 2010
New Revision: 203145
URL: http://svn.freebsd.org/changeset/base/203145

Log:
  Simplify attach for UMASS_PROTO_CBI_I mode and change some switch() returns
  into breaks.
  
  Submitted by: Hans Petter Selesky

Modified:
  head/sys/dev/usb/storage/umass.c

Modified: head/sys/dev/usb/storage/umass.c
==============================================================================
--- head/sys/dev/usb/storage/umass.c    Fri Jan 29 02:33:50 2010        
(r203144)
+++ head/sys/dev/usb/storage/umass.c    Fri Jan 29 02:35:50 2010        
(r203145)
@@ -671,7 +671,7 @@ static struct usb_config umass_cbi_confi
                .type = UE_INTERRUPT,
                .endpoint = UE_ADDR_ANY,
                .direction = UE_DIR_IN,
-               .flags = {.short_xfer_ok = 1,},
+               .flags = {.short_xfer_ok = 1,.no_pipe_ok = 1,},
                .bufsize = sizeof(umass_cbi_sbl_t),
                .callback = &umass_t_cbi_status_callback,
                .timeout = 5000,        /* ms */
@@ -984,9 +984,7 @@ umass_attach(device_t dev)
 
                err = usbd_transfer_setup(uaa->device,
                    &uaa->info.bIfaceIndex, sc->sc_xfer, umass_cbi_config,
-                   (sc->sc_proto & UMASS_PROTO_CBI_I) ?
-                   UMASS_T_CBI_MAX : (UMASS_T_CBI_MAX - 2), sc,
-                   &sc->sc_mtx);
+                   UMASS_T_CBI_MAX, sc, &sc->sc_mtx);
 
                /* skip reset first time */
                sc->sc_last_xfer_index = UMASS_T_CBI_COMMAND;
@@ -1676,7 +1674,7 @@ umass_t_cbi_reset1_callback(struct usb_x
        switch (USB_GET_STATE(xfer)) {
        case USB_ST_TRANSFERRED:
                umass_transfer_start(sc, UMASS_T_CBI_RESET2);
-               return;
+               break;
 
        case USB_ST_SETUP:
                /*
@@ -1723,11 +1721,14 @@ umass_t_cbi_reset1_callback(struct usb_x
                usbd_xfer_set_frame_len(xfer, 1, sizeof(buf));
                usbd_xfer_set_frames(xfer, 2);
                usbd_transfer_submit(xfer);
-               return;
+               break;
 
        default:                        /* Error */
-               umass_tr_error(xfer, error);
-               return;
+               if (error == USB_ERR_CANCELLED)
+                       umass_tr_error(xfer, error);
+               else
+                       umass_transfer_start(sc, UMASS_T_CBI_RESET2);
+               break;
 
        }
 }
@@ -1772,17 +1773,17 @@ tr_transferred:
                } else {
                        umass_transfer_start(sc, next_xfer);
                }
-               return;
+               break;
 
        case USB_ST_SETUP:
                if (usbd_clear_stall_callback(xfer, sc->sc_xfer[stall_xfer])) {
                        goto tr_transferred;    /* should not happen */
                }
-               return;
+               break;
 
        default:                        /* Error */
                umass_tr_error(xfer, error);
-               return;
+               break;
 
        }
 }
@@ -1805,7 +1806,7 @@ umass_t_cbi_command_callback(struct usb_
                            (sc, (sc->sc_transfer.dir == DIR_IN) ?
                            UMASS_T_CBI_DATA_READ : UMASS_T_CBI_DATA_WRITE);
                }
-               return;
+               break;
 
        case USB_ST_SETUP:
 
@@ -1844,12 +1845,13 @@ umass_t_cbi_command_callback(struct usb_
 
                        usbd_transfer_submit(xfer);
                }
-               return;
+               break;
 
        default:                        /* Error */
                umass_tr_error(xfer, error);
-               return;
-
+               /* skip reset */
+               sc->sc_last_xfer_index = UMASS_T_CBI_COMMAND;
+               break;
        }
 }
 
@@ -1885,7 +1887,7 @@ umass_t_cbi_data_read_callback(struct us
 
                if (sc->sc_transfer.data_rem == 0) {
                        umass_cbi_start_status(sc);
-                       return;
+                       break;
                }
                if (max_bulk > sc->sc_transfer.data_rem) {
                        max_bulk = sc->sc_transfer.data_rem;
@@ -1899,7 +1901,7 @@ umass_t_cbi_data_read_callback(struct us
                usbd_xfer_set_frame_len(xfer, 0, max_bulk);
 #endif
                usbd_transfer_submit(xfer);
-               return;
+               break;
 
        default:                        /* Error */
                if ((error == USB_ERR_CANCELLED) ||
@@ -1908,7 +1910,7 @@ umass_t_cbi_data_read_callback(struct us
                } else {
                        umass_transfer_start(sc, UMASS_T_CBI_DATA_RD_CS);
                }
-               return;
+               break;
 
        }
 }
@@ -1948,7 +1950,7 @@ umass_t_cbi_data_write_callback(struct u
 
                if (sc->sc_transfer.data_rem == 0) {
                        umass_cbi_start_status(sc);
-                       return;
+                       break;
                }
                if (max_bulk > sc->sc_transfer.data_rem) {
                        max_bulk = sc->sc_transfer.data_rem;
@@ -1965,7 +1967,7 @@ umass_t_cbi_data_write_callback(struct u
 #endif
 
                usbd_transfer_submit(xfer);
-               return;
+               break;
 
        default:                        /* Error */
                if ((error == USB_ERR_CANCELLED) ||
@@ -1974,7 +1976,7 @@ umass_t_cbi_data_write_callback(struct u
                } else {
                        umass_transfer_start(sc, UMASS_T_CBI_DATA_WR_CS);
                }
-               return;
+               break;
 
        }
 }
@@ -2035,7 +2037,7 @@ umass_t_cbi_status_callback(struct usb_x
                        (sc->sc_transfer.callback)
                            (sc, ccb, residue, status);
 
-                       return;
+                       break;
 
                } else {
 
@@ -2060,7 +2062,7 @@ umass_t_cbi_status_callback(struct usb_x
                                (sc->sc_transfer.callback)
                                    (sc, ccb, residue, status);
 
-                               return;
+                               break;
                        }
                }
 
@@ -2070,13 +2072,13 @@ umass_t_cbi_status_callback(struct usb_x
 tr_setup:
                usbd_xfer_set_frame_len(xfer, 0, usbd_xfer_max_len(xfer));
                usbd_transfer_submit(xfer);
-               return;
+               break;
 
        default:                        /* Error */
                DPRINTF(sc, UDMASS_CBI, "Failed to read CSW: %s\n",
                    usbd_errstr(error));
                umass_tr_error(xfer, error);
-               return;
+               break;
 
        }
 }
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to