All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Staging: rts5208: Coding style and dma mapping fixes
@ 2016-01-26  2:27 ` Shaun Ren
  0 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-01-26  2:27 UTC (permalink / raw)
  To: gregkh, rjui
  Cc: sbranden, jonmason, mahfouz.saif.elyazal, joe, devel,
	linux-arm-kernel, bcm-kernel-feedback-list, linux-kernel

This set of patches fixes the coding style issues in rtsx_transport.c, and adds
a missing dma_mapping_error check.

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [PATCH 0/2] Staging: rts5208: Coding style and dma mapping fixes
@ 2016-01-26  2:27 ` Shaun Ren
  0 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-01-26  2:27 UTC (permalink / raw)
  To: linux-arm-kernel

This set of patches fixes the coding style issues in rtsx_transport.c, and adds
a missing dma_mapping_error check.

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [PATCH 1/2] Staging: rts5208: Cleanup rtsx_transport.c
  2016-01-26  2:27 ` Shaun Ren
@ 2016-01-26  2:27   ` Shaun Ren
  -1 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-01-26  2:27 UTC (permalink / raw)
  To: gregkh, rjui
  Cc: sbranden, jonmason, mahfouz.saif.elyazal, joe, devel,
	linux-arm-kernel, bcm-kernel-feedback-list, linux-kernel,
	Shaun Ren

This patch fixes coding style issues in rtsx_transport.c.

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 115 +++++++++++++++++--------------
 1 file changed, 65 insertions(+), 50 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index f27491e..eff9a4b621 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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;
 }
-
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH 1/2] Staging: rts5208: Cleanup rtsx_transport.c
@ 2016-01-26  2:27   ` Shaun Ren
  0 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-01-26  2:27 UTC (permalink / raw)
  To: linux-arm-kernel

This patch fixes coding style issues in rtsx_transport.c.

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 115 +++++++++++++++++--------------
 1 file changed, 65 insertions(+), 50 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index f27491e..eff9a4b621 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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;
 }
-
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH 2/2] Staging: rts5208: Add missing dma_mapping_error
  2016-01-26  2:27 ` Shaun Ren
@ 2016-01-26  2:27   ` Shaun Ren
  -1 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-01-26  2:27 UTC (permalink / raw)
  To: gregkh, rjui
  Cc: sbranden, jonmason, mahfouz.saif.elyazal, joe, devel,
	linux-arm-kernel, bcm-kernel-feedback-list, linux-kernel,
	Shaun Ren

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index eff9a4b621..43787df 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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)
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH 2/2] Staging: rts5208: Add missing dma_mapping_error
@ 2016-01-26  2:27   ` Shaun Ren
  0 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-01-26  2:27 UTC (permalink / raw)
  To: linux-arm-kernel

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index eff9a4b621..43787df 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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)
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* Re: [PATCH 1/2] Staging: rts5208: Cleanup rtsx_transport.c
  2016-01-26  2:27   ` Shaun Ren
@ 2016-02-08  4:03     ` Greg KH
  -1 siblings, 0 replies; 106+ messages in thread
From: Greg KH @ 2016-02-08  4:03 UTC (permalink / raw)
  To: Shaun Ren
  Cc: rjui, devel, sbranden, jonmason, linux-kernel,
	bcm-kernel-feedback-list, joe, linux-arm-kernel

On Mon, Jan 25, 2016 at 06:27:27PM -0800, Shaun Ren wrote:
> This patch fixes coding style issues in rtsx_transport.c.
> 
> Signed-off-by: Shaun Ren <shaun.ren@linux.com>
> ---
>  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

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [PATCH 1/2] Staging: rts5208: Cleanup rtsx_transport.c
@ 2016-02-08  4:03     ` Greg KH
  0 siblings, 0 replies; 106+ messages in thread
From: Greg KH @ 2016-02-08  4:03 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Jan 25, 2016 at 06:27:27PM -0800, Shaun Ren wrote:
> This patch fixes coding style issues in rtsx_transport.c.
> 
> Signed-off-by: Shaun Ren <shaun.ren@linux.com>
> ---
>  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

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH 2/2] Staging: rts5208: Add missing dma_mapping_error
  2016-01-26  2:27   ` Shaun Ren
@ 2016-02-08  4:03     ` Greg KH
  -1 siblings, 0 replies; 106+ messages in thread
From: Greg KH @ 2016-02-08  4:03 UTC (permalink / raw)
  To: Shaun Ren
  Cc: rjui, devel, sbranden, jonmason, linux-kernel,
	bcm-kernel-feedback-list, joe, linux-arm-kernel

On Mon, Jan 25, 2016 at 06:27:28PM -0800, Shaun Ren wrote:
> Signed-off-by: Shaun Ren <shaun.ren@linux.com>
> ---

I can't take a patch without a changelog entry, sorry.

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [PATCH 2/2] Staging: rts5208: Add missing dma_mapping_error
@ 2016-02-08  4:03     ` Greg KH
  0 siblings, 0 replies; 106+ messages in thread
From: Greg KH @ 2016-02-08  4:03 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Jan 25, 2016 at 06:27:28PM -0800, Shaun Ren wrote:
> Signed-off-by: Shaun Ren <shaun.ren@linux.com>
> ---

I can't take a patch without a changelog entry, sorry.

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [PATCH v2 0/9] Staging: rts5208: Coding style and dma mapping fixes
  2016-01-26  2:27 ` Shaun Ren
@ 2016-02-09  1:31   ` Shaun Ren
  -1 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-09  1:31 UTC (permalink / raw)
  To: gregkh, rjui
  Cc: sbranden, jonmason, mahfouz.saif.elyazal, joe, devel,
	linux-arm-kernel, bcm-kernel-feedback-list, linux-kernel

This set of patches fixes the coding style issues in rtsx_transport.c, and
dds a missing call dma_mapping_error() after dma_map_single().

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [PATCH v2 0/9] Staging: rts5208: Coding style and dma mapping fixes
@ 2016-02-09  1:31   ` Shaun Ren
  0 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-09  1:31 UTC (permalink / raw)
  To: linux-arm-kernel

This set of patches fixes the coding style issues in rtsx_transport.c, and
dds a missing call dma_mapping_error() after dma_map_single().

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [PATCH v2 1/9] Staging: rts5208: rtsx_transport.c: Fix comment style warnings
  2016-02-09  1:31   ` Shaun Ren
@ 2016-02-09  1:31     ` Shaun Ren
  -1 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-09  1:31 UTC (permalink / raw)
  To: gregkh, rjui
  Cc: sbranden, jonmason, mahfouz.saif.elyazal, joe, devel,
	linux-arm-kernel, bcm-kernel-feedback-list, linux-kernel,
	Shaun Ren

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

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index f27491e..3e3f6fb 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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;
 }
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v2 1/9] Staging: rts5208: rtsx_transport.c: Fix comment style warnings
@ 2016-02-09  1:31     ` Shaun Ren
  0 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-09  1:31 UTC (permalink / raw)
  To: linux-arm-kernel

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

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index f27491e..3e3f6fb 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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;
 }
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v2 2/9] Staging: rts5208: rtsx_transport.c: Align to open parenthesis
  2016-02-09  1:31   ` Shaun Ren
@ 2016-02-09  1:31     ` Shaun Ren
  -1 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-09  1:31 UTC (permalink / raw)
  To: gregkh, rjui
  Cc: sbranden, jonmason, mahfouz.saif.elyazal, joe, devel,
	linux-arm-kernel, bcm-kernel-feedback-list, linux-kernel,
	Shaun Ren

This patch fixes the alignment issue reported by checkpatch.pl:

CHECK: Alignment should match open parenthesis

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 61 ++++++++++++++++++--------------
 1 file changed, 35 insertions(+), 26 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index 3e3f6fb..67162f6 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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);
 	}
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v2 2/9] Staging: rts5208: rtsx_transport.c: Align to open parenthesis
@ 2016-02-09  1:31     ` Shaun Ren
  0 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-09  1:31 UTC (permalink / raw)
  To: linux-arm-kernel

This patch fixes the alignment issue reported by checkpatch.pl:

CHECK: Alignment should match open parenthesis

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 61 ++++++++++++++++++--------------
 1 file changed, 35 insertions(+), 26 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index 3e3f6fb..67162f6 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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);
 	}
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v2 3/9] Staging: rts5208: rtsx_transport.c: Remove spaces after casts
  2016-02-09  1:31   ` Shaun Ren
@ 2016-02-09  1:31     ` Shaun Ren
  -1 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-09  1:31 UTC (permalink / raw)
  To: gregkh, rjui
  Cc: sbranden, jonmason, mahfouz.saif.elyazal, joe, devel,
	linux-arm-kernel, bcm-kernel-feedback-list, linux-kernel,
	Shaun Ren

This patch removes all spaces after casts in rtsx_transport.c, as reported
by checkpatch.pl:

CHECK: No space is necessary after a cast

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index 67162f6..8a68f64 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v2 3/9] Staging: rts5208: rtsx_transport.c: Remove spaces after casts
@ 2016-02-09  1:31     ` Shaun Ren
  0 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-09  1:31 UTC (permalink / raw)
  To: linux-arm-kernel

