Commit aaeb94c9 authored by Kelley Nielsen's avatar Kelley Nielsen Committed by Greg Kroah-Hartman

staging: ft1000: function request_code_segment extracted

function scram_dnldr in ft1000_download.c is very long and contains many
coding style errors and best practice violations. It consists of nested
switch statements inside a while loop. One of the inner switch cases has
been extracted as a helper function. Also, some style errors (such as
C99 comments) have been fixed, an assignment to an unread variable has
been removed, and break statements inside ifs have been converted to
returns.
Signed-off-by: default avatarKelley Nielsen <kelleynnn@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent eb3836ce
......@@ -575,6 +575,34 @@ static int scram_start_dwnld(struct ft1000_usb *ft1000dev, u16 *hshake,
return status;
}
static u16 request_code_segment(struct ft1000_usb *ft1000dev, u16 **s_file,
u8 **c_file, const u8 *boot_end)
{
long word_length;
u16 status;
/*DEBUG("FT1000:REQUEST_CODE_SEGMENT\n");i*/
word_length = get_request_value(ft1000dev);
/*DEBUG("FT1000:word_length = 0x%x\n", (int)word_length); */
/*NdisMSleep (100); */
if (word_length > MAX_LENGTH) {
DEBUG("FT1000:download:Download error: Max length exceeded\n");
return STATUS_FAILURE;
}
if ((word_length * 2 + (long)c_file) > (long)boot_end) {
/* Error, beyond boot code range.*/
DEBUG("FT1000:download:Download error: Requested len=%d exceeds BOOT code boundary.\n", (int)word_length);
return STATUS_FAILURE;
}
if (word_length & 0x1)
word_length++;
word_length = word_length / 2;
status = write_blk(ft1000dev, s_file, c_file, word_length);
/*DEBUG("write_blk returned %d\n", status); */
return status;
}
/* Scramble downloader for Harley based ASIC via USB interface */
u16 scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,
u32 FileLength)
......@@ -673,40 +701,9 @@ u16 scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart,
ft1000dev->fcodeldr = 1;
break;
case REQUEST_CODE_SEGMENT:
//DEBUG("FT1000:REQUEST_CODE_SEGMENT\n");
word_length =
get_request_value(ft1000dev);
//DEBUG("FT1000:word_length = 0x%x\n", (int)word_length);
//NdisMSleep (100);
if (word_length > MAX_LENGTH) {
DEBUG
("FT1000:download:Download error: Max length exceeded\n");
status = STATUS_FAILURE;
break;
}
if ((word_length * 2 + c_file) >
boot_end) {
/*
* Error, beyond boot code range.
*/
DEBUG
("FT1000:download:Download error: Requested len=%d exceeds BOOT code boundary.\n",
(int)word_length);
status = STATUS_FAILURE;
break;
}
/*
* Position ASIC DPRAM auto-increment pointer.
*/
dpram = (u16) DWNLD_MAG1_PS_HDR_LOC;
if (word_length & 0x1)
word_length++;
word_length = word_length / 2;
status =
write_blk(ft1000dev, &s_file,
&c_file, word_length);
//DEBUG("write_blk returned %d\n", status);
status = request_code_segment(ft1000dev,
&s_file, &c_file,
(const u8 *)boot_end);
break;
default:
DEBUG
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment