Browse Source

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 <kelleynnn@gmail.com>
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Kelley Nielsen 11 years ago
parent
commit
43fc69b112

+ 3 - 6
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;
 		}
 	}

+ 1 - 1
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;