This patch removes all spaces after casts in rtsx_transport.c, as reported
by checkpatch.pl:

CHECK: No space is necessary after a cast

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index 67162f6..8a68f64 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v2 4/9] Staging: rts5208: rtsx_transport.c: Add spaces around -
  2016-02-09  1:31   ` Shaun Ren
@ 2016-02-09  1:31     ` Shaun Ren
  -1 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-09  1:31 UTC (permalink / raw)
  To: gregkh, rjui
  Cc: sbranden, jonmason, mahfouz.saif.elyazal, joe, devel,
	linux-arm-kernel, bcm-kernel-feedback-list, linux-kernel,
	Shaun Ren

This patch fixes the following styling issue in rtsx_transport.c
as reported by checkpatch.pl:

CHECK: spaces preferred around that '-' (ctx:VxV)

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index 8a68f64..901c64a 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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) {
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v2 4/9] Staging: rts5208: rtsx_transport.c: Add spaces around -
@ 2016-02-09  1:31     ` Shaun Ren
  0 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-09  1:31 UTC (permalink / raw)
  To: linux-arm-kernel

This patch fixes the following styling issue in rtsx_transport.c
as reported by checkpatch.pl:

CHECK: spaces preferred around that '-' (ctx:VxV)

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index 8a68f64..901c64a 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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) {
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v2 5/9] Staging: rts5208: rtsx_transport.c: Remove extra newlines
  2016-02-09  1:31   ` Shaun Ren
@ 2016-02-09  1:31     ` Shaun Ren
  -1 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-09  1:31 UTC (permalink / raw)
  To: gregkh, rjui
  Cc: sbranden, jonmason, mahfouz.saif.elyazal, joe, devel,
	linux-arm-kernel, bcm-kernel-feedback-list, linux-kernel,
	Shaun Ren

This 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

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index 901c64a..73302af 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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
  ***********************************************************************/
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v2 5/9] Staging: rts5208: rtsx_transport.c: Remove extra newlines
@ 2016-02-09  1:31     ` Shaun Ren
  0 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-09  1:31 UTC (permalink / raw)
  To: linux-arm-kernel

This 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

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index 901c64a..73302af 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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
  ***********************************************************************/
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v2 6/9] Staging: rts5208: rtsx_transport.c: Fix label naming convention
  2016-02-09  1:31   ` Shaun Ren
@ 2016-02-09  1:31     ` Shaun Ren
  -1 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-09  1:31 UTC (permalink / raw)
  To: gregkh, rjui
  Cc: sbranden, jonmason, mahfouz.saif.elyazal, joe, devel,
	linux-arm-kernel, bcm-kernel-feedback-list, linux-kernel,
	Shaun Ren

This patch fixes the following naming convention issue in rtsx_transport.c,
as reported by checkpatch.pl:

CHECK: Avoid CamelCase: <Handle_Errors>

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index 73302af..ca209c6 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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;
 }
 
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v2 6/9] Staging: rts5208: rtsx_transport.c: Fix label naming convention
@ 2016-02-09  1:31     ` Shaun Ren
  0 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-09  1:31 UTC (permalink / raw)
  To: linux-arm-kernel

This patch fixes the following naming convention issue in rtsx_transport.c,
as reported by checkpatch.pl:

CHECK: Avoid CamelCase: <Handle_Errors>

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index 73302af..ca209c6 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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;
 }
 
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v2 7/9] Staging: rts5208: rtsx_transport.c: Remove unnecessary parentheses
  2016-02-09  1:31   ` Shaun Ren
@ 2016-02-09  1:31     ` Shaun Ren
  -1 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-09  1:31 UTC (permalink / raw)
  To: gregkh, rjui
  Cc: sbranden, jonmason, mahfouz.saif.elyazal, joe, devel,
	linux-arm-kernel, bcm-kernel-feedback-list, linux-kernel,
	Shaun Ren

This patch removes all unnecessary parentheses found by checkpatch.pl.

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index ca209c6..fa062f6 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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);
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v2 7/9] Staging: rts5208: rtsx_transport.c: Remove unnecessary parentheses
@ 2016-02-09  1:31     ` Shaun Ren
  0 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-09  1:31 UTC (permalink / raw)
  To: linux-arm-kernel

This patch removes all unnecessary parentheses found by checkpatch.pl.

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index ca209c6..fa062f6 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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);
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v2 8/9] Staging: rts5208: rtsx_transport.c: Fix comparisons to NULL
  2016-02-09  1:31   ` Shaun Ren
@ 2016-02-09  1:31     ` Shaun Ren
  -1 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-09  1:31 UTC (permalink / raw)
  To: gregkh, rjui
  Cc: sbranden, jonmason, mahfouz.saif.elyazal, joe, devel,
	linux-arm-kernel, bcm-kernel-feedback-list, linux-kernel,
	Shaun Ren

This patch changes all comparsions to NULL with !..., as reported by
checkpatch.pl.

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index fa062f6..c0fd8c5 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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)
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v2 8/9] Staging: rts5208: rtsx_transport.c: Fix comparisons to NULL
@ 2016-02-09  1:31     ` Shaun Ren
  0 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-09  1:31 UTC (permalink / raw)
  To: linux-arm-kernel

This patch changes all comparsions to NULL with !..., as reported by
checkpatch.pl.

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index fa062f6..c0fd8c5 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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)
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v2 9/9] Staging: rts5208: Add missing dma_mapping_error
  2016-02-09  1:31   ` Shaun Ren
@ 2016-02-09  1:31     ` Shaun Ren
  -1 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-09  1:31 UTC (permalink / raw)
  To: gregkh, rjui
  Cc: sbranden, jonmason, mahfouz.saif.elyazal, joe, devel,
	linux-arm-kernel, bcm-kernel-feedback-list, linux-kernel,
	Shaun Ren

This patch adds a dma_mapping_error call to debug potential DMA mapping
errors after the dma_map_single call in rtsx_transport.c.

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index c0fd8c5..00da7ab 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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)
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v2 9/9] Staging: rts5208: Add missing dma_mapping_error
@ 2016-02-09  1:31     ` Shaun Ren
  0 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-09  1:31 UTC (permalink / raw)
  To: linux-arm-kernel

This patch adds a dma_mapping_error call to debug potential DMA mapping
errors after the dma_map_single call in rtsx_transport.c.

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index c0fd8c5..00da7ab 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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)
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* Re: [PATCH v2 1/9] Staging: rts5208: rtsx_transport.c: Fix comment style warnings
  2016-02-09  1:31     ` Shaun Ren
@ 2016-02-09  3:05       ` Joshua Clayton
  -1 siblings, 0 replies; 106+ messages in thread
From: Joshua Clayton @ 2016-02-09  3:05 UTC (permalink / raw)
  To: linux-arm-kernel, Shaun Ren
  Cc: gregkh, rjui, devel, sbranden, jonmason, linux-kernel,
	bcm-kernel-feedback-list, joe, mahfouz.saif.elyazal

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. 

On Monday, February 08, 2016 05:31:17 PM Shaun Ren wrote:
> 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
> 
> Signed-off-by: Shaun Ren <shaun.ren@linux.com>
> ---
>  drivers/staging/rts5208/rtsx_transport.c | 21 ++++++++++++++-------
>  1 file changed, 14 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
> index f27491e..3e3f6fb 100644
> --- a/drivers/staging/rts5208/rtsx_transport.c
> +++ b/drivers/staging/rts5208/rtsx_transport.c
> @@ -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.
 
>  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.
> +	 */

Either fix the beginning...  or better yet, get rid of the useless
(obvious) second line so it can be a single line comment.

>  	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.
> +	 */

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. 

>  	} 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.

>  		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.
> +			 */

I'd get rid of this comment. It parrots what the code does, but does not
add any information.

>  			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.
> + */

Fix the beginning as well.

>  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.
> +	 */

This comment  describes something that does not
happen in this function. Perhaps it did at one point. 
Regardless, It should be removed.

