Commit e7af0786 authored by Marek Belisko's avatar Marek Belisko Committed by Greg Kroah-Hartman

staging: ft1000: Create common function for buffers check.

Same check was done on three places which make code unreadable.
Put repeat routine to separate function.
Signed-off-by: default avatarMarek Belisko <marek.belisko@open-nandra.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 672dfeba
...@@ -470,6 +470,17 @@ static u16 hdr_checksum(struct pseudo_hdr *pHdr) ...@@ -470,6 +470,17 @@ static u16 hdr_checksum(struct pseudo_hdr *pHdr)
return chksum; return chksum;
} }
static int check_buffers(u16 *buff_w, u16 *buff_r, int len, int offset)
{
int i;
for (i = 0; i < len; i++) {
if (buff_w[i] != buff_r[i + offset])
return -1;
}
return 0;
}
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// Function: write_blk // Function: write_blk
...@@ -560,43 +571,31 @@ static u32 write_blk (struct ft1000_device *ft1000dev, u16 **pUsFile, u8 **pUcFi ...@@ -560,43 +571,31 @@ static u32 write_blk (struct ft1000_device *ft1000dev, u16 **pUsFile, u8 **pUcFi
Status = ft1000_read_dpram32 (ft1000dev, dpram, (u8 *)&resultbuffer[0], 64); Status = ft1000_read_dpram32 (ft1000dev, dpram, (u8 *)&resultbuffer[0], 64);
if ( (tempbuffer[31] & 0xfe00) == 0xfe00) if ( (tempbuffer[31] & 0xfe00) == 0xfe00)
{ {
for (i=0; i<28; i++) if (check_buffers(tempbuffer, resultbuffer, 28, 0)) {
{
if (resultbuffer[i] != tempbuffer[i])
{
//NdisMSleep (100);
DEBUG("FT1000:download:DPRAM write failed 1 during bootloading\n"); DEBUG("FT1000:download:DPRAM write failed 1 during bootloading\n");
msleep(10); msleep(10);
Status = STATUS_FAILURE; Status = STATUS_FAILURE;
break; break;
} }
}
Status = ft1000_read_dpram32 (ft1000dev, dpram+12, (u8 *)&resultbuffer[0], 64); Status = ft1000_read_dpram32 (ft1000dev, dpram+12, (u8 *)&resultbuffer[0], 64);
for (i=0; i<16; i++)
{ if (check_buffers(tempbuffer, resultbuffer, 16, 24)) {
if (resultbuffer[i] != tempbuffer[i+24])
{
//NdisMSleep (100);
DEBUG("FT1000:download:DPRAM write failed 2 during bootloading\n"); DEBUG("FT1000:download:DPRAM write failed 2 during bootloading\n");
msleep(10); msleep(10);
Status = STATUS_FAILURE; Status = STATUS_FAILURE;
break; break;
} }
}
} }
else else
{ {
for (i=0; i<32; i++) if (check_buffers(tempbuffer, resultbuffer, 32, 0)) {
{
if (resultbuffer[i] != tempbuffer[i])
{
//NdisMSleep (100);
DEBUG("FT1000:download:DPRAM write failed 3 during bootloading\n"); DEBUG("FT1000:download:DPRAM write failed 3 during bootloading\n");
msleep(10); msleep(10);
Status = STATUS_FAILURE; Status = STATUS_FAILURE;
break; break;
} }
}
} }
if (Status == STATUS_SUCCESS) if (Status == STATUS_SUCCESS)
......
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