Merge v3.13-rc2 into staging-next
[firefly-linux-kernel-4.4.55.git] / drivers / staging / ft1000 / ft1000-usb / ft1000_download.c
index 12f333fa59b525ef7598d2a9cf0e213f925b34a4..21f4a3bbd0644a4efe98ee892229ee2f0a52a804 100644 (file)
 #define  DWNLD_MAG1_PS_HDR_LOC        0x03
 
 struct dsp_file_hdr {
-   long              version_id;          // Version ID of this image format.
-   long              package_id;          // Package ID of code release.
-   long              build_date;          // Date/time stamp when file was built.
-   long              commands_offset;     // Offset to attached commands in Pseudo Hdr format.
-   long              loader_offset;       // Offset to bootloader code.
-   long              loader_code_address; // Start address of bootloader.
-   long              loader_code_end;     // Where bootloader code ends.
-   long              loader_code_size;
-   long              version_data_offset; // Offset were scrambled version data begins.
-   long              version_data_size;   // Size, in words, of scrambled version data.
-   long              nDspImages;          // Number of DSP images in file.
+       long              version_id;          // Version ID of this image format.
+       long              package_id;          // Package ID of code release.
+       long              build_date;          // Date/time stamp when file was built.
+       long              commands_offset;     // Offset to attached commands in Pseudo Hdr format.
+       long              loader_offset;       // Offset to bootloader code.
+       long              loader_code_address; // Start address of bootloader.
+       long              loader_code_end;     // Where bootloader code ends.
+       long              loader_code_size;
+       long              version_data_offset; // Offset were scrambled version data begins.
+       long              version_data_size;   // Size, in words, of scrambled version data.
+       long              nDspImages;          // Number of DSP images in file.
 };
 
 #pragma pack(1)
 struct dsp_image_info {
-   long              coff_date;           // Date/time when DSP Coff image was built.
-   long              begin_offset;        // Offset in file where image begins.
-   long              end_offset;          // Offset in file where image begins.
-   long              run_address;         // On chip Start address of DSP code.
-   long              image_size;          // Size of image.
-   long              version;             // Embedded version # of DSP code.
-   unsigned short    checksum;            // DSP File checksum
-   unsigned short    pad1;
+       long              coff_date;           // Date/time when DSP Coff image was built.
+       long              begin_offset;        // Offset in file where image begins.
+       long              end_offset;          // Offset in file where image begins.
+       long              run_address;         // On chip Start address of DSP code.
+       long              image_size;          // Size of image.
+       long              version;             // Embedded version # of DSP code.
+       unsigned short    checksum;            // DSP File checksum
+       unsigned short    pad1;
 };
 
 
@@ -151,7 +151,7 @@ static int check_usb_db(struct ft1000_usb *ft1000dev)
                }
        }
 
-       return HANDSHAKE_MAG_TIMEOUT_VALUE;
+       return -1;
 }
 
 /* gets the handshake and compares it with the expected value */
@@ -172,9 +172,8 @@ static u16 get_handshake(struct ft1000_usb *ft1000dev, u16 expected_value)
                                ft1000dev->fcodeldr);
                        ft1000dev->fcodeldr = 0;
                        status = check_usb_db(ft1000dev);
-                       if (status != STATUS_SUCCESS) {
+                       if (status != 0) {
                                DEBUG("get_handshake: check_usb_db failed\n");
-                               status = STATUS_FAILURE;
                                break;
                        }
                        status = ft1000_write_register(ft1000dev,
@@ -202,7 +201,7 @@ static u16 get_handshake(struct ft1000_usb *ft1000dev, u16 expected_value)
 }
 
 /* write the handshake value to the handshake location */
-static void put_handshake(struct ft1000_usb *ft1000dev,u16 handshake_value)
+static void put_handshake(struct ft1000_usb *ft1000dev, u16 handshake_value)
 {
        u32 tempx;
        u16 tempword;
@@ -268,11 +267,12 @@ static u16 get_handshake_usb(struct ft1000_usb *ft1000dev, u16 expected_value)
        return HANDSHAKE_TIMEOUT_VALUE;
 }
 
-static void put_handshake_usb(struct ft1000_usb *ft1000dev,u16 handshake_value)
+static void put_handshake_usb(struct ft1000_usb *ft1000dev, u16 handshake_value)
 {
        int i;
 
-        for (i=0; i<1000; i++);
+       for (i = 0; i < 1000; i++)
+               ;
 }
 
 static u16 get_request_type(struct ft1000_usb *ft1000dev)
@@ -450,7 +450,7 @@ static int write_dpram32_and_check(struct ft1000_usb *ft1000dev,
 static int write_blk(struct ft1000_usb *ft1000dev, u16 **pUsFile, u8 **pUcFile,
                long word_length)
 {
-       int status = STATUS_SUCCESS;
+       int status = 0;
        u16 dpram;
        int loopcnt, i;
        u16 tempword;
@@ -499,7 +499,7 @@ static int write_blk(struct ft1000_usb *ft1000dev, u16 **pUsFile, u8 **pUcFile,
                } else {
                        status = write_dpram32_and_check(ft1000dev, tempbuffer,
                                        dpram);
-                       if (status != STATUS_SUCCESS) {
+                       if (status != 0) {
                                DEBUG("FT1000:download:Write failed tempbuffer[31] = 0x%x\n", tempbuffer[31]);
                                break;
                        }
@@ -509,9 +509,9 @@ static int write_blk(struct ft1000_usb *ft1000dev, u16 **pUsFile, u8 **pUcFile,
        return status;
 }
 
-static void usb_dnld_complete (struct urb *urb)
+static void usb_dnld_complete(struct urb *urb)
 {
-    //DEBUG("****** usb_dnld_complete\n");
+       //DEBUG("****** usb_dnld_complete\n");
 }
 
 /* writes a block of DSP image to DPRAM
@@ -523,7 +523,7 @@ static void usb_dnld_complete (struct urb *urb)
 static int write_blk_fifo(struct ft1000_usb *ft1000dev, u16 **pUsFile,
                          u8 **pUcFile, long word_length)
 {
-       int Status = STATUS_SUCCESS;
+       int Status = 0;
        int byte_length;
 
        byte_length = word_length * 4;
@@ -586,12 +586,12 @@ static int request_code_segment(struct ft1000_usb *ft1000dev, u16 **s_file,
        /*NdisMSleep (100); */
        if (word_length > MAX_LENGTH) {
                DEBUG("FT1000:download:Download error: Max length exceeded\n");
-               return STATUS_FAILURE;
+               return -1;
        }
        if ((word_length * 2 + (long)c_file) > (long)endpoint) {
                /* Error, beyond boot code range.*/
                DEBUG("FT1000:download:Download error: Requested len=%d exceeds BOOT code boundary.\n", (int)word_length);
-               return STATUS_FAILURE;
+               return -1;
        }
        if (word_length & 0x1)
                word_length++;
@@ -601,11 +601,11 @@ static int request_code_segment(struct ft1000_usb *ft1000dev, u16 **s_file,
                status = write_blk(ft1000dev, s_file, c_file, word_length);
                /*DEBUG("write_blk returned %d\n", status); */
        } else {
-               write_blk_fifo(ft1000dev, s_file, c_file, word_length);
+               status = write_blk_fifo(ft1000dev, s_file, c_file, word_length);
                if (ft1000dev->usbboot == 0)
                        ft1000dev->usbboot++;
                if (ft1000dev->usbboot == 1)
-                       ft1000_write_dpram16(ft1000dev,
+                       status |= ft1000_write_dpram16(ft1000dev,
                                        DWNLD_MAG1_PS_HDR_LOC, 0, 0);
        }
        return status;
@@ -615,7 +615,7 @@ static int request_code_segment(struct ft1000_usb *ft1000dev, u16 **s_file,
 int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,
                u32 FileLength)
 {
-       int status = STATUS_SUCCESS;
+       int status = 0;
        u32 state;
        u16 handshake;
        struct pseudo_hdr *pseudo_header;
@@ -670,7 +670,7 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,
        loader_code_size = file_hdr->loader_code_size;
        correct_version = false;
 
-       while ((status == STATUS_SUCCESS) && (state != STATE_DONE_FILE)) {
+       while ((status == 0) && (state != STATE_DONE_FILE)) {
                switch (state) {
                case STATE_START_DWNLD:
                        status = scram_start_dwnld(ft1000dev, &handshake,
@@ -717,7 +717,7 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,
                                        DEBUG
                                            ("FT1000:download:Download error: Bad request type=%d in BOOT download state.\n",
                                             request);
-                                       status = STATUS_FAILURE;
+                                       status = -1;
                                        break;
                                }
                                if (ft1000dev->usbboot)
@@ -729,7 +729,7 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,
                        } else {
                                DEBUG
                                    ("FT1000:download:Download error: Handshake failed\n");
-                               status = STATUS_FAILURE;
+                               status = -1;
                        }
 
                        break;
@@ -773,7 +773,7 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,
                                        } else {
                                                DEBUG
                                                    ("FT1000:download:Download error: Got Run address request before image offset request.\n");
-                                               status = STATUS_FAILURE;
+                                               status = -1;
                                                break;
                                        }
                                        break;
@@ -789,7 +789,7 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,
                                        } else {
                                                DEBUG
                                                    ("FT1000:download:Download error: Got Size request before image offset request.\n");
-                                               status = STATUS_FAILURE;
+                                               status = -1;
                                                break;
                                        }
                                        break;
@@ -809,7 +809,7 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,
                                        if (!correct_version) {
                                                DEBUG
                                                    ("FT1000:download:Download error: Got Code Segment request before image offset request.\n");
-                                               status = STATUS_FAILURE;
+                                               status = -1;
                                                break;
                                        }
 
@@ -836,7 +836,7 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,
                                         * Position ASIC DPRAM auto-increment pointer.
                                         */
 
-                                       data = (u16 *) & mailbox_data->data[0];
+                                       data = (u16 *) &mailbox_data->data[0];
                                        dpram = (u16) DWNLD_MAG1_PS_HDR_LOC;
                                        if (word_length & 0x1)
                                                word_length++;
@@ -850,7 +850,7 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,
                                                status =
                                                    fix_ft1000_write_dpram32
                                                    (ft1000dev, dpram++,
-                                                    (u8 *) & templong);
+                                                    (u8 *) &templong);
 
                                        }
                                        break;
@@ -948,7 +948,7 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,
                                                DEBUG
                                                    ("FT1000:download:Download error: Bad Version Request = 0x%x.\n",
                                                     (int)requested_version);
-                                               status = STATUS_FAILURE;
+                                               status = -1;
                                                break;
                                        }
                                        break;
@@ -957,7 +957,7 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,
                                        DEBUG
                                            ("FT1000:download:Download error: Bad request type=%d in CODE download state.\n",
                                             request);
-                                       status = STATUS_FAILURE;
+                                       status = -1;
                                        break;
                                }
                                if (ft1000dev->usbboot)
@@ -969,7 +969,7 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,
                        } else {
                                DEBUG
                                    ("FT1000:download:Download error: Handshake failed\n");
-                               status = STATUS_FAILURE;
+                               status = -1;
                        }
 
                        break;
@@ -1026,14 +1026,14 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,
                                                }
                                        } else {
                                                kfree(pbuffer);
-                                               status = STATUS_FAILURE;
+                                               status = -1;
                                        }
                                } else {
-                                       status = STATUS_FAILURE;
+                                       status = -1;
                                }
                        } else {
                                /* Checksum did not compute */
-                               status = STATUS_FAILURE;
+                               status = -1;
                        }
                        DEBUG
                            ("ft1000:download: after STATE_SECTION_PROV, state = %d, status= %d\n",
@@ -1046,23 +1046,23 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,
                        break;
 
                default:
-                       status = STATUS_FAILURE;
+                       status = -1;
                        break;
                }               /* End Switch */
 
-               if (status != STATUS_SUCCESS)
+               if (status != 0)
                        break;
 
 /****
       // Check if Card is present
       status = Harley_Read_Register(&temp, FT1000_REG_SUP_IMASK);
       if ( (status != NDIS_STATUS_SUCCESS) || (temp == 0x0000) ) {
-          break;
+       break;
       }
 
       status = Harley_Read_Register(&temp, FT1000_REG_ASIC_ID);
       if ( (status != NDIS_STATUS_SUCCESS) || (temp == 0xffff) ) {
-          break;
+       break;
       }
 ****/