>  Handle_Errors:
>  	return;
>  }
> 

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [PATCH v2 1/9] Staging: rts5208: rtsx_transport.c: Fix comment style warnings
@ 2016-02-09  3:05       ` Joshua Clayton
  0 siblings, 0 replies; 106+ messages in thread
From: Joshua Clayton @ 2016-02-09  3:05 UTC (permalink / raw)
  To: linux-arm-kernel

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. 

On Monday, February 08, 2016 05:31:17 PM Shaun Ren wrote:
> 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
> 
> Signed-off-by: Shaun Ren <shaun.ren@linux.com>
> ---
>  drivers/staging/rts5208/rtsx_transport.c | 21 ++++++++++++++-------
>  1 file changed, 14 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
> index f27491e..3e3f6fb 100644
> --- a/drivers/staging/rts5208/rtsx_transport.c
> +++ b/drivers/staging/rts5208/rtsx_transport.c
> @@ -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.
 
>  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.
> +	 */

Either fix the beginning...  or better yet, get rid of the useless
(obvious) second line so it can be a single line comment.

>  	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.
> +	 */

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. 

>  	} 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.

>  		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.
> +			 */

I'd get rid of this comment. It parrots what the code does, but does not
add any information.

>  			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.
> + */

Fix the beginning as well.

>  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.
> +	 */

This comment  describes something that does not
happen in this function. Perhaps it did at one point. 
Regardless, It should be removed.

>  Handle_Errors:
>  	return;
>  }
> 

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [PATCH v3 0/9] Staging: rts5208: Coding style and dma mapping fixes
  2016-02-09  1:31   ` Shaun Ren
@ 2016-02-10  2:45     ` Shaun Ren
  -1 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-10  2:45 UTC (permalink / raw)
  To: gregkh, rjui
  Cc: sbranden, jonmason, mahfouz.saif.elyazal, joe, devel,
	linux-arm-kernel, bcm-kernel-feedback-list, linux-kernel

This 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

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [PATCH v3 0/9] Staging: rts5208: Coding style and dma mapping fixes
@ 2016-02-10  2:45     ` Shaun Ren
  0 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-10  2:45 UTC (permalink / raw)
  To: linux-arm-kernel

This 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

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [PATCH v3 1/9] Staging: rts5208: rtsx_transport.c: Cleanup comments
  2016-02-10  2:45     ` Shaun Ren
@ 2016-02-10  2:45       ` Shaun Ren
  -1 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-10  2:45 UTC (permalink / raw)
  To: gregkh, rjui
  Cc: sbranden, jonmason, mahfouz.saif.elyazal, joe, devel,
	linux-arm-kernel, bcm-kernel-feedback-list, linux-kernel,
	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 <shaun.ren@linux.com>
---
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(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index f27491e..5de8913 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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);
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v3 1/9] Staging: rts5208: rtsx_transport.c: Cleanup comments
@ 2016-02-10  2:45       ` Shaun Ren
  0 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-10  2:45 UTC (permalink / raw)
  To: linux-arm-kernel

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 <shaun.ren@linux.com>
---
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(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index f27491e..5de8913 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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);
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v3 2/9] Staging: rts5208: rtsx_transport.c: Align to open parenthesis
  2016-02-10  2:45     ` Shaun Ren
@ 2016-02-10  2:45       ` Shaun Ren
  -1 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-10  2:45 UTC (permalink / raw)
  To: gregkh, rjui
  Cc: sbranden, jonmason, mahfouz.saif.elyazal, joe, devel,
	linux-arm-kernel, bcm-kernel-feedback-list, linux-kernel,
	Shaun Ren

This patch fixes the alignment issue reported by checkpatch.pl:

CHECK: Alignment should match open parenthesis

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 61 ++++++++++++++++++--------------
 1 file changed, 35 insertions(+), 26 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index 5de8913..17bea8a 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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);
 	}
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v3 2/9] Staging: rts5208: rtsx_transport.c: Align to open parenthesis
@ 2016-02-10  2:45       ` Shaun Ren
  0 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-10  2:45 UTC (permalink / raw)
  To: linux-arm-kernel

This patch fixes the alignment issue reported by checkpatch.pl:

CHECK: Alignment should match open parenthesis

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 61 ++++++++++++++++++--------------
 1 file changed, 35 insertions(+), 26 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index 5de8913..17bea8a 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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);
 	}
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v3 3/9] Staging: rts5208: rtsx_transport.c: Remove spaces after casts
  2016-02-10  2:45     ` Shaun Ren
@ 2016-02-10  2:45       ` Shaun Ren
  -1 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-10  2:45 UTC (permalink / raw)
  To: gregkh, rjui
  Cc: sbranden, jonmason, mahfouz.saif.elyazal, joe, devel,
	linux-arm-kernel, bcm-kernel-feedback-list, linux-kernel,
	Shaun Ren

This patch removes all spaces after casts in rtsx_transport.c, as reported
by checkpatch.pl:

CHECK: No space is necessary after a cast

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index 17bea8a..57b1f46 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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;
 
 		/*
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v3 3/9] Staging: rts5208: rtsx_transport.c: Remove spaces after casts
@ 2016-02-10  2:45       ` Shaun Ren
  0 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-10  2:45 UTC (permalink / raw)
  To: linux-arm-kernel

This patch removes all spaces after casts in rtsx_transport.c, as reported
by checkpatch.pl:

CHECK: No space is necessary after a cast

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index 17bea8a..57b1f46 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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;
 
 		/*
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v3 4/9] Staging: rts5208: rtsx_transport.c: Add spaces around -
  2016-02-10  2:45     ` Shaun Ren
@ 2016-02-10  2:45       ` Shaun Ren
  -1 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-10  2:45 UTC (permalink / raw)
  To: gregkh, rjui
  Cc: sbranden, jonmason, mahfouz.saif.elyazal, joe, devel,
	linux-arm-kernel, bcm-kernel-feedback-list, linux-kernel,
	Shaun Ren

This patch fixes the following styling issue in rtsx_transport.c
as reported by checkpatch.pl:

CHECK: spaces preferred around that '-' (ctx:VxV)

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index 57b1f46..b137aca 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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) {
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v3 4/9] Staging: rts5208: rtsx_transport.c: Add spaces around -
@ 2016-02-10  2:45       ` Shaun Ren
  0 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-10  2:45 UTC (permalink / raw)
  To: linux-arm-kernel

This patch fixes the following styling issue in rtsx_transport.c
as reported by checkpatch.pl:

CHECK: spaces preferred around that '-' (ctx:VxV)

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index 57b1f46..b137aca 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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) {
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v3 5/9] Staging: rts5208: rtsx_transport.c: Remove extra newlines
  2016-02-10  2:45     ` Shaun Ren
@ 2016-02-10  2:45       ` Shaun Ren
  -1 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-10  2:45 UTC (permalink / raw)
  To: gregkh, rjui
  Cc: sbranden, jonmason, mahfouz.saif.elyazal, joe, devel,
	linux-arm-kernel, bcm-kernel-feedback-list, linux-kernel,
	Shaun Ren

This 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

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index b137aca..14321c0 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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
  ***********************************************************************/
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v3 5/9] Staging: rts5208: rtsx_transport.c: Remove extra newlines
@ 2016-02-10  2:45       ` Shaun Ren
  0 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-10  2:45 UTC (permalink / raw)
  To: linux-arm-kernel

This 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

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index b137aca..14321c0 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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
  ***********************************************************************/
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v3 6/9] Staging: rts5208: rtsx_transport.c: Fix label naming convention
  2016-02-10  2:45     ` Shaun Ren
@ 2016-02-10  2:45       ` Shaun Ren
  -1 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-10  2:45 UTC (permalink / raw)
  To: gregkh, rjui
  Cc: sbranden, jonmason, mahfouz.saif.elyazal, joe, devel,
	linux-arm-kernel, bcm-kernel-feedback-list, linux-kernel,
	Shaun Ren

This patch fixes the following naming convention issue in rtsx_transport.c,
as reported by checkpatch.pl:

CHECK: Avoid CamelCase: <Handle_Errors>

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
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(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index 14321c0..ea00347 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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;
 }
 
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v3 6/9] Staging: rts5208: rtsx_transport.c: Fix label naming convention
@ 2016-02-10  2:45       ` Shaun Ren
  0 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-10  2:45 UTC (permalink / raw)
  To: linux-arm-kernel

This patch fixes the following naming convention issue in rtsx_transport.c,
as reported by checkpatch.pl:

CHECK: Avoid CamelCase: <Handle_Errors>

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
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(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index 14321c0..ea00347 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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;
 }
 
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v3 7/9] Staging: rts5208: rtsx_transport.c: Remove unnecessary parentheses
  2016-02-10  2:45     ` Shaun Ren
@ 2016-02-10  2:45       ` Shaun Ren
  -1 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-10  2:45 UTC (permalink / raw)
  To: gregkh, rjui
  Cc: sbranden, jonmason, mahfouz.saif.elyazal, joe, devel,
	linux-arm-kernel, bcm-kernel-feedback-list, linux-kernel,
	Shaun Ren

This patch removes all unnecessary parentheses found by checkpatch.pl.

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index ea00347..c956072 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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);
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v3 7/9] Staging: rts5208: rtsx_transport.c: Remove unnecessary parentheses
@ 2016-02-10  2:45       ` Shaun Ren
  0 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-10  2:45 UTC (permalink / raw)
  To: linux-arm-kernel

This patch removes all unnecessary parentheses found by checkpatch.pl.

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index ea00347..c956072 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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);
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v3 8/9] Staging: rts5208: rtsx_transport.c: Fix comparisons to NULL
  2016-02-10  2:45     ` Shaun Ren
