Author: thompsa
Date: Sat Mar 21 05:44:22 2009
New Revision: 190195
URL: http://svn.freebsd.org/changeset/base/190195

Log:
  Revert r190173 as it breaks 64bit arches.

Modified:
  head/sys/dev/usb/storage/ustorage_fs.c
  head/sys/dev/usb/usb_endian.h

Modified: head/sys/dev/usb/storage/ustorage_fs.c
==============================================================================
--- head/sys/dev/usb/storage/ustorage_fs.c      Sat Mar 21 00:23:07 2009        
(r190194)
+++ head/sys/dev/usb/storage/ustorage_fs.c      Sat Mar 21 05:44:22 2009        
(r190195)
@@ -60,10 +60,12 @@ SYSCTL_INT(_hw_usb2_ustorage_fs, OID_AUT
 /* Define some limits */
 
 #ifndef USTORAGE_FS_BULK_SIZE 
-#define        USTORAGE_FS_BULK_SIZE (1UL << 17)       /* bytes */
+#define        USTORAGE_FS_BULK_SIZE (1 << 17) /* bytes */
 #endif
 
 #define        USTORAGE_FS_MAX_LUN 8   /* units */
+#define        USTORAGE_FS_RELEASE 0x0101
+#define        USTORAGE_FS_RAM_SECT (1 << 13)
 
 /*
  * The SCSI ID string must be exactly 28 characters long
@@ -974,6 +976,8 @@ static uint8_t
 ustorage_fs_inquiry(struct ustorage_fs_softc *sc)
 {
        uint8_t *buf = sc->sc_transfer.data_ptr;
+       static const char vendor_id[] = "FreeBSD ";
+       static const char product_id[] = "File-Stor Gadget";
 
        struct ustorage_fs_lun *currlun = sc->sc_transfer.currlun;
 
@@ -995,9 +999,12 @@ ustorage_fs_inquiry(struct ustorage_fs_s
        buf[4] = 31;
        /* Additional length */
        /* No special options */
-       /* Copy in ID string */
-       memcpy(buf + 8, USTORAGE_FS_ID_STRING, 28);
-
+       /*
+        * NOTE: We are writing an extra zero here, that is not
+        * transferred to the peer:
+        */
+       snprintf(buf + 8, 28 + 1, "%-8s%-16s%04x", vendor_id, product_id,
+           USTORAGE_FS_RELEASE);
        return (ustorage_fs_min_len(sc, 36, 0 - 1));
 }
 
