From 43fc69b1122b8a3e540b9d6ab36dc9840fa918ff Mon Sep 17 00:00:00 2001 From: Kelley Nielsen Date: Tue, 29 Oct 2013 14:54:31 -0700 Subject: [PATCH] staging: ft1000: change values of status return variable in write_dpram32_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 Suggested-by: Greg Kroah-Hartman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ft1000/ft1000-usb/ft1000_download.c | 9 +++------ drivers/staging/ft1000/ft1000-usb/ft1000_hw.c | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c index 605156852b44..72f3cfc95aa1 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c @@ -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; @@ -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, @@ -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, @@ -425,7 +424,6 @@ 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 { @@ -433,11 +431,10 @@ static int write_dpram32_and_check(struct ft1000_usb *ft1000dev, 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; } } diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c b/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c index ca5b56c290fa..0d4931b2c2e2 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c @@ -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; -- 2.20.1