@ 2016-02-10  2:45       ` Shaun Ren
  -1 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-10  2:45 UTC (permalink / raw)
  To: gregkh, rjui
  Cc: sbranden, jonmason, mahfouz.saif.elyazal, joe, devel,
	linux-arm-kernel, bcm-kernel-feedback-list, linux-kernel,
	Shaun Ren

This patch changes all comparsions to NULL with !..., as reported by
checkpatch.pl.

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index c956072..46fc8c2 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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)
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v3 8/9] Staging: rts5208: rtsx_transport.c: Fix comparisons to NULL
@ 2016-02-10  2:45       ` Shaun Ren
  0 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-10  2:45 UTC (permalink / raw)
  To: linux-arm-kernel

This patch changes all comparsions to NULL with !..., as reported by
checkpatch.pl.

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index c956072..46fc8c2 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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)
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v3 9/9] Staging: rts5208: Add missing dma_mapping_error
  2016-02-10  2:45     ` Shaun Ren
@ 2016-02-10  2:45       ` Shaun Ren
  -1 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-10  2:45 UTC (permalink / raw)
  To: gregkh, rjui
  Cc: sbranden, jonmason, mahfouz.saif.elyazal, joe, devel,
	linux-arm-kernel, bcm-kernel-feedback-list, linux-kernel,
	Shaun Ren

This patch adds a dma_mapping_error call to debug potential DMA mapping
errors after the dma_map_single call in rtsx_transport.c.

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index 46fc8c2..2b38de7 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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)
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v3 9/9] Staging: rts5208: Add missing dma_mapping_error
@ 2016-02-10  2:45       ` Shaun Ren
  0 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-10  2:45 UTC (permalink / raw)
  To: linux-arm-kernel

This patch adds a dma_mapping_error call to debug potential DMA mapping
errors after the dma_map_single call in rtsx_transport.c.

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index 46fc8c2..2b38de7 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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)
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* Re: [PATCH v3 2/9] Staging: rts5208: rtsx_transport.c: Align to open parenthesis
  2016-02-10  2:45       ` Shaun Ren
@ 2016-02-10  2:58         ` Joe Perches
  -1 siblings, 0 replies; 106+ messages in thread
From: Joe Perches @ 2016-02-10  2:58 UTC (permalink / raw)
  To: Shaun Ren, gregkh, rjui
  Cc: sbranden, jonmason, mahfouz.saif.elyazal, devel,
	linux-arm-kernel, bcm-kernel-feedback-list, linux-kernel

On Tue, 2016-02-09 at 18:45 -0800, Shaun Ren wrote:
> This patch fixes the alignment issue reported by checkpatch.pl:
> 
> CHECK: Alignment should match open parenthesis
> 
> Signed-off-by: Shaun Ren <shaun.ren@linux.com>
> ---
>  drivers/staging/rts5208/rtsx_transport.c | 61 ++++++++++++++++++--------------
>  1 file changed, 35 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
> index 5de8913..17bea8a 100644
> --- a/drivers/staging/rts5208/rtsx_transport.c
> +++ b/drivers/staging/rts5208/rtsx_transport.c
> @@ -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)

Doesn't this look odd to you?

>  {
>  	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);

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);

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [PATCH v3 2/9] Staging: rts5208: rtsx_transport.c: Align to open parenthesis
@ 2016-02-10  2:58         ` Joe Perches
  0 siblings, 0 replies; 106+ messages in thread
From: Joe Perches @ 2016-02-10  2:58 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 2016-02-09 at 18:45 -0800, Shaun Ren wrote:
> This patch fixes the alignment issue reported by checkpatch.pl:
> 
> CHECK: Alignment should match open parenthesis
> 
> Signed-off-by: Shaun Ren <shaun.ren@linux.com>
> ---
> ?drivers/staging/rts5208/rtsx_transport.c | 61 ++++++++++++++++++--------------
> ?1 file changed, 35 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
> index 5de8913..17bea8a 100644
> --- a/drivers/staging/rts5208/rtsx_transport.c
> +++ b/drivers/staging/rts5208/rtsx_transport.c
> @@ -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)

Doesn't this look odd to you?

> ?{
> ?	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);

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);

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v3 1/9] Staging: rts5208: rtsx_transport.c: Cleanup comments
  2016-02-10  2:45       ` Shaun Ren
@ 2016-02-10  3:06         ` Joshua Clayton
  -1 siblings, 0 replies; 106+ messages in thread
From: Joshua Clayton @ 2016-02-10  3:06 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Shaun Ren, gregkh, rjui, devel, sbranden, jonmason, linux-kernel,
	bcm-kernel-feedback-list, joe, mahfouz.saif.elyazal

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.

On Tuesday, February 09, 2016 06:45:20 PM Shaun Ren wrote:
> 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 <shaun.ren@linux.com>
> ---
> 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(-)
> 
> diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
> index f27491e..5de8913 100644
> --- a/drivers/staging/rts5208/rtsx_transport.c
> +++ b/drivers/staging/rts5208/rtsx_transport.c
> @@ -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.
> + */

SCSI SCSI 

>  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);
> 

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [PATCH v3 1/9] Staging: rts5208: rtsx_transport.c: Cleanup comments
@ 2016-02-10  3:06         ` Joshua Clayton
  0 siblings, 0 replies; 106+ messages in thread
From: Joshua Clayton @ 2016-02-10  3:06 UTC (permalink / raw)
  To: linux-arm-kernel

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.

On Tuesday, February 09, 2016 06:45:20 PM Shaun Ren wrote:
> 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 <shaun.ren@linux.com>
> ---
> 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(-)
> 
> diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
> index f27491e..5de8913 100644
> --- a/drivers/staging/rts5208/rtsx_transport.c
> +++ b/drivers/staging/rts5208/rtsx_transport.c
> @@ -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.
> + */

SCSI SCSI 

>  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);
> 

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v2 2/9] Staging: rts5208: rtsx_transport.c: Align to open parenthesis
  2016-02-09  1:31     ` Shaun Ren
@ 2016-02-10  5:21       ` Sudip Mukherjee
  -1 siblings, 0 replies; 106+ messages in thread
From: Sudip Mukherjee @ 2016-02-10  5:21 UTC (permalink / raw)
  To: Shaun Ren
  Cc: gregkh, rjui, devel, sbranden, jonmason, linux-kernel,
	bcm-kernel-feedback-list, joe, linux-arm-kernel

On Mon, Feb 08, 2016 at 05:31:18PM -0800, Shaun Ren wrote:
> This patch fixes the alignment issue reported by checkpatch.pl:
> 
> CHECK: Alignment should match open parenthesis
> 
> Signed-off-by: Shaun Ren <shaun.ren@linux.com>
> ---
>  drivers/staging/rts5208/rtsx_transport.c | 61 ++++++++++++++++++--------------
>  1 file changed, 35 insertions(+), 26 deletions(-)
> 
<snip>
>  
> @@ -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.	
> +
> +		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

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [PATCH v2 2/9] Staging: rts5208: rtsx_transport.c: Align to open parenthesis
@ 2016-02-10  5:21       ` Sudip Mukherjee
  0 siblings, 0 replies; 106+ messages in thread
From: Sudip Mukherjee @ 2016-02-10  5:21 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Feb 08, 2016 at 05:31:18PM -0800, Shaun Ren wrote:
> This patch fixes the alignment issue reported by checkpatch.pl:
> 
> CHECK: Alignment should match open parenthesis
> 
> Signed-off-by: Shaun Ren <shaun.ren@linux.com>
> ---
>  drivers/staging/rts5208/rtsx_transport.c | 61 ++++++++++++++++++--------------
>  1 file changed, 35 insertions(+), 26 deletions(-)
> 
<snip>
>  
> @@ -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.	
> +
> +		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

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v2 7/9] Staging: rts5208: rtsx_transport.c: Remove unnecessary parentheses
  2016-02-09  1:31     ` Shaun Ren
@ 2016-02-10  5:26       ` Sudip Mukherjee
  -1 siblings, 0 replies; 106+ messages in thread
From: Sudip Mukherjee @ 2016-02-10  5:26 UTC (permalink / raw)
  To: Shaun Ren
  Cc: gregkh, rjui, devel, sbranden, jonmason, linux-kernel,
	bcm-kernel-feedback-list, joe, linux-arm-kernel

On Mon, Feb 08, 2016 at 05:31:23PM -0800, Shaun Ren wrote:
> This patch removes all unnecessary parentheses found by checkpatch.pl.
> 
> Signed-off-by: Shaun Ren <shaun.ren@linux.com>

