]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - common/usb_storage.c
gpio: remove gpiolib.c and define remaining functions as static inline in asm/gpio.h
[karo-tx-uboot.git] / common / usb_storage.c
index 457970f770ce774b6c3e5f461f3216b411258951..1411737bed8912180810c0e9cb239f4602a52bfa 100644 (file)
  * BBB support based on /sys/dev/usb/umass.c from
  * FreeBSD.
  *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- *
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 
 /* Note:
@@ -50,6 +33,7 @@
 
 #include <common.h>
 #include <command.h>
+#include <inttypes.h>
 #include <asm/byteorder.h>
 #include <asm/processor.h>
 
@@ -170,9 +154,9 @@ int usb_stor_get_info(struct usb_device *dev, struct us_data *us,
                      block_dev_desc_t *dev_desc);
 int usb_storage_probe(struct usb_device *dev, unsigned int ifnum,
                      struct us_data *ss);
-unsigned long usb_stor_read(int device, unsigned long blknr,
+unsigned long usb_stor_read(int device, lbaint_t blknr,
                            lbaint_t blkcnt, void *buffer);
-unsigned long usb_stor_write(int device, unsigned long blknr,
+unsigned long usb_stor_write(int device, lbaint_t blknr,
                             lbaint_t blkcnt, const void *buffer);
 struct usb_device * usb_get_dev_index(int index);
 void uhci_show_temp_int_td(void);
@@ -1054,7 +1038,7 @@ static void usb_bin_fixup(struct usb_device_descriptor descriptor,
 }
 #endif /* CONFIG_USB_BIN_FIXUP */
 
-unsigned long usb_stor_read(int device, unsigned long blknr,
+unsigned long usb_stor_read(int device, lbaint_t blknr,
                            lbaint_t blkcnt, void *buffer)
 {
        lbaint_t start, blks;
@@ -1088,7 +1072,7 @@ unsigned long usb_stor_read(int device, unsigned long blknr,
        blks = blkcnt;
 
        debug("\nusb_read: dev %d startblk " LBAF ", blccnt " LBAF
-             " buffer %lx\n", device, start, blks, buf_addr);
+             " buffer %" PRIxPTR "\n", device, start, blks, buf_addr);
 
        do {
                /* XXX need some comment here */
@@ -1118,7 +1102,7 @@ retry_it:
        ss->flags &= ~USB_READY;
 
        debug("usb_read: end startblk " LBAF
-             ", blccnt %x buffer %lx\n",
+             ", blccnt %x buffer %" PRIxPTR "\n",
              start, smallblks, buf_addr);
 
        usb_disable_asynch(0); /* asynch transfer allowed */
@@ -1127,7 +1111,7 @@ retry_it:
        return blkcnt;
 }
 
-unsigned long usb_stor_write(int device, unsigned long blknr,
+unsigned long usb_stor_write(int device, lbaint_t blknr,
                                lbaint_t blkcnt, const void *buffer)
 {
        lbaint_t start, blks;
@@ -1162,7 +1146,7 @@ unsigned long usb_stor_write(int device, unsigned long blknr,
        blks = blkcnt;
 
        debug("\nusb_write: dev %d startblk " LBAF ", blccnt " LBAF
-             " buffer %lx\n", device, start, blks, buf_addr);
+             " buffer %" PRIxPTR "\n", device, start, blks, buf_addr);
 
        do {
                /* If write fails retry for max retry count else
@@ -1193,8 +1177,8 @@ retry_it:
        } while (blks != 0);
        ss->flags &= ~USB_READY;
 
-       debug("usb_write: end startblk " LBAF ", blccnt %x buffer %lx\n",
-             start, smallblks, buf_addr);
+       debug("usb_write: end startblk " LBAF ", blccnt %x buffer %"
+             PRIxPTR "\n", start, smallblks, buf_addr);
 
        usb_disable_asynch(0); /* asynch transfer allowed */
        if (blkcnt >= USB_MAX_XFER_BLK)
@@ -1367,8 +1351,11 @@ int usb_stor_get_info(struct usb_device *dev, struct us_data *ss,
        perq = usb_stor_buf[0];
        modi = usb_stor_buf[1];
 
-       if ((perq & 0x1f) == 0x1f) {
-               /* skip unknown devices */
+       /*
+        * Skip unknown devices (0x1f) and enclosure service devices (0x0d),
+        * they would not respond to test_unit_ready .
+        */
+       if (((perq & 0x1f) == 0x1f) || ((perq & 0x1f) == 0x0d)) {
                return 0;
        }
        if ((modi&0x80) == 0x80) {