@@ -1346,7 +1353,7 @@ ustorage_fs_read(struct ustorage_fs_soft
         * too big
         */
        if (sc->sc_transfer.cmd_data[0] == SC_READ_6) {
-               lba = (((uint32_t)sc->sc_transfer.cmd_data[1]) << 16) |
+               lba = (sc->sc_transfer.cmd_data[1] << 16) |
                    get_be16(&sc->sc_transfer.cmd_data[2]);
        } else {
                lba = get_be32(&sc->sc_transfer.cmd_data[2]);
@@ -1404,7 +1411,7 @@ ustorage_fs_write(struct ustorage_fs_sof
         * too big.
         */
        if (sc->sc_transfer.cmd_data[0] == SC_WRITE_6)
-               lba = (((uint32_t)sc->sc_transfer.cmd_data[1]) << 16) |
+               lba = (sc->sc_transfer.cmd_data[1] << 16) |
                    get_be16(&sc->sc_transfer.cmd_data[2]);
        else {
                lba = get_be32(&sc->sc_transfer.cmd_data[2]);
@@ -1551,7 +1558,7 @@ ustorage_fs_check_cmd(struct ustorage_fs
         * non-zero.
         */
        for (i = 0; i != min_cmd_size; i++) {
-               if (sc->sc_transfer.cmd_data[i] && !(mask & (1UL << i))) {
+               if (sc->sc_transfer.cmd_data[i] && !(mask & (1 << i))) {
                        if (currlun) {
                                currlun->sense_data = SS_INVALID_FIELD_IN_CDB;
                        }
@@ -1582,7 +1589,6 @@ ustorage_fs_do_cmd(struct ustorage_fs_so
 {
        uint8_t error = 1;
        uint8_t i;
-       uint32_t temp;
 
        /* set default data transfer pointer */
        sc->sc_transfer.data_ptr = sc->sc_qdata;
@@ -1598,7 +1604,7 @@ ustorage_fs_do_cmd(struct ustorage_fs_so
                        break;
                }
                error = ustorage_fs_check_cmd(sc, 6,
-                   (1UL << 4) | 1, 0);
+                   (1 << 4) | 1, 0);
                if (error) {
                        break;
                }
@@ -1613,7 +1619,7 @@ ustorage_fs_do_cmd(struct ustorage_fs_so
                        break;
                }
                error = ustorage_fs_check_cmd(sc, 6,
-                   (1UL << 1) | (1UL << 4) | 1, 0);
+                   (1 << 1) | (1 << 4) | 1, 0);
                if (error) {
                        break;
                }
@@ -1629,7 +1635,7 @@ ustorage_fs_do_cmd(struct ustorage_fs_so
                        break;
                }
                error = ustorage_fs_check_cmd(sc, 10,
-                   (1UL << 1) | (3UL << 7) | 1, 0);
+                   (1 << 1) | (3 << 7) | 1, 0);
                if (error) {
                        break;
                }
@@ -1644,7 +1650,7 @@ ustorage_fs_do_cmd(struct ustorage_fs_so
                        break;
                }
                error = ustorage_fs_check_cmd(sc, 6,
-                   (1UL << 1) | (1UL << 2) | (1UL << 4) | 1, 0);
+                   (1 << 1) | (1 << 2) | (1 << 4) | 1, 0);
                if (error) {
                        break;
                }
@@ -1660,7 +1666,7 @@ ustorage_fs_do_cmd(struct ustorage_fs_so
                        break;
                }
                error = ustorage_fs_check_cmd(sc, 10,
-                   (1UL << 1) | (1UL << 2) | (3UL << 7) | 1, 0);
+                   (1 << 1) | (1 << 2) | (3 << 7) | 1, 0);
                if (error) {
                        break;
                }
@@ -1674,7 +1680,7 @@ ustorage_fs_do_cmd(struct ustorage_fs_so
                        break;
                }
                error = ustorage_fs_check_cmd(sc, 6,
-                   (1UL << 4) | 1, 0);
+                   (1 << 4) | 1, 0);
                if (error) {
                        break;
                }
@@ -1685,13 +1691,13 @@ ustorage_fs_do_cmd(struct ustorage_fs_so
        case SC_READ_6:
                i = sc->sc_transfer.cmd_data[4];
                sc->sc_transfer.cmd_dir = DIR_WRITE;
-               temp = ((i == 0) ? 256UL : i);
-               error = ustorage_fs_min_len(sc, temp << 9, 0 - (1UL << 9));
+               error = ustorage_fs_min_len(sc,
+                   ((i == 0) ? 256 : i) << 9, 0 - (1 << 9));
                if (error) {
                        break;
                }
                error = ustorage_fs_check_cmd(sc, 6,
-                   (7UL << 1) | (1UL << 4) | 1, 1);
+                   (7 << 1) | (1 << 4) | 1, 1);
                if (error) {
                        break;
                }
@@ -1701,13 +1707,13 @@ ustorage_fs_do_cmd(struct ustorage_fs_so
 
        case SC_READ_10:
                sc->sc_transfer.cmd_dir = DIR_WRITE;
-               temp = get_be16(&sc->sc_transfer.cmd_data[7]);
-               error = ustorage_fs_min_len(sc, temp << 9, 0 - (1UL << 9));
+               error = ustorage_fs_min_len(sc,
+                   get_be16(&sc->sc_transfer.cmd_data[7]) << 9, 0 - (1 << 9));
                if (error) {
                        break;
                }
                error = ustorage_fs_check_cmd(sc, 10,
-                   (1UL << 1) | (0xfUL << 2) | (3UL << 7) | 1, 1);
+                   (1 << 1) | (0xf << 2) | (3 << 7) | 1, 1);
                if (error) {
                        break;
                }
@@ -1717,19 +1723,13 @@ ustorage_fs_do_cmd(struct ustorage_fs_so
 
        case SC_READ_12:
                sc->sc_transfer.cmd_dir = DIR_WRITE;
-               temp = get_be32(&sc->sc_transfer.cmd_data[6]);
-               if (temp >= (1UL << (32 - 9))) {
-                       /* numerical overflow */
-                       sc->sc_csw.bCSWStatus = CSWSTATUS_FAILED;
-                       error = 1;
-                       break;
-               }
-               error = ustorage_fs_min_len(sc, temp << 9, 0 - (1UL << 9));
+               error = ustorage_fs_min_len(sc,
+                   get_be32(&sc->sc_transfer.cmd_data[6]) << 9, 0 - (1 << 9));
                if (error) {
                        break;
                }
                error = ustorage_fs_check_cmd(sc, 12,
-                   (1UL << 1) | (0xfUL << 2) | (0xfUL << 6) | 1, 1);
+                   (1 << 1) | (0xf << 2) | (0xf << 6) | 1, 1);
                if (error) {
                        break;
                }
@@ -1740,7 +1740,7 @@ ustorage_fs_do_cmd(struct ustorage_fs_so
        case SC_READ_CAPACITY:
                sc->sc_transfer.cmd_dir = DIR_WRITE;
                error = ustorage_fs_check_cmd(sc, 10,
-                   (0xfUL << 2) | (1UL << 8) | 1, 1);
+                   (0xf << 2) | (1 << 8) | 1, 1);
                if (error) {
                        break;
                }
@@ -1756,7 +1756,7 @@ ustorage_fs_do_cmd(struct ustorage_fs_so
                        break;
                }
                error = ustorage_fs_check_cmd(sc, 10,
-                   (3UL << 7) | 1, 1);
+                   (3 << 7) | 1, 1);
                if (error) {
                        break;
                }
@@ -1771,7 +1771,7 @@ ustorage_fs_do_cmd(struct ustorage_fs_so
                        break;
                }
                error = ustorage_fs_check_cmd(sc, 6,
-                   (1UL << 4) | 1, 0);
+                   (1 << 4) | 1, 0);
                if (error) {
                        break;
                }
@@ -1785,7 +1785,7 @@ ustorage_fs_do_cmd(struct ustorage_fs_so
                        break;
                }
                error = ustorage_fs_check_cmd(sc, 6,
-                   (1UL << 1) | (1UL << 4) | 1, 0);
+                   (1 << 1) | (1 << 4) | 1, 0);
                if (error) {
                        break;
                }
@@ -1799,7 +1799,7 @@ ustorage_fs_do_cmd(struct ustorage_fs_so
                        break;
                }
                error = ustorage_fs_check_cmd(sc, 10,
-                   (0xfUL << 2) | (3UL << 7) | 1, 1);
+                   (0xf << 2) | (3 << 7) | 1, 1);
                if (error) {
                        break;
                }