This will not apply anymore because of some other changes done by:
9a66d05d82db ("Staging: rts5208: fix check for dma mapping error")

regards
sudip

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [PATCH v2 7/9] Staging: rts5208: rtsx_transport.c: Remove unnecessary parentheses
@ 2016-02-10  5:26       ` Sudip Mukherjee
  0 siblings, 0 replies; 106+ messages in thread
From: Sudip Mukherjee @ 2016-02-10  5:26 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Feb 08, 2016 at 05:31:23PM -0800, Shaun Ren wrote:
> This patch removes all unnecessary parentheses found by checkpatch.pl.
> 
> Signed-off-by: Shaun Ren <shaun.ren@linux.com>

This will not apply anymore because of some other changes done by:
9a66d05d82db ("Staging: rts5208: fix check for dma mapping error")

regards
sudip

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v2 7/9] Staging: rts5208: rtsx_transport.c: Remove unnecessary parentheses
  2016-02-10  5:26       ` Sudip Mukherjee
@ 2016-02-10 18:38         ` Shaun Ren
  -1 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-10 18:38 UTC (permalink / raw)
  To: Sudip Mukherjee
  Cc: gregkh, rjui, devel, sbranden, jonmason, linux-kernel,
	bcm-kernel-feedback-list, joe, linux-arm-kernel


On Tue 2016-02-09 at 21:26 (-0800), Sudip Mukherjee wrote:
> On Mon, Feb 08, 2016 at 05:31:23PM -0800, Shaun Ren wrote:
>> This patch removes all unnecessary parentheses found by checkpatch.pl.
>> 
>> Signed-off-by: Shaun Ren <shaun.ren@linux.com>
>
> 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

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [PATCH v2 7/9] Staging: rts5208: rtsx_transport.c: Remove unnecessary parentheses
@ 2016-02-10 18:38         ` Shaun Ren
  0 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-10 18:38 UTC (permalink / raw)
  To: linux-arm-kernel


On Tue 2016-02-09 at 21:26 (-0800), Sudip Mukherjee wrote:
> On Mon, Feb 08, 2016 at 05:31:23PM -0800, Shaun Ren wrote:
>> This patch removes all unnecessary parentheses found by checkpatch.pl.
>> 
>> Signed-off-by: Shaun Ren <shaun.ren@linux.com>
>
> 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

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [PATCH v4 0/8] Staging: rts5208: Fix coding style
  2016-02-10  2:45     ` Shaun Ren
@ 2016-02-12  4:07       ` Shaun Ren
  -1 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-12  4:07 UTC (permalink / raw)
  To: gregkh, rjui
  Cc: sbranden, jonmason, mahfouz.saif.elyazal, joe, devel,
	linux-arm-kernel, bcm-kernel-feedback-list, linux-kernel,
	Shaun Ren

This 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(-)

-- 
2.7.0

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [PATCH v4 0/8] Staging: rts5208: Fix coding style
@ 2016-02-12  4:07       ` Shaun Ren
  0 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-12  4:07 UTC (permalink / raw)
  To: linux-arm-kernel

This 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(-)

-- 
2.7.0

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [PATCH v4 1/8] Staging: rts5208: rtsx_transport.c: Cleanup comments
  2016-02-12  4:07       ` Shaun Ren
@ 2016-02-12  4:07         ` Shaun Ren
  -1 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-12  4:07 UTC (permalink / raw)
  To: gregkh, rjui
  Cc: sbranden, jonmason, mahfouz.saif.elyazal, joe, devel,
	linux-arm-kernel, bcm-kernel-feedback-list, linux-kernel,
	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 <shaun.ren@linux.com>
---
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(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index f2eb18e..91fdccf 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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);
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v4 1/8] Staging: rts5208: rtsx_transport.c: Cleanup comments
@ 2016-02-12  4:07         ` Shaun Ren
  0 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-12  4:07 UTC (permalink / raw)
  To: linux-arm-kernel

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 <shaun.ren@linux.com>
---
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(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index f2eb18e..91fdccf 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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);
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v4 2/8] Staging: rts5208: rtsx_transport.c: Align to open parenthesis
  2016-02-12  4:07       ` Shaun Ren
@ 2016-02-12  4:07         ` Shaun Ren
  -1 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-12  4:07 UTC (permalink / raw)
  To: gregkh, rjui
  Cc: sbranden, jonmason, mahfouz.saif.elyazal, joe, devel,
	linux-arm-kernel, bcm-kernel-feedback-list, linux-kernel,
	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_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.

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
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(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index 91fdccf..1a4da89 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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);
 	}
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v4 2/8] Staging: rts5208: rtsx_transport.c: Align to open parenthesis
@ 2016-02-12  4:07         ` Shaun Ren
  0 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-12  4:07 UTC (permalink / raw)
  To: linux-arm-kernel

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.

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
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(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index 91fdccf..1a4da89 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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);
 	}
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v4 3/8] Staging: rts5208: rtsx_transport.c: Remove spaces after casts
  2016-02-12  4:07       ` Shaun Ren
@ 2016-02-12  4:07         ` Shaun Ren
  -1 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-12  4:07 UTC (permalink / raw)
  To: gregkh, rjui
  Cc: sbranden, jonmason, mahfouz.saif.elyazal, joe, devel,
	linux-arm-kernel, bcm-kernel-feedback-list, linux-kernel,
	Shaun Ren

This patch removes all spaces after casts in rtsx_transport.c, as reported
by checkpatch.pl:

CHECK: No space is necessary after a cast

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index 1a4da89..1a6018a 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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;
 
 		/*
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v4 3/8] Staging: rts5208: rtsx_transport.c: Remove spaces after casts
@ 2016-02-12  4:07         ` Shaun Ren
  0 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-12  4:07 UTC (permalink / raw)
  To: linux-arm-kernel

This patch removes all spaces after casts in rtsx_transport.c, as reported
by checkpatch.pl:

CHECK: No space is necessary after a cast

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index 1a4da89..1a6018a 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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;
 
 		/*
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v4 4/8] Staging: rts5208: rtsx_transport.c: Add spaces around -
  2016-02-12  4:07       ` Shaun Ren
@ 2016-02-12  4:07         ` Shaun Ren
  -1 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-12  4:07 UTC (permalink / raw)
  To: gregkh, rjui
  Cc: sbranden, jonmason, mahfouz.saif.elyazal, joe, devel,
	linux-arm-kernel, bcm-kernel-feedback-list, linux-kernel,
	Shaun Ren

This patch fixes the following styling issue in rtsx_transport.c
as reported by checkpatch.pl:

CHECK: spaces preferred around that '-' (ctx:VxV)

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index 1a6018a..d8c8436 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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) {
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v4 4/8] Staging: rts5208: rtsx_transport.c: Add spaces around -
@ 2016-02-12  4:07         ` Shaun Ren
  0 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-12  4:07 UTC (permalink / raw)
  To: linux-arm-kernel

This patch fixes the following styling issue in rtsx_transport.c
as reported by checkpatch.pl:

CHECK: spaces preferred around that '-' (ctx:VxV)

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index 1a6018a..d8c8436 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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) {
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v4 5/8] Staging: rts5208: rtsx_transport.c: Remove extra newlines
  2016-02-12  4:07       ` Shaun Ren
@ 2016-02-12  4:07         ` Shaun Ren
  -1 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-12  4:07 UTC (permalink / raw)
  To: gregkh, rjui
  Cc: sbranden, jonmason, mahfouz.saif.elyazal, joe, devel,
	linux-arm-kernel, bcm-kernel-feedback-list, linux-kernel,
	Shaun Ren

This 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

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index d8c8436..1ce9b9d 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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
  ***********************************************************************/
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v4 5/8] Staging: rts5208: rtsx_transport.c: Remove extra newlines
@ 2016-02-12  4:07         ` Shaun Ren
  0 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-12  4:07 UTC (permalink / raw)
  To: linux-arm-kernel

This 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

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index d8c8436..1ce9b9d 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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
  ***********************************************************************/
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v4 6/8] Staging: rts5208: rtsx_transport.c: Fix label naming convention
  2016-02-12  4:07       ` Shaun Ren
@ 2016-02-12  4:07         ` Shaun Ren
  -1 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-12  4:07 UTC (permalink / raw)
  To: gregkh, rjui
  Cc: sbranden, jonmason, mahfouz.saif.elyazal, joe, devel,
	linux-arm-kernel, bcm-kernel-feedback-list, linux-kernel,
	Shaun Ren

This patch fixes the following naming convention issue in rtsx_transport.c,
as reported by checkpatch.pl:

CHECK: Avoid CamelCase: <Handle_Errors>

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index 1ce9b9d..0d332f5 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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;
 }
 
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v4 6/8] Staging: rts5208: rtsx_transport.c: Fix label naming convention
@ 2016-02-12  4:07         ` Shaun Ren
  0 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-12  4:07 UTC (permalink / raw)
  To: linux-arm-kernel

