Skip to content

Commit

Permalink
staging: ft1000: change values of status return variable in write_dpr…
Browse files Browse the repository at this point in the history
…am32_and_check

The ft1000 usb driver ignores expected Linux error codes, and uses two
values defined in ft1000_usb.h: STATUS_SUCCESS 0, and STATUS_FAILURE
0x1001; and sometimes -1. This patch changes the return value of the
function write_dpram_32_and check to 0 or -EREMOTEIO, respectively. The
relevant change was made in the helper function check_buffers (which is
only called from write_dpram32_and_check); it now returns 0 on success
and -EREMOTEIO on failure, and this is allowed to propagate through
write_dpram32_and_check. Assignments to the return variable status that
are no longer needed were removed as well. In one function up the call
chain, dsp_reload in ft1000_hw.c, the status variable was changed from
u16 to int to avoid collecting a signed value in an unsigned variable.

Signed-off-by: Kelley Nielsen <kelleynnn@gmail.com>
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Kelley Nielsen authored and Greg Kroah-Hartman committed Oct 30, 2013
1 parent 2fef7e1 commit 43fc69b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
9 changes: 3 additions & 6 deletions drivers/staging/ft1000/ft1000-usb/ft1000_download.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ static int check_buffers(u16 *buff_w, u16 *buff_r, int len, int offset)

for (i = 0; i < len; i++) {
if (buff_w[i] != buff_r[i + offset])
return -1;
return -EREMOTEIO;
}

return 0;
Expand All @@ -399,7 +399,7 @@ static int write_dpram32_and_check(struct ft1000_usb *ft1000dev,
for (i = 0; i < 10; i++) {
status = ft1000_write_dpram32(ft1000dev, dpram,
(u8 *)&tempbuffer[0], 64);
if (status == STATUS_SUCCESS) {
if (status == 0) {
/* Work around for ASIC bit stuffing problem. */
if ((tempbuffer[31] & 0xfe00) == 0xfe00) {
status = ft1000_write_dpram32(ft1000dev,
Expand All @@ -414,7 +414,6 @@ static int write_dpram32_and_check(struct ft1000_usb *ft1000dev,
0)) {
DEBUG("FT1000:download:DPRAM write failed 1 during bootloading\n");
usleep_range(9000, 11000);
status = STATUS_FAILURE;
break;
}
status = ft1000_read_dpram32(ft1000dev,
Expand All @@ -425,19 +424,17 @@ static int write_dpram32_and_check(struct ft1000_usb *ft1000dev,
24)) {
DEBUG("FT1000:download:DPRAM write failed 2 during bootloading\n");
usleep_range(9000, 11000);
status = STATUS_FAILURE;
break;
}
} else {
if (check_buffers(tempbuffer, resultbuffer, 32,
0)) {
DEBUG("FT1000:download:DPRAM write failed 3 during bootloading\n");
usleep_range(9000, 11000);
status = STATUS_FAILURE;
break;
}
}
if (status == STATUS_SUCCESS)
if (status == 0)
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/ft1000/ft1000-usb/ft1000_hw.c
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ void card_send_command(struct ft1000_usb *ft1000dev, void *ptempbuffer,
//-----------------------------------------------------------------------
int dsp_reload(struct ft1000_usb *ft1000dev)
{
u16 status;
int status;
u16 tempword;
u32 templong;

Expand Down

0 comments on commit 43fc69b

Please sign in to comment.