@@ -1826,7 +1826,7 @@ ustorage_fs_do_cmd(struct ustorage_fs_so
                        break;
                }
                error = ustorage_fs_check_cmd(sc, 10,
-                   (1UL << 1) | (0xfUL << 2) | (3UL << 7) | 1, 1);
+                   (1 << 1) | (0xf << 2) | (3 << 7) | 1, 1);
                if (error) {
                        break;
                }
@@ -1837,13 +1837,13 @@ ustorage_fs_do_cmd(struct ustorage_fs_so
        case SC_WRITE_6:
                i = sc->sc_transfer.cmd_data[4];
                sc->sc_transfer.cmd_dir = DIR_READ;
-               temp = ((i == 0) ? 256UL : i);
-               error = ustorage_fs_min_len(sc, temp << 9, 0 - (1UL << 9));
+               error = ustorage_fs_min_len(sc,
+                   ((i == 0) ? 256 : i) << 9, 0 - (1 << 9));
                if (error) {
                        break;
                }
                error = ustorage_fs_check_cmd(sc, 6,
-                   (7UL << 1) | (1UL << 4) | 1, 1);
+                   (7 << 1) | (1 << 4) | 1, 1);
                if (error) {
                        break;
                }
@@ -1853,13 +1853,13 @@ ustorage_fs_do_cmd(struct ustorage_fs_so
 
        case SC_WRITE_10:
                sc->sc_transfer.cmd_dir = DIR_READ;
-               temp = get_be16(&sc->sc_transfer.cmd_data[7]);
-               error = ustorage_fs_min_len(sc, temp << 9, 0 - (1UL << 9));
+               error = ustorage_fs_min_len(sc,
+                   get_be16(&sc->sc_transfer.cmd_data[7]) << 9, 0 - (1 << 9));
                if (error) {
                        break;
                }
                error = ustorage_fs_check_cmd(sc, 10,
-                   (1UL << 1) | (0xfUL << 2) | (3UL << 7) | 1, 1);
+                   (1 << 1) | (0xf << 2) | (3 << 7) | 1, 1);
                if (error) {
                        break;
                }
