From e072241a31cb7469dcaf5d0e0d5066b9ed30e58c Mon Sep 17 00:00:00 2001 From: Kelley Nielsen Date: Fri, 11 Oct 2013 23:08:28 -0700 Subject: staging: ft1000-usb: remove space between function name and open paren in ft1000_download.c fixed checkpatch.pl warning: space prohibited between function name and open parenthesis '(' Signed-off-by: Kelley Nielsen Reviewed-by: Josh Triplett Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ft1000/ft1000-usb/ft1000_download.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging/ft1000/ft1000-usb/ft1000_download.c') diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c index 5190c8ac4e0a..978b9796665b 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c @@ -123,7 +123,7 @@ struct dsp_image_info { // Notes: // //--------------------------------------------------------------------------- -static u32 check_usb_db (struct ft1000_usb *ft1000dev) +static u32 check_usb_db(struct ft1000_usb *ft1000dev) { int loopcnt; u16 temp; -- cgit v1.2.3 From 0c5e802c1c42f0c2882400fa0e24150e55c4c62e Mon Sep 17 00:00:00 2001 From: Kelley Nielsen Date: Sat, 12 Oct 2013 08:32:46 -0700 Subject: staging: ft1000: change comment style Coding style requires that comments use the standard /* */ style instead of C99 style. Signed-off-by: Kelley Nielsen Reviewed-by: Josh Triplett Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ft1000/ft1000-usb/ft1000_download.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging/ft1000/ft1000-usb/ft1000_download.c') diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c index 978b9796665b..1e62b5060d00 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c @@ -1143,7 +1143,7 @@ u16 scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, } pseudo_header_len = ntohs(pseudo_header->length); /* Byte length for PROV records */ - // Get buffer for provisioning data + /* Get buffer for provisioning data */ pbuffer = kmalloc((pseudo_header_len + sizeof(struct pseudo_hdr)), -- cgit v1.2.3 From cfd9d1fad6bd0fe6679c3ffa455ca3c14651aecb Mon Sep 17 00:00:00 2001 From: Kelley Nielsen Date: Sat, 12 Oct 2013 08:37:53 -0700 Subject: staging: ft1000: remove braces from one-line conditional As per coding style, braces {} are not necessary for single statement blocks Signed-off-by: Kelley Nielsen Reviewed-by: Josh Triplett Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ft1000/ft1000-usb/ft1000_download.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/staging/ft1000/ft1000-usb/ft1000_download.c') diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c index 1e62b5060d00..85c9ce175aef 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c @@ -1201,9 +1201,8 @@ u16 scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, break; } /* End Switch */ - if (status != STATUS_SUCCESS) { + if (status != STATUS_SUCCESS) break; - } /**** // Check if Card is present -- cgit v1.2.3 From 610554d3ac98c75da20acbd79837510ed7435e11 Mon Sep 17 00:00:00 2001 From: Kelley Nielsen Date: Sat, 12 Oct 2013 10:26:48 -0700 Subject: staging: ft1000: remove space before address operator as per coding style (checkpatch error), space prohibited after that '&' Signed-off-by: Kelley Nielsen Reviewed-by: Josh Triplett Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ft1000/ft1000-usb/ft1000_download.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging/ft1000/ft1000-usb/ft1000_download.c') diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c index 85c9ce175aef..d2cfafd6a8b4 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c @@ -1036,7 +1036,7 @@ u16 scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, status = fix_ft1000_write_dpram32 (ft1000dev, dpram++, - (u8 *) & templong); + (u8 *) &templong); } break; -- cgit v1.2.3 From 6f5519fd833abd8066cc7a8f6e8c5b31dfcc7ea9 Mon Sep 17 00:00:00 2001 From: Kelley Nielsen Date: Sat, 12 Oct 2013 10:28:50 -0700 Subject: staging: ft1000: remove space before closing paren as per coding style, space prohibited before that close parenthesis Signed-off-by: Kelley Nielsen Reviewed-by: Josh Triplett Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ft1000/ft1000-usb/ft1000_download.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging/ft1000/ft1000-usb/ft1000_download.c') diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c index d2cfafd6a8b4..11225f5cae4a 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c @@ -1137,7 +1137,7 @@ u16 scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, if (pseudo_header->checksum == hdr_checksum(pseudo_header)) { if (pseudo_header->portdest != - 0x80 /* Dsp OAM */ ) { + 0x80 /* Dsp OAM */) { state = STATE_DONE_PROV; break; } -- cgit v1.2.3 From de7a0cc15a9ce952a06053e3e155affe0119e772 Mon Sep 17 00:00:00 2001 From: Kelley Nielsen Date: Sat, 12 Oct 2013 12:16:33 -0700 Subject: staging: ft1000: convert formal function header to single line comment As per coding style,C99 comments are not allowed also, the formal header contained empty space and redundant information that's right there in the function Signed-off-by: Kelley Nielsen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ft1000/ft1000-usb/ft1000_download.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'drivers/staging/ft1000/ft1000-usb/ft1000_download.c') diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c index 11225f5cae4a..229306ff8ad2 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c @@ -111,18 +111,7 @@ struct dsp_image_info { }; -//--------------------------------------------------------------------------- -// Function: check_usb_db -// -// Parameters: struct ft1000_usb - device structure -// -// Returns: 0 - success -// -// Description: This function checks if the doorbell register is cleared -// -// Notes: -// -//--------------------------------------------------------------------------- +/* checks if the doorbell register is cleared */ static u32 check_usb_db(struct ft1000_usb *ft1000dev) { int loopcnt; -- cgit v1.2.3 From 135a9ea056df506619fa50bafdf0d66133295e97 Mon Sep 17 00:00:00 2001 From: Kelley Nielsen Date: Sun, 13 Oct 2013 18:52:46 -0700 Subject: staging: ft1000: convert formal get_handshake() function header to single line comment As per coding style,C99 comments are not allowed also, the formal header contained empty space and redundant information that's right there in the function Signed-off-by: Kelley Nielsen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ft1000/ft1000-usb/ft1000_download.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) (limited to 'drivers/staging/ft1000/ft1000-usb/ft1000_download.c') diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c index 229306ff8ad2..f80dc433e6d5 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c @@ -158,20 +158,7 @@ static u32 check_usb_db(struct ft1000_usb *ft1000dev) return HANDSHAKE_MAG_TIMEOUT_VALUE; } -//--------------------------------------------------------------------------- -// Function: get_handshake -// -// Parameters: struct ft1000_usb - device structure -// u16 expected_value - the handshake value expected -// -// Returns: handshakevalue - success -// HANDSHAKE_TIMEOUT_VALUE - failure -// -// Description: This function gets the handshake and compare with the expected value -// -// Notes: -// -//--------------------------------------------------------------------------- +/* gets the handshake and compares it with the expected value */ static u16 get_handshake(struct ft1000_usb *ft1000dev, u16 expected_value) { u16 handshake; -- cgit v1.2.3 From 89a03d3662916e1541f8c2a956c283b24ab82a67 Mon Sep 17 00:00:00 2001 From: Kelley Nielsen Date: Mon, 14 Oct 2013 14:21:30 -0700 Subject: staging: ft1000: change ft1000-download.c header to /* */ comment style Coding style requires that comments use the standard /* */ style instead of C99 style. Also removed author comment from a previous contributor Signed-off-by: Kelley Nielsen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ft1000/ft1000-usb/ft1000_download.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'drivers/staging/ft1000/ft1000-usb/ft1000_download.c') diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c index f80dc433e6d5..46c746236724 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c @@ -1,12 +1,8 @@ -//===================================================== -// CopyRight (C) 2007 Qualcomm Inc. All Rights Reserved. -// -// -// This file is part of Express Card USB Driver -// -// $Id: -//==================================================== -// 20090926; aelias; removed compiler warnings; ubuntu 9.04; 2.6.28-15-generic +/* +* CopyRight (C) 2007 Qualcomm Inc. All Rights Reserved. +* +* This file is part of Express Card USB Driver +*/ #include #include -- cgit v1.2.3 From fafa4dcef4b5438427d194926e804b13e441fc92 Mon Sep 17 00:00:00 2001 From: Kelley Nielsen Date: Mon, 14 Oct 2013 14:40:01 -0700 Subject: staging: ft1000: convert formal put_handshake() header to single line comment As per coding style,C99 comments are not allowed also, the formal header contained empty space and redundant information that's right there in the function Signed-off-by: Kelley Nielsen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ft1000/ft1000-usb/ft1000_download.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) (limited to 'drivers/staging/ft1000/ft1000-usb/ft1000_download.c') diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c index 46c746236724..911acfda27c3 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c @@ -201,20 +201,7 @@ static u16 get_handshake(struct ft1000_usb *ft1000dev, u16 expected_value) return HANDSHAKE_TIMEOUT_VALUE; } -//--------------------------------------------------------------------------- -// Function: put_handshake -// -// Parameters: struct ft1000_usb - device structure -// u16 handshake_value - handshake to be written -// -// Returns: none -// -// Description: This function write the handshake value to the handshake location -// in DPRAM -// -// Notes: -// -//--------------------------------------------------------------------------- +/* write the handshake value to the handshake location */ static void put_handshake(struct ft1000_usb *ft1000dev,u16 handshake_value) { u32 tempx; -- cgit v1.2.3 From c50ede79751ffcf263b8f4bbb4060f41eec3dfe0 Mon Sep 17 00:00:00 2001 From: Kelley Nielsen Date: Mon, 14 Oct 2013 15:21:48 -0700 Subject: staging: ft1000: remove formal get_request_type function header from ft1000-download.c since there was no information in the C99 style header for function get_request_type() that was not easily obtainable by looking at the function, the header was completely removed. Signed-off-by: Kelley Nielsen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ft1000/ft1000-usb/ft1000_download.c | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'drivers/staging/ft1000/ft1000-usb/ft1000_download.c') diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c index 911acfda27c3..f47546aa1385 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c @@ -275,18 +275,6 @@ static void put_handshake_usb(struct ft1000_usb *ft1000dev,u16 handshake_value) for (i=0; i<1000; i++); } -//--------------------------------------------------------------------------- -// Function: get_request_type -// -// Parameters: struct ft1000_usb - device structure -// -// Returns: request type - success -// -// Description: This function returns the request type -// -// Notes: -// -//--------------------------------------------------------------------------- static u16 get_request_type(struct ft1000_usb *ft1000dev) { u16 request_type; -- cgit v1.2.3 From 1f13b0b8e7a60cfdc5fcc7367350592b37789528 Mon Sep 17 00:00:00 2001 From: Kelley Nielsen Date: Mon, 14 Oct 2013 15:38:18 -0700 Subject: staging: ft1000: remove formal get_request_value function header from ft1000-download.c since there was no information in the C99 style header for function get_request_type() that was not easily obtainable by looking at the function, the header was completely removed. Signed-off-by: Kelley Nielsen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ft1000/ft1000-usb/ft1000_download.c | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'drivers/staging/ft1000/ft1000-usb/ft1000_download.c') diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c index f47546aa1385..97950b98919f 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c @@ -327,18 +327,6 @@ static u16 get_request_type_usb(struct ft1000_usb *ft1000dev) return request_type; } -//--------------------------------------------------------------------------- -// Function: get_request_value -// -// Parameters: struct ft1000_usb - device structure -// -// Returns: request value - success -// -// Description: This function returns the request value -// -// Notes: -// -//--------------------------------------------------------------------------- static long get_request_value(struct ft1000_usb *ft1000dev) { u32 value; -- cgit v1.2.3 From 9e80d03c757085987377e7e08fa858ee6912a5c2 Mon Sep 17 00:00:00 2001 From: Kelley Nielsen Date: Tue, 15 Oct 2013 14:05:09 -0700 Subject: staging: ft1000: change put_request_value() header to single line comment in ft1000_download.c As per coding style,C99 comments are not allowed also, the formal header contained empty space and redundant information that's right there in the function Signed-off-by: Kelley Nielsen Reviewed-by: Josh Triplett Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ft1000/ft1000-usb/ft1000_download.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'drivers/staging/ft1000/ft1000-usb/ft1000_download.c') diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c index 97950b98919f..1d9f07aeecac 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c @@ -351,19 +351,7 @@ static long get_request_value(struct ft1000_usb *ft1000dev) } -//--------------------------------------------------------------------------- -// Function: put_request_value -// -// Parameters: struct ft1000_usb - device structure -// long lvalue - value to be put into DPRAM location DWNLD_MAG1_SIZE_LOC -// -// Returns: none -// -// Description: This function writes a value to DWNLD_MAG1_SIZE_LOC -// -// Notes: -// -//--------------------------------------------------------------------------- +/* writes a value to DWNLD_MAG1_SIZE_LOC */ static void put_request_value(struct ft1000_usb *ft1000dev, long lvalue) { u32 tempx; -- cgit v1.2.3 From b30f4e234f3fd771b01137ff92c7b9a2caa67f10 Mon Sep 17 00:00:00 2001 From: Kelley Nielsen Date: Tue, 15 Oct 2013 14:05:41 -0700 Subject: staging: ft1000: change hdr_checksum() header to one line comment in ft1000_download.c As per coding style,C99 comments are not allowed also, the formal header contained empty space and redundant information that's right there in the function Signed-off-by: Kelley Nielsen Reviewed-by: Josh Triplett Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ft1000/ft1000-usb/ft1000_download.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'drivers/staging/ft1000/ft1000-usb/ft1000_download.c') diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c index 1d9f07aeecac..95c89e937cfa 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c @@ -364,18 +364,7 @@ static void put_request_value(struct ft1000_usb *ft1000dev, long lvalue) -//--------------------------------------------------------------------------- -// Function: hdr_checksum -// -// Parameters: struct pseudo_hdr *pHdr - Pseudo header pointer -// -// Returns: checksum - success -// -// Description: This function returns the checksum of the pseudo header -// -// Notes: -// -//--------------------------------------------------------------------------- +/* returns the checksum of the pseudo header */ static u16 hdr_checksum(struct pseudo_hdr *pHdr) { u16 *usPtr = (u16 *)pHdr; -- cgit v1.2.3 From 69f7be1fbaabe775f5c6b0a2762ebc9a82ded870 Mon Sep 17 00:00:00 2001 From: Kelley Nielsen Date: Tue, 15 Oct 2013 14:06:12 -0700 Subject: staging: ft1000: change write_blk header to /* */ style in ft1000_download.c As per coding style, C99 comments are not allowed removed some redundant information and empty space Left the parameter descriptions because the parameter list is long and cryptic looking Signed-off-by: Kelley Nielsen Reviewed-by: Josh Triplett Signed-off-by: Greg Kroah-Hartman --- .../staging/ft1000/ft1000-usb/ft1000_download.c | 23 ++++++---------------- 1 file changed, 6 insertions(+), 17 deletions(-) (limited to 'drivers/staging/ft1000/ft1000-usb/ft1000_download.c') diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c index 95c89e937cfa..becab042aee4 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c @@ -389,23 +389,12 @@ static int check_buffers(u16 *buff_w, u16 *buff_r, int len, int offset) return 0; } -//--------------------------------------------------------------------------- -// Function: write_blk -// -// Parameters: struct ft1000_usb - device structure -// u16 **pUsFile - DSP image file pointer in u16 -// u8 **pUcFile - DSP image file pointer in u8 -// long word_length - length of the buffer to be written -// to DPRAM -// -// Returns: STATUS_SUCCESS - success -// STATUS_FAILURE - failure -// -// Description: This function writes a block of DSP image to DPRAM -// -// Notes: -// -//--------------------------------------------------------------------------- +/* writes a block of DSP image to DPRAM + * Parameters: struct ft1000_usb - device structure + * u16 **pUsFile - DSP image file pointer in u16 + * u8 **pUcFile - DSP image file pointer in u8 + * long word_length - length of the buffer to be written to DPRAM + */ static u32 write_blk (struct ft1000_usb *ft1000dev, u16 **pUsFile, u8 **pUcFile, long word_length) { u32 Status = STATUS_SUCCESS; -- cgit v1.2.3 From 456ae7ebfd2f38103f620294a7f3b92539baca04 Mon Sep 17 00:00:00 2001 From: Kelley Nielsen Date: Tue, 15 Oct 2013 14:06:41 -0700 Subject: staging: ft1000: change write_block_fifo() header to /* */ style in ft1000_download.c As per coding style, C99 comments are not allowed removed some redundant information and empty space Left the parameter descriptions because the parameter list is long and cryptic looking Signed-off-by: Kelley Nielsen Reviewed-by: Josh Triplett Signed-off-by: Greg Kroah-Hartman --- .../staging/ft1000/ft1000-usb/ft1000_download.c | 23 ++++++---------------- 1 file changed, 6 insertions(+), 17 deletions(-) (limited to 'drivers/staging/ft1000/ft1000-usb/ft1000_download.c') diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c index becab042aee4..b3a37eaa04df 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c @@ -517,23 +517,12 @@ static void usb_dnld_complete (struct urb *urb) //DEBUG("****** usb_dnld_complete\n"); } -//--------------------------------------------------------------------------- -// Function: write_blk_fifo -// -// Parameters: struct ft1000_usb - device structure -// u16 **pUsFile - DSP image file pointer in u16 -// u8 **pUcFile - DSP image file pointer in u8 -// long word_length - length of the buffer to be written -// to DPRAM -// -// Returns: STATUS_SUCCESS - success -// STATUS_FAILURE - failure -// -// Description: This function writes a block of DSP image to DPRAM -// -// Notes: -// -//--------------------------------------------------------------------------- +/* writes a block of DSP image to DPRAM + * Parameters: struct ft1000_usb - device structure + * u16 **pUsFile - DSP image file pointer in u16 + * u8 **pUcFile - DSP image file pointer in u8 + * long word_length - length of the buffer to be written to DPRAM + */ static u32 write_blk_fifo(struct ft1000_usb *ft1000dev, u16 **pUsFile, u8 **pUcFile, long word_length) { -- cgit v1.2.3 From 4b31e1f8ff7165832d4e7293af4a0b5672217103 Mon Sep 17 00:00:00 2001 From: Kelley Nielsen Date: Tue, 15 Oct 2013 14:07:09 -0700 Subject: staging: ft1000: change scram_dnldr() header to one line comment in ft1000_download.c As per coding style,C99 comments are not allowed also, the formal header contained empty space and redundant information that's right there in the function Signed-off-by: Kelley Nielsen Reviewed-by: Josh Triplett Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ft1000/ft1000-usb/ft1000_download.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'drivers/staging/ft1000/ft1000-usb/ft1000_download.c') diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c index b3a37eaa04df..1a1413d31af6 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c @@ -554,18 +554,7 @@ static u32 write_blk_fifo(struct ft1000_usb *ft1000dev, u16 **pUsFile, return Status; } -//--------------------------------------------------------------------------- -// -// Function: scram_dnldr -// -// Synopsis: Scramble downloader for Harley based ASIC via USB interface -// -// Arguments: pFileStart - pointer to start of file -// FileLength - file length -// -// Returns: status - return code -//--------------------------------------------------------------------------- - +/* Scramble downloader for Harley based ASIC via USB interface */ u16 scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, u32 FileLength) { -- cgit v1.2.3 From 36f955bf06ccc5edf8133368cb077707a01eba6c Mon Sep 17 00:00:00 2001 From: Rashika Kheria Date: Sun, 27 Oct 2013 19:50:45 +0530 Subject: Staging: ft1000: Fix assignment of bool to non-0/1 constant in ft1000_download.c This patch fixes the following coccinelle error in ft1000-usb/ft1000_download.c - drivers/staging/ft1000/ft1000-usb/ft1000_download.c:615:1-16: ERROR: Assignment of bool to non-0/1 constant drivers/staging/ft1000/ft1000-usb/ft1000_download.c:926:5-20: ERROR: Assignment of bool to non-0/1 constant drivers/staging/ft1000/ft1000-usb/ft1000_download.c:943:7-22: ERROR: Assignment of bool to non-0/1 constant Signed-off-by: Rashika Kheria Reviewed-by: Lisa Nguyen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ft1000/ft1000-usb/ft1000_download.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/staging/ft1000/ft1000-usb/ft1000_download.c') diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c index 1a1413d31af6..bfffce5b1445 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c @@ -612,7 +612,7 @@ u16 scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, loader_code_address = file_hdr->loader_code_address; loader_code_size = file_hdr->loader_code_size; - correct_version = FALSE; + correct_version = false; while ((status == STATUS_SUCCESS) && (state != STATE_DONE_FILE)) { switch (state) { @@ -923,7 +923,7 @@ u16 scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, case REQUEST_CODE_BY_VERSION: DEBUG ("FT1000:download:REQUEST_CODE_BY_VERSION\n"); - correct_version = FALSE; + correct_version = false; requested_version = get_request_value(ft1000dev); @@ -940,7 +940,7 @@ u16 scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, if (dsp_img_info->version == requested_version) { - correct_version = TRUE; + correct_version = true; DEBUG ("FT1000:download: correct_version is TRUE\n"); s_file = -- cgit v1.2.3 From eb3836cefcc315c53ba25cb589f7b06aa962578b Mon Sep 17 00:00:00 2001 From: Kelley Nielsen Date: Sun, 27 Oct 2013 16:40:39 -0700 Subject: staging: ft1000: function scram_start_dwnld extracted from scram_dnldr in ft1000_download.c function scram_dnldr is over 500 lines long, with deep indents that trigger checkpatch warnings for too many tabs. It mainly consists of a switch statement with long, complicated cases. The first case has been extracted to form the helper function scram_start_dwnld. Some style issues in the extracted lines have been corrected as well. Signed-off-by: Kelley Nielsen Reviewed-by: Peter P Waskiewicz Jr Signed-off-by: Greg Kroah-Hartman --- .../staging/ft1000/ft1000-usb/ft1000_download.c | 46 +++++++++++----------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'drivers/staging/ft1000/ft1000-usb/ft1000_download.c') diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c index bfffce5b1445..4ac92eea3896 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c @@ -554,6 +554,27 @@ static u32 write_blk_fifo(struct ft1000_usb *ft1000dev, u16 **pUsFile, return Status; } +static int scram_start_dwnld(struct ft1000_usb *ft1000dev, u16 *hshake, + u32 *state) +{ + int status = STATUS_SUCCESS; + + DEBUG("FT1000:STATE_START_DWNLD\n"); + if (ft1000dev->usbboot) + *hshake = get_handshake_usb(ft1000dev, HANDSHAKE_DSP_BL_READY); + else + *hshake = get_handshake(ft1000dev, HANDSHAKE_DSP_BL_READY); + if (*hshake == HANDSHAKE_DSP_BL_READY) { + DEBUG("scram_dnldr: handshake is HANDSHAKE_DSP_BL_READY, call put_handshake(HANDSHAKE_DRIVER_READY)\n"); + put_handshake(ft1000dev, HANDSHAKE_DRIVER_READY); + } else { + DEBUG("FT1000:download:Download error: Handshake failed\n"); + status = STATUS_FAILURE; + } + *state = STATE_BOOT_DWNLD; + return status; +} + /* Scramble downloader for Harley based ASIC via USB interface */ u16 scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, u32 FileLength) @@ -617,29 +638,8 @@ u16 scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, while ((status == STATUS_SUCCESS) && (state != STATE_DONE_FILE)) { switch (state) { case STATE_START_DWNLD: - DEBUG("FT1000:STATE_START_DWNLD\n"); - if (ft1000dev->usbboot) - handshake = - get_handshake_usb(ft1000dev, - HANDSHAKE_DSP_BL_READY); - else - handshake = - get_handshake(ft1000dev, - HANDSHAKE_DSP_BL_READY); - - if (handshake == HANDSHAKE_DSP_BL_READY) { - DEBUG - ("scram_dnldr: handshake is HANDSHAKE_DSP_BL_READY, call put_handshake(HANDSHAKE_DRIVER_READY)\n"); - put_handshake(ft1000dev, - HANDSHAKE_DRIVER_READY); - } else { - DEBUG - ("FT1000:download:Download error: Handshake failed\n"); - status = STATUS_FAILURE; - } - - state = STATE_BOOT_DWNLD; - + status = scram_start_dwnld(ft1000dev, &handshake, + &state); break; case STATE_BOOT_DWNLD: -- cgit v1.2.3 From aaeb94c93ca6de2da1901a6ca97693672ab3458c Mon Sep 17 00:00:00 2001 From: Kelley Nielsen Date: Tue, 29 Oct 2013 08:01:50 -0700 Subject: 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: Kelley Nielsen Signed-off-by: Greg Kroah-Hartman --- .../staging/ft1000/ft1000-usb/ft1000_download.c | 67 +++++++++++----------- 1 file changed, 32 insertions(+), 35 deletions(-) (limited to 'drivers/staging/ft1000/ft1000-usb/ft1000_download.c') diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c index 4ac92eea3896..eeceb5355a99 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c @@ -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,41 +701,10 @@ 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); - break; + status = request_code_segment(ft1000dev, + &s_file, &c_file, + (const u8 *)boot_end); + break; default: DEBUG ("FT1000:download:Download error: Bad request type=%d in BOOT download state.\n", -- cgit v1.2.3 From e0a223b465c609e2d03bea3551183e9a8ad2be81 Mon Sep 17 00:00:00 2001 From: Kelley Nielsen Date: Tue, 29 Oct 2013 08:05:23 -0700 Subject: staging: ft1000: duplicate code replaced with call to request_code_segment function scram_dnldr, in ft1000_download.c, is very long and consists mainly of nested switch statements inside a while loop. Some code in one of the inner switch cases was almost identical to the code in the previously extracted function request_code_segment. The duplicated code was replaced with a call to request_code_segment, and request_code_segment was slightly modified to work in both cases. A new parameter was added to request_code_segment, a bool to distinguish which case it was replacing. The name of an existing parameter (now called endpoint) was changed to reflect the fact that it will be passed in from more than one place. Several lines from the case containing the duplicated code were moved to request_code_segment, and a test was added to determine if these lines or a line from the original function should be run. Finally, an unused variable (tempword) was removed from scram_dnldr. Signed-off-by: Kelley Nielsen Reviewed-by: Peter P Waskiewicz Jr Signed-off-by: Greg Kroah-Hartman --- .../staging/ft1000/ft1000-usb/ft1000_download.c | 64 +++++++--------------- 1 file changed, 19 insertions(+), 45 deletions(-) (limited to 'drivers/staging/ft1000/ft1000-usb/ft1000_download.c') diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c index eeceb5355a99..afeafcdd517f 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c @@ -576,7 +576,7 @@ static int scram_start_dwnld(struct ft1000_usb *ft1000dev, u16 *hshake, } static u16 request_code_segment(struct ft1000_usb *ft1000dev, u16 **s_file, - u8 **c_file, const u8 *boot_end) + u8 **c_file, const u8 *endpoint, bool boot_case) { long word_length; u16 status; @@ -589,7 +589,7 @@ static u16 request_code_segment(struct ft1000_usb *ft1000dev, u16 **s_file, DEBUG("FT1000:download:Download error: Max length exceeded\n"); return STATUS_FAILURE; } - if ((word_length * 2 + (long)c_file) > (long)boot_end) { + if ((word_length * 2 + (long)c_file) > (long)endpoint) { /* Error, beyond boot code range.*/ DEBUG("FT1000:download:Download error: Requested len=%d exceeds BOOT code boundary.\n", (int)word_length); return STATUS_FAILURE; @@ -597,9 +597,18 @@ static u16 request_code_segment(struct ft1000_usb *ft1000dev, u16 **s_file, 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); */ + if (boot_case) { + status = write_blk(ft1000dev, s_file, c_file, word_length); + /*DEBUG("write_blk returned %d\n", status); */ + } else { + write_blk_fifo(ft1000dev, s_file, c_file, word_length); + if (ft1000dev->usbboot == 0) + ft1000dev->usbboot++; + if (ft1000dev->usbboot == 1) + ft1000_write_dpram16(ft1000dev, + DWNLD_MAG1_PS_HDR_LOC, 0, 0); + } return status; } @@ -615,7 +624,6 @@ u16 scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, long word_length; u16 request; u16 temp; - u16 tempword; struct dsp_file_hdr *file_hdr; struct dsp_image_info *dsp_img_info = NULL; @@ -703,7 +711,8 @@ u16 scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, case REQUEST_CODE_SEGMENT: status = request_code_segment(ft1000dev, &s_file, &c_file, - (const u8 *)boot_end); + (const u8 *)boot_end, + true); break; default: DEBUG @@ -805,45 +814,10 @@ u16 scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, break; } - word_length = - get_request_value(ft1000dev); - //DEBUG("FT1000:download:word_length = %d\n", (int)word_length); - if (word_length > MAX_LENGTH) { - DEBUG - ("FT1000:download:Download error: Max length exceeded\n"); - status = STATUS_FAILURE; - break; - } - if ((word_length * 2 + c_file) > - code_end) { - /* - * Error, beyond boot code range. - */ - DEBUG - ("FT1000:download:Download error: Requested len=%d exceeds DSP 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; - - write_blk_fifo(ft1000dev, &s_file, - &c_file, word_length); - if (ft1000dev->usbboot == 0) - ft1000dev->usbboot++; - if (ft1000dev->usbboot == 1) { - tempword = 0; - ft1000_write_dpram16(ft1000dev, - DWNLD_MAG1_PS_HDR_LOC, - tempword, - 0); - } + status = request_code_segment(ft1000dev, + &s_file, &c_file, + (const u8 *)code_end, + false); break; -- cgit v1.2.3 From eb2ec63979702f04d45f608f635b0533defefa16 Mon Sep 17 00:00:00 2001 From: Kelley Nielsen Date: Tue, 29 Oct 2013 08:06:56 -0700 Subject: staging: ft1000: function write_dpram32_and_check extracted from write_blk function write_blk is long and overly complex, consisting of a triply nested loop. It also has improper indentation and line lengths throughout, and has return type of u32 rather than int. Some of the lines, when converted to proper indentation, create checkpatch warnings for too many leading tabs. This patch extracts the innermost loop into its own function, write_dpram32_and_check. This removes several levels of indentation from the extracted lines and makes the original function simpler. Two local variables from the original function, u16 resultbuffer[] and a loop counter, have been made local variables of the new function. Two calls to msleep() have been replaced with usleep_range() as per Documentation/ timers/timers-howto.txt (which was referred to in a checkpatch warning). Several other style issues in the extracted code have been corrected as well. Signed-off-by: Kelley Nielsen Signed-off-by: Greg Kroah-Hartman --- .../staging/ft1000/ft1000-usb/ft1000_download.c | 107 +++++++++++---------- 1 file changed, 58 insertions(+), 49 deletions(-) (limited to 'drivers/staging/ft1000/ft1000-usb/ft1000_download.c') diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c index afeafcdd517f..e5281b97775b 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c @@ -389,6 +389,61 @@ static int check_buffers(u16 *buff_w, u16 *buff_r, int len, int offset) return 0; } +static int write_dpram32_and_check(struct ft1000_usb *ft1000dev, + u16 tempbuffer[], u16 dpram) +{ + int status; + u16 resultbuffer[64]; + int i; + + for (i = 0; i < 10; i++) { + status = ft1000_write_dpram32(ft1000dev, dpram, + (u8 *)&tempbuffer[0], 64); + if (status == STATUS_SUCCESS) { + /* Work around for ASIC bit stuffing problem. */ + if ((tempbuffer[31] & 0xfe00) == 0xfe00) { + status = ft1000_write_dpram32(ft1000dev, + dpram+12, (u8 *)&tempbuffer[24], + 64); + } + /* Let's check the data written */ + status = ft1000_read_dpram32(ft1000dev, dpram, + (u8 *)&resultbuffer[0], 64); + if ((tempbuffer[31] & 0xfe00) == 0xfe00) { + if (check_buffers(tempbuffer, resultbuffer, 28, + 0)) { + DEBUG("FT1000:download:DPRAM write failed 1 during bootloading\n"); + usleep_range(9000, 11000); + status = STATUS_FAILURE; + break; + } + status = ft1000_read_dpram32(ft1000dev, + dpram+12, + (u8 *)&resultbuffer[0], 64); + + if (check_buffers(tempbuffer, resultbuffer, 16, + 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) + break; + } + } + return status; +} + /* writes a block of DSP image to DPRAM * Parameters: struct ft1000_usb - device structure * u16 **pUsFile - DSP image file pointer in u16 @@ -399,10 +454,9 @@ static u32 write_blk (struct ft1000_usb *ft1000dev, u16 **pUsFile, u8 **pUcFile, { u32 Status = STATUS_SUCCESS; u16 dpram; - int loopcnt, i, j; + int loopcnt, i; u16 tempword; u16 tempbuffer[64]; - u16 resultbuffer[64]; //DEBUG("FT1000:download:start word_length = %d\n",(int)word_length); dpram = (u16)DWNLD_MAG1_PS_HDR_LOC; @@ -452,53 +506,8 @@ static u32 write_blk (struct ft1000_usb *ft1000dev, u16 **pUsFile, u8 **pUcFile, } else { - for (j=0; j<10; j++) - { - Status = ft1000_write_dpram32 (ft1000dev, dpram, (u8 *)&tempbuffer[0], 64); - if (Status == STATUS_SUCCESS) - { - // Work around for ASIC bit stuffing problem. - if ( (tempbuffer[31] & 0xfe00) == 0xfe00) - { - Status = ft1000_write_dpram32(ft1000dev, dpram+12, (u8 *)&tempbuffer[24], 64); - } - // Let's check the data written - Status = ft1000_read_dpram32 (ft1000dev, dpram, (u8 *)&resultbuffer[0], 64); - if ( (tempbuffer[31] & 0xfe00) == 0xfe00) - { - if (check_buffers(tempbuffer, resultbuffer, 28, 0)) { - DEBUG("FT1000:download:DPRAM write failed 1 during bootloading\n"); - msleep(10); - Status = STATUS_FAILURE; - break; - } - Status = ft1000_read_dpram32 (ft1000dev, dpram+12, (u8 *)&resultbuffer[0], 64); - - if (check_buffers(tempbuffer, resultbuffer, 16, 24)) { - DEBUG("FT1000:download:DPRAM write failed 2 during bootloading\n"); - msleep(10); - Status = STATUS_FAILURE; - break; - } - - } - else - { - if (check_buffers(tempbuffer, resultbuffer, 32, 0)) { - DEBUG("FT1000:download:DPRAM write failed 3 during bootloading\n"); - msleep(10); - Status = STATUS_FAILURE; - break; - } - - } - - if (Status == STATUS_SUCCESS) - break; - - } - } - + Status = write_dpram32_and_check(ft1000dev, tempbuffer, + dpram); if (Status != STATUS_SUCCESS) { DEBUG("FT1000:download:Write failed tempbuffer[31] = 0x%x\n", tempbuffer[31]); -- cgit v1.2.3 From 74827f8dfa52103db66c32958f2844abbcec92c5 Mon Sep 17 00:00:00 2001 From: Kelley Nielsen Date: Tue, 29 Oct 2013 08:07:40 -0700 Subject: staging: ft1000: style issues fixed in write_blk function write_blk, in ft1000_download.c, contains many coding style issues. It has indentations of 3 spaces, long lines, C99 comments, and extra whitespace. It also has a return type of u32, and changing the returned variable in the function triggers a checkpatch leading spaces warning. Indentation should be fixed throughout the file for consistency. This patch fixes those issues, in preparation for correcting the status return type throughout the file. The variable Status has been changed from u32 to int and renamed status. Signed-off-by: Kelley Nielsen Signed-off-by: Greg Kroah-Hartman --- .../staging/ft1000/ft1000-usb/ft1000_download.c | 123 ++++++++++----------- 1 file changed, 57 insertions(+), 66 deletions(-) (limited to 'drivers/staging/ft1000/ft1000-usb/ft1000_download.c') diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c index e5281b97775b..57bd87b91e3c 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c @@ -450,75 +450,66 @@ static int write_dpram32_and_check(struct ft1000_usb *ft1000dev, * u8 **pUcFile - DSP image file pointer in u8 * long word_length - length of the buffer to be written to DPRAM */ -static u32 write_blk (struct ft1000_usb *ft1000dev, u16 **pUsFile, u8 **pUcFile, long word_length) +static int write_blk(struct ft1000_usb *ft1000dev, u16 **pUsFile, u8 **pUcFile, + long word_length) { - u32 Status = STATUS_SUCCESS; - u16 dpram; - int loopcnt, i; - u16 tempword; - u16 tempbuffer[64]; - - //DEBUG("FT1000:download:start word_length = %d\n",(int)word_length); - dpram = (u16)DWNLD_MAG1_PS_HDR_LOC; - tempword = *(*pUsFile); - (*pUsFile)++; - Status = ft1000_write_dpram16(ft1000dev, dpram, tempword, 0); - tempword = *(*pUsFile); - (*pUsFile)++; - Status = ft1000_write_dpram16(ft1000dev, dpram++, tempword, 1); - - *pUcFile = *pUcFile + 4; - word_length--; - tempword = (u16)word_length; - word_length = (word_length / 16) + 1; - for (; word_length > 0; word_length--) /* In words */ - { - loopcnt = 0; - - for (i=0; i<32; i++) - { - if (tempword != 0) - { - tempbuffer[i++] = *(*pUsFile); - (*pUsFile)++; - tempbuffer[i] = *(*pUsFile); - (*pUsFile)++; - *pUcFile = *pUcFile + 4; - loopcnt++; - tempword--; - } - else - { - tempbuffer[i++] = 0; - tempbuffer[i] = 0; - } - } - - //DEBUG("write_blk: loopcnt is %d\n", loopcnt); - //DEBUG("write_blk: bootmode = %d\n", bootmode); - //DEBUG("write_blk: dpram = %x\n", dpram); - if (ft1000dev->bootmode == 0) - { - if (dpram >= 0x3F4) - Status = ft1000_write_dpram32 (ft1000dev, dpram, (u8 *)&tempbuffer[0], 8); - else - Status = ft1000_write_dpram32 (ft1000dev, dpram, (u8 *)&tempbuffer[0], 64); - } - else - { - Status = write_dpram32_and_check(ft1000dev, tempbuffer, - dpram); - if (Status != STATUS_SUCCESS) - { - DEBUG("FT1000:download:Write failed tempbuffer[31] = 0x%x\n", tempbuffer[31]); - break; + int status = STATUS_SUCCESS; + u16 dpram; + int loopcnt, i; + u16 tempword; + u16 tempbuffer[64]; + + /*DEBUG("FT1000:download:start word_length = %d\n",(int)word_length); */ + dpram = (u16)DWNLD_MAG1_PS_HDR_LOC; + tempword = *(*pUsFile); + (*pUsFile)++; + status = ft1000_write_dpram16(ft1000dev, dpram, tempword, 0); + tempword = *(*pUsFile); + (*pUsFile)++; + status = ft1000_write_dpram16(ft1000dev, dpram++, tempword, 1); + + *pUcFile = *pUcFile + 4; + word_length--; + tempword = (u16)word_length; + word_length = (word_length / 16) + 1; + for (; word_length > 0; word_length--) { /* In words */ + loopcnt = 0; + for (i = 0; i < 32; i++) { + if (tempword != 0) { + tempbuffer[i++] = *(*pUsFile); + (*pUsFile)++; + tempbuffer[i] = *(*pUsFile); + (*pUsFile)++; + *pUcFile = *pUcFile + 4; + loopcnt++; + tempword--; + } else { + tempbuffer[i++] = 0; + tempbuffer[i] = 0; + } } - } - dpram = dpram + loopcnt; - } - - return Status; + /*DEBUG("write_blk: loopcnt is %d\n", loopcnt); */ + /*DEBUG("write_blk: bootmode = %d\n", bootmode); */ + /*DEBUG("write_blk: dpram = %x\n", dpram); */ + if (ft1000dev->bootmode == 0) { + if (dpram >= 0x3F4) + status = ft1000_write_dpram32(ft1000dev, dpram, + (u8 *)&tempbuffer[0], 8); + else + status = ft1000_write_dpram32(ft1000dev, dpram, + (u8 *)&tempbuffer[0], 64); + } else { + status = write_dpram32_and_check(ft1000dev, tempbuffer, + dpram); + if (status != STATUS_SUCCESS) { + DEBUG("FT1000:download:Write failed tempbuffer[31] = 0x%x\n", tempbuffer[31]); + break; + } + } + dpram = dpram + loopcnt; + } + return status; } static void usb_dnld_complete (struct urb *urb) -- cgit v1.2.3 From 8cf9ff570b73273c6439ade681466c87199a8104 Mon Sep 17 00:00:00 2001 From: Kelley Nielsen Date: Tue, 29 Oct 2013 08:08:06 -0700 Subject: staging: ft1000: status variables changed to int in ft1000_download.c Linux uses a return type of int for status codes. The file ft1000_download.c uses a mixture of u16 and u32. This patch changes all variables called status or Status to ints, whether they are returned from the function or not. It also changes the return type of all functions returning one of the variables to correspond. Also, the declaration of scram_dnldr has been changed in ft1000_usb.h. Signed-off-by: Kelley Nielsen Signed-off-by: Greg Kroah-Hartman --- .../staging/ft1000/ft1000-usb/ft1000_download.c | 30 +++++++++++----------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'drivers/staging/ft1000/ft1000-usb/ft1000_download.c') diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c index 57bd87b91e3c..605156852b44 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c @@ -108,11 +108,11 @@ struct dsp_image_info { /* checks if the doorbell register is cleared */ -static u32 check_usb_db(struct ft1000_usb *ft1000dev) +static int check_usb_db(struct ft1000_usb *ft1000dev) { int loopcnt; u16 temp; - u32 status; + int status; loopcnt = 0; @@ -159,7 +159,7 @@ static u16 get_handshake(struct ft1000_usb *ft1000dev, u16 expected_value) { u16 handshake; int loopcnt; - u32 status = 0; + int status = 0; loopcnt = 0; @@ -206,7 +206,7 @@ static void put_handshake(struct ft1000_usb *ft1000dev,u16 handshake_value) { u32 tempx; u16 tempword; - u32 status; + int status; tempx = (u32)handshake_value; tempx = ntohl(tempx); @@ -226,7 +226,7 @@ static u16 get_handshake_usb(struct ft1000_usb *ft1000dev, u16 expected_value) u16 handshake; int loopcnt; u16 temp; - u32 status = 0; + int status = 0; loopcnt = 0; handshake = 0; @@ -278,7 +278,7 @@ static void put_handshake_usb(struct ft1000_usb *ft1000dev,u16 handshake_value) static u16 get_request_type(struct ft1000_usb *ft1000dev) { u16 request_type; - u32 status; + int status; u16 tempword; u32 tempx; @@ -301,7 +301,7 @@ static u16 get_request_type(struct ft1000_usb *ft1000dev) static u16 get_request_type_usb(struct ft1000_usb *ft1000dev) { u16 request_type; - u32 status; + int status; u16 tempword; u32 tempx; @@ -331,7 +331,7 @@ static long get_request_value(struct ft1000_usb *ft1000dev) { u32 value; u16 tempword; - u32 status; + int status; if (ft1000dev->bootmode == 1) { status = fix_ft1000_read_dpram32(ft1000dev, @@ -355,7 +355,7 @@ static long get_request_value(struct ft1000_usb *ft1000dev) static void put_request_value(struct ft1000_usb *ft1000dev, long lvalue) { u32 tempx; - u32 status; + int status; tempx = ntohl(lvalue); status = fix_ft1000_write_dpram32(ft1000dev, DWNLD_MAG1_SIZE_LOC, @@ -523,10 +523,10 @@ static void usb_dnld_complete (struct urb *urb) * u8 **pUcFile - DSP image file pointer in u8 * long word_length - length of the buffer to be written to DPRAM */ -static u32 write_blk_fifo(struct ft1000_usb *ft1000dev, u16 **pUsFile, +static int write_blk_fifo(struct ft1000_usb *ft1000dev, u16 **pUsFile, u8 **pUcFile, long word_length) { - u32 Status = STATUS_SUCCESS; + int Status = STATUS_SUCCESS; int byte_length; byte_length = word_length * 4; @@ -575,11 +575,11 @@ 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, +static int request_code_segment(struct ft1000_usb *ft1000dev, u16 **s_file, u8 **c_file, const u8 *endpoint, bool boot_case) { long word_length; - u16 status; + int status; /*DEBUG("FT1000:REQUEST_CODE_SEGMENT\n");i*/ word_length = get_request_value(ft1000dev); @@ -613,10 +613,10 @@ static u16 request_code_segment(struct ft1000_usb *ft1000dev, u16 **s_file, } /* Scramble downloader for Harley based ASIC via USB interface */ -u16 scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, +int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, u32 FileLength) { - u16 status = STATUS_SUCCESS; + int status = STATUS_SUCCESS; u32 state; u16 handshake; struct pseudo_hdr *pseudo_header; -- cgit v1.2.3 From 43fc69b1122b8a3e540b9d6ab36dc9840fa918ff Mon Sep 17 00:00:00 2001 From: Kelley Nielsen Date: Tue, 29 Oct 2013 14:54:31 -0700 Subject: 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 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'drivers/staging/ft1000/ft1000-usb/ft1000_download.c') 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; } } -- cgit v1.2.3 From b1bdd4d3ed3b501063d81618be547be0cfe61b0f Mon Sep 17 00:00:00 2001 From: Kelley Nielsen Date: Tue, 29 Oct 2013 16:06:36 -0700 Subject: staging: ft1000: return values corrected in scram_start_dwnld 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 values of the function scram_start_dwnld to match the status of the handshake returned by its helper functions, get_handshake and get_handshake_usb. If the handshake fails, -ENETRESET is returned instead of the inappropriate STATUS_FAILURE. Also, a new test has been added to differentiate failure due to timeout from failure due to net reset (the default). -ETIMEDOUT is returned in this case. Finally, 0 is returned on success instead of STATUS_SUCCESS. Signed-off-by: Kelley Nielsen Suggested-by: Greg Kroah-Hartman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ft1000/ft1000-usb/ft1000_download.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'drivers/staging/ft1000/ft1000-usb/ft1000_download.c') diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c index 72f3cfc95aa1..68ded17c0f5c 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c @@ -554,7 +554,7 @@ static int write_blk_fifo(struct ft1000_usb *ft1000dev, u16 **pUsFile, static int scram_start_dwnld(struct ft1000_usb *ft1000dev, u16 *hshake, u32 *state) { - int status = STATUS_SUCCESS; + int status = 0; DEBUG("FT1000:STATE_START_DWNLD\n"); if (ft1000dev->usbboot) @@ -564,9 +564,11 @@ static int scram_start_dwnld(struct ft1000_usb *ft1000dev, u16 *hshake, if (*hshake == HANDSHAKE_DSP_BL_READY) { DEBUG("scram_dnldr: handshake is HANDSHAKE_DSP_BL_READY, call put_handshake(HANDSHAKE_DRIVER_READY)\n"); put_handshake(ft1000dev, HANDSHAKE_DRIVER_READY); + } else if (*hshake == HANDSHAKE_TIMEOUT_VALUE) { + status = -ETIMEDOUT; } else { DEBUG("FT1000:download:Download error: Handshake failed\n"); - status = STATUS_FAILURE; + status = -ENETRESET; } *state = STATE_BOOT_DWNLD; return status; -- cgit v1.2.3 From 8aced950222434b84e568663f5941ea39f112a7f Mon Sep 17 00:00:00 2001 From: Michal Nazarewicz Date: Sun, 10 Nov 2013 19:37:54 +0100 Subject: staging: ft1000: fix use of potentially uninitialized variable If boot_case is false, status in never assigned a value. Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ft1000/ft1000-usb/ft1000_download.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/staging/ft1000/ft1000-usb/ft1000_download.c') diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c index 68ded17c0f5c..12f333fa59b5 100644 --- a/drivers/staging/ft1000/ft1000-usb/ft1000_download.c +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_download.c @@ -578,7 +578,7 @@ static int request_code_segment(struct ft1000_usb *ft1000dev, u16 **s_file, u8 **c_file, const u8 *endpoint, bool boot_case) { long word_length; - int status; + int status = 0; /*DEBUG("FT1000:REQUEST_CODE_SEGMENT\n");i*/ word_length = get_request_value(ft1000dev); @@ -1074,4 +1074,3 @@ int scram_dnldr(struct ft1000_usb *ft1000dev, void *pFileStart, return status; } - -- cgit v1.2.3