Staging: rts5208: Coding style and dma mapping fixes
cover Staging: rts5208: Coding style and dma mapping fixes
This set of patches fixes the coding style issues in rtsx_transport.c, and adds a missing dma_mapping_error check.
PATCH 1/2 Staging: rts5208: Cleanup rtsx_transport.c
This patch fixes coding style issues in rtsx_transport.c.
--- drivers/staging/rts5208/rtsx_transport.c | 115 +++++++++++++++++-------------- 1 file changed, 65 insertions(+), 50 deletions(-)
drivers/staging/rts5208/rtsx_transport.c +65 -50
@@ -36,25 +36,30 @@* For non-scatter-gather transfers, srb->request_buffer points to the * transfer buffer itself and srb->request_bufflen is the buffer's length.) * Update the *index and *offset variables so that the next copy will -* pick up from where this one left off. */ +* pick up from where this one left off. +*/ unsigned int rtsx_stor_access_xfer_buf (unsigned char *buffer, -unsigned int buflen,struct scsi_cmnd *srb,unsigned int *index, -unsigned int *offset,enum xfer_buf_dir dir) +unsigned int buflen, +struct scsi_cmnd *srb, +unsigned int *index, +unsigned int *offset, +enum xfer_buf_dir dir) {unsigned int cnt;/* If not using scatter-gather, just transfer the data directly. -* Make certain it will fit in the available buffer space. */ +* Make certain it will fit in the available buffer space. +*/ if (scsi_sg_count (srb) ==0 ) {if (*offset >=scsi_bufflen (srb))return 0 ; cnt =min (buflen,scsi_bufflen (srb) - *offset);if (dir ==TO_XFER_BUF ) -memcpy ((unsigned char *)scsi_sglist (srb) + *offset, - buffer, cnt); +memcpy ((unsigned char *)scsi_sglist (srb) + *offset, + buffer, cnt);else -memcpy (buffer, (unsigned char *)scsi_sglist (srb) + +memcpy (buffer, (unsigned char *)scsi_sglist (srb) + *offset, cnt); *offset += cnt;
@@ -64,31 +69,31 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer,* in kernel-addressable memory then kmap() will return its address. * If the page is not directly accessible -- such as a user buffer * located in high memory -- then kmap() will map it to a temporary -* position in the kernel's virtual address space. */ +* position in the kernel's virtual address space. +*/ }else {struct scatterlist *sg = - (struct scatterlist *)scsi_sglist (srb) + (struct scatterlist *)scsi_sglist (srb) + *index;/* This loop handles a single s-g list entry, which may * include multiple pages. Find the initial page structure * and the starting offset within the page, and update -* the *offset and *index values for the next loop. */ +* the *offset and *index values for the next loop. +*/ cnt =0 ;while (cnt < buflen && *index <scsi_sg_count (srb)) {struct page *page =sg_page (sg) + ((sg->offset + *offset) >>PAGE_SHIFT ); -unsigned int poff = - (sg->offset + *offset) & (PAGE_SIZE -1 ); +unsigned int poff = (sg->offset + *offset) & + (PAGE_SIZE -1 );unsigned int sglen = sg->length - *offset;if (sglen > buflen - cnt) { -/* Transfer ends within this s-g entry */ sglen = buflen - cnt; *offset += sglen; }else { -/* Transfer continues to next s-g entry */ *offset =0 ; ++*index;
@@ -97,7 +102,8 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer,/* Transfer the data for all the pages in this * s-g entry. For each page: call kmap(), do the -* transfer, and call kunmap() immediately after. */ +* transfer, and call kunmap() immediately after. +*/ while (sglen >0 ) {unsigned int plen =min (sglen, (unsigned int )PAGE_SIZE - poff);
@@ -123,9 +129,10 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer, }/* Store the contents of buffer into srb's transfer buffer and set the -* SCSI residue. */ +* SCSI residue. +*/ void rtsx_stor_set_xfer_buf (unsigned char *buffer, -unsigned int buflen,struct scsi_cmnd *srb) +unsigned int buflen,struct scsi_cmnd *srb) {unsigned int index =0 , offset =0 ;
@@ -136,7 +143,7 @@ void rtsx_stor_set_xfer_buf(unsigned char *buffer, }void rtsx_stor_get_xfer_buf (unsigned char *buffer, -unsigned int buflen,struct scsi_cmnd *srb) +unsigned int buflen,struct scsi_cmnd *srb) {unsigned int index =0 , offset =0 ;
@@ -146,7 +153,6 @@ void rtsx_stor_get_xfer_buf(unsigned char *buffer,scsi_set_resid (srb,scsi_bufflen (srb) - buflen); } -/*********************************************************************** * Transport routines ***********************************************************************/
@@ -167,14 +173,14 @@ void rtsx_invoke_transport(struct scsi_cmnd *srb, struct rtsx_chip *chip)if (rtsx_chk_stat (chip,RTSX_STAT_ABORT )) {dev_dbg (rtsx_dev (chip),"-- command was aborted\n" ); srb->result =DID_ABORT <<16 ; - goto Handle_Errors; + goto handle_errors; }/* if there is a transport error, reset and don't auto-sense */ if (result ==TRANSPORT_ERROR ) {dev_dbg (rtsx_dev (chip),"-- transport indicates error, resetting\n" ); srb->result =DID_ERROR <<16 ; - goto Handle_Errors; + goto handle_errors; } srb->result =SAM_STAT_GOOD ;
@@ -188,7 +194,7 @@ void rtsx_invoke_transport(struct scsi_cmnd *srb, struct rtsx_chip *chip)/* set the result so the higher layers expect this data */ srb->result =SAM_STAT_CHECK_CONDITION ;memcpy (srb->sense_buffer, - (unsigned char *)&(chip->sense_buffer[SCSI_LUN (srb)]), + (unsigned char *)&chip->sense_buffer[SCSI_LUN (srb)],sizeof (struct sense_data_t )); }
@@ -196,13 +202,14 @@ void rtsx_invoke_transport(struct scsi_cmnd *srb, struct rtsx_chip *chip)/* Error and abort processing: try to resynchronize with the device * by issuing a port reset. If that fails, try a class-specific -* device reset. */ -Handle_Errors: +* device reset. +*/ +handle_errors:return ; }void rtsx_add_cmd (struct rtsx_chip *chip, -u8 cmd_type,u16 reg_addr,u8 mask,u8 data) +u8 cmd_type,u16 reg_addr,u8 mask,u8 data) {u32 *cb = (u32 *)(chip->host_cmds_ptr);u32 val =0 ;
@@ -321,9 +328,11 @@ static inline void rtsx_add_sg_tbl( }static int rtsx_transfer_sglist_adma_partial (struct rtsx_chip *chip,u8 card, -struct scatterlist *sg,int num_sg,unsigned int *index, -unsigned int *offset,int size, -enum dma_data_direction dma_dir,int timeout) +struct scatterlist *sg,int num_sg, +unsigned int *index, +unsigned int *offset,int size, +enum dma_data_direction dma_dir, +int timeout) {struct rtsx_dev *rtsx = chip->rtsx;struct completion trans_done;
@@ -334,7 +343,7 @@ static int rtsx_transfer_sglist_adma_partial(struct rtsx_chip *chip, u8 card,struct scatterlist *sg_ptr;u32 val =TRIG_DMA ; -if ((sg ==NULL ) || (num_sg <=0 ) || !offset || !index) +if ((!sg) || (num_sg <=0 ) || !offset || !index)return -EIO ;if (dma_dir ==DMA_TO_DEVICE )
@@ -363,7 +372,7 @@ static int rtsx_transfer_sglist_adma_partial(struct rtsx_chip *chip, u8 card,spin_unlock_irq (&rtsx->reg_lock); - sg_cnt =dma_map_sg (&(rtsx->pci->dev), sg, num_sg, dma_dir); + sg_cnt =dma_map_sg (&rtsx->pci->dev, sg, num_sg, dma_dir); resid = size; sg_ptr = sg;
@@ -476,7 +485,7 @@ static int rtsx_transfer_sglist_adma_partial(struct rtsx_chip *chip, u8 card, out: rtsx->done =NULL ; rtsx->trans_state =STATE_TRANS_NONE ; -dma_unmap_sg (&(rtsx->pci->dev), sg, num_sg, dma_dir); +dma_unmap_sg (&rtsx->pci->dev, sg, num_sg, dma_dir);if (err <0 )rtsx_stop_cmd (chip, card);
@@ -485,7 +494,7 @@ out: }static int rtsx_transfer_sglist_adma (struct rtsx_chip *chip,u8 card, -struct scatterlist *sg,int num_sg, +struct scatterlist *sg,int num_sg,enum dma_data_direction dma_dir,int timeout) {struct rtsx_dev *rtsx = chip->rtsx;
@@ -496,7 +505,7 @@ static int rtsx_transfer_sglist_adma(struct rtsx_chip *chip, u8 card,long timeleft;struct scatterlist *sg_ptr; -if ((sg ==NULL ) || (num_sg <=0 )) +if ((!sg) || (num_sg <=0 ))return -EIO ;if (dma_dir ==DMA_TO_DEVICE )
@@ -525,7 +534,7 @@ static int rtsx_transfer_sglist_adma(struct rtsx_chip *chip, u8 card,spin_unlock_irq (&rtsx->reg_lock); - buf_cnt =dma_map_sg (&(rtsx->pci->dev), sg, num_sg, dma_dir); + buf_cnt =dma_map_sg (&rtsx->pci->dev, sg, num_sg, dma_dir); sg_ptr = sg;
@@ -623,7 +632,7 @@ static int rtsx_transfer_sglist_adma(struct rtsx_chip *chip, u8 card, out: rtsx->done =NULL ; rtsx->trans_state =STATE_TRANS_NONE ; -dma_unmap_sg (&(rtsx->pci->dev), sg, num_sg, dma_dir); +dma_unmap_sg (&rtsx->pci->dev, sg, num_sg, dma_dir);if (err <0 )rtsx_stop_cmd (chip, card);
@@ -632,7 +641,8 @@ out: }static int rtsx_transfer_buf (struct rtsx_chip *chip,u8 card,void *buf, -size_t len,enum dma_data_direction dma_dir,int timeout) +size_t len,enum dma_data_direction dma_dir, +int timeout) {struct rtsx_dev *rtsx = chip->rtsx;struct completion trans_done;
@@ -642,7 +652,7 @@ static int rtsx_transfer_buf(struct rtsx_chip *chip, u8 card, void *buf,u32 val =1 <<31 ;long timeleft; -if ((buf ==NULL ) || (len <=0 )) +if ((!buf) || (len <=0 ))return -EIO ;if (dma_dir ==DMA_TO_DEVICE )
@@ -652,7 +662,7 @@ static int rtsx_transfer_buf(struct rtsx_chip *chip, u8 card, void *buf,else return -ENXIO ; - addr =dma_map_single (&(rtsx->pci->dev), buf, len, dma_dir); + addr =dma_map_single (&rtsx->pci->dev, buf, len, dma_dir);if (!addr)return -ENOMEM ;
@@ -706,7 +716,7 @@ static int rtsx_transfer_buf(struct rtsx_chip *chip, u8 card, void *buf, out: rtsx->done =NULL ; rtsx->trans_state =STATE_TRANS_NONE ; -dma_unmap_single (&(rtsx->pci->dev), addr, len, dma_dir); +dma_unmap_single (&rtsx->pci->dev, addr, len, dma_dir);if (err <0 )rtsx_stop_cmd (chip, card);
@@ -715,9 +725,11 @@ out: }int rtsx_transfer_data_partial (struct rtsx_chip *chip,u8 card, -void *buf,size_t len,int use_sg,unsigned int *index, -unsigned int *offset,enum dma_data_direction dma_dir, -int timeout) +void *buf,size_t len,int use_sg, +unsigned int *index, +unsigned int *offset, +enum dma_data_direction dma_dir, +int timeout) {int err =0 ;
@@ -725,11 +737,15 @@ int rtsx_transfer_data_partial(struct rtsx_chip *chip, u8 card,if (rtsx_chk_stat (chip,RTSX_STAT_ABORT ))return -EIO ; -if (use_sg) +if (use_sg) { +struct scatterlist *sg = (struct scatterlist *)buf; + err =rtsx_transfer_sglist_adma_partial (chip, card, - (struct scatterlist *)buf, use_sg, - index, offset, (int )len, dma_dir, timeout); -else + sg, + use_sg, + index, offset, (int )len, + dma_dir, timeout); + }else err =rtsx_transfer_buf (chip, card, buf, len, dma_dir, timeout);if (err <0 ) {
@@ -744,7 +760,7 @@ int rtsx_transfer_data_partial(struct rtsx_chip *chip, u8 card, }int rtsx_transfer_data (struct rtsx_chip *chip,u8 card,void *buf,size_t len, -int use_sg,enum dma_data_direction dma_dir,int timeout) +int use_sg,enum dma_data_direction dma_dir,int timeout) {int err =0 ;
@@ -756,8 +772,8 @@ int rtsx_transfer_data(struct rtsx_chip *chip, u8 card, void *buf, size_t len,if (use_sg) { err =rtsx_transfer_sglist_adma (chip, card, - (struct scatterlist *)buf, - use_sg, dma_dir, timeout); + (struct scatterlist *)buf, + use_sg, dma_dir, timeout); }else { err =rtsx_transfer_buf (chip, card, buf, len, dma_dir, timeout); }
@@ -772,4 +788,3 @@ int rtsx_transfer_data(struct rtsx_chip *chip, u8 card, void *buf, size_t len,return err; } -
Signature · 1 line
2.7.0
Greg KH
maintainerRe: [PATCH 1/2] Staging: rts5208: Cleanup rtsx_transport.c
Quoted 6 lines · Shaun Ren
This patch fixes coding style issues in
rtsx_transport.c.Signed-off-by Shaun Ren <[email protected]>--- drivers/staging/rts5208/rtsx_transport.c | 115 +++++++++++++++++-------------- 1 file changed, 65 insertions(+), 50 deletions(-)
What coding style issues? Please be specific, and only do one type of cleanup per patch, otherwise it's hard to review them.
thanks,
greg k-h
PATCH 2/2 Staging: rts5208: Add missing dma_mapping_error
In reply to Shaun Ren--- drivers/staging/rts5208/rtsx_transport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rts5208/rtsx_transport.c +1 -1
@@ -663,7 +663,7 @@ static int rtsx_transfer_buf(struct rtsx_chip *chip, u8 card, void *buf,return -ENXIO ; addr =dma_map_single (&rtsx->pci->dev, buf, len, dma_dir); -if (!addr) +if (dma_mapping_error (&rtsx->pci->dev, addr))return -ENOMEM ;if (card ==SD_CARD )
Signature · 1 line
2.7.0
Greg KH
maintainerRe: [PATCH 2/2] Staging: rts5208: Add missing dma_mapping_error
Quoted 2 lines · Shaun Ren
Signed-off-by Shaun Ren <[email protected]>---
I can't take a patch without a changelog entry, sorry.
v2 cover Staging: rts5208: Coding style and dma mapping fixes
In reply to Shaun RenThis set of patches fixes the coding style issues in rtsx_transport.c, and dds a missing call dma_mapping_error() after dma_map_single().
PATCH v2 1/9 Staging: rts5208: rtsx_transport.c: Fix comment style warnings
This patch fixes all comment style warnings in rtsx_transport.c reported by checkpatch.pl:
WARNING: Block comments use a trailing */ on a separate line
--- drivers/staging/rts5208/rtsx_transport.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
drivers/staging/rts5208/rtsx_transport.c +14 -7
@@ -36,7 +36,8 @@* For non-scatter-gather transfers, srb->request_buffer points to the * transfer buffer itself and srb->request_bufflen is the buffer's length.) * Update the *index and *offset variables so that the next copy will -* pick up from where this one left off. */ +* pick up from where this one left off. +*/ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer, unsigned int buflen, struct scsi_cmnd *srb, unsigned int *index,
@@ -45,7 +46,8 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer,unsigned int cnt;/* If not using scatter-gather, just transfer the data directly. -* Make certain it will fit in the available buffer space. */ +* Make certain it will fit in the available buffer space. +*/ if (scsi_sg_count (srb) ==0 ) {if (*offset >=scsi_bufflen (srb))return 0 ;
@@ -64,7 +66,8 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer,* in kernel-addressable memory then kmap() will return its address. * If the page is not directly accessible -- such as a user buffer * located in high memory -- then kmap() will map it to a temporary -* position in the kernel's virtual address space. */ +* position in the kernel's virtual address space. +*/ }else {struct scatterlist *sg = (struct scatterlist *)scsi_sglist (srb)
@@ -73,7 +76,8 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer,/* This loop handles a single s-g list entry, which may * include multiple pages. Find the initial page structure * and the starting offset within the page, and update -* the *offset and *index values for the next loop. */ +* the *offset and *index values for the next loop. +*/ cnt =0 ;while (cnt < buflen && *index <scsi_sg_count (srb)) { struct page *page = sg_page(sg) +
@@ -97,7 +101,8 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer,/* Transfer the data for all the pages in this * s-g entry. For each page: call kmap(), do the -* transfer, and call kunmap() immediately after. */ +* transfer, and call kunmap() immediately after. +*/ while (sglen >0 ) {unsigned int plen =min (sglen, (unsigned int )PAGE_SIZE - poff);
@@ -123,7 +128,8 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer, }/* Store the contents of buffer into srb's transfer buffer and set the -* SCSI residue. */ +* SCSI residue. +*/ void rtsx_stor_set_xfer_buf (unsigned char *buffer,unsigned int buflen,struct scsi_cmnd *srb) {
@@ -196,7 +202,8 @@ void rtsx_invoke_transport(struct scsi_cmnd *srb, struct rtsx_chip *chip)/* Error and abort processing: try to resynchronize with the device * by issuing a port reset. If that fails, try a class-specific -* device reset. */ +* device reset. +*/ Handle_Errors:return ; }
Signature · 1 line
2.7.0
Re: [PATCH v2 1/9] Staging: rts5208: rtsx_transport.c: Fix comment style warnings
Hello Shaun,
/*
* Multiline comments (except in the net subsystem) should
* start with "/*" on a separate line. see Documentation/CodingStyle */
If you are going to fix the comments you should get both the beginning and the end.
More comments inline.
Quoted 15 lines · Shaun Ren
This patch fixes all comment style warnings in
rtsx_transport.creported by checkpatch.pl:WARNING: Block comments use a trailing */ on a separate line
Signed-off-by Shaun Ren <[email protected]>--- drivers/staging/rts5208/rtsx_transport.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)drivers/staging/rts5208/rtsx_transport.c +0
-0
drivers/staging/rts5208/rtsx_transport.c line 41
Quoted 7 lines
drivers/staging/rts5208/rtsx_transport.c +2
-1@@ -36,7 +36,8 @@* For non-scatter-gather transfers, srb->request_buffer points to the * transfer buffer itself and srb->request_bufflen is the buffer's length.) * Update the *index and *offset variables so that the next copy will -* pick up from where this one left off. */ +* pick up from where this one left off. +*/
Fix the beginning too, as mentioned above.
drivers/staging/rts5208/rtsx_transport.c unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer, · line 50
Quoted 9 lines
drivers/staging/rts5208/rtsx_transport.c +2
-1unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer, unsigned int buflen, struct scsi_cmnd *srb, unsigned int *index,@@ -45,7 +46,8 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer,unsigned int cnt;/* If not using scatter-gather, just transfer the data directly. -* Make certain it will fit in the available buffer space. */ +* Make certain it will fit in the available buffer space. +*/
Either fix the beginning... or better yet, get rid of the useless (obvious) second line so it can be a single line comment.
drivers/staging/rts5208/rtsx_transport.c unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer, · line 70
Quoted 10 lines
drivers/staging/rts5208/rtsx_transport.c +2
-1if (scsi_sg_count (srb) ==0 ) {if (*offset >=scsi_bufflen (srb))return 0 ;@@ -64,7 +66,8 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer,* in kernel-addressable memory then kmap() will return its address. * If the page is not directly accessible -- such as a user buffer * located in high memory -- then kmap() will map it to a temporary -* position in the kernel's virtual address space. */ +* position in the kernel's virtual address space. +*/
Fix the beginning of this comment as well.
Also, from "If the page is already in kernel -addressible memory..." on is just a description of what kmap() does.
I'd get rid of those lines.
drivers/staging/rts5208/rtsx_transport.c unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer, · line 80
Quoted 10 lines
drivers/staging/rts5208/rtsx_transport.c +2
-1}else {struct scatterlist *sg = (struct scatterlist *)scsi_sglist (srb)@@ -73,7 +76,8 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer,/* This loop handles a single s-g list entry, which may * include multiple pages. Find the initial page structure * and the starting offset within the page, and update -* the *offset and *index values for the next loop. */ +* the *offset and *index values for the next loop. +*/
Fix the beginning of this comment.
drivers/staging/rts5208/rtsx_transport.c unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer, · line 105
Quoted 10 lines
drivers/staging/rts5208/rtsx_transport.c +2
-1cnt =0 ;while (cnt < buflen && *index <scsi_sg_count (srb)) { struct page *page = sg_page(sg) +@@ -97,7 +101,8 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer,/* Transfer the data for all the pages in this * s-g entry. For each page: call kmap(), do the -* transfer, and call kunmap() immediately after. */ +* transfer, and call kunmap() immediately after. +*/
I'd get rid of this comment. It parrots what the code does, but does not add any information.
drivers/staging/rts5208/rtsx_transport.c unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer, · line 132
Quoted 10 lines
drivers/staging/rts5208/rtsx_transport.c +2
-1while (sglen >0 ) {unsigned int plen =min (sglen, (unsigned int )PAGE_SIZE - poff);@@ -123,7 +128,8 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer, }/* Store the contents of buffer into srb's transfer buffer and set the -* SCSI residue. */ +* SCSI residue. +*/
Fix the beginning as well.
drivers/staging/rts5208/rtsx_transport.c void rtsx_invoke_transport(struct scsi_cmnd *srb, struct rtsx_chip *chip) · line 206
Quoted 10 lines
drivers/staging/rts5208/rtsx_transport.c +2
-1void rtsx_stor_set_xfer_buf (unsigned char *buffer,unsigned int buflen,struct scsi_cmnd *srb) {@@ -196,7 +202,8 @@ void rtsx_invoke_transport(struct scsi_cmnd *srb, struct rtsx_chip *chip)/* Error and abort processing: try to resynchronize with the device * by issuing a port reset. If that fails, try a class-specific -* device reset. */ +* device reset. +*/
This comment describes something that does not happen in this function. Perhaps it did at one point. Regardless, It should be removed.
Quoted 4 lines
drivers/staging/rts5208/rtsx_transport.c +0
-0Handle_Errors:return ; }
PATCH v2 2/9 Staging: rts5208: rtsx_transport.c: Align to open parenthesis
In reply to Shaun RenThis patch fixes the alignment issue reported by checkpatch.pl:
CHECK: Alignment should match open parenthesis
--- drivers/staging/rts5208/rtsx_transport.c | 61 ++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 26 deletions(-)
drivers/staging/rts5208/rtsx_transport.c +35 -26
@@ -40,8 +40,11 @@*/ unsigned int rtsx_stor_access_xfer_buf (unsigned char *buffer, -unsigned int buflen,struct scsi_cmnd *srb,unsigned int *index, -unsigned int *offset,enum xfer_buf_dir dir) +unsigned int buflen, +struct scsi_cmnd *srb, +unsigned int *index, +unsigned int *offset, +enum xfer_buf_dir dir) {unsigned int cnt;
@@ -54,10 +57,10 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer, cnt =min (buflen,scsi_bufflen (srb) - *offset);if (dir ==TO_XFER_BUF )memcpy ((unsigned char *)scsi_sglist (srb) + *offset, - buffer, cnt); + buffer, cnt);else memcpy (buffer, (unsigned char *)scsi_sglist (srb) + - *offset, cnt); + *offset, cnt); *offset += cnt;/* Using scatter-gather. We have to go through the list one entry
@@ -131,7 +134,7 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer,* SCSI residue. */ void rtsx_stor_set_xfer_buf (unsigned char *buffer, -unsigned int buflen,struct scsi_cmnd *srb) +unsigned int buflen,struct scsi_cmnd *srb) {unsigned int index =0 , offset =0 ;
@@ -142,7 +145,7 @@ void rtsx_stor_set_xfer_buf(unsigned char *buffer, }void rtsx_stor_get_xfer_buf (unsigned char *buffer, -unsigned int buflen,struct scsi_cmnd *srb) +unsigned int buflen,struct scsi_cmnd *srb) {unsigned int index =0 , offset =0 ;
@@ -194,8 +197,8 @@ void rtsx_invoke_transport(struct scsi_cmnd *srb, struct rtsx_chip *chip)/* set the result so the higher layers expect this data */ srb->result =SAM_STAT_CHECK_CONDITION ;memcpy (srb->sense_buffer, - (unsigned char *)&(chip->sense_buffer[SCSI_LUN (srb)]), -sizeof (struct sense_data_t )); + (unsigned char *)&(chip->sense_buffer[SCSI_LUN (srb)]), +sizeof (struct sense_data_t )); }return ;
@@ -209,7 +212,7 @@ Handle_Errors: }void rtsx_add_cmd (struct rtsx_chip *chip, -u8 cmd_type,u16 reg_addr,u8 mask,u8 data) +u8 cmd_type,u16 reg_addr,u8 mask,u8 data) {u32 *cb = (u32 *)(chip->host_cmds_ptr);u32 val =0 ;
@@ -328,9 +331,11 @@ static inline void rtsx_add_sg_tbl( }static int rtsx_transfer_sglist_adma_partial (struct rtsx_chip *chip,u8 card, -struct scatterlist *sg,int num_sg,unsigned int *index, -unsigned int *offset,int size, -enum dma_data_direction dma_dir,int timeout) +struct scatterlist *sg,int num_sg, +unsigned int *index, +unsigned int *offset,int size, +enum dma_data_direction dma_dir, +int timeout) {struct rtsx_dev *rtsx = chip->rtsx;struct completion trans_done;
@@ -492,8 +497,9 @@ out: }static int rtsx_transfer_sglist_adma (struct rtsx_chip *chip,u8 card, -struct scatterlist *sg,int num_sg, -enum dma_data_direction dma_dir,int timeout) +struct scatterlist *sg,int num_sg, +enum dma_data_direction dma_dir, +int timeout) {struct rtsx_dev *rtsx = chip->rtsx;struct completion trans_done;
@@ -639,7 +645,8 @@ out: }static int rtsx_transfer_buf (struct rtsx_chip *chip,u8 card,void *buf, -size_t len,enum dma_data_direction dma_dir,int timeout) +size_t len,enum dma_data_direction dma_dir, +int timeout) {struct rtsx_dev *rtsx = chip->rtsx;struct completion trans_done;
@@ -722,9 +729,9 @@ out: }int rtsx_transfer_data_partial (struct rtsx_chip *chip,u8 card, -void *buf,size_t len,int use_sg,unsigned int *index, -unsigned int *offset,enum dma_data_direction dma_dir, -int timeout) +void *buf,size_t len,int use_sg, +unsigned int *index,unsigned int *offset, +enum dma_data_direction dma_dir,int timeout) {int err =0 ;
@@ -732,11 +739,13 @@ int rtsx_transfer_data_partial(struct rtsx_chip *chip, u8 card,if (rtsx_chk_stat (chip,RTSX_STAT_ABORT ))return -EIO ; -if (use_sg) - err =rtsx_transfer_sglist_adma_partial (chip, card, - (struct scatterlist *)buf, use_sg, - index, offset, (int )len, dma_dir, timeout); -else +if (use_sg) { +struct scatterlist *sg = (struct scatterlist *)buf; + + err =rtsx_transfer_sglist_adma_partial (chip, card, sg, use_sg, + index, offset, (int )len, + dma_dir, timeout); + }else err =rtsx_transfer_buf (chip, card, buf, len, dma_dir, timeout);if (err <0 ) {
@@ -751,7 +760,7 @@ int rtsx_transfer_data_partial(struct rtsx_chip *chip, u8 card, }int rtsx_transfer_data (struct rtsx_chip *chip,u8 card,void *buf,size_t len, -int use_sg,enum dma_data_direction dma_dir,int timeout) +int use_sg,enum dma_data_direction dma_dir,int timeout) {int err =0 ;
@@ -763,8 +772,8 @@ int rtsx_transfer_data(struct rtsx_chip *chip, u8 card, void *buf, size_t len,if (use_sg) { err =rtsx_transfer_sglist_adma (chip, card, - (struct scatterlist *)buf, - use_sg, dma_dir, timeout); + (struct scatterlist *)buf, + use_sg, dma_dir, timeout); }else { err =rtsx_transfer_buf (chip, card, buf, len, dma_dir, timeout); }
Signature · 1 line
2.7.0
Re: [PATCH v2 2/9] Staging: rts5208: rtsx_transport.c: Align to open parenthesis
Quoted 9 lines · Shaun Ren
This patch fixes the alignment issue reported by checkpatch.pl:
CHECK: Alignment should match open parenthesis
Signed-off-by Shaun Ren <[email protected]>--- drivers/staging/rts5208/rtsx_transport.c | 61 ++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 26 deletions(-)
<snip>
drivers/staging/rts5208/rtsx_transport.c int rtsx_transfer_data_partial(struct rtsx_chip *chip, u8 card, · line 743
Quoted 12 lines
drivers/staging/rts5208/rtsx_transport.c +2
-5@@ -732,11 +739,13 @@ int rtsx_transfer_data_partial(struct rtsx_chip *chip, u8 card,if (rtsx_chk_stat (chip,RTSX_STAT_ABORT ))return -EIO ; -if (use_sg) - err =rtsx_transfer_sglist_adma_partial (chip, card, - (struct scatterlist *)buf, use_sg, - index, offset, (int )len, dma_dir, timeout); -else +if (use_sg) { +struct scatterlist *sg = (struct scatterlist *)buf;
this change is not documented in commit message.
drivers/staging/rts5208/rtsx_transport.c int rtsx_transfer_data_partial(struct rtsx_chip *chip, u8 card, · line 748
Quoted 5 lines
drivers/staging/rts5208/rtsx_transport.c +5
-0+ + err =rtsx_transfer_sglist_adma_partial (chip, card, sg, use_sg, + index, offset, (int )len, + dma_dir, timeout); + }else
This will introduce new checkpatch warning. If you are giving braces in the if block then you need to have braces in the else part also.
regards
sudip
PATCH v2 3/9 Staging: rts5208: rtsx_transport.c: Remove spaces after casts
In reply to Shaun RenThis patch removes all spaces after casts in rtsx_transport.c, as reported by checkpatch.pl:
CHECK: No space is necessary after a cast
--- drivers/staging/rts5208/rtsx_transport.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/rts5208/rtsx_transport.c +3 -3
@@ -56,10 +56,10 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer,return 0 ; cnt =min (buflen,scsi_bufflen (srb) - *offset);if (dir ==TO_XFER_BUF ) -memcpy ((unsigned char *)scsi_sglist (srb) + *offset, +memcpy ((unsigned char *)scsi_sglist (srb) + *offset, buffer, cnt);else -memcpy (buffer, (unsigned char *)scsi_sglist (srb) + +memcpy (buffer, (unsigned char *)scsi_sglist (srb) + *offset, cnt); *offset += cnt;
@@ -73,7 +73,7 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer,*/ }else {struct scatterlist *sg = - (struct scatterlist *)scsi_sglist (srb) + (struct scatterlist *)scsi_sglist (srb) + *index;/* This loop handles a single s-g list entry, which may
Signature · 1 line
2.7.0
PATCH v2 4/9 Staging: rts5208: rtsx_transport.c: Add spaces around -
In reply to Shaun RenThis patch fixes the following styling issue in rtsx_transport.c as reported by checkpatch.pl:
CHECK: spaces preferred around that '-' (ctx:VxV)
--- drivers/staging/rts5208/rtsx_transport.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/rts5208/rtsx_transport.c +2 -2
@@ -85,8 +85,8 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer,while (cnt < buflen && *index <scsi_sg_count (srb)) {struct page *page =sg_page (sg) + ((sg->offset + *offset) >>PAGE_SHIFT ); -unsigned int poff = - (sg->offset + *offset) & (PAGE_SIZE -1 ); +unsigned int poff = (sg->offset + *offset) & + (PAGE_SIZE -1 );unsigned int sglen = sg->length - *offset;if (sglen > buflen - cnt) {
Signature · 1 line
2.7.0
PATCH v2 5/9 Staging: rts5208: rtsx_transport.c: Remove extra newlines
In reply to Shaun RenThis patch fixes the following issues in rtsx_transport.c as reported by checkpatch.pl:
CHECK: Blank lines aren't necessary after an open brace '{'
CHECK: Please don't use multiple blank lines
--- drivers/staging/rts5208/rtsx_transport.c | 3 --- 1 file changed, 3 deletions(-)
drivers/staging/rts5208/rtsx_transport.c +0 -3
@@ -90,12 +90,10 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer,unsigned int sglen = sg->length - *offset;if (sglen > buflen - cnt) { -/* Transfer ends within this s-g entry */ sglen = buflen - cnt; *offset += sglen; }else { -/* Transfer continues to next s-g entry */ *offset =0 ; ++*index;
@@ -155,7 +153,6 @@ void rtsx_stor_get_xfer_buf(unsigned char *buffer,scsi_set_resid (srb,scsi_bufflen (srb) - buflen); } -/*********************************************************************** * Transport routines ***********************************************************************/
Signature · 1 line
2.7.0
PATCH v2 6/9 Staging: rts5208: rtsx_transport.c: Fix label naming convention
In reply to Shaun RenThis patch fixes the following naming convention issue in rtsx_transport.c, as reported by checkpatch.pl:
CHECK: Avoid CamelCase: <Handle_Errors>
--- drivers/staging/rts5208/rtsx_transport.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/rts5208/rtsx_transport.c +3 -3
@@ -173,14 +173,14 @@ void rtsx_invoke_transport(struct scsi_cmnd *srb, struct rtsx_chip *chip)if (rtsx_chk_stat (chip,RTSX_STAT_ABORT )) {dev_dbg (rtsx_dev (chip),"-- command was aborted\n" ); srb->result =DID_ABORT <<16 ; - goto Handle_Errors; + goto handle_errors; }/* if there is a transport error, reset and don't auto-sense */ if (result ==TRANSPORT_ERROR ) {dev_dbg (rtsx_dev (chip),"-- transport indicates error, resetting\n" ); srb->result =DID_ERROR <<16 ; - goto Handle_Errors; + goto handle_errors; } srb->result =SAM_STAT_GOOD ;
@@ -204,7 +204,7 @@ void rtsx_invoke_transport(struct scsi_cmnd *srb, struct rtsx_chip *chip)* by issuing a port reset. If that fails, try a class-specific * device reset. */ -Handle_Errors: +handle_errors:return ; }
Signature · 1 line
2.7.0
PATCH v2 7/9 Staging: rts5208: rtsx_transport.c: Remove unnecessary parentheses
In reply to Shaun RenThis patch removes all unnecessary parentheses found by checkpatch.pl.
--- drivers/staging/rts5208/rtsx_transport.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/staging/rts5208/rtsx_transport.c +7 -7
@@ -194,7 +194,7 @@ void rtsx_invoke_transport(struct scsi_cmnd *srb, struct rtsx_chip *chip)/* set the result so the higher layers expect this data */ srb->result =SAM_STAT_CHECK_CONDITION ;memcpy (srb->sense_buffer, - (unsigned char *)&(chip->sense_buffer[SCSI_LUN (srb)]), + (unsigned char *)&chip->sense_buffer[SCSI_LUN (srb)],sizeof (struct sense_data_t )); }
@@ -372,7 +372,7 @@ static int rtsx_transfer_sglist_adma_partial(struct rtsx_chip *chip, u8 card,spin_unlock_irq (&rtsx->reg_lock); - sg_cnt =dma_map_sg (&(rtsx->pci->dev), sg, num_sg, dma_dir); + sg_cnt =dma_map_sg (&rtsx->pci->dev, sg, num_sg, dma_dir); resid = size; sg_ptr = sg;
@@ -485,7 +485,7 @@ static int rtsx_transfer_sglist_adma_partial(struct rtsx_chip *chip, u8 card, out: rtsx->done =NULL ; rtsx->trans_state =STATE_TRANS_NONE ; -dma_unmap_sg (&(rtsx->pci->dev), sg, num_sg, dma_dir); +dma_unmap_sg (&rtsx->pci->dev, sg, num_sg, dma_dir);if (err <0 )rtsx_stop_cmd (chip, card);
@@ -535,7 +535,7 @@ static int rtsx_transfer_sglist_adma(struct rtsx_chip *chip, u8 card,spin_unlock_irq (&rtsx->reg_lock); - buf_cnt =dma_map_sg (&(rtsx->pci->dev), sg, num_sg, dma_dir); + buf_cnt =dma_map_sg (&rtsx->pci->dev, sg, num_sg, dma_dir); sg_ptr = sg;
@@ -633,7 +633,7 @@ static int rtsx_transfer_sglist_adma(struct rtsx_chip *chip, u8 card, out: rtsx->done =NULL ; rtsx->trans_state =STATE_TRANS_NONE ; -dma_unmap_sg (&(rtsx->pci->dev), sg, num_sg, dma_dir); +dma_unmap_sg (&rtsx->pci->dev, sg, num_sg, dma_dir);if (err <0 )rtsx_stop_cmd (chip, card);
@@ -663,7 +663,7 @@ static int rtsx_transfer_buf(struct rtsx_chip *chip, u8 card, void *buf,else return -ENXIO ; - addr =dma_map_single (&(rtsx->pci->dev), buf, len, dma_dir); + addr =dma_map_single (&rtsx->pci->dev, buf, len, dma_dir);if (!addr)return -ENOMEM ;
@@ -717,7 +717,7 @@ static int rtsx_transfer_buf(struct rtsx_chip *chip, u8 card, void *buf, out: rtsx->done =NULL ; rtsx->trans_state =STATE_TRANS_NONE ; -dma_unmap_single (&(rtsx->pci->dev), addr, len, dma_dir); +dma_unmap_single (&rtsx->pci->dev, addr, len, dma_dir);if (err <0 )rtsx_stop_cmd (chip, card);
Signature · 1 line
2.7.0
Re: [PATCH v2 7/9] Staging: rts5208: rtsx_transport.c: Remove unnecessary parentheses
Quoted 3 lines · Shaun Ren
This patch removes all unnecessary parentheses found by checkpatch.pl.
Signed-off-by Shaun Ren <[email protected]>
This will not apply anymore because of some other changes done by:9a66d05d82db ("Staging: rts5208: fix check for dma mapping error")
regards
sudip
Re: [PATCH v2 7/9] Staging: rts5208: rtsx_transport.c: Remove unnecessary parentheses
Quoted 7 lines · Sudip Mukherjee
Quoted 3 lines · Shaun Ren
This patch removes all unnecessary parentheses found by checkpatch.pl.
Signed-off-by Shaun Ren <[email protected]>This will not apply anymore because of some other changes done by:
9a66d05d82db("Staging: rts5208: fix check for dma mapping error")
I don't see that commit anywhere. Is it in linux-next?
Regards,
--
Shaun Ren
PATCH v2 8/9 Staging: rts5208: rtsx_transport.c: Fix comparisons to NULL
In reply to Shaun RenThis patch changes all comparsions to NULL with !..., as reported by checkpatch.pl.
--- drivers/staging/rts5208/rtsx_transport.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/rts5208/rtsx_transport.c +3 -3
@@ -343,7 +343,7 @@ static int rtsx_transfer_sglist_adma_partial(struct rtsx_chip *chip, u8 card,struct scatterlist *sg_ptr;u32 val =TRIG_DMA ; -if ((sg ==NULL ) || (num_sg <=0 ) || !offset || !index) +if (!sg || (num_sg <=0 ) || !offset || !index)return -EIO ;if (dma_dir ==DMA_TO_DEVICE )
@@ -506,7 +506,7 @@ static int rtsx_transfer_sglist_adma(struct rtsx_chip *chip, u8 card,long timeleft;struct scatterlist *sg_ptr; -if ((sg ==NULL ) || (num_sg <=0 )) +if (!sg || (num_sg <=0 ))return -EIO ;if (dma_dir ==DMA_TO_DEVICE )
@@ -653,7 +653,7 @@ static int rtsx_transfer_buf(struct rtsx_chip *chip, u8 card, void *buf,u32 val =1 <<31 ;long timeleft; -if ((buf ==NULL ) || (len <=0 )) +if (!buf || (len <=0 ))return -EIO ;if (dma_dir ==DMA_TO_DEVICE )
Signature · 1 line
2.7.0
PATCH v2 9/9 Staging: rts5208: Add missing dma_mapping_error
In reply to Shaun RenThis patch adds a dma_mapping_error call to debug potential DMA mapping errors after the dma_map_single call in rtsx_transport.c.
--- drivers/staging/rts5208/rtsx_transport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rts5208/rtsx_transport.c +1 -1
@@ -664,7 +664,7 @@ static int rtsx_transfer_buf(struct rtsx_chip *chip, u8 card, void *buf,return -ENXIO ; addr =dma_map_single (&rtsx->pci->dev, buf, len, dma_dir); -if (!addr) +if (dma_mapping_error (&rtsx->pci->dev, addr))return -ENOMEM ;if (card ==SD_CARD )
Signature · 1 line
2.7.0
v3 cover Staging: rts5208: Coding style and dma mapping fixes
In reply to Shaun RenThis set of patches fixes the coding style issues in rtsx_transport.c, and dds a missing call dma_mapping_error() after dma_map_single().
Changes since v2
* Incorporated Joshua Clayton's suggestions regarding the block comments
PATCH v3 1/9 Staging: rts5208: rtsx_transport.c: Cleanup comments
This patch fixes all multiline comments to conform to the coding style, which states that multiline comments should start with "/*" and end with "*/" on a separate line.
Also cleans up some comments to make them more clear and/or reflect what the code is doing.
---
Changes since v2
* Cleaned up comments as per Joshua Clayton's suggestions
drivers/staging/rts5208/rtsx_transport.c | 53 ++++++++++++++++---------------- 1 file changed, 27 insertions(+), 26 deletions(-)
drivers/staging/rts5208/rtsx_transport.c +27 -26
@@ -1,4 +1,5 @@ -/* Driver for Realtek PCI-Express card reader +/* +* Driver for Realtek PCI-Express card reader * * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved. *
@@ -30,13 +31,15 @@* Scatter-gather transfer buffer access routines ***********************************************************************/ -/* Copy a buffer of length buflen to/from the srb's transfer buffer. +/* +* Copy a buffer of length buflen to/from the srb's transfer buffer. * (Note: for scatter-gather transfers (srb->use_sg > 0), srb->request_buffer * points to a list of s-g entries and we ignore srb->request_bufflen. * For non-scatter-gather transfers, srb->request_buffer points to the * transfer buffer itself and srb->request_bufflen is the buffer's length.) * Update the *index and *offset variables so that the next copy will -* pick up from where this one left off. */ +* pick up from where this one left off. +*/ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer, unsigned int buflen, struct scsi_cmnd *srb, unsigned int *index,
@@ -44,8 +47,7 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer, {unsigned int cnt; -/* If not using scatter-gather, just transfer the data directly. -* Make certain it will fit in the available buffer space. */ +/* If not using scatter-gather, just transfer the data directly. */ if (scsi_sg_count (srb) ==0 ) {if (*offset >=scsi_bufflen (srb))return 0 ;
@@ -58,22 +60,22 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer, *offset, cnt); *offset += cnt; -/* Using scatter-gather. We have to go through the list one entry +/* +* Using scatter-gather. We have to go through the list one entry * at a time. Each s-g entry contains some number of pages, and -* each page has to be kmap()'ed separately. If the page is already -* in kernel-addressable memory then kmap() will return its address. -* If the page is not directly accessible -- such as a user buffer -* located in high memory -- then kmap() will map it to a temporary -* position in the kernel's virtual address space. */ +* each page has to be kmap()'ed separately. +*/ }else {struct scatterlist *sg = (struct scatterlist *)scsi_sglist (srb) + *index; -/* This loop handles a single s-g list entry, which may +/* +* This loop handles a single s-g list entry, which may * include multiple pages. Find the initial page structure * and the starting offset within the page, and update -* the *offset and *index values for the next loop. */ +* the *offset and *index values for the next loop. +*/ cnt =0 ;while (cnt < buflen && *index <scsi_sg_count (srb)) { struct page *page = sg_page(sg) +
@@ -95,9 +97,6 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer, ++sg; } -/* Transfer the data for all the pages in this -* s-g entry. For each page: call kmap(), do the -* transfer, and call kunmap() immediately after. */ while (sglen >0 ) {unsigned int plen =min (sglen, (unsigned int )PAGE_SIZE - poff);
@@ -122,8 +121,10 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer,return cnt; } -/* Store the contents of buffer into srb's transfer buffer and set the -* SCSI residue. */ +/* +* Store the contents of buffer into srb's transfer buffer and set the SCSI +* SCSI residue. +*/ void rtsx_stor_set_xfer_buf (unsigned char *buffer,unsigned int buflen,struct scsi_cmnd *srb) {
@@ -151,7 +152,8 @@ void rtsx_stor_get_xfer_buf(unsigned char *buffer,* Transport routines ***********************************************************************/ -/* Invoke the transport and basic error-handling/recovery methods +/* +* Invoke the transport and basic error-handling/recovery methods * * This is used to send the message to the device and receive the response. */
@@ -161,8 +163,9 @@ void rtsx_invoke_transport(struct scsi_cmnd *srb, struct rtsx_chip *chip) result =rtsx_scsi_handler (srb, chip); -/* if the command gets aborted by the higher layers, we need to -* short-circuit all other processing +/* +* if the command gets aborted by the higher layers, we need to +* short-circuit all other processing. */ if (rtsx_chk_stat (chip,RTSX_STAT_ABORT )) {dev_dbg (rtsx_dev (chip),"-- command was aborted\n" );
@@ -194,9 +197,6 @@ void rtsx_invoke_transport(struct scsi_cmnd *srb, struct rtsx_chip *chip)return ; -/* Error and abort processing: try to resynchronize with the device -* by issuing a port reset. If that fails, try a class-specific -* device reset. */ Handle_Errors:return ; }
@@ -368,10 +368,11 @@ static int rtsx_transfer_sglist_adma_partial(struct rtsx_chip *chip, u8 card, resid = size; sg_ptr = sg; chip->sgi =0 ; -/* Usually the next entry will be @sg@ + 1, but if this sg element +/* +* Usually the next entry will be @sg@ + 1, but if this sg element * is part of a chained scatterlist, it could jump to the start of * a new scatterlist array. So here we use sg_next to move to -* the proper sg +* the proper sg. */ for (i =0 ; i < *index; i++) sg_ptr =sg_next (sg_ptr);
Signature · 1 line
2.7.0
Re: [PATCH v3 1/9] Staging: rts5208: rtsx_transport.c: Cleanup comments
Hi Shaun.
These comments now reflect common kernel style.
Thanks for addressing my comments.
Just one minor note below. It seems the word SCSI SCSI got duplicated in one comment. (Noted below).
The rest look great to me.
Quoted 96 lines · Shaun Ren
This patch fixes all multiline comments to conform to the coding style, which states that multiline comments should start with "/*" and end with "*/" on a separate line.
Also cleans up some comments to make them more clear and/or reflect what the code is doing.
Signed-off-by Shaun Ren <[email protected]>---
Changes since v2
* Cleaned up comments as per Joshua Clayton's suggestionsdrivers/staging/rts5208/rtsx_transport.c | 53 ++++++++++++++++---------------- 1 file changed, 27 insertions(+), 26 deletions(-)drivers/staging/rts5208/rtsx_transport.c +15
-16@@ -1,4 +1,5 @@ -/* Driver for Realtek PCI-Express card reader +/* +* Driver for Realtek PCI-Express card reader * * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved. * @@ -30,13 +31,15 @@* Scatter-gather transfer buffer access routines ***********************************************************************/ -/* Copy a buffer of length buflen to/from the srb's transfer buffer. +/* +* Copy a buffer of length buflen to/from the srb's transfer buffer. * (Note: for scatter-gather transfers (srb->use_sg > 0), srb->request_buffer * points to a list of s-g entries and we ignore srb->request_bufflen. * For non-scatter-gather transfers, srb->request_buffer points to the * transfer buffer itself and srb->request_bufflen is the buffer's length.) * Update the *index and *offset variables so that the next copy will -* pick up from where this one left off. */ +* pick up from where this one left off. +*/ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer, unsigned int buflen, struct scsi_cmnd *srb, unsigned int *index,@@ -44,8 +47,7 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer, {unsigned int cnt; -/* If not using scatter-gather, just transfer the data directly. -* Make certain it will fit in the available buffer space. */ +/* If not using scatter-gather, just transfer the data directly. */ if (scsi_sg_count (srb) ==0 ) {if (*offset >=scsi_bufflen (srb))return 0 ;@@ -58,22 +60,22 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer, *offset, cnt); *offset += cnt; -/* Using scatter-gather. We have to go through the list one entry +/* +* Using scatter-gather. We have to go through the list one entry * at a time. Each s-g entry contains some number of pages, and -* each page has to be kmap()'ed separately. If the page is already -* in kernel-addressable memory then kmap() will return its address. -* If the page is not directly accessible -- such as a user buffer -* located in high memory -- then kmap() will map it to a temporary -* position in the kernel's virtual address space. */ +* each page has to be kmap()'ed separately. +*/ }else {struct scatterlist *sg = (struct scatterlist *)scsi_sglist (srb) + *index; -/* This loop handles a single s-g list entry, which may +/* +* This loop handles a single s-g list entry, which may * include multiple pages. Find the initial page structure * and the starting offset within the page, and update -* the *offset and *index values for the next loop. */ +* the *offset and *index values for the next loop. +*/ cnt =0 ;while (cnt < buflen && *index <scsi_sg_count (srb)) { struct page *page = sg_page(sg) +@@ -95,9 +97,6 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer, ++sg; } -/* Transfer the data for all the pages in this -* s-g entry. For each page: call kmap(), do the -* transfer, and call kunmap() immediately after. */ while (sglen >0 ) {unsigned int plen =min (sglen, (unsigned int )PAGE_SIZE - poff);
drivers/staging/rts5208/rtsx_transport.c unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer, · line 127
Quoted 9 lines
drivers/staging/rts5208/rtsx_transport.c +4
-2@@ -122,8 +121,10 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer,return cnt; } -/* Store the contents of buffer into srb's transfer buffer and set the -* SCSI residue. */ +/* +* Store the contents of buffer into srb's transfer buffer and set the SCSI +* SCSI residue. +*/
SCSI SCSI
Quoted 50 lines
drivers/staging/rts5208/rtsx_transport.c +8
-8void rtsx_stor_set_xfer_buf (unsigned char *buffer,unsigned int buflen,struct scsi_cmnd *srb) {@@ -151,7 +152,8 @@ void rtsx_stor_get_xfer_buf(unsigned char *buffer,* Transport routines ***********************************************************************/ -/* Invoke the transport and basic error-handling/recovery methods +/* +* Invoke the transport and basic error-handling/recovery methods * * This is used to send the message to the device and receive the response. */ @@ -161,8 +163,9 @@ void rtsx_invoke_transport(struct scsi_cmnd *srb, struct rtsx_chip *chip) result =rtsx_scsi_handler (srb, chip); -/* if the command gets aborted by the higher layers, we need to -* short-circuit all other processing +/* +* if the command gets aborted by the higher layers, we need to +* short-circuit all other processing. */ if (rtsx_chk_stat (chip,RTSX_STAT_ABORT )) {dev_dbg (rtsx_dev (chip),"-- command was aborted\n" );@@ -194,9 +197,6 @@ void rtsx_invoke_transport(struct scsi_cmnd *srb, struct rtsx_chip *chip)return ; -/* Error and abort processing: try to resynchronize with the device -* by issuing a port reset. If that fails, try a class-specific -* device reset. */ Handle_Errors:return ; }@@ -368,10 +368,11 @@ static int rtsx_transfer_sglist_adma_partial(struct rtsx_chip *chip, u8 card, resid = size; sg_ptr = sg; chip->sgi =0 ; -/* Usually the next entry will be @sg@ + 1, but if this sg element +/* +* Usually the next entry will be @sg@ + 1, but if this sg element * is part of a chained scatterlist, it could jump to the start of * a new scatterlist array. So here we use sg_next to move to -* the proper sg +* the proper sg. */ for (i =0 ; i < *index; i++) sg_ptr =sg_next (sg_ptr);
PATCH v3 2/9 Staging: rts5208: rtsx_transport.c: Align to open parenthesis
In reply to Shaun RenThis patch fixes the alignment issue reported by checkpatch.pl:
CHECK: Alignment should match open parenthesis
--- drivers/staging/rts5208/rtsx_transport.c | 61 ++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 26 deletions(-)
drivers/staging/rts5208/rtsx_transport.c +35 -26
@@ -42,8 +42,11 @@*/ unsigned int rtsx_stor_access_xfer_buf (unsigned char *buffer, -unsigned int buflen,struct scsi_cmnd *srb,unsigned int *index, -unsigned int *offset,enum xfer_buf_dir dir) +unsigned int buflen, +struct scsi_cmnd *srb, +unsigned int *index, +unsigned int *offset, +enum xfer_buf_dir dir) {unsigned int cnt;
@@ -54,10 +57,10 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer, cnt =min (buflen,scsi_bufflen (srb) - *offset);if (dir ==TO_XFER_BUF )memcpy ((unsigned char *)scsi_sglist (srb) + *offset, - buffer, cnt); + buffer, cnt);else memcpy (buffer, (unsigned char *)scsi_sglist (srb) + - *offset, cnt); + *offset, cnt); *offset += cnt;/*
@@ -126,7 +129,7 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer,* SCSI residue. */ void rtsx_stor_set_xfer_buf (unsigned char *buffer, -unsigned int buflen,struct scsi_cmnd *srb) +unsigned int buflen,struct scsi_cmnd *srb) {unsigned int index =0 , offset =0 ;
@@ -137,7 +140,7 @@ void rtsx_stor_set_xfer_buf(unsigned char *buffer, }void rtsx_stor_get_xfer_buf (unsigned char *buffer, -unsigned int buflen,struct scsi_cmnd *srb) +unsigned int buflen,struct scsi_cmnd *srb) {unsigned int index =0 , offset =0 ;
@@ -191,8 +194,8 @@ void rtsx_invoke_transport(struct scsi_cmnd *srb, struct rtsx_chip *chip)/* set the result so the higher layers expect this data */ srb->result =SAM_STAT_CHECK_CONDITION ;memcpy (srb->sense_buffer, - (unsigned char *)&(chip->sense_buffer[SCSI_LUN (srb)]), -sizeof (struct sense_data_t )); + (unsigned char *)&(chip->sense_buffer[SCSI_LUN (srb)]), +sizeof (struct sense_data_t )); }return ;
@@ -202,7 +205,7 @@ Handle_Errors: }void rtsx_add_cmd (struct rtsx_chip *chip, -u8 cmd_type,u16 reg_addr,u8 mask,u8 data) +u8 cmd_type,u16 reg_addr,u8 mask,u8 data) {u32 *cb = (u32 *)(chip->host_cmds_ptr);u32 val =0 ;
@@ -321,9 +324,11 @@ static inline void rtsx_add_sg_tbl( }static int rtsx_transfer_sglist_adma_partial (struct rtsx_chip *chip,u8 card, -struct scatterlist *sg,int num_sg,unsigned int *index, -unsigned int *offset,int size, -enum dma_data_direction dma_dir,int timeout) +struct scatterlist *sg,int num_sg, +unsigned int *index, +unsigned int *offset,int size, +enum dma_data_direction dma_dir, +int timeout) {struct rtsx_dev *rtsx = chip->rtsx;struct completion trans_done;
@@ -486,8 +491,9 @@ out: }static int rtsx_transfer_sglist_adma (struct rtsx_chip *chip,u8 card, -struct scatterlist *sg,int num_sg, -enum dma_data_direction dma_dir,int timeout) +struct scatterlist *sg,int num_sg, +enum dma_data_direction dma_dir, +int timeout) {struct rtsx_dev *rtsx = chip->rtsx;struct completion trans_done;
@@ -633,7 +639,8 @@ out: }static int rtsx_transfer_buf (struct rtsx_chip *chip,u8 card,void *buf, -size_t len,enum dma_data_direction dma_dir,int timeout) +size_t len,enum dma_data_direction dma_dir, +int timeout) {struct rtsx_dev *rtsx = chip->rtsx;struct completion trans_done;
@@ -716,9 +723,9 @@ out: }int rtsx_transfer_data_partial (struct rtsx_chip *chip,u8 card, -void *buf,size_t len,int use_sg,unsigned int *index, -unsigned int *offset,enum dma_data_direction dma_dir, -int timeout) +void *buf,size_t len,int use_sg, +unsigned int *index,unsigned int *offset, +enum dma_data_direction dma_dir,int timeout) {int err =0 ;
@@ -726,11 +733,13 @@ int rtsx_transfer_data_partial(struct rtsx_chip *chip, u8 card,if (rtsx_chk_stat (chip,RTSX_STAT_ABORT ))return -EIO ; -if (use_sg) - err =rtsx_transfer_sglist_adma_partial (chip, card, - (struct scatterlist *)buf, use_sg, - index, offset, (int )len, dma_dir, timeout); -else +if (use_sg) { +struct scatterlist *sg = (struct scatterlist *)buf; + + err =rtsx_transfer_sglist_adma_partial (chip, card, sg, use_sg, + index, offset, (int )len, + dma_dir, timeout); + }else err =rtsx_transfer_buf (chip, card, buf, len, dma_dir, timeout);if (err <0 ) {
@@ -745,7 +754,7 @@ int rtsx_transfer_data_partial(struct rtsx_chip *chip, u8 card, }int rtsx_transfer_data (struct rtsx_chip *chip,u8 card,void *buf,size_t len, -int use_sg,enum dma_data_direction dma_dir,int timeout) +int use_sg,enum dma_data_direction dma_dir,int timeout) {int err =0 ;
@@ -757,8 +766,8 @@ int rtsx_transfer_data(struct rtsx_chip *chip, u8 card, void *buf, size_t len,if (use_sg) { err =rtsx_transfer_sglist_adma (chip, card, - (struct scatterlist *)buf, - use_sg, dma_dir, timeout); + (struct scatterlist *)buf, + use_sg, dma_dir, timeout); }else { err =rtsx_transfer_buf (chip, card, buf, len, dma_dir, timeout); }
Signature · 1 line
2.7.0
Re: [PATCH v3 2/9] Staging: rts5208: rtsx_transport.c: Align to open parenthesis
Quoted 17 lines · Shaun Ren
This patch fixes the alignment issue reported by checkpatch.pl:
CHECK: Alignment should match open parenthesis
Signed-off-by Shaun Ren <[email protected]>---
?drivers/staging/rts5208/rtsx_transport.c | 61 ++++++++++++++++++-------------- ?1 file changed, 35 insertions(+), 26 deletions(-)drivers/staging/rts5208/rtsx_transport.c +0
-0@@ -42,8 +42,11 @@? */
?
?unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer,
drivers/staging/rts5208/rtsx_transport.c
Quoted 7 lines
drivers/staging/rts5208/rtsx_transport.c +5
-2- unsigned int buflen, struct scsi_cmnd *srb, unsigned int *index, - unsigned int *offset, enum xfer_buf_dir dir) + ???????unsigned int buflen, + ???????struct scsi_cmnd *srb, + ???????unsigned int *index, + ???????unsigned int *offset, + ?????enum xfer_buf_dir dir)
Doesn't this look odd to you?
drivers/staging/rts5208/rtsx_transport.c
Quoted 13 lines
?{
? unsigned int cnt;
?drivers/staging/rts5208/rtsx_transport.c +1
-1@@ -54,10 +57,10 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer, ? cnt = min(buflen, scsi_bufflen(srb) - *offset); ? if (dir == TO_XFER_BUF) ? memcpy((unsigned char *) scsi_sglist(srb) + *offset, - buffer, cnt); + ???????buffer, cnt);? else
? memcpy(buffer, (unsigned char *)scsi_sglist(srb)+drivers/staging/rts5208/rtsx_transport.c +1
-1- *offset, cnt); + ???????*offset, cnt);
If you really want to make this look nicer and more intelligible, it's probably be better to use a more symmetric form like:
if (dir == TO_XFER_BUF) memcpy((unsigned char *)scsi_sglist(srb) + *offset, buffer, cnt); else memcpy(buffer, (unsigned char *)scsi_sglist(srb) + *offset, cnt);
or maybe
void *to;
void *from;
[...]
if (dir == TO_XFER_BUF) {
to = (unsigned char *)scsi_sglist(srb) + *offset;
from = buffer;
} else {
to = buffer;
from = (unsigned char *)scsi_sglist(srb) +
*offset;
}
memcpy(to, from, cnt);or maybe
void *to; void *from; [...] to = (unsigned char *)scsi_sglist(srb) + *offset; from = buffer; if (dir != TO_XFER_BUF) swap(to, from); memcpy(to, from, cnt);
PATCH v3 3/9 Staging: rts5208: rtsx_transport.c: Remove spaces after casts
In reply to Shaun RenThis patch removes all spaces after casts in rtsx_transport.c, as reported by checkpatch.pl:
CHECK: No space is necessary after a cast
--- drivers/staging/rts5208/rtsx_transport.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/rts5208/rtsx_transport.c +3 -3
@@ -56,10 +56,10 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer,return 0 ; cnt =min (buflen,scsi_bufflen (srb) - *offset);if (dir ==TO_XFER_BUF ) -memcpy ((unsigned char *)scsi_sglist (srb) + *offset, +memcpy ((unsigned char *)scsi_sglist (srb) + *offset, buffer, cnt);else -memcpy (buffer, (unsigned char *)scsi_sglist (srb) + +memcpy (buffer, (unsigned char *)scsi_sglist (srb) + *offset, cnt); *offset += cnt;
@@ -70,7 +70,7 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer,*/ }else {struct scatterlist *sg = - (struct scatterlist *)scsi_sglist (srb) + (struct scatterlist *)scsi_sglist (srb) + *index;/*
Signature · 1 line
2.7.0
PATCH v3 4/9 Staging: rts5208: rtsx_transport.c: Add spaces around -
In reply to Shaun RenThis patch fixes the following styling issue in rtsx_transport.c as reported by checkpatch.pl:
CHECK: spaces preferred around that '-' (ctx:VxV)
--- drivers/staging/rts5208/rtsx_transport.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/rts5208/rtsx_transport.c +2 -2
@@ -83,8 +83,8 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer,while (cnt < buflen && *index <scsi_sg_count (srb)) {struct page *page =sg_page (sg) + ((sg->offset + *offset) >>PAGE_SHIFT ); -unsigned int poff = - (sg->offset + *offset) & (PAGE_SIZE -1 ); +unsigned int poff = (sg->offset + *offset) & + (PAGE_SIZE -1 );unsigned int sglen = sg->length - *offset;if (sglen > buflen - cnt) {
Signature · 1 line
2.7.0
PATCH v3 5/9 Staging: rts5208: rtsx_transport.c: Remove extra newlines
In reply to Shaun RenThis patch fixes the following issues in rtsx_transport.c as reported by checkpatch.pl:
CHECK: Blank lines aren't necessary after an open brace '{'
CHECK: Please don't use multiple blank lines
--- drivers/staging/rts5208/rtsx_transport.c | 3 --- 1 file changed, 3 deletions(-)
drivers/staging/rts5208/rtsx_transport.c +0 -3
@@ -88,12 +88,10 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer,unsigned int sglen = sg->length - *offset;if (sglen > buflen - cnt) { -/* Transfer ends within this s-g entry */ sglen = buflen - cnt; *offset += sglen; }else { -/* Transfer continues to next s-g entry */ *offset =0 ; ++*index;
@@ -150,7 +148,6 @@ void rtsx_stor_get_xfer_buf(unsigned char *buffer,scsi_set_resid (srb,scsi_bufflen (srb) - buflen); } -/*********************************************************************** * Transport routines ***********************************************************************/
Signature · 1 line
2.7.0
PATCH v3 6/9 Staging: rts5208: rtsx_transport.c: Fix label naming convention
In reply to Shaun RenThis patch fixes the following naming convention issue in rtsx_transport.c, as reported by checkpatch.pl:
CHECK: Avoid CamelCase: <Handle_Errors>
---
Changes since v2
* Update patch to reflect the changes made in PATCH 1/9 (block comments)
drivers/staging/rts5208/rtsx_transport.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/rts5208/rtsx_transport.c +3 -3
@@ -170,14 +170,14 @@ void rtsx_invoke_transport(struct scsi_cmnd *srb, struct rtsx_chip *chip)if (rtsx_chk_stat (chip,RTSX_STAT_ABORT )) {dev_dbg (rtsx_dev (chip),"-- command was aborted\n" ); srb->result =DID_ABORT <<16 ; - goto Handle_Errors; + goto handle_errors; }/* if there is a transport error, reset and don't auto-sense */ if (result ==TRANSPORT_ERROR ) {dev_dbg (rtsx_dev (chip),"-- transport indicates error, resetting\n" ); srb->result =DID_ERROR <<16 ; - goto Handle_Errors; + goto handle_errors; } srb->result =SAM_STAT_GOOD ;
@@ -197,7 +197,7 @@ void rtsx_invoke_transport(struct scsi_cmnd *srb, struct rtsx_chip *chip)return ; -Handle_Errors: +handle_errors:return ; }
Signature · 1 line
2.7.0
PATCH v3 7/9 Staging: rts5208: rtsx_transport.c: Remove unnecessary parentheses
In reply to Shaun RenThis patch removes all unnecessary parentheses found by checkpatch.pl.
--- drivers/staging/rts5208/rtsx_transport.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/staging/rts5208/rtsx_transport.c +7 -7
@@ -191,7 +191,7 @@ void rtsx_invoke_transport(struct scsi_cmnd *srb, struct rtsx_chip *chip)/* set the result so the higher layers expect this data */ srb->result =SAM_STAT_CHECK_CONDITION ;memcpy (srb->sense_buffer, - (unsigned char *)&(chip->sense_buffer[SCSI_LUN (srb)]), + (unsigned char *)&chip->sense_buffer[SCSI_LUN (srb)],sizeof (struct sense_data_t )); }
@@ -365,7 +365,7 @@ static int rtsx_transfer_sglist_adma_partial(struct rtsx_chip *chip, u8 card,spin_unlock_irq (&rtsx->reg_lock); - sg_cnt =dma_map_sg (&(rtsx->pci->dev), sg, num_sg, dma_dir); + sg_cnt =dma_map_sg (&rtsx->pci->dev, sg, num_sg, dma_dir); resid = size; sg_ptr = sg;
@@ -479,7 +479,7 @@ static int rtsx_transfer_sglist_adma_partial(struct rtsx_chip *chip, u8 card, out: rtsx->done =NULL ; rtsx->trans_state =STATE_TRANS_NONE ; -dma_unmap_sg (&(rtsx->pci->dev), sg, num_sg, dma_dir); +dma_unmap_sg (&rtsx->pci->dev, sg, num_sg, dma_dir);if (err <0 )rtsx_stop_cmd (chip, card);
@@ -529,7 +529,7 @@ static int rtsx_transfer_sglist_adma(struct rtsx_chip *chip, u8 card,spin_unlock_irq (&rtsx->reg_lock); - buf_cnt =dma_map_sg (&(rtsx->pci->dev), sg, num_sg, dma_dir); + buf_cnt =dma_map_sg (&rtsx->pci->dev, sg, num_sg, dma_dir); sg_ptr = sg;
@@ -627,7 +627,7 @@ static int rtsx_transfer_sglist_adma(struct rtsx_chip *chip, u8 card, out: rtsx->done =NULL ; rtsx->trans_state =STATE_TRANS_NONE ; -dma_unmap_sg (&(rtsx->pci->dev), sg, num_sg, dma_dir); +dma_unmap_sg (&rtsx->pci->dev, sg, num_sg, dma_dir);if (err <0 )rtsx_stop_cmd (chip, card);
@@ -657,7 +657,7 @@ static int rtsx_transfer_buf(struct rtsx_chip *chip, u8 card, void *buf,else return -ENXIO ; - addr =dma_map_single (&(rtsx->pci->dev), buf, len, dma_dir); + addr =dma_map_single (&rtsx->pci->dev, buf, len, dma_dir);if (!addr)return -ENOMEM ;
@@ -711,7 +711,7 @@ static int rtsx_transfer_buf(struct rtsx_chip *chip, u8 card, void *buf, out: rtsx->done =NULL ; rtsx->trans_state =STATE_TRANS_NONE ; -dma_unmap_single (&(rtsx->pci->dev), addr, len, dma_dir); +dma_unmap_single (&rtsx->pci->dev, addr, len, dma_dir);if (err <0 )rtsx_stop_cmd (chip, card);
Signature · 1 line
2.7.0
PATCH v3 8/9 Staging: rts5208: rtsx_transport.c: Fix comparisons to NULL
In reply to Shaun RenThis patch changes all comparsions to NULL with !..., as reported by checkpatch.pl.
--- drivers/staging/rts5208/rtsx_transport.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/rts5208/rtsx_transport.c +3 -3
@@ -336,7 +336,7 @@ static int rtsx_transfer_sglist_adma_partial(struct rtsx_chip *chip, u8 card,struct scatterlist *sg_ptr;u32 val =TRIG_DMA ; -if ((sg ==NULL ) || (num_sg <=0 ) || !offset || !index) +if (!sg || (num_sg <=0 ) || !offset || !index)return -EIO ;if (dma_dir ==DMA_TO_DEVICE )
@@ -500,7 +500,7 @@ static int rtsx_transfer_sglist_adma(struct rtsx_chip *chip, u8 card,long timeleft;struct scatterlist *sg_ptr; -if ((sg ==NULL ) || (num_sg <=0 )) +if (!sg || (num_sg <=0 ))return -EIO ;if (dma_dir ==DMA_TO_DEVICE )
@@ -647,7 +647,7 @@ static int rtsx_transfer_buf(struct rtsx_chip *chip, u8 card, void *buf,u32 val =1 <<31 ;long timeleft; -if ((buf ==NULL ) || (len <=0 )) +if (!buf || (len <=0 ))return -EIO ;if (dma_dir ==DMA_TO_DEVICE )
Signature · 1 line
2.7.0
PATCH v3 9/9 Staging: rts5208: Add missing dma_mapping_error
In reply to Shaun RenThis patch adds a dma_mapping_error call to debug potential DMA mapping errors after the dma_map_single call in rtsx_transport.c.
--- drivers/staging/rts5208/rtsx_transport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rts5208/rtsx_transport.c +1 -1
@@ -658,7 +658,7 @@ static int rtsx_transfer_buf(struct rtsx_chip *chip, u8 card, void *buf,return -ENXIO ; addr =dma_map_single (&rtsx->pci->dev, buf, len, dma_dir); -if (!addr) +if (dma_mapping_error (&rtsx->pci->dev, addr))return -ENOMEM ;if (card ==SD_CARD )
Signature · 1 line
2.7.0
v4 cover Staging: rts5208: Fix coding style
In reply to Shaun RenThis set of patches fixes the coding style issues in rtsx_transport.c.
Changes since v3
* Removed the extraneous SCSI comment in the first patch
* Removed the last patch (Staging: rts5208: Add missing dma_mapping_error) as it is already done in change 9a66d05d82db
(Staging: rts5208: fix check for dma mapping error)
Changes since v2
* Incorporated Joshua Clayton's suggestions regarding the block comments
Shaun Ren (8):
Staging: rts5208: rtsx_transport.c: Cleanup comments
Staging: rts5208: rtsx_transport.c: Align to open parenthesis
Staging: rts5208: rtsx_transport.c: Remove spaces after casts
Staging: rts5208: rtsx_transport.c: Add spaces around -
Staging: rts5208: rtsx_transport.c: Remove extra newlines
Staging: rts5208: rtsx_transport.c: Fix label naming convention
Staging: rts5208: rtsx_transport.c: Remove unnecessary parentheses
Staging: rts5208: rtsx_transport.c: Fix comparisons to NULL
drivers/staging/rts5208/rtsx_transport.c | 152 ++++++++++++++++--------------- 1 file changed, 81 insertions(+), 71 deletions(-)
Signature · 1 line
2.7.0
PATCH v4 1/8 Staging: rts5208: rtsx_transport.c: Cleanup comments
This patch fixes all multiline comments to conform to the coding style, which states that multiline comments should start with "/*" and end with "*/" on a separate line.
Also cleans up some comments to make them more clear and/or reflect what the code is doing.
---
Changes since v3
* Removed the extraneous SCSI comment in the first patch in rtsx_stor_access_xfer_buf()
Changes since v2
* Cleaned up comments as per Joshua Clayton's suggestions
drivers/staging/rts5208/rtsx_transport.c | 53 ++++++++++++++++---------------- 1 file changed, 27 insertions(+), 26 deletions(-)
drivers/staging/rts5208/rtsx_transport.c +27 -26
@@ -1,4 +1,5 @@ -/* Driver for Realtek PCI-Express card reader +/* +* Driver for Realtek PCI-Express card reader * * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved. *
@@ -30,13 +31,15 @@* Scatter-gather transfer buffer access routines ***********************************************************************/ -/* Copy a buffer of length buflen to/from the srb's transfer buffer. +/* +* Copy a buffer of length buflen to/from the srb's transfer buffer. * (Note: for scatter-gather transfers (srb->use_sg > 0), srb->request_buffer * points to a list of s-g entries and we ignore srb->request_bufflen. * For non-scatter-gather transfers, srb->request_buffer points to the * transfer buffer itself and srb->request_bufflen is the buffer's length.) * Update the *index and *offset variables so that the next copy will -* pick up from where this one left off. */ +* pick up from where this one left off. +*/ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer, unsigned int buflen, struct scsi_cmnd *srb, unsigned int *index,
@@ -44,8 +47,7 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer, {unsigned int cnt; -/* If not using scatter-gather, just transfer the data directly. -* Make certain it will fit in the available buffer space. */ +/* If not using scatter-gather, just transfer the data directly. */ if (scsi_sg_count (srb) ==0 ) {if (*offset >=scsi_bufflen (srb))return 0 ;
@@ -58,22 +60,22 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer, *offset, cnt); *offset += cnt; -/* Using scatter-gather. We have to go through the list one entry +/* +* Using scatter-gather. We have to go through the list one entry * at a time. Each s-g entry contains some number of pages, and -* each page has to be kmap()'ed separately. If the page is already -* in kernel-addressable memory then kmap() will return its address. -* If the page is not directly accessible -- such as a user buffer -* located in high memory -- then kmap() will map it to a temporary -* position in the kernel's virtual address space. */ +* each page has to be kmap()'ed separately. +*/ }else {struct scatterlist *sg = (struct scatterlist *)scsi_sglist (srb) + *index; -/* This loop handles a single s-g list entry, which may +/* +* This loop handles a single s-g list entry, which may * include multiple pages. Find the initial page structure * and the starting offset within the page, and update -* the *offset and *index values for the next loop. */ +* the *offset and *index values for the next loop. +*/ cnt =0 ;while (cnt < buflen && *index <scsi_sg_count (srb)) { struct page *page = sg_page(sg) +
@@ -95,9 +97,6 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer, ++sg; } -/* Transfer the data for all the pages in this -* s-g entry. For each page: call kmap(), do the -* transfer, and call kunmap() immediately after. */ while (sglen >0 ) {unsigned int plen =min (sglen, (unsigned int )PAGE_SIZE - poff);
@@ -122,8 +121,10 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer,return cnt; } -/* Store the contents of buffer into srb's transfer buffer and set the -* SCSI residue. */ +/* +* Store the contents of buffer into srb's transfer buffer and set the +* SCSI residue. +*/ void rtsx_stor_set_xfer_buf (unsigned char *buffer,unsigned int buflen,struct scsi_cmnd *srb) {
@@ -151,7 +152,8 @@ void rtsx_stor_get_xfer_buf(unsigned char *buffer,* Transport routines ***********************************************************************/ -/* Invoke the transport and basic error-handling/recovery methods +/* +* Invoke the transport and basic error-handling/recovery methods * * This is used to send the message to the device and receive the response. */
@@ -161,8 +163,9 @@ void rtsx_invoke_transport(struct scsi_cmnd *srb, struct rtsx_chip *chip) result =rtsx_scsi_handler (srb, chip); -/* if the command gets aborted by the higher layers, we need to -* short-circuit all other processing +/* +* if the command gets aborted by the higher layers, we need to +* short-circuit all other processing. */ if (rtsx_chk_stat (chip,RTSX_STAT_ABORT )) {dev_dbg (rtsx_dev (chip),"-- command was aborted\n" );
@@ -194,9 +197,6 @@ void rtsx_invoke_transport(struct scsi_cmnd *srb, struct rtsx_chip *chip)return ; -/* Error and abort processing: try to resynchronize with the device -* by issuing a port reset. If that fails, try a class-specific -* device reset. */ Handle_Errors:return ; }
@@ -368,10 +368,11 @@ static int rtsx_transfer_sglist_adma_partial(struct rtsx_chip *chip, u8 card, resid = size; sg_ptr = sg; chip->sgi =0 ; -/* Usually the next entry will be @sg@ + 1, but if this sg element +/* +* Usually the next entry will be @sg@ + 1, but if this sg element * is part of a chained scatterlist, it could jump to the start of * a new scatterlist array. So here we use sg_next to move to -* the proper sg +* the proper sg. */ for (i =0 ; i < *index; i++) sg_ptr =sg_next (sg_ptr);
Signature · 1 line
2.7.0
PATCH v4 2/8 Staging: rts5208: rtsx_transport.c: Align to open parenthesis
In reply to Shaun RenThis patch fixes the alignment issue reported by checkpatch.pl:
CHECK: Alignment should match open parenthesis
Add a unsigned char *sgbuffer in rtsx_stor_access_xfer_buffer to make the following memcpy logic easier to read.
Add a struct scatterlist *sg in the use_sg branch of rtsx_transfer_data_partial to make the parameters of the rtsx_transfer_sglist_adma_partial call fit in 80 character lines after aligning them to the open parenthesis.
Refactor memcpy logic in rtsx_stor_access_xfer_buf to make it more legible.
---
Changes since v3
* Fixed misalignment of the last parameter of rtsx_stor_access_xfer_buf()
* Refactored memcpy in rtsx_stor_access_xfer_buf() for legibility
drivers/staging/rts5208/rtsx_transport.c | 68 +++++++++++++++++++------------- 1 file changed, 40 insertions(+), 28 deletions(-)
drivers/staging/rts5208/rtsx_transport.c +40 -28
@@ -42,8 +42,11 @@*/ unsigned int rtsx_stor_access_xfer_buf (unsigned char *buffer, -unsigned int buflen,struct scsi_cmnd *srb,unsigned int *index, -unsigned int *offset,enum xfer_buf_dir dir) +unsigned int buflen, +struct scsi_cmnd *srb, +unsigned int *index, +unsigned int *offset, +enum xfer_buf_dir dir) {unsigned int cnt;
@@ -52,12 +55,14 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer,if (*offset >=scsi_bufflen (srb))return 0 ; cnt =min (buflen,scsi_bufflen (srb) - *offset); + +unsigned char *sgbuffer = (unsigned char *)scsi_sglist (srb) + + *offset; +if (dir ==TO_XFER_BUF ) -memcpy ((unsigned char *)scsi_sglist (srb) + *offset, - buffer, cnt); +memcpy (sgbuffer, buffer, cnt);else -memcpy (buffer, (unsigned char *)scsi_sglist (srb) + - *offset, cnt); +memcpy (buffer, sgbuffer, cnt); *offset += cnt;/*
@@ -126,7 +131,7 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer,* SCSI residue. */ void rtsx_stor_set_xfer_buf (unsigned char *buffer, -unsigned int buflen,struct scsi_cmnd *srb) +unsigned int buflen,struct scsi_cmnd *srb) {unsigned int index =0 , offset =0 ;
@@ -137,7 +142,7 @@ void rtsx_stor_set_xfer_buf(unsigned char *buffer, }void rtsx_stor_get_xfer_buf (unsigned char *buffer, -unsigned int buflen,struct scsi_cmnd *srb) +unsigned int buflen,struct scsi_cmnd *srb) {unsigned int index =0 , offset =0 ;
@@ -191,8 +196,8 @@ void rtsx_invoke_transport(struct scsi_cmnd *srb, struct rtsx_chip *chip)/* set the result so the higher layers expect this data */ srb->result =SAM_STAT_CHECK_CONDITION ;memcpy (srb->sense_buffer, - (unsigned char *)&(chip->sense_buffer[SCSI_LUN (srb)]), -sizeof (struct sense_data_t )); + (unsigned char *)&(chip->sense_buffer[SCSI_LUN (srb)]), +sizeof (struct sense_data_t )); }return ;
@@ -202,7 +207,7 @@ Handle_Errors: }void rtsx_add_cmd (struct rtsx_chip *chip, -u8 cmd_type,u16 reg_addr,u8 mask,u8 data) +u8 cmd_type,u16 reg_addr,u8 mask,u8 data) {u32 *cb = (u32 *)(chip->host_cmds_ptr);u32 val =0 ;
@@ -321,9 +326,11 @@ static inline void rtsx_add_sg_tbl( }static int rtsx_transfer_sglist_adma_partial (struct rtsx_chip *chip,u8 card, -struct scatterlist *sg,int num_sg,unsigned int *index, -unsigned int *offset,int size, -enum dma_data_direction dma_dir,int timeout) +struct scatterlist *sg,int num_sg, +unsigned int *index, +unsigned int *offset,int size, +enum dma_data_direction dma_dir, +int timeout) {struct rtsx_dev *rtsx = chip->rtsx;struct completion trans_done;
@@ -486,8 +493,9 @@ out: }static int rtsx_transfer_sglist_adma (struct rtsx_chip *chip,u8 card, -struct scatterlist *sg,int num_sg, -enum dma_data_direction dma_dir,int timeout) +struct scatterlist *sg,int num_sg, +enum dma_data_direction dma_dir, +int timeout) {struct rtsx_dev *rtsx = chip->rtsx;struct completion trans_done;
@@ -633,7 +641,8 @@ out: }static int rtsx_transfer_buf (struct rtsx_chip *chip,u8 card,void *buf, -size_t len,enum dma_data_direction dma_dir,int timeout) +size_t len,enum dma_data_direction dma_dir, +int timeout) {struct rtsx_dev *rtsx = chip->rtsx;struct completion trans_done;
@@ -716,9 +725,9 @@ out: }int rtsx_transfer_data_partial (struct rtsx_chip *chip,u8 card, -void *buf,size_t len,int use_sg,unsigned int *index, -unsigned int *offset,enum dma_data_direction dma_dir, -int timeout) +void *buf,size_t len,int use_sg, +unsigned int *index,unsigned int *offset, +enum dma_data_direction dma_dir,int timeout) {int err =0 ;
@@ -726,13 +735,16 @@ int rtsx_transfer_data_partial(struct rtsx_chip *chip, u8 card,if (rtsx_chk_stat (chip,RTSX_STAT_ABORT ))return -EIO ; -if (use_sg) - err =rtsx_transfer_sglist_adma_partial (chip, card, - (struct scatterlist *)buf, use_sg, - index, offset, (int )len, dma_dir, timeout); -else +if (use_sg) { +struct scatterlist *sg = (struct scatterlist *)buf; + + err =rtsx_transfer_sglist_adma_partial (chip, card, sg, use_sg, + index, offset, (int )len, + dma_dir, timeout); + }else { err =rtsx_transfer_buf (chip, card, buf, len, dma_dir, timeout); + }if (err <0 ) {if (RTSX_TST_DELINK (chip)) {RTSX_CLR_DELINK (chip);
@@ -745,7 +757,7 @@ int rtsx_transfer_data_partial(struct rtsx_chip *chip, u8 card, }int rtsx_transfer_data (struct rtsx_chip *chip,u8 card,void *buf,size_t len, -int use_sg,enum dma_data_direction dma_dir,int timeout) +int use_sg,enum dma_data_direction dma_dir,int timeout) {int err =0 ;
@@ -757,8 +769,8 @@ int rtsx_transfer_data(struct rtsx_chip *chip, u8 card, void *buf, size_t len,if (use_sg) { err =rtsx_transfer_sglist_adma (chip, card, - (struct scatterlist *)buf, - use_sg, dma_dir, timeout); + (struct scatterlist *)buf, + use_sg, dma_dir, timeout); }else { err =rtsx_transfer_buf (chip, card, buf, len, dma_dir, timeout); }
Signature · 1 line
2.7.0
Re: [PATCH v4 2/8] Staging: rts5208: rtsx_transport.c: Align to open parenthesis
Quoted 3 lines · Shaun Ren
This patch fixes the alignment issue reported by checkpatch.pl:
CHECK: Alignment should match open parenthesis
[]
drivers/staging/rts5208/rtsx_transport.c
Quoted 1 line
drivers/staging/rts5208/rtsx_transport.c +0
-0
[]
drivers/staging/rts5208/rtsx_transport.c unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer, · line 60
Quoted 7 lines
drivers/staging/rts5208/rtsx_transport.c +3
-0@@ -52,12 +55,14 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer, ? if (*offset >= scsi_bufflen(srb)) ? return 0; ? cnt = min(buflen, scsi_bufflen(srb) - *offset); + + unsigned char *sgbuffer = (unsigned char *)scsi_sglist(srb) + + *offset;
Please don't declare variables in the middle of functions. Variable declarations are only done at the beginning of functions.
Quoted 10 lines
drivers/staging/rts5208/rtsx_transport.c +2
-2+ ? if (dir == TO_XFER_BUF) -memcpy ((unsigned char *)scsi_sglist (srb) + *offset, - buffer, cnt); +memcpy (sgbuffer, buffer, cnt);? else
drivers/staging/rts5208/rtsx_transport.c +1
-2-memcpy (buffer, (unsigned char *)scsi_sglist (srb) + - *offset, cnt); +memcpy (buffer, sgbuffer, cnt);? *offset += cnt;
PATCH v5 2/8 Staging: rts5208: rtsx_transport.c: Align to open parenthesis
This patch fixes the alignment issue reported by checkpatch.pl:
CHECK: Alignment should match open parenthesis
Add a unsigned char *sgbuffer in rtsx_stor_access_xfer_buffer to make the following memcpy logic easier to read.
Add a struct scatterlist *sg in the use_sg branch of rtsx_transfer_data_partial to make the parameters of the rtsx_transfer_sglist_adma_partial call fit in 80 character lines after aligning them to the open parenthesis.
Refactor memcpy logic in rtsx_stor_access_xfer_buf to make it more legible.
--- drivers/staging/rts5208/rtsx_transport.c | 69 +++++++++++++++++++-------------
Changes since v3
* Fixed misalignment of the last parameter of rtsx_stor_access_xfer_buf()
* Refactored memcpy in rtsx_stor_access_xfer_buf() for legibility
1 file changed, 41 insertions(+), 28 deletions(-)
drivers/staging/rts5208/rtsx_transport.c +41 -28
@@ -42,22 +42,28 @@*/ unsigned int rtsx_stor_access_xfer_buf (unsigned char *buffer, -unsigned int buflen,struct scsi_cmnd *srb,unsigned int *index, -unsigned int *offset,enum xfer_buf_dir dir) +unsigned int buflen, +struct scsi_cmnd *srb, +unsigned int *index, +unsigned int *offset, +enum xfer_buf_dir dir) {unsigned int cnt;/* If not using scatter-gather, just transfer the data directly. */ if (scsi_sg_count (srb) ==0 ) { +unsigned char *sgbuffer; +if (*offset >=scsi_bufflen (srb))return 0 ; cnt =min (buflen,scsi_bufflen (srb) - *offset); + + sgbuffer = (unsigned char *)scsi_sglist (srb) + *offset; +if (dir ==TO_XFER_BUF ) -memcpy ((unsigned char *)scsi_sglist (srb) + *offset, - buffer, cnt); +memcpy (sgbuffer, buffer, cnt);else -memcpy (buffer, (unsigned char *)scsi_sglist (srb) + - *offset, cnt); +memcpy (buffer, sgbuffer, cnt); *offset += cnt;/*
@@ -126,7 +132,7 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer,* SCSI residue. */ void rtsx_stor_set_xfer_buf (unsigned char *buffer, -unsigned int buflen,struct scsi_cmnd *srb) +unsigned int buflen,struct scsi_cmnd *srb) {unsigned int index =0 , offset =0 ;
@@ -137,7 +143,7 @@ void rtsx_stor_set_xfer_buf(unsigned char *buffer, }void rtsx_stor_get_xfer_buf (unsigned char *buffer, -unsigned int buflen,struct scsi_cmnd *srb) +unsigned int buflen,struct scsi_cmnd *srb) {unsigned int index =0 , offset =0 ;
@@ -191,8 +197,8 @@ void rtsx_invoke_transport(struct scsi_cmnd *srb, struct rtsx_chip *chip)/* set the result so the higher layers expect this data */ srb->result =SAM_STAT_CHECK_CONDITION ;memcpy (srb->sense_buffer, - (unsigned char *)&(chip->sense_buffer[SCSI_LUN (srb)]), -sizeof (struct sense_data_t )); + (unsigned char *)&(chip->sense_buffer[SCSI_LUN (srb)]), +sizeof (struct sense_data_t )); }return ;
@@ -202,7 +208,7 @@ Handle_Errors: }void rtsx_add_cmd (struct rtsx_chip *chip, -u8 cmd_type,u16 reg_addr,u8 mask,u8 data) +u8 cmd_type,u16 reg_addr,u8 mask,u8 data) {u32 *cb = (u32 *)(chip->host_cmds_ptr);u32 val =0 ;
@@ -321,9 +327,11 @@ static inline void rtsx_add_sg_tbl( }static int rtsx_transfer_sglist_adma_partial (struct rtsx_chip *chip,u8 card, -struct scatterlist *sg,int num_sg,unsigned int *index, -unsigned int *offset,int size, -enum dma_data_direction dma_dir,int timeout) +struct scatterlist *sg,int num_sg, +unsigned int *index, +unsigned int *offset,int size, +enum dma_data_direction dma_dir, +int timeout) {struct rtsx_dev *rtsx = chip->rtsx;struct completion trans_done;
@@ -486,8 +494,9 @@ out: }static int rtsx_transfer_sglist_adma (struct rtsx_chip *chip,u8 card, -struct scatterlist *sg,int num_sg, -enum dma_data_direction dma_dir,int timeout) +struct scatterlist *sg,int num_sg, +enum dma_data_direction dma_dir, +int timeout) {struct rtsx_dev *rtsx = chip->rtsx;struct completion trans_done;
@@ -633,7 +642,8 @@ out: }static int rtsx_transfer_buf (struct rtsx_chip *chip,u8 card,void *buf, -size_t len,enum dma_data_direction dma_dir,int timeout) +size_t len,enum dma_data_direction dma_dir, +int timeout) {struct rtsx_dev *rtsx = chip->rtsx;struct completion trans_done;
@@ -716,9 +726,9 @@ out: }int rtsx_transfer_data_partial (struct rtsx_chip *chip,u8 card, -void *buf,size_t len,int use_sg,unsigned int *index, -unsigned int *offset,enum dma_data_direction dma_dir, -int timeout) +void *buf,size_t len,int use_sg, +unsigned int *index,unsigned int *offset, +enum dma_data_direction dma_dir,int timeout) {int err =0 ;
@@ -726,13 +736,16 @@ int rtsx_transfer_data_partial(struct rtsx_chip *chip, u8 card,if (rtsx_chk_stat (chip,RTSX_STAT_ABORT ))return -EIO ; -if (use_sg) - err =rtsx_transfer_sglist_adma_partial (chip, card, - (struct scatterlist *)buf, use_sg, - index, offset, (int )len, dma_dir, timeout); -else +if (use_sg) { +struct scatterlist *sg = (struct scatterlist *)buf; + + err =rtsx_transfer_sglist_adma_partial (chip, card, sg, use_sg, + index, offset, (int )len, + dma_dir, timeout); + }else { err =rtsx_transfer_buf (chip, card, buf, len, dma_dir, timeout); + }if (err <0 ) {if (RTSX_TST_DELINK (chip)) {RTSX_CLR_DELINK (chip);
@@ -745,7 +758,7 @@ int rtsx_transfer_data_partial(struct rtsx_chip *chip, u8 card, }int rtsx_transfer_data (struct rtsx_chip *chip,u8 card,void *buf,size_t len, -int use_sg,enum dma_data_direction dma_dir,int timeout) +int use_sg,enum dma_data_direction dma_dir,int timeout) {int err =0 ;
@@ -757,8 +770,8 @@ int rtsx_transfer_data(struct rtsx_chip *chip, u8 card, void *buf, size_t len,if (use_sg) { err =rtsx_transfer_sglist_adma (chip, card, - (struct scatterlist *)buf, - use_sg, dma_dir, timeout); + (struct scatterlist *)buf, + use_sg, dma_dir, timeout); }else { err =rtsx_transfer_buf (chip, card, buf, len, dma_dir, timeout); }
Signature · 1 line
2.7.0
Greg KH
maintainerRe: [PATCH v5 2/8] Staging: rts5208: rtsx_transport.c: Align to open parenthesis
Quoted 12 lines · Shaun Ren
This patch fixes the alignment issue reported by checkpatch.pl:
CHECK: Alignment should match open parenthesis
Add a unsigned char *sgbuffer in
rtsx_stor_access_xfer_bufferto make the following memcpy logic easier to read.Add a struct scatterlist *sg in the
use_sgbranch ofrtsx_transfer_data_partialto make the parameters of thertsx_transfer_sglist_adma_partialcall fit in 80 character lines after aligning them to the open parenthesis.
Quoted 8 lines
Refactor memcpy logic in
rtsx_stor_access_xfer_bufto make it more legible.Signed-off-by Shaun Ren <[email protected]>--- drivers/staging/rts5208/rtsx_transport.c | 69 +++++++++++++++++++-------------Changes since v3
* Fixed misalignment of the last parameter ofrtsx_stor_access_xfer_buf()
* Refactored memcpy inrtsx_stor_access_xfer_buf()for legibility
Where are the 7 other patches in this series?
Please resend all of them.
thanks,
greg k-h
kbuild test robot
build botRe: [PATCH v4 2/8] Staging: rts5208: rtsx_transport.c: Align to open parenthesis
In reply to Shaun Renreproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree…
Hi Shaun,
[auto build test WARNING on staging/staging-testing]
[also build test WARNING on v4.5-rc3 next-20160211]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]
url: https://github.com/0day-ci/linux/commits/Shaun-Ren/Staging-rts5208-Fix-coding-style/20160212-122003 config: xtensa-allyesconfig (attached as .config)
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=xtensa
All warnings (new ones prefixed by >>):
drivers/staging/rts5208/rtsx_transport.c: In function 'rtsx_stor_access_xfer_buf':
>> drivers/staging/rts5208/rtsx_transport.c:59:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
unsigned char *sgbuffer = (unsigned char *)scsi_sglist(srb) + ^
vim +59 drivers/staging/rts5208/rtsx_transport.c
43
44 unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer,
45 unsigned int buflen,
46 struct scsi_cmnd *srb,
47 unsigned int *index,
48 unsigned int *offset,
49 enum xfer_buf_dir dir)
50 {
51 unsigned int cnt;
52
53 /* If not using scatter-gather, just transfer the data directly. */
54 if (scsi_sg_count(srb) == 0) {
55 if (*offset >= scsi_bufflen(srb))
56 return 0;
57 cnt = min(buflen, scsi_bufflen(srb) - *offset);
58
> 59 unsigned char *sgbuffer = (unsigned char *)scsi_sglist(srb) +
60 *offset;
61
62 if (dir == TO_XFER_BUF)
63 memcpy(sgbuffer, buffer, cnt);
64 else
65 memcpy(buffer, sgbuffer, cnt);
66 *offset += cnt;
67 ---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/octet-stream
Size: 44081 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20160212/e0fa3a29/attachment-0001.obj>
PATCH v4 3/8 Staging: rts5208: rtsx_transport.c: Remove spaces after casts
In reply to Shaun RenThis patch removes all spaces after casts in rtsx_transport.c, as reported by checkpatch.pl:
CHECK: No space is necessary after a cast
--- drivers/staging/rts5208/rtsx_transport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rts5208/rtsx_transport.c +1 -1
@@ -72,7 +72,7 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer,*/ }else {struct scatterlist *sg = - (struct scatterlist *)scsi_sglist (srb) + (struct scatterlist *)scsi_sglist (srb) + *index;/*
Signature · 1 line
2.7.0
PATCH v4 4/8 Staging: rts5208: rtsx_transport.c: Add spaces around -
In reply to Shaun RenThis patch fixes the following styling issue in rtsx_transport.c as reported by checkpatch.pl:
CHECK: spaces preferred around that '-' (ctx:VxV)
--- drivers/staging/rts5208/rtsx_transport.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/rts5208/rtsx_transport.c +2 -2
@@ -85,8 +85,8 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer,while (cnt < buflen && *index <scsi_sg_count (srb)) {struct page *page =sg_page (sg) + ((sg->offset + *offset) >>PAGE_SHIFT ); -unsigned int poff = - (sg->offset + *offset) & (PAGE_SIZE -1 ); +unsigned int poff = (sg->offset + *offset) & + (PAGE_SIZE -1 );unsigned int sglen = sg->length - *offset;if (sglen > buflen - cnt) {
Signature · 1 line
2.7.0
PATCH v4 5/8 Staging: rts5208: rtsx_transport.c: Remove extra newlines
In reply to Shaun RenThis patch fixes the following issues in rtsx_transport.c as reported by checkpatch.pl:
CHECK: Blank lines aren't necessary after an open brace '{'
CHECK: Please don't use multiple blank lines
--- drivers/staging/rts5208/rtsx_transport.c | 3 --- 1 file changed, 3 deletions(-)
drivers/staging/rts5208/rtsx_transport.c +0 -3
@@ -90,12 +90,10 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer,unsigned int sglen = sg->length - *offset;if (sglen > buflen - cnt) { -/* Transfer ends within this s-g entry */ sglen = buflen - cnt; *offset += sglen; }else { -/* Transfer continues to next s-g entry */ *offset =0 ; ++*index;
@@ -152,7 +150,6 @@ void rtsx_stor_get_xfer_buf(unsigned char *buffer,scsi_set_resid (srb,scsi_bufflen (srb) - buflen); } -/*********************************************************************** * Transport routines ***********************************************************************/
Signature · 1 line
2.7.0
PATCH v4 6/8 Staging: rts5208: rtsx_transport.c: Fix label naming convention
In reply to Shaun RenThis patch fixes the following naming convention issue in rtsx_transport.c, as reported by checkpatch.pl:
CHECK: Avoid CamelCase: <Handle_Errors>
--- drivers/staging/rts5208/rtsx_transport.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/rts5208/rtsx_transport.c +3 -3
@@ -172,14 +172,14 @@ void rtsx_invoke_transport(struct scsi_cmnd *srb, struct rtsx_chip *chip)if (rtsx_chk_stat (chip,RTSX_STAT_ABORT )) {dev_dbg (rtsx_dev (chip),"-- command was aborted\n" ); srb->result =DID_ABORT <<16 ; - goto Handle_Errors; + goto handle_errors; }/* if there is a transport error, reset and don't auto-sense */ if (result ==TRANSPORT_ERROR ) {dev_dbg (rtsx_dev (chip),"-- transport indicates error, resetting\n" ); srb->result =DID_ERROR <<16 ; - goto Handle_Errors; + goto handle_errors; } srb->result =SAM_STAT_GOOD ;
@@ -199,7 +199,7 @@ void rtsx_invoke_transport(struct scsi_cmnd *srb, struct rtsx_chip *chip)return ; -Handle_Errors: +handle_errors:return ; }
Signature · 1 line
2.7.0
PATCH v4 7/8 Staging: rts5208: rtsx_transport.c: Remove unnecessary parentheses
In reply to Shaun RenThis patch removes all unnecessary parentheses found by checkpatch.pl.
---
Changes since v3
* Fixed patch conflicts due to commit 9a66d05d82db
("Staging: rts5208: fix check for dma mapping error"), and commit b3232842dbef ("Staging: rts5208: remove unnecessary parantheses")
drivers/staging/rts5208/rtsx_transport.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/staging/rts5208/rtsx_transport.c +6 -6
@@ -193,7 +193,7 @@ void rtsx_invoke_transport(struct scsi_cmnd *srb, struct rtsx_chip *chip)/* set the result so the higher layers expect this data */ srb->result =SAM_STAT_CHECK_CONDITION ;memcpy (srb->sense_buffer, - (unsigned char *)&(chip->sense_buffer[SCSI_LUN (srb)]), + (unsigned char *)&chip->sense_buffer[SCSI_LUN (srb)],sizeof (struct sense_data_t )); }
@@ -367,7 +367,7 @@ static int rtsx_transfer_sglist_adma_partial(struct rtsx_chip *chip, u8 card,spin_unlock_irq (&rtsx->reg_lock); - sg_cnt =dma_map_sg (&(rtsx->pci->dev), sg, num_sg, dma_dir); + sg_cnt =dma_map_sg (&rtsx->pci->dev, sg, num_sg, dma_dir); resid = size; sg_ptr = sg;
@@ -481,7 +481,7 @@ static int rtsx_transfer_sglist_adma_partial(struct rtsx_chip *chip, u8 card, out: rtsx->done =NULL ; rtsx->trans_state =STATE_TRANS_NONE ; -dma_unmap_sg (&(rtsx->pci->dev), sg, num_sg, dma_dir); +dma_unmap_sg (&rtsx->pci->dev, sg, num_sg, dma_dir);if (err <0 )rtsx_stop_cmd (chip, card);
@@ -531,7 +531,7 @@ static int rtsx_transfer_sglist_adma(struct rtsx_chip *chip, u8 card,spin_unlock_irq (&rtsx->reg_lock); - buf_cnt =dma_map_sg (&(rtsx->pci->dev), sg, num_sg, dma_dir); + buf_cnt =dma_map_sg (&rtsx->pci->dev, sg, num_sg, dma_dir); sg_ptr = sg;
@@ -629,7 +629,7 @@ static int rtsx_transfer_sglist_adma(struct rtsx_chip *chip, u8 card, out: rtsx->done =NULL ; rtsx->trans_state =STATE_TRANS_NONE ; -dma_unmap_sg (&(rtsx->pci->dev), sg, num_sg, dma_dir); +dma_unmap_sg (&rtsx->pci->dev, sg, num_sg, dma_dir);if (err <0 )rtsx_stop_cmd (chip, card);
@@ -713,7 +713,7 @@ static int rtsx_transfer_buf(struct rtsx_chip *chip, u8 card, void *buf, out: rtsx->done =NULL ; rtsx->trans_state =STATE_TRANS_NONE ; -dma_unmap_single (&(rtsx->pci->dev), addr, len, dma_dir); +dma_unmap_single (&rtsx->pci->dev, addr, len, dma_dir);if (err <0 )rtsx_stop_cmd (chip, card);
Signature · 1 line
2.7.0
PATCH v4 8/8 Staging: rts5208: rtsx_transport.c: Fix comparisons to NULL
In reply to Shaun RenThis patch changes all comparsions to NULL with !..., as reported by checkpatch.pl.
--- drivers/staging/rts5208/rtsx_transport.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/rts5208/rtsx_transport.c +3 -3
@@ -338,7 +338,7 @@ static int rtsx_transfer_sglist_adma_partial(struct rtsx_chip *chip, u8 card,struct scatterlist *sg_ptr;u32 val =TRIG_DMA ; -if ((sg ==NULL ) || (num_sg <=0 ) || !offset || !index) +if (!sg || (num_sg <=0 ) || !offset || !index)return -EIO ;if (dma_dir ==DMA_TO_DEVICE )
@@ -502,7 +502,7 @@ static int rtsx_transfer_sglist_adma(struct rtsx_chip *chip, u8 card,long timeleft;struct scatterlist *sg_ptr; -if ((sg ==NULL ) || (num_sg <=0 )) +if (!sg || (num_sg <=0 ))return -EIO ;if (dma_dir ==DMA_TO_DEVICE )
@@ -649,7 +649,7 @@ static int rtsx_transfer_buf(struct rtsx_chip *chip, u8 card, void *buf,u32 val =1 <<31 ;long timeleft; -if ((buf ==NULL ) || (len <=0 )) +if (!buf || (len <=0 ))return -EIO ;if (dma_dir ==DMA_TO_DEVICE )
Signature · 1 line
2.7.0
v5 cover Staging: rts5208: Fix coding style
In reply to Shaun RenThis set of patches fixes the coding style issues in rtsx_transport.c.
Changes since v4
* Moved a declaration to the beginning of an if branch
Changes since v3
* Removed the extraneous SCSI comment in the first patch
* Removed the last patch (Staging: rts5208: Add missing dma_mapping_error) as it is already done in change 9a66d05d82db
(Staging: rts5208: fix check for dma mapping error)
Changes since v2
* Incorporated Joshua Clayton's suggestions regarding the block comments
Shaun Ren (8):
Staging: rts5208: rtsx_transport.c: Cleanup comments
Staging: rts5208: rtsx_transport.c: Align to open parenthesis
Staging: rts5208: rtsx_transport.c: Remove spaces after casts
Staging: rts5208: rtsx_transport.c: Add spaces around -
Staging: rts5208: rtsx_transport.c: Remove extra newlines
Staging: rts5208: rtsx_transport.c: Fix label naming convention
Staging: rts5208: rtsx_transport.c: Remove unnecessary parentheses
Staging: rts5208: rtsx_transport.c: Fix comparisons to NULL
drivers/staging/rts5208/rtsx_transport.c | 153 +++++++++++++++++-------------- 1 file changed, 82 insertions(+), 71 deletions(-)
Signature · 1 line
2.7.1
PATCH RESEND v5 1/8 Staging: rts5208: rtsx_transport.c: Cleanup comments
This patch fixes all multiline comments to conform to the coding style, which states that multiline comments should start with "/*" and end with "*/" on a separate line.
Also cleans up some comments to make them more clear and/or reflect what the code is doing.
---
Changes since v3
* Removed the extraneous SCSI comment in the first patch in rtsx_stor_access_xfer_buf()
Changes since v2
* Cleaned up comments as per Joshua Clayton's suggestions
drivers/staging/rts5208/rtsx_transport.c | 53 ++++++++++++++++---------------- 1 file changed, 27 insertions(+), 26 deletions(-)
drivers/staging/rts5208/rtsx_transport.c +27 -26
@@ -1,4 +1,5 @@ -/* Driver for Realtek PCI-Express card reader +/* +* Driver for Realtek PCI-Express card reader * * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved. *
@@ -30,13 +31,15 @@* Scatter-gather transfer buffer access routines ***********************************************************************/ -/* Copy a buffer of length buflen to/from the srb's transfer buffer. +/* +* Copy a buffer of length buflen to/from the srb's transfer buffer. * (Note: for scatter-gather transfers (srb->use_sg > 0), srb->request_buffer * points to a list of s-g entries and we ignore srb->request_bufflen. * For non-scatter-gather transfers, srb->request_buffer points to the * transfer buffer itself and srb->request_bufflen is the buffer's length.) * Update the *index and *offset variables so that the next copy will -* pick up from where this one left off. */ +* pick up from where this one left off. +*/ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer, unsigned int buflen, struct scsi_cmnd *srb, unsigned int *index,
@@ -44,8 +47,7 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer, {unsigned int cnt; -/* If not using scatter-gather, just transfer the data directly. -* Make certain it will fit in the available buffer space. */ +/* If not using scatter-gather, just transfer the data directly. */ if (scsi_sg_count (srb) ==0 ) {if (*offset >=scsi_bufflen (srb))return 0 ;
@@ -58,22 +60,22 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer, *offset, cnt); *offset += cnt; -/* Using scatter-gather. We have to go through the list one entry +/* +* Using scatter-gather. We have to go through the list one entry * at a time. Each s-g entry contains some number of pages, and -* each page has to be kmap()'ed separately. If the page is already -* in kernel-addressable memory then kmap() will return its address. -* If the page is not directly accessible -- such as a user buffer -* located in high memory -- then kmap() will map it to a temporary -* position in the kernel's virtual address space. */ +* each page has to be kmap()'ed separately. +*/ }else {struct scatterlist *sg = (struct scatterlist *)scsi_sglist (srb) + *index; -/* This loop handles a single s-g list entry, which may +/* +* This loop handles a single s-g list entry, which may * include multiple pages. Find the initial page structure * and the starting offset within the page, and update -* the *offset and *index values for the next loop. */ +* the *offset and *index values for the next loop. +*/ cnt =0 ;while (cnt < buflen && *index <scsi_sg_count (srb)) { struct page *page = sg_page(sg) +
@@ -95,9 +97,6 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer, ++sg; } -/* Transfer the data for all the pages in this -* s-g entry. For each page: call kmap(), do the -* transfer, and call kunmap() immediately after. */ while (sglen >0 ) {unsigned int plen =min (sglen, (unsigned int )PAGE_SIZE - poff);
@@ -122,8 +121,10 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer,return cnt; } -/* Store the contents of buffer into srb's transfer buffer and set the -* SCSI residue. */ +/* +* Store the contents of buffer into srb's transfer buffer and set the +* SCSI residue. +*/ void rtsx_stor_set_xfer_buf (unsigned char *buffer,unsigned int buflen,struct scsi_cmnd *srb) {
@@ -151,7 +152,8 @@ void rtsx_stor_get_xfer_buf(unsigned char *buffer,* Transport routines ***********************************************************************/ -/* Invoke the transport and basic error-handling/recovery methods +/* +* Invoke the transport and basic error-handling/recovery methods * * This is used to send the message to the device and receive the response. */
@@ -161,8 +163,9 @@ void rtsx_invoke_transport(struct scsi_cmnd *srb, struct rtsx_chip *chip) result =rtsx_scsi_handler (srb, chip); -/* if the command gets aborted by the higher layers, we need to -* short-circuit all other processing +/* +* if the command gets aborted by the higher layers, we need to +* short-circuit all other processing. */ if (rtsx_chk_stat (chip,RTSX_STAT_ABORT )) {dev_dbg (rtsx_dev (chip),"-- command was aborted\n" );
@@ -194,9 +197,6 @@ void rtsx_invoke_transport(struct scsi_cmnd *srb, struct rtsx_chip *chip)return ; -/* Error and abort processing: try to resynchronize with the device -* by issuing a port reset. If that fails, try a class-specific -* device reset. */ Handle_Errors:return ; }
@@ -368,10 +368,11 @@ static int rtsx_transfer_sglist_adma_partial(struct rtsx_chip *chip, u8 card, resid = size; sg_ptr = sg; chip->sgi =0 ; -/* Usually the next entry will be @sg@ + 1, but if this sg element +/* +* Usually the next entry will be @sg@ + 1, but if this sg element * is part of a chained scatterlist, it could jump to the start of * a new scatterlist array. So here we use sg_next to move to -* the proper sg +* the proper sg. */ for (i =0 ; i < *index; i++) sg_ptr =sg_next (sg_ptr);
Signature · 1 line
2.7.1
PATCH RESEND v5 2/8 Staging: rts5208: rtsx_transport.c: Align to open parenthesis
In reply to Shaun RenThis patch fixes the alignment issue reported by checkpatch.pl:
CHECK: Alignment should match open parenthesis
Add a unsigned char *sgbuffer in rtsx_stor_access_xfer_buffer to make the following memcpy logic easier to read.
Add a struct scatterlist *sg in the use_sg branch of rtsx_transfer_data_partial to make the parameters of the rtsx_transfer_sglist_adma_partial call fit in 80 character lines after aligning them to the open parenthesis.
Refactor memcpy logic in rtsx_stor_access_xfer_buf to make it more legible.
---
Changes since v4
* Moved unsigned char *sgbuffer decleration to the beginning of the if branch in rtsx_stor_access_xfer_buf()
Changes since v3
* Fixed misalignment of the last parameter of rtsx_stor_access_xfer_buf()
* Refactored memcpy in rtsx_stor_access_xfer_buf() for legibility
drivers/staging/rts5208/rtsx_transport.c | 69 +++++++++++++++++++------------- 1 file changed, 41 insertions(+), 28 deletions(-)
drivers/staging/rts5208/rtsx_transport.c +41 -28
@@ -42,22 +42,28 @@*/ unsigned int rtsx_stor_access_xfer_buf (unsigned char *buffer, -unsigned int buflen,struct scsi_cmnd *srb,unsigned int *index, -unsigned int *offset,enum xfer_buf_dir dir) +unsigned int buflen, +struct scsi_cmnd *srb, +unsigned int *index, +unsigned int *offset, +enum xfer_buf_dir dir) {unsigned int cnt;/* If not using scatter-gather, just transfer the data directly. */ if (scsi_sg_count (srb) ==0 ) { +unsigned char *sgbuffer; +if (*offset >=scsi_bufflen (srb))return 0 ; cnt =min (buflen,scsi_bufflen (srb) - *offset); + + sgbuffer = (unsigned char *)scsi_sglist (srb) + *offset; +if (dir ==TO_XFER_BUF ) -memcpy ((unsigned char *)scsi_sglist (srb) + *offset, - buffer, cnt); +memcpy (sgbuffer, buffer, cnt);else -memcpy (buffer, (unsigned char *)scsi_sglist (srb) + - *offset, cnt); +memcpy (buffer, sgbuffer, cnt); *offset += cnt;/*
@@ -126,7 +132,7 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer,* SCSI residue. */ void rtsx_stor_set_xfer_buf (unsigned char *buffer, -unsigned int buflen,struct scsi_cmnd *srb) +unsigned int buflen,struct scsi_cmnd *srb) {unsigned int index =0 , offset =0 ;
@@ -137,7 +143,7 @@ void rtsx_stor_set_xfer_buf(unsigned char *buffer, }void rtsx_stor_get_xfer_buf (unsigned char *buffer, -unsigned int buflen,struct scsi_cmnd *srb) +unsigned int buflen,struct scsi_cmnd *srb) {unsigned int index =0 , offset =0 ;
@@ -191,8 +197,8 @@ void rtsx_invoke_transport(struct scsi_cmnd *srb, struct rtsx_chip *chip)/* set the result so the higher layers expect this data */ srb->result =SAM_STAT_CHECK_CONDITION ;memcpy (srb->sense_buffer, - (unsigned char *)&(chip->sense_buffer[SCSI_LUN (srb)]), -sizeof (struct sense_data_t )); + (unsigned char *)&(chip->sense_buffer[SCSI_LUN (srb)]), +sizeof (struct sense_data_t )); }return ;
@@ -202,7 +208,7 @@ Handle_Errors: }void rtsx_add_cmd (struct rtsx_chip *chip, -u8 cmd_type,u16 reg_addr,u8 mask,u8 data) +u8 cmd_type,u16 reg_addr,u8 mask,u8 data) {u32 *cb = (u32 *)(chip->host_cmds_ptr);u32 val =0 ;
@@ -321,9 +327,11 @@ static inline void rtsx_add_sg_tbl( }static int rtsx_transfer_sglist_adma_partial (struct rtsx_chip *chip,u8 card, -struct scatterlist *sg,int num_sg,unsigned int *index, -unsigned int *offset,int size, -enum dma_data_direction dma_dir,int timeout) +struct scatterlist *sg,int num_sg, +unsigned int *index, +unsigned int *offset,int size, +enum dma_data_direction dma_dir, +int timeout) {struct rtsx_dev *rtsx = chip->rtsx;struct completion trans_done;
@@ -486,8 +494,9 @@ out: }static int rtsx_transfer_sglist_adma (struct rtsx_chip *chip,u8 card, -struct scatterlist *sg,int num_sg, -enum dma_data_direction dma_dir,int timeout) +struct scatterlist *sg,int num_sg, +enum dma_data_direction dma_dir, +int timeout) {struct rtsx_dev *rtsx = chip->rtsx;struct completion trans_done;
@@ -633,7 +642,8 @@ out: }static int rtsx_transfer_buf (struct rtsx_chip *chip,u8 card,void *buf, -size_t len,enum dma_data_direction dma_dir,int timeout) +size_t len,enum dma_data_direction dma_dir, +int timeout) {struct rtsx_dev *rtsx = chip->rtsx;struct completion trans_done;
@@ -716,9 +726,9 @@ out: }int rtsx_transfer_data_partial (struct rtsx_chip *chip,u8 card, -void *buf,size_t len,int use_sg,unsigned int *index, -unsigned int *offset,enum dma_data_direction dma_dir, -int timeout) +void *buf,size_t len,int use_sg, +unsigned int *index,unsigned int *offset, +enum dma_data_direction dma_dir,int timeout) {int err =0 ;
@@ -726,13 +736,16 @@ int rtsx_transfer_data_partial(struct rtsx_chip *chip, u8 card,if (rtsx_chk_stat (chip,RTSX_STAT_ABORT ))return -EIO ; -if (use_sg) - err =rtsx_transfer_sglist_adma_partial (chip, card, - (struct scatterlist *)buf, use_sg, - index, offset, (int )len, dma_dir, timeout); -else +if (use_sg) { +struct scatterlist *sg = (struct scatterlist *)buf; + + err =rtsx_transfer_sglist_adma_partial (chip, card, sg, use_sg, + index, offset, (int )len, + dma_dir, timeout); + }else { err =rtsx_transfer_buf (chip, card, buf, len, dma_dir, timeout); + }if (err <0 ) {if (RTSX_TST_DELINK (chip)) {RTSX_CLR_DELINK (chip);
@@ -745,7 +758,7 @@ int rtsx_transfer_data_partial(struct rtsx_chip *chip, u8 card, }int rtsx_transfer_data (struct rtsx_chip *chip,u8 card,void *buf,size_t len, -int use_sg,enum dma_data_direction dma_dir,int timeout) +int use_sg,enum dma_data_direction dma_dir,int timeout) {int err =0 ;
@@ -757,8 +770,8 @@ int rtsx_transfer_data(struct rtsx_chip *chip, u8 card, void *buf, size_t len,if (use_sg) { err =rtsx_transfer_sglist_adma (chip, card, - (struct scatterlist *)buf, - use_sg, dma_dir, timeout); + (struct scatterlist *)buf, + use_sg, dma_dir, timeout); }else { err =rtsx_transfer_buf (chip, card, buf, len, dma_dir, timeout); }
Signature · 1 line
2.7.1
PATCH RESEND v5 3/8 Staging: rts5208: rtsx_transport.c: Remove spaces after casts
In reply to Shaun RenThis patch removes all spaces after casts in rtsx_transport.c, as reported by checkpatch.pl:
CHECK: No space is necessary after a cast
--- drivers/staging/rts5208/rtsx_transport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rts5208/rtsx_transport.c +1 -1
@@ -73,7 +73,7 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer,*/ }else {struct scatterlist *sg = - (struct scatterlist *)scsi_sglist (srb) + (struct scatterlist *)scsi_sglist (srb) + *index;/*
Signature · 1 line
2.7.1
PATCH RESEND v5 4/8 Staging: rts5208: rtsx_transport.c: Add spaces around -
In reply to Shaun RenThis patch fixes the following styling issue in rtsx_transport.c as reported by checkpatch.pl:
CHECK: spaces preferred around that '-' (ctx:VxV)
--- drivers/staging/rts5208/rtsx_transport.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/rts5208/rtsx_transport.c +2 -2
@@ -86,8 +86,8 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer,while (cnt < buflen && *index <scsi_sg_count (srb)) {struct page *page =sg_page (sg) + ((sg->offset + *offset) >>PAGE_SHIFT ); -unsigned int poff = - (sg->offset + *offset) & (PAGE_SIZE -1 ); +unsigned int poff = (sg->offset + *offset) & + (PAGE_SIZE -1 );unsigned int sglen = sg->length - *offset;if (sglen > buflen - cnt) {
Signature · 1 line
2.7.1
PATCH RESEND v5 5/8 Staging: rts5208: rtsx_transport.c: Remove extra newlines
In reply to Shaun RenThis patch fixes the following issues in rtsx_transport.c as reported by checkpatch.pl:
CHECK: Blank lines aren't necessary after an open brace '{'
CHECK: Please don't use multiple blank lines
--- drivers/staging/rts5208/rtsx_transport.c | 3 --- 1 file changed, 3 deletions(-)
drivers/staging/rts5208/rtsx_transport.c +0 -3
@@ -91,12 +91,10 @@ unsigned int rtsx_stor_access_xfer_buf(unsigned char *buffer,unsigned int sglen = sg->length - *offset;if (sglen > buflen - cnt) { -/* Transfer ends within this s-g entry */ sglen = buflen - cnt; *offset += sglen; }else { -/* Transfer continues to next s-g entry */ *offset =0 ; ++*index;
@@ -153,7 +151,6 @@ void rtsx_stor_get_xfer_buf(unsigned char *buffer,scsi_set_resid (srb,scsi_bufflen (srb) - buflen); } -/*********************************************************************** * Transport routines ***********************************************************************/
Signature · 1 line
2.7.1
PATCH RESEND v5 6/8 Staging: rts5208: rtsx_transport.c: Fix label naming convention
In reply to Shaun RenThis patch fixes the following naming convention issue in rtsx_transport.c, as reported by checkpatch.pl:
CHECK: Avoid CamelCase: <Handle_Errors>
--- drivers/staging/rts5208/rtsx_transport.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/rts5208/rtsx_transport.c +3 -3
@@ -173,14 +173,14 @@ void rtsx_invoke_transport(struct scsi_cmnd *srb, struct rtsx_chip *chip)if (rtsx_chk_stat (chip,RTSX_STAT_ABORT )) {dev_dbg (rtsx_dev (chip),"-- command was aborted\n" ); srb->result =DID_ABORT <<16 ; - goto Handle_Errors; + goto handle_errors; }/* if there is a transport error, reset and don't auto-sense */ if (result ==TRANSPORT_ERROR ) {dev_dbg (rtsx_dev (chip),"-- transport indicates error, resetting\n" ); srb->result =DID_ERROR <<16 ; - goto Handle_Errors; + goto handle_errors; } srb->result =SAM_STAT_GOOD ;
@@ -200,7 +200,7 @@ void rtsx_invoke_transport(struct scsi_cmnd *srb, struct rtsx_chip *chip)return ; -Handle_Errors: +handle_errors:return ; }
Signature · 1 line
2.7.1
PATCH RESEND v5 7/8 Staging: rts5208: rtsx_transport.c: Remove unnecessary parentheses
In reply to Shaun RenThis patch removes all unnecessary parentheses found by checkpatch.pl.
---
Changes since v3
* Fixed patch conflicts due to commit 9a66d05d82db
("Staging: rts5208: fix check for dma mapping error"), and commit b3232842dbef ("Staging: rts5208: remove unnecessary parantheses")
drivers/staging/rts5208/rtsx_transport.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/staging/rts5208/rtsx_transport.c +6 -6
@@ -194,7 +194,7 @@ void rtsx_invoke_transport(struct scsi_cmnd *srb, struct rtsx_chip *chip)/* set the result so the higher layers expect this data */ srb->result =SAM_STAT_CHECK_CONDITION ;memcpy (srb->sense_buffer, - (unsigned char *)&(chip->sense_buffer[SCSI_LUN (srb)]), + (unsigned char *)&chip->sense_buffer[SCSI_LUN (srb)],sizeof (struct sense_data_t )); }
@@ -368,7 +368,7 @@ static int rtsx_transfer_sglist_adma_partial(struct rtsx_chip *chip, u8 card,spin_unlock_irq (&rtsx->reg_lock); - sg_cnt =dma_map_sg (&(rtsx->pci->dev), sg, num_sg, dma_dir); + sg_cnt =dma_map_sg (&rtsx->pci->dev, sg, num_sg, dma_dir); resid = size; sg_ptr = sg;
@@ -482,7 +482,7 @@ static int rtsx_transfer_sglist_adma_partial(struct rtsx_chip *chip, u8 card, out: rtsx->done =NULL ; rtsx->trans_state =STATE_TRANS_NONE ; -dma_unmap_sg (&(rtsx->pci->dev), sg, num_sg, dma_dir); +dma_unmap_sg (&rtsx->pci->dev, sg, num_sg, dma_dir);if (err <0 )rtsx_stop_cmd (chip, card);
@@ -532,7 +532,7 @@ static int rtsx_transfer_sglist_adma(struct rtsx_chip *chip, u8 card,spin_unlock_irq (&rtsx->reg_lock); - buf_cnt =dma_map_sg (&(rtsx->pci->dev), sg, num_sg, dma_dir); + buf_cnt =dma_map_sg (&rtsx->pci->dev, sg, num_sg, dma_dir); sg_ptr = sg;
@@ -630,7 +630,7 @@ static int rtsx_transfer_sglist_adma(struct rtsx_chip *chip, u8 card, out: rtsx->done =NULL ; rtsx->trans_state =STATE_TRANS_NONE ; -dma_unmap_sg (&(rtsx->pci->dev), sg, num_sg, dma_dir); +dma_unmap_sg (&rtsx->pci->dev, sg, num_sg, dma_dir);if (err <0 )rtsx_stop_cmd (chip, card);
@@ -714,7 +714,7 @@ static int rtsx_transfer_buf(struct rtsx_chip *chip, u8 card, void *buf, out: rtsx->done =NULL ; rtsx->trans_state =STATE_TRANS_NONE ; -dma_unmap_single (&(rtsx->pci->dev), addr, len, dma_dir); +dma_unmap_single (&rtsx->pci->dev, addr, len, dma_dir);if (err <0 )rtsx_stop_cmd (chip, card);
Signature · 1 line
2.7.1
PATCH RESEND v5 8/8 Staging: rts5208: rtsx_transport.c: Fix comparisons to NULL
In reply to Shaun RenThis patch changes all comparsions to NULL with !..., as reported by checkpatch.pl.
--- drivers/staging/rts5208/rtsx_transport.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/rts5208/rtsx_transport.c +3 -3
@@ -339,7 +339,7 @@ static int rtsx_transfer_sglist_adma_partial(struct rtsx_chip *chip, u8 card,struct scatterlist *sg_ptr;u32 val =TRIG_DMA ; -if ((sg ==NULL ) || (num_sg <=0 ) || !offset || !index) +if (!sg || (num_sg <=0 ) || !offset || !index)return -EIO ;if (dma_dir ==DMA_TO_DEVICE )
@@ -503,7 +503,7 @@ static int rtsx_transfer_sglist_adma(struct rtsx_chip *chip, u8 card,long timeleft;struct scatterlist *sg_ptr; -if ((sg ==NULL ) || (num_sg <=0 )) +if (!sg || (num_sg <=0 ))return -EIO ;if (dma_dir ==DMA_TO_DEVICE )
@@ -650,7 +650,7 @@ static int rtsx_transfer_buf(struct rtsx_chip *chip, u8 card, void *buf,u32 val =1 <<31 ;long timeleft; -if ((buf ==NULL ) || (len <=0 )) +if (!buf || (len <=0 ))return -EIO ;if (dma_dir ==DMA_TO_DEVICE )
Signature · 1 line
2.7.1