This patch fixes the following naming convention issue in rtsx_transport.c,
as reported by checkpatch.pl:

CHECK: Avoid CamelCase: <Handle_Errors>

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index 1ce9b9d..0d332f5 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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;
 }
 
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v4 7/8] Staging: rts5208: rtsx_transport.c: Remove unnecessary parentheses
  2016-02-12  4:07       ` Shaun Ren
@ 2016-02-12  4:07         ` Shaun Ren
  -1 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-12  4:07 UTC (permalink / raw)
  To: gregkh, rjui
  Cc: sbranden, jonmason, mahfouz.saif.elyazal, joe, devel,
	linux-arm-kernel, bcm-kernel-feedback-list, linux-kernel,
	Shaun Ren

This patch removes all unnecessary parentheses found by checkpatch.pl.

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
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(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index 0d332f5..be3423a 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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);
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v4 7/8] Staging: rts5208: rtsx_transport.c: Remove unnecessary parentheses
@ 2016-02-12  4:07         ` Shaun Ren
  0 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-12  4:07 UTC (permalink / raw)
  To: linux-arm-kernel

This patch removes all unnecessary parentheses found by checkpatch.pl.

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
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(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index 0d332f5..be3423a 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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);
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v4 8/8] Staging: rts5208: rtsx_transport.c: Fix comparisons to NULL
  2016-02-12  4:07       ` Shaun Ren
@ 2016-02-12  4:08         ` Shaun Ren
  -1 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-12  4:08 UTC (permalink / raw)
  To: gregkh, rjui
  Cc: sbranden, jonmason, mahfouz.saif.elyazal, joe, devel,
	linux-arm-kernel, bcm-kernel-feedback-list, linux-kernel,
	Shaun Ren

This patch changes all comparsions to NULL with !..., as reported by
checkpatch.pl.

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index be3423a..73e50ec 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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)
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v4 8/8] Staging: rts5208: rtsx_transport.c: Fix comparisons to NULL
@ 2016-02-12  4:08         ` Shaun Ren
  0 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-12  4:08 UTC (permalink / raw)
  To: linux-arm-kernel

This patch changes all comparsions to NULL with !..., as reported by
checkpatch.pl.

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index be3423a..73e50ec 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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)
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* Re: [PATCH v4 2/8] Staging: rts5208: rtsx_transport.c: Align to open parenthesis
  2016-02-12  4:07         ` Shaun Ren
@ 2016-02-12  4:32           ` Joe Perches
  -1 siblings, 0 replies; 106+ messages in thread
From: Joe Perches @ 2016-02-12  4:32 UTC (permalink / raw)
  To: Shaun Ren, gregkh, rjui
  Cc: sbranden, jonmason, mahfouz.saif.elyazal, devel,
	linux-arm-kernel, bcm-kernel-feedback-list, linux-kernel

On Thu, 2016-02-11 at 20:07 -0800, Shaun Ren wrote:
> This patch fixes the alignment issue reported by checkpatch.pl:
> 
> CHECK: Alignment should match open parenthesis
[]
> diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
[]
> @@ -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.

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

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [PATCH v4 2/8] Staging: rts5208: rtsx_transport.c: Align to open parenthesis
@ 2016-02-12  4:32           ` Joe Perches
  0 siblings, 0 replies; 106+ messages in thread
From: Joe Perches @ 2016-02-12  4:32 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, 2016-02-11 at 20:07 -0800, Shaun Ren wrote:
> This patch fixes the alignment issue reported by checkpatch.pl:
> 
> CHECK: Alignment should match open parenthesis
[]
> diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
[]
> @@ -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.

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

^ permalink raw reply	[flat|nested] 106+ messages in thread

* Re: [PATCH v4 2/8] Staging: rts5208: rtsx_transport.c: Align to open parenthesis
  2016-02-12  4:07         ` Shaun Ren
@ 2016-02-12  4:38           ` kbuild test robot
  -1 siblings, 0 replies; 106+ messages in thread
From: kbuild test robot @ 2016-02-12  4:38 UTC (permalink / raw)
  To: Shaun Ren
  Cc: kbuild-all, gregkh, rjui, devel, sbranden, jonmason,
	linux-kernel, Shaun Ren, bcm-kernel-feedback-list, joe,
	linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 2001 bytes --]

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

[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 44081 bytes --]

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [PATCH v4 2/8] Staging: rts5208: rtsx_transport.c: Align to open parenthesis
@ 2016-02-12  4:38           ` kbuild test robot
  0 siblings, 0 replies; 106+ messages in thread
From: kbuild test robot @ 2016-02-12  4:38 UTC (permalink / raw)
  To: linux-arm-kernel

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>

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [PATCH v5 2/8] Staging: rts5208: rtsx_transport.c: Align to open parenthesis
  2016-02-12  4:32           ` Joe Perches
@ 2016-02-12  6:56             ` Shaun Ren
  -1 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-12  6:56 UTC (permalink / raw)
  To: joe, gregkh, rjui
  Cc: sbranden, jonmason, mahfouz.saif.elyazal, devel,
	linux-arm-kernel, bcm-kernel-feedback-list, linux-kernel,
	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_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.

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 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(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index 91fdccf..b6de93f 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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);
 	}
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v5 2/8] Staging: rts5208: rtsx_transport.c: Align to open parenthesis
@ 2016-02-12  6:56             ` Shaun Ren
  0 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-12  6:56 UTC (permalink / raw)
  To: linux-arm-kernel

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.

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 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(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index 91fdccf..b6de93f 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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);
 	}
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* Re: [PATCH v5 2/8] Staging: rts5208: rtsx_transport.c: Align to open parenthesis
  2016-02-12  6:56             ` Shaun Ren
@ 2016-02-15  0:41               ` Greg KH
  -1 siblings, 0 replies; 106+ messages in thread
From: Greg KH @ 2016-02-15  0:41 UTC (permalink / raw)
  To: Shaun Ren
  Cc: joe, rjui, devel, sbranden, jonmason, linux-kernel,
	bcm-kernel-feedback-list, linux-arm-kernel

On Thu, Feb 11, 2016 at 10:56:08PM -0800, Shaun Ren wrote:
> 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.
> 
> Signed-off-by: Shaun Ren <shaun.ren@linux.com>
> ---
>  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

Where are the 7 other patches in this series?

Please resend all of them.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [PATCH v5 2/8] Staging: rts5208: rtsx_transport.c: Align to open parenthesis
@ 2016-02-15  0:41               ` Greg KH
  0 siblings, 0 replies; 106+ messages in thread
From: Greg KH @ 2016-02-15  0:41 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Feb 11, 2016 at 10:56:08PM -0800, Shaun Ren wrote:
> 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.
> 
> Signed-off-by: Shaun Ren <shaun.ren@linux.com>
> ---
>  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

Where are the 7 other patches in this series?

Please resend all of them.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [PATCH v5 RESEND 0/8] Staging: rts5208: Fix coding style
  2016-02-12  4:07       ` Shaun Ren
@ 2016-02-15 18:58         ` Shaun Ren
  -1 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-15 18:58 UTC (permalink / raw)
  To: gregkh, rjui
  Cc: sbranden, jonmason, mahfouz.saif.elyazal, joe, devel,
	linux-arm-kernel, bcm-kernel-feedback-list, linux-kernel,
	Shaun Ren

This 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(-)

-- 
2.7.1

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [PATCH v5 RESEND 0/8] Staging: rts5208: Fix coding style
@ 2016-02-15 18:58         ` Shaun Ren
  0 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-15 18:58 UTC (permalink / raw)
  To: linux-arm-kernel

This 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(-)

-- 
2.7.1

^ permalink raw reply	[flat|nested] 106+ messages in thread

* [PATCH v5 RESEND 1/8] Staging: rts5208: rtsx_transport.c: Cleanup comments
  2016-02-15 18:58         ` Shaun Ren
@ 2016-02-15 18:58           ` Shaun Ren
  -1 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-15 18:58 UTC (permalink / raw)
  To: gregkh, rjui
  Cc: sbranden, jonmason, mahfouz.saif.elyazal, joe, devel,
	linux-arm-kernel, bcm-kernel-feedback-list, linux-kernel,
	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 <shaun.ren@linux.com>
---
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(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index f2eb18e..91fdccf 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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);
-- 
2.7.1

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v5 RESEND 1/8] Staging: rts5208: rtsx_transport.c: Cleanup comments
@ 2016-02-15 18:58           ` Shaun Ren
  0 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-15 18:58 UTC (permalink / raw)
  To: linux-arm-kernel

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 <shaun.ren@linux.com>
---
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(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index f2eb18e..91fdccf 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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);
-- 
2.7.1

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v5 RESEND 2/8] Staging: rts5208: rtsx_transport.c: Align to open parenthesis
  2016-02-15 18:58         ` Shaun Ren
@ 2016-02-15 18:58           ` Shaun Ren
  -1 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-15 18:58 UTC (permalink / raw)
  To: gregkh, rjui
  Cc: sbranden, jonmason, mahfouz.saif.elyazal, joe, devel,
	linux-arm-kernel, bcm-kernel-feedback-list, linux-kernel,
	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_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.

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
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(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index 91fdccf..b6de93f 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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);
 	}