@@ -1869,19 +1869,13 @@ ustorage_fs_do_cmd(struct ustorage_fs_so
 
        case SC_WRITE_12:
                sc->sc_transfer.cmd_dir = DIR_READ;
-               temp = get_be32(&sc->sc_transfer.cmd_data[6]);
-               if (temp >= (1UL << (32 - 9))) {
-                       /* numerical overflow */
-                       sc->sc_csw.bCSWStatus = CSWSTATUS_FAILED;
-                       error = 1;
-                       break;
-               }
-               error = ustorage_fs_min_len(sc, temp << 9, 0 - (1UL << 9));
+               error = ustorage_fs_min_len(sc,
+                   get_be32(&sc->sc_transfer.cmd_data[6]) << 9, 0 - (1 << 9));
                if (error) {
                        break;
                }
                error = ustorage_fs_check_cmd(sc, 12,
-                   (1UL << 1) | (0xfUL << 2) | (0xfUL << 6) | 1, 1);
+                   (1 << 1) | (0xf << 2) | (0xf << 6) | 1, 1);
                if (error) {
                        break;
                }

Modified: head/sys/dev/usb/usb_endian.h
==============================================================================
--- head/sys/dev/usb/usb_endian.h       Sat Mar 21 00:23:07 2009        
(r190194)
+++ head/sys/dev/usb/usb_endian.h       Sat Mar 21 05:44:22 2009        
(r190195)
@@ -48,19 +48,19 @@ typedef uint8_t uQWord[8];
 
 #define        UGETW(w)                        \
   ((w)[0] |                            \
-  (((uint16_t)((w)[1])) << 8))
+  ((w)[1] << 8))
 
 #define        UGETDW(w)                       \
   ((w)[0] |                            \
-  (((uint16_t)((w)[1])) << 8) |                \
-  (((uint32_t)((w)[2])) << 16) |       \
-  (((uint32_t)((w)[3])) << 24))
+  ((w)[1] << 8) |                      \
+  ((w)[2] << 16) |                     \
+  ((w)[3] << 24))
 
 #define        UGETQW(w)                       \
   ((w)[0] |                            \
-  (((uint16_t)((w)[1])) << 8) |                \
-  (((uint32_t)((w)[2])) << 16) |       \
-  (((uint32_t)((w)[3])) << 24) |       \
+  ((w)[1] << 8) |                      \
+  ((w)[2] << 16) |                     \
+  ((w)[3] << 24) |                     \
   (((uint64_t)((w)[4])) << 32) |       \
   (((uint64_t)((w)[5])) << 40) |       \
   (((uint64_t)((w)[6])) << 48) |       \
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to