]> git.sur5r.net Git - u-boot/blobdiff - common/usb_storage.c
ppc4xx: Merge xilinx-ppc440 and xilinx-ppc405 cfg
[u-boot] / common / usb_storage.c
index 81d2f92100eb54686f9a3f030ca7f851b4ff8fc5..94f659fd31d6097f8f347a769350ed0f5e806ff3 100644 (file)
 
 #include <common.h>
 #include <command.h>
+#include <asm/byteorder.h>
 #include <asm/processor.h>
 
-
-#if defined(CONFIG_CMD_USB)
 #include <part.h>
 #include <usb.h>
 
-#ifdef CONFIG_USB_STORAGE
-
 #undef USB_STOR_DEBUG
 #undef BBB_COMDAT_TRACE
 #undef BBB_XPORT_TRACE
@@ -196,12 +193,12 @@ int usb_stor_info(void)
                for (i = 0; i < usb_max_devs; i++) {
                        printf ("  Device %d: ", i);
                        dev_print(&usb_dev_desc[i]);
-                       return 0;
                }
-       } else {
-               printf("No storage devices, perhaps not 'usb start'ed..?\n");
-               return 1;
+               return 0;
        }
+
+       printf("No storage devices, perhaps not 'usb start'ed..?\n");
+       return 1;
 }
 
 /*********************************************************************************
@@ -474,9 +471,9 @@ int usb_stor_BBB_comdat(ccb *srb, struct us_data *us)
        /* always OUT to the ep */
        pipe = usb_sndbulkpipe(us->pusb_dev, us->ep_out);
 
-       cbw.dCBWSignature = swap_32(CBWSIGNATURE);
-       cbw.dCBWTag = swap_32(CBWTag++);
-       cbw.dCBWDataTransferLength = swap_32(srb->datalen);
+       cbw.dCBWSignature = cpu_to_le32(CBWSIGNATURE);
+       cbw.dCBWTag = cpu_to_le32(CBWTag++);
+       cbw.dCBWDataTransferLength = cpu_to_le32(srb->datalen);
        cbw.bCBWFlags = (dir_in? CBWFLAGS_IN : CBWFLAGS_OUT);
        cbw.bCBWLUN = srb->lun;
        cbw.bCDBLength = srb->cmdlen;
@@ -692,14 +689,14 @@ int usb_stor_BBB_transport(ccb *srb, struct us_data *us)
        printf("\n");
 #endif
        /* misuse pipe to get the residue */
-       pipe = swap_32(csw.dCSWDataResidue);
+       pipe = le32_to_cpu(csw.dCSWDataResidue);
        if (pipe == 0 && srb->datalen != 0 && srb->datalen - data_actlen != 0)
                pipe = srb->datalen - data_actlen;
-       if (CSWSIGNATURE != swap_32(csw.dCSWSignature)) {
+       if (CSWSIGNATURE != le32_to_cpu(csw.dCSWSignature)) {
                USB_STOR_PRINTF("!CSWSIGNATURE\n");
                usb_stor_BBB_reset(us);
                return USB_STOR_TRANSPORT_FAILED;
-       } else if ((CBWTag - 1) != swap_32(csw.dCSWTag)) {
+       } else if ((CBWTag - 1) != le32_to_cpu(csw.dCSWTag)) {
                USB_STOR_PRINTF("!Tag\n");
                usb_stor_BBB_reset(us);
                return USB_STOR_TRANSPORT_FAILED;
@@ -730,7 +727,7 @@ int usb_stor_CB_transport(ccb *srb, struct us_data *us)
        ccb reqsrb;
        int retry,notready;
 
-       psrb=&reqsrb;
+       psrb = &reqsrb;
        status=USB_STOR_TRANSPORT_GOOD;
        retry=0;
        notready=0;
@@ -775,7 +772,7 @@ do_retry:
        psrb->cmd[1]=srb->lun<<5;
        psrb->cmd[4]=18;
        psrb->datalen=18;
-       psrb->pdata=&srb->sense_buf[0];
+       psrb->pdata = &srb->sense_buf[0];
        psrb->cmdlen=12;
        /* issue the command */
        result=usb_stor_CB_comdat(psrb,us);
@@ -857,7 +854,7 @@ static int usb_request_sense(ccb *srb,struct us_data *ss)
        srb->cmd[1]=srb->lun<<5;
        srb->cmd[4]=18;
        srb->datalen=18;
-       srb->pdata=&srb->sense_buf[0];
+       srb->pdata = &srb->sense_buf[0];
        srb->cmdlen=12;
        ss->transport(srb,ss);
        USB_STOR_PRINTF("Request Sense returned %02X %02X %02X\n",srb->sense_buf[2],srb->sense_buf[12],srb->sense_buf[13]);
@@ -1222,18 +1219,9 @@ int usb_stor_get_info(struct usb_device *dev,struct us_data *ss,block_dev_desc_t
        if(cap[0]>(0x200000 * 10)) /* greater than 10 GByte */
                cap[0]>>=16;
 #endif
-#ifdef LITTLEENDIAN
-       cap[0] = ((unsigned long)(
-               (((unsigned long)(cap[0]) & (unsigned long)0x000000ffUL) << 24) |
-               (((unsigned long)(cap[0]) & (unsigned long)0x0000ff00UL) <<  8) |
-               (((unsigned long)(cap[0]) & (unsigned long)0x00ff0000UL) >>  8) |
-               (((unsigned long)(cap[0]) & (unsigned long)0xff000000UL) >> 24) ));
-       cap[1] = ((unsigned long)(
-               (((unsigned long)(cap[1]) & (unsigned long)0x000000ffUL) << 24) |
-               (((unsigned long)(cap[1]) & (unsigned long)0x0000ff00UL) <<  8) |
-               (((unsigned long)(cap[1]) & (unsigned long)0x00ff0000UL) >>  8) |
-               (((unsigned long)(cap[1]) & (unsigned long)0xff000000UL) >> 24) ));
-#endif
+       cap[0] = cpu_to_be32(cap[0]);
+       cap[1] = cpu_to_be32(cap[1]);
+
        /* this assumes bigendian! */
        cap[0] += 1;
        capacity = &cap[0];
@@ -1250,6 +1238,3 @@ int usb_stor_get_info(struct usb_device *dev,struct us_data *ss,block_dev_desc_t
        USB_STOR_PRINTF("partype: %d\n",dev_desc->part_type);
        return 1;
 }
-
-#endif /* CONFIG_USB_STORAGE */
-#endif