-- 
2.7.1

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v5 RESEND 2/8] Staging: rts5208: rtsx_transport.c: Align to open parenthesis
@ 2016-02-15 18:58           ` Shaun Ren
  0 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-15 18:58 UTC (permalink / raw)
  To: linux-arm-kernel

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.

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
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(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index 91fdccf..b6de93f 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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);
 	}
-- 
2.7.1

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v5 RESEND 3/8] Staging: rts5208: rtsx_transport.c: Remove spaces after casts
  2016-02-15 18:58         ` Shaun Ren
@ 2016-02-15 18:58           ` Shaun Ren
  -1 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-15 18:58 UTC (permalink / raw)
  To: gregkh, rjui
  Cc: sbranden, jonmason, mahfouz.saif.elyazal, joe, devel,
	linux-arm-kernel, bcm-kernel-feedback-list, linux-kernel,
	Shaun Ren

This patch removes all spaces after casts in rtsx_transport.c, as reported
by checkpatch.pl:

CHECK: No space is necessary after a cast

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index b6de93f..54e2027 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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;
 
 		/*
-- 
2.7.1

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v5 RESEND 3/8] Staging: rts5208: rtsx_transport.c: Remove spaces after casts
@ 2016-02-15 18:58           ` Shaun Ren
  0 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-15 18:58 UTC (permalink / raw)
  To: linux-arm-kernel

This patch removes all spaces after casts in rtsx_transport.c, as reported
by checkpatch.pl:

CHECK: No space is necessary after a cast

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index b6de93f..54e2027 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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;
 
 		/*
-- 
2.7.1

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v5 RESEND 4/8] Staging: rts5208: rtsx_transport.c: Add spaces around -
  2016-02-15 18:58         ` Shaun Ren
@ 2016-02-15 18:58           ` Shaun Ren
  -1 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-15 18:58 UTC (permalink / raw)
  To: gregkh, rjui
  Cc: sbranden, jonmason, mahfouz.saif.elyazal, joe, devel,
	linux-arm-kernel, bcm-kernel-feedback-list, linux-kernel,
	Shaun Ren

This patch fixes the following styling issue in rtsx_transport.c
as reported by checkpatch.pl:

CHECK: spaces preferred around that '-' (ctx:VxV)

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index 54e2027..6d2420f 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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) {
-- 
2.7.1

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v5 RESEND 4/8] Staging: rts5208: rtsx_transport.c: Add spaces around -
@ 2016-02-15 18:58           ` Shaun Ren
  0 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-15 18:58 UTC (permalink / raw)
  To: linux-arm-kernel

This patch fixes the following styling issue in rtsx_transport.c
as reported by checkpatch.pl:

CHECK: spaces preferred around that '-' (ctx:VxV)

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index 54e2027..6d2420f 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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) {
-- 
2.7.1

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v5 RESEND 5/8] Staging: rts5208: rtsx_transport.c: Remove extra newlines
  2016-02-15 18:58         ` Shaun Ren
@ 2016-02-15 18:58           ` Shaun Ren
  -1 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-15 18:58 UTC (permalink / raw)
  To: gregkh, rjui
  Cc: sbranden, jonmason, mahfouz.saif.elyazal, joe, devel,
	linux-arm-kernel, bcm-kernel-feedback-list, linux-kernel,
	Shaun Ren

This 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

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index 6d2420f..00401e2 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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
  ***********************************************************************/
-- 
2.7.1

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v5 RESEND 5/8] Staging: rts5208: rtsx_transport.c: Remove extra newlines
@ 2016-02-15 18:58           ` Shaun Ren
  0 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-15 18:58 UTC (permalink / raw)
  To: linux-arm-kernel

This 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

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index 6d2420f..00401e2 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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
  ***********************************************************************/
-- 
2.7.1

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v5 RESEND 6/8] Staging: rts5208: rtsx_transport.c: Fix label naming convention
  2016-02-15 18:58         ` Shaun Ren
@ 2016-02-15 18:58           ` Shaun Ren
  -1 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-15 18:58 UTC (permalink / raw)
  To: gregkh, rjui
  Cc: sbranden, jonmason, mahfouz.saif.elyazal, joe, devel,
	linux-arm-kernel, bcm-kernel-feedback-list, linux-kernel,
	Shaun Ren

This patch fixes the following naming convention issue in rtsx_transport.c,
as reported by checkpatch.pl:

CHECK: Avoid CamelCase: <Handle_Errors>

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index 00401e2..aadef51 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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;
 }
 
-- 
2.7.1

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v5 RESEND 6/8] Staging: rts5208: rtsx_transport.c: Fix label naming convention
@ 2016-02-15 18:58           ` Shaun Ren
  0 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-15 18:58 UTC (permalink / raw)
  To: linux-arm-kernel

This patch fixes the following naming convention issue in rtsx_transport.c,
as reported by checkpatch.pl:

CHECK: Avoid CamelCase: <Handle_Errors>

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index 00401e2..aadef51 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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;
 }
 
-- 
2.7.1

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v5 RESEND 7/8] Staging: rts5208: rtsx_transport.c: Remove unnecessary parentheses
  2016-02-15 18:58         ` Shaun Ren
@ 2016-02-15 18:58           ` Shaun Ren
  -1 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-15 18:58 UTC (permalink / raw)
  To: gregkh, rjui
  Cc: sbranden, jonmason, mahfouz.saif.elyazal, joe, devel,
	linux-arm-kernel, bcm-kernel-feedback-list, linux-kernel,
	Shaun Ren

This patch removes all unnecessary parentheses found by checkpatch.pl.

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
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(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index aadef51..c604576 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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);
-- 
2.7.1

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v5 RESEND 7/8] Staging: rts5208: rtsx_transport.c: Remove unnecessary parentheses
@ 2016-02-15 18:58           ` Shaun Ren
  0 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-15 18:58 UTC (permalink / raw)
  To: linux-arm-kernel

This patch removes all unnecessary parentheses found by checkpatch.pl.

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
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(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index aadef51..c604576 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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);
-- 
2.7.1

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v5 RESEND 8/8] Staging: rts5208: rtsx_transport.c: Fix comparisons to NULL
  2016-02-15 18:58         ` Shaun Ren
@ 2016-02-15 18:58           ` Shaun Ren
  -1 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-15 18:58 UTC (permalink / raw)
  To: gregkh, rjui
  Cc: sbranden, jonmason, mahfouz.saif.elyazal, joe, devel,
	linux-arm-kernel, bcm-kernel-feedback-list, linux-kernel,
	Shaun Ren

This patch changes all comparsions to NULL with !..., as reported by
checkpatch.pl.

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index c604576..f564a74 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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)
-- 
2.7.1

^ permalink raw reply related	[flat|nested] 106+ messages in thread

* [PATCH v5 RESEND 8/8] Staging: rts5208: rtsx_transport.c: Fix comparisons to NULL
@ 2016-02-15 18:58           ` Shaun Ren
  0 siblings, 0 replies; 106+ messages in thread
From: Shaun Ren @ 2016-02-15 18:58 UTC (permalink / raw)
  To: linux-arm-kernel

This patch changes all comparsions to NULL with !..., as reported by
checkpatch.pl.

Signed-off-by: Shaun Ren <shaun.ren@linux.com>
---
 drivers/staging/rts5208/rtsx_transport.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c
index c604576..f564a74 100644
--- a/drivers/staging/rts5208/rtsx_transport.c
+++ b/drivers/staging/rts5208/rtsx_transport.c
@@ -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)
-- 
2.7.1

^ permalink raw reply related	[flat|nested] 106+ messages in thread

end of thread, other threads:[~2016-02-15 19:01 UTC | newest]

Thread overview: 106+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-26  2:27 [PATCH 0/2] Staging: rts5208: Coding style and dma mapping fixes Shaun Ren
2016-01-26  2:27 ` Shaun Ren
2016-01-26  2:27 ` [PATCH 1/2] Staging: rts5208: Cleanup rtsx_transport.c Shaun Ren
2016-01-26  2:27   ` Shaun Ren
2016-02-08  4:03   ` Greg KH
2016-02-08  4:03     ` Greg KH
2016-01-26  2:27 ` [PATCH 2/2] Staging: rts5208: Add missing dma_mapping_error Shaun Ren
2016-01-26  2:27   ` Shaun Ren
2016-02-08  4:03   ` Greg KH
2016-02-08  4:03     ` Greg KH
2016-02-09  1:31 ` [PATCH v2 0/9] Staging: rts5208: Coding style and dma mapping fixes Shaun Ren
2016-02-09  1:31   ` Shaun Ren
2016-02-09  1:31   ` [PATCH v2 1/9] Staging: rts5208: rtsx_transport.c: Fix comment style warnings Shaun Ren
2016-02-09  1:31     ` Shaun Ren
2016-02-09  3:05     ` Joshua Clayton
2016-02-09  3:05       ` Joshua Clayton
2016-02-09  1:31   ` [PATCH v2 2/9] Staging: rts5208: rtsx_transport.c: Align to open parenthesis Shaun Ren
2016-02-09  1:31     ` Shaun Ren
2016-02-10  5:21     ` Sudip Mukherjee
2016-02-10  5:21       ` Sudip Mukherjee
2016-02-09  1:31   ` [PATCH v2 3/9] Staging: rts5208: rtsx_transport.c: Remove spaces after casts Shaun Ren
2016-02-09  1:31     ` Shaun Ren
2016-02-09  1:31   ` [PATCH v2 4/9] Staging: rts5208: rtsx_transport.c: Add spaces around - Shaun Ren
2016-02-09  1:31     ` Shaun Ren
2016-02-09  1:31   ` [PATCH v2 5/9] Staging: rts5208: rtsx_transport.c: Remove extra newlines Shaun Ren
2016-02-09  1:31     ` Shaun Ren
2016-02-09  1:31   ` [PATCH v2 6/9] Staging: rts5208: rtsx_transport.c: Fix label naming convention Shaun Ren
2016-02-09  1:31     ` Shaun Ren
2016-02-09  1:31   ` [PATCH v2 7/9] Staging: rts5208: rtsx_transport.c: Remove unnecessary parentheses Shaun Ren
2016-02-09  1:31     ` Shaun Ren
2016-02-10  5:26     ` Sudip Mukherjee
2016-02-10  5:26       ` Sudip Mukherjee
2016-02-10 18:38       ` Shaun Ren
2016-02-10 18:38         ` Shaun Ren
2016-02-09  1:31   ` [PATCH v2 8/9] Staging: rts5208: rtsx_transport.c: Fix comparisons to NULL Shaun Ren
2016-02-09  1:31     ` Shaun Ren
2016-02-09  1:31   ` [PATCH v2 9/9] Staging: rts5208: Add missing dma_mapping_error Shaun Ren
2016-02-09  1:31     ` Shaun Ren
2016-02-10  2:45   ` [PATCH v3 0/9] Staging: rts5208: Coding style and dma mapping fixes Shaun Ren
2016-02-10  2:45     ` Shaun Ren
2016-02-10  2:45     ` [PATCH v3 1/9] Staging: rts5208: rtsx_transport.c: Cleanup comments Shaun Ren
2016-02-10  2:45       ` Shaun Ren
2016-02-10  3:06       ` Joshua Clayton
2016-02-10  3:06         ` Joshua Clayton
2016-02-10  2:45     ` [PATCH v3 2/9] Staging: rts5208: rtsx_transport.c: Align to open parenthesis Shaun Ren
2016-02-10  2:45       ` Shaun Ren
2016-02-10  2:58       ` Joe Perches
2016-02-10  2:58         ` Joe Perches
2016-02-10  2:45     ` [PATCH v3 3/9] Staging: rts5208: rtsx_transport.c: Remove spaces after casts Shaun Ren
2016-02-10  2:45       ` Shaun Ren
2016-02-10  2:45     ` [PATCH v3 4/9] Staging: rts5208: rtsx_transport.c: Add spaces around - Shaun Ren
2016-02-10  2:45       ` Shaun Ren
2016-02-10  2:45     ` [PATCH v3 5/9] Staging: rts5208: rtsx_transport.c: Remove extra newlines Shaun Ren
2016-02-10  2:45       ` Shaun Ren
2016-02-10  2:45     ` [PATCH v3 6/9] Staging: rts5208: rtsx_transport.c: Fix label naming convention Shaun Ren
2016-02-10  2:45       ` Shaun Ren
2016-02-10  2:45     ` [PATCH v3 7/9] Staging: rts5208: rtsx_transport.c: Remove unnecessary parentheses Shaun Ren
2016-02-10  2:45       ` Shaun Ren
2016-02-10  2:45     ` [PATCH v3 8/9] Staging: rts5208: rtsx_transport.c: Fix comparisons to NULL Shaun Ren
2016-02-10  2:45       ` Shaun Ren
2016-02-10  2:45     ` [PATCH v3 9/9] Staging: rts5208: Add missing dma_mapping_error Shaun Ren
2016-02-10  2:45       ` Shaun Ren
2016-02-12  4:07     ` [PATCH v4 0/8] Staging: rts5208: Fix coding style Shaun Ren
2016-02-12  4:07       ` Shaun Ren
2016-02-12  4:07       ` [PATCH v4 1/8] Staging: rts5208: rtsx_transport.c: Cleanup comments Shaun Ren
2016-02-12  4:07         ` Shaun Ren
2016-02-12  4:07       ` [PATCH v4 2/8] Staging: rts5208: rtsx_transport.c: Align to open parenthesis Shaun Ren
2016-02-12  4:07         ` Shaun Ren
2016-02-12  4:32         ` Joe Perches
2016-02-12  4:32           ` Joe Perches
2016-02-12  6:56           ` [PATCH v5 " Shaun Ren
2016-02-12  6:56             ` Shaun Ren
2016-02-15  0:41             ` Greg KH
2016-02-15  0:41               ` Greg KH
2016-02-12  4:38         ` [PATCH v4 " kbuild test robot
2016-02-12  4:38           ` kbuild test robot
2016-02-12  4:07       ` [PATCH v4 3/8] Staging: rts5208: rtsx_transport.c: Remove spaces after casts Shaun Ren
2016-02-12  4:07         ` Shaun Ren
2016-02-12  4:07       ` [PATCH v4 4/8] Staging: rts5208: rtsx_transport.c: Add spaces around - Shaun Ren
2016-02-12  4:07         ` Shaun Ren
2016-02-12  4:07       ` [PATCH v4 5/8] Staging: rts5208: rtsx_transport.c: Remove extra newlines Shaun Ren
2016-02-12  4:07         ` Shaun Ren
2016-02-12  4:07       ` [PATCH v4 6/8] Staging: rts5208: rtsx_transport.c: Fix label naming convention Shaun Ren
2016-02-12  4:07         ` Shaun Ren
2016-02-12  4:07       ` [PATCH v4 7/8] Staging: rts5208: rtsx_transport.c: Remove unnecessary parentheses Shaun Ren
2016-02-12  4:07         ` Shaun Ren
2016-02-12  4:08       ` [PATCH v4 8/8] Staging: rts5208: rtsx_transport.c: Fix comparisons to NULL Shaun Ren
2016-02-12  4:08         ` Shaun Ren
2016-02-15 18:58       ` [PATCH v5 RESEND 0/8] Staging: rts5208: Fix coding style Shaun Ren
2016-02-15 18:58         ` Shaun Ren
2016-02-15 18:58         ` [PATCH v5 RESEND 1/8] Staging: rts5208: rtsx_transport.c: Cleanup comments Shaun Ren
2016-02-15 18:58           ` Shaun Ren
2016-02-15 18:58         ` [PATCH v5 RESEND 2/8] Staging: rts5208: rtsx_transport.c: Align to open parenthesis Shaun Ren
2016-02-15 18:58           ` Shaun Ren
2016-02-15 18:58         ` [PATCH v5 RESEND 3/8] Staging: rts5208: rtsx_transport.c: Remove spaces after casts Shaun Ren
2016-02-15 18:58           ` Shaun Ren
2016-02-15 18:58         ` [PATCH v5 RESEND 4/8] Staging: rts5208: rtsx_transport.c: Add spaces around - Shaun Ren
2016-02-15 18:58           ` Shaun Ren
2016-02-15 18:58         ` [PATCH v5 RESEND 5/8] Staging: rts5208: rtsx_transport.c: Remove extra newlines Shaun Ren
2016-02-15 18:58           ` Shaun Ren
2016-02-15 18:58         ` [PATCH v5 RESEND 6/8] Staging: rts5208: rtsx_transport.c: Fix label naming convention Shaun Ren
2016-02-15 18:58           ` Shaun Ren
2016-02-15 18:58         ` [PATCH v5 RESEND 7/8] Staging: rts5208: rtsx_transport.c: Remove unnecessary parentheses Shaun Ren
2016-02-15 18:58           ` Shaun Ren
2016-02-15 18:58         ` [PATCH v5 RESEND 8/8] Staging: rts5208: rtsx_transport.c: Fix comparisons to NULL Shaun Ren
2016-02-15 18:58           ` Shaun Ren

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.