Skip to contentSkip to conversation

Fix multiple checkpatch issues

PATCH New Rehas Sachdeva 1 participant 8 messages Sep 20, 2016 Staging

lore
Share & tools
lore
#0 lore raw

cover Fix multiple checkpatch issues

Fixes multiple checkpatch.pl issues in rts5208 driver.

Rehas Sachdeva (7):
staging: rts5208: Remove unnecessary parentheses
staging: rts5208: Add spaces around operators
staging: rts5208: Remove explicit NULL comparison
staging: rts5208: Fix indentation
staging: rts5208: Put constant on right side of comparison
staging: rts5208: Use BIT(x) macro
staging: rts5208: Remove space after cast

 drivers/staging/rts5208/ms.c        | 30 +++++++++++++++---------------
 drivers/staging/rts5208/rtsx.c      |  2 +-
 drivers/staging/rts5208/rtsx.h      | 12 ++++++------
 drivers/staging/rts5208/rtsx_card.c |  2 +-
 drivers/staging/rts5208/rtsx_chip.h | 30 +++++++++++++++---------------
 drivers/staging/rts5208/rtsx_scsi.c |  2 +-
 drivers/staging/rts5208/sd.c        |  6 +++---
 drivers/staging/rts5208/xd.c        | 12 ++++++------
 8 files changed, 48 insertions(+), 48 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/7 staging: rts5208: Remove unnecessary parentheses

Removes unnecessary parentheses from an expression of the form &(x). Issue found by checkpatch.

---
 drivers/staging/rts5208/ms.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/staging/rts5208/ms.c +10 -10
index f927ba6..7923230 100644
@@ -2465,7 +2465,7 @@ static u16 ms_get_l2p_tbl(struct rtsx_chip *chip, int seg_no, u16 log_off)
 	if (!ms_card->segment)
 		return 0xFFFF;
 
-	segment = &(ms_card->segment[seg_no]);
+	segment = &ms_card->segment[seg_no];
 
 	if (segment->l2p_table)
 		return segment->l2p_table[log_off];
@@ -2482,7 +2482,7 @@ static void ms_set_l2p_tbl(struct rtsx_chip *chip,
 	if (!ms_card->segment)
 		return;
 
-	segment = &(ms_card->segment[seg_no]);
+	segment = &ms_card->segment[seg_no];
 	if (segment->l2p_table)
 		segment->l2p_table[log_off] = phy_blk;
 }
@@ -2494,7 +2494,7 @@ static void ms_set_unused_block(struct rtsx_chip *chip, u16 phy_blk)
 	int seg_no;
 
 	seg_no = (int)phy_blk >> 9;
-	segment = &(ms_card->segment[seg_no]);
+	segment = &ms_card->segment[seg_no];
 
 	segment->free_table[segment->set_index++] = phy_blk;
 	if (segment->set_index >= MS_FREE_TABLE_CNT)
@@ -2509,7 +2509,7 @@ static u16 ms_get_unused_block(struct rtsx_chip *chip, int seg_no)
 	struct zone_entry *segment;
 	u16 phy_blk;
 
-	segment = &(ms_card->segment[seg_no]);
+	segment = &ms_card->segment[seg_no];
 
 	if (segment->unused_blk_cnt <= 0)
 		return 0xFFFF;
@@ -2538,7 +2538,7 @@ static int ms_arbitrate_l2p(struct rtsx_chip *chip, u16 phy_blk,
 	u16 tmp_blk;
 
 	seg_no = (int)phy_blk >> 9;
-	segment = &(ms_card->segment[seg_no]);
+	segment = &ms_card->segment[seg_no];
 	tmp_blk = segment->l2p_table[log_off];
 
 	if (us1 != us2) {
@@ -2602,7 +2602,7 @@ static int ms_build_l2p_tbl(struct rtsx_chip *chip, int seg_no)
 	else
 		table_size = 496;
 
-	segment = &(ms_card->segment[seg_no]);
+	segment = &ms_card->segment[seg_no];
 
 	if (!segment->l2p_table) {
 		segment->l2p_table = vmalloc(table_size * 2);
@@ -3760,7 +3760,7 @@ static int ms_prepare_write(struct rtsx_chip *chip, u16 old_blk, u16 new_blk,
 int ms_delay_write(struct rtsx_chip *chip)
 {
 	struct ms_info *ms_card = &chip->ms_card;
-	struct ms_delay_write_tag *delay_write = &(ms_card->delay_write);
+	struct ms_delay_write_tag *delay_write = &ms_card->delay_write;
 	int retval;
 
 	if (delay_write->delay_write_flag) {
@@ -3806,7 +3806,7 @@ static int ms_rw_multi_sector(struct scsi_cmnd *srb, struct rtsx_chip *chip,
 	u8 start_page, end_page = 0, page_cnt;
 	u8 *ptr;
 #ifdef MS_DELAY_WRITE
-	struct ms_delay_write_tag *delay_write = &(ms_card->delay_write);
+	struct ms_delay_write_tag *delay_write = &ms_card->delay_write;
 #endif
 
 	ms_set_err_code(chip, MS_NO_ERROR);
@@ -4696,7 +4696,7 @@ SetICVFinish:
 
 void ms_cleanup_work(struct rtsx_chip *chip)
 {
-	struct ms_info *ms_card = &(chip->ms_card);
+	struct ms_info *ms_card = &chip->ms_card;
 
 	if (CHK_MSPRO(ms_card)) {
 		if (ms_card->seq_mode) {
@@ -4761,7 +4761,7 @@ int ms_power_off_card3v3(struct rtsx_chip *chip)
 
 int release_ms_card(struct rtsx_chip *chip)
 {
-	struct ms_info *ms_card = &(chip->ms_card);
+	struct ms_info *ms_card = &chip->ms_card;
 	int retval;
 
 #ifdef MS_DELAY_WRITE
Signature · 1 line
2.7.4
#2 lore raw

PATCH 2/7 staging: rts5208: Add spaces around operators

In reply to Rehas Sachdeva

Adds spaces on either side of arithmetic and relational operators like '-', '<' and '*'. Issue found by checkpatch.

---
 drivers/staging/rts5208/ms.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/staging/rts5208/ms.c +4 -4
index 7923230..91cd37b 100644
@@ -2711,7 +2711,7 @@ static int ms_build_l2p_tbl(struct rtsx_chip *chip, int seg_no)
 		us2 = extra[0] & 0x10;
 
 		(void)ms_arbitrate_l2p(chip, phy_blk,
-				log_blk-ms_start_idx[seg_no], us1, us2);
+				log_blk - ms_start_idx[seg_no], us1, us2);
 		continue;
 	}
 
@@ -3986,7 +3986,7 @@ static int ms_rw_multi_sector(struct scsi_cmnd *srb, struct rtsx_chip *chip,
 
 		for (seg_no = 0; seg_no < ARRAY_SIZE(ms_start_idx) - 1;
 				seg_no++) {
-			if (log_blk < ms_start_idx[seg_no+1])
+			if (log_blk < ms_start_idx[seg_no + 1])
 				break;
 		}
 
@@ -4648,8 +4648,8 @@ int mg_set_ICV(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 
 		rtsx_send_cmd_no_wait(chip);
 
-		retval = rtsx_transfer_data(chip, MS_CARD, buf + 4 + i*512,
-					512, 0, DMA_TO_DEVICE, 3000);
+		retval = rtsx_transfer_data(chip, MS_CARD, buf + 4 + i * 512,
+					    512, 0, DMA_TO_DEVICE, 3000);
 		if ((retval < 0) || check_ms_err(chip)) {
 			rtsx_clear_ms_error(chip);
 			if (ms_card->mg_auth == 0) {
Signature · 1 line
2.7.4
#3 lore raw

PATCH 3/7 staging: rts5208: Remove explicit NULL comparison

In reply to Rehas Sachdeva

Replaces explicit NULL comparison of the form '(x != NULL)' to '(x)' and '(x == NULL)' to '(!x)'. Issue found by checkpatch.

---
 drivers/staging/rts5208/ms.c        |  2 +-
 drivers/staging/rts5208/rtsx.c      |  2 +-
 drivers/staging/rts5208/rtsx_card.c |  2 +-
 drivers/staging/rts5208/rtsx_scsi.c |  2 +-
 drivers/staging/rts5208/xd.c        | 10 +++++-----
 5 files changed, 9 insertions(+), 9 deletions(-)
drivers/staging/rts5208/ms.c +1 -1
index 91cd37b..9fc64da 100644
@@ -4077,7 +4077,7 @@ void ms_free_l2p_tbl(struct rtsx_chip *chip)
 	struct ms_info *ms_card = &chip->ms_card;
 	int i = 0;
 
-	if (ms_card->segment != NULL) {
+	if (ms_card->segment) {
 		for (i = 0; i < ms_card->segment_cnt; i++) {
 			vfree(ms_card->segment[i].l2p_table);
 			ms_card->segment[i].l2p_table = NULL;
drivers/staging/rts5208/rtsx.c +1 -1
index d75fa8d..d7554f4 100644
@@ -131,7 +131,7 @@ static int queuecommand_lck(struct scsi_cmnd *srb,
 	struct rtsx_chip *chip = dev->chip;
 
 	/* check for state-transition errors */
-	if (chip->srb != NULL) {
+	if (chip->srb) {
 		dev_err(&dev->pci->dev, "Error: chip->srb = %p\n",
 			chip->srb);
 		return SCSI_MLQUEUE_HOST_BUSY;
drivers/staging/rts5208/rtsx_card.c +1 -1
index 91e62c1..7f78ee7 100644
@@ -984,7 +984,7 @@ int card_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip,
 	unsigned int lun = SCSI_LUN(srb);
 	int i;
 
-	if (chip->rw_card[lun] == NULL) {
+	if (!chip->rw_card[lun]) {
 		rtsx_trace(chip);
 		return STATUS_FAIL;
 	}
drivers/staging/rts5208/rtsx_scsi.c +1 -1
index def53d9..687a7ff 100644
@@ -1397,7 +1397,7 @@ static int trace_msg_cmd(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 	buf_len = 4 + ((2 + MSG_FUNC_LEN + MSG_FILE_LEN + TIME_VAL_LEN) *
 		TRACE_ITEM_CNT);
 
-	if ((scsi_bufflen(srb) < buf_len) || (scsi_sglist(srb) == NULL)) {
+	if ((scsi_bufflen(srb) < buf_len) || !scsi_sglist(srb)) {
 		set_sense_type(chip, SCSI_LUN(srb),
 			SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR);
 		rtsx_trace(chip);
drivers/staging/rts5208/xd.c +5 -5
index 126a2dc..2d6a606 100644
@@ -922,7 +922,7 @@ static void xd_set_unused_block(struct rtsx_chip *chip, u32 phy_blk)
 	}
 	zone = &(xd_card->zone[zone_no]);
 
-	if (zone->free_table == NULL) {
+	if (!zone->free_table) {
 		if (xd_build_l2p_tbl(chip, zone_no) != STATUS_SUCCESS)
 			return;
 	}
@@ -1413,7 +1413,7 @@ static int xd_build_l2p_tbl(struct rtsx_chip *chip, int zone_no)
 
 	dev_dbg(rtsx_dev(chip), "xd_build_l2p_tbl: %d\n", zone_no);
 
-	if (xd_card->zone == NULL) {
+	if (!xd_card->zone) {
 		retval = xd_init_l2p_tbl(chip);
 		if (retval != STATUS_SUCCESS)
 			return retval;
@@ -1427,7 +1427,7 @@ static int xd_build_l2p_tbl(struct rtsx_chip *chip, int zone_no)
 
 	zone = &(xd_card->zone[zone_no]);
 
-	if (zone->l2p_table == NULL) {
+	if (!zone->l2p_table) {
 		zone->l2p_table = vmalloc(2000);
 		if (!zone->l2p_table) {
 			rtsx_trace(chip);
@@ -1436,7 +1436,7 @@ static int xd_build_l2p_tbl(struct rtsx_chip *chip, int zone_no)
 	}
 	memset((u8 *)(zone->l2p_table), 0xff, 2000);
 
-	if (zone->free_table == NULL) {
+	if (!zone->free_table) {
 		zone->free_table = vmalloc(XD_FREE_TABLE_CNT * 2);
 		if (!zone->free_table) {
 			rtsx_trace(chip);
@@ -2237,7 +2237,7 @@ void xd_free_l2p_tbl(struct rtsx_chip *chip)
 	struct xd_info *xd_card = &(chip->xd_card);
 	int i = 0;
 
-	if (xd_card->zone != NULL) {
+	if (xd_card->zone) {
 		for (i = 0; i < xd_card->zone_cnt; i++) {
 			vfree(xd_card->zone[i].l2p_table);
 			xd_card->zone[i].l2p_table = NULL;
Signature · 1 line
2.7.4
#4 lore raw

PATCH 4/7 staging: rts5208: Fix indentation

In reply to Rehas Sachdeva

Fixes indentation by removing unnecessary TAB. Issue found by checkpatch.

---
 drivers/staging/rts5208/rtsx.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/staging/rts5208/rtsx.h +4 -4
index 2f902d5..c0f513c 100644
@@ -70,10 +70,10 @@
 #define rtsx_write_config_byte(chip, where, val) \
 	pci_write_config_byte((chip)->rtsx->pci, where, val)
 
-#define wait_timeout_x(task_state, msecs)		\
-do {							\
-		set_current_state((task_state));	\
-		schedule_timeout((msecs) * HZ / 1000);	\
+#define wait_timeout_x(task_state, msecs)	\
+do {						\
+	set_current_state((task_state));	\
+	schedule_timeout((msecs) * HZ / 1000);	\
 } while (0)
 #define wait_timeout(msecs)	wait_timeout_x(TASK_INTERRUPTIBLE, (msecs))
 
Signature · 1 line
2.7.4
#5 lore raw

PATCH 5/7 staging: rts5208: Put constant on right side of comparison

In reply to Rehas Sachdeva

Replaces position of constant from left to right side of a comparison. Additionally, modifies logical continuations to be on the previous line and fixes alignment to match open parenthesis. Issues found by checkpatch.

---
 drivers/staging/rts5208/sd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/rts5208/sd.c +3 -3
index 345313a..e72c432 100644
@@ -1436,9 +1436,9 @@ static int sd_switch_function(struct rtsx_chip *chip, u8 bus_width)
 		func_to_switch);
 
 #ifdef SUPPORT_SD_LOCK
-	if ((sd_card->sd_lock_status & SD_SDR_RST)
-			&& (DDR50_SUPPORT == func_to_switch)
-			&& (sd_card->func_group1_mask & SDR50_SUPPORT_MASK)) {
+	if ((sd_card->sd_lock_status & SD_SDR_RST) &&
+	    (func_to_switch == DDR50_SUPPORT) &&
+	    (sd_card->func_group1_mask & SDR50_SUPPORT_MASK)) {
 		func_to_switch = SDR50_SUPPORT;
 		dev_dbg(rtsx_dev(chip), "Using SDR50 instead of DDR50 for SD Lock\n");
 	}
Signature · 1 line
2.7.4
#6 lore raw

PATCH 6/7 staging: rts5208: Use BIT(x) macro

In reply to Rehas Sachdeva

Replaces left shift operation (1 << x) by BIT(x). Issue found by checkpatch.

---
 drivers/staging/rts5208/rtsx_chip.h | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)
drivers/staging/rts5208/rtsx_chip.h +15 -15
index 79d1df6..132c2e6 100644
@@ -266,22 +266,22 @@ struct sense_data_t {
 #define TRIG_DMA		(0x01 << 31)
 
 /* Bus interrupt pending register */
-#define CMD_DONE_INT		(1 << 31)
-#define DATA_DONE_INT		(1 << 30)
-#define TRANS_OK_INT		(1 << 29)
-#define TRANS_FAIL_INT		(1 << 28)
-#define XD_INT			(1 << 27)
-#define MS_INT			(1 << 26)
-#define SD_INT			(1 << 25)
-#define GPIO0_INT		(1 << 24)
-#define OC_INT			(1 << 23)
-#define SD_WRITE_PROTECT	(1 << 19)
-#define XD_EXIST		(1 << 18)
-#define MS_EXIST		(1 << 17)
-#define SD_EXIST		(1 << 16)
+#define CMD_DONE_INT		BIT(31)
+#define DATA_DONE_INT		BIT(30)
+#define TRANS_OK_INT		BIT(29)
+#define TRANS_FAIL_INT		BIT(28)
+#define XD_INT			BIT(27)
+#define MS_INT			BIT(26)
+#define SD_INT			BIT(25)
+#define GPIO0_INT		BIT(24)
+#define OC_INT			BIT(23)
+#define SD_WRITE_PROTECT	BIT(19)
+#define XD_EXIST		BIT(18)
+#define MS_EXIST		BIT(17)
+#define SD_EXIST		BIT(16)
 #define DELINK_INT		GPIO0_INT
-#define MS_OC_INT		(1 << 23)
-#define SD_OC_INT		(1 << 22)
+#define MS_OC_INT		BIT(23)
+#define SD_OC_INT		BIT(22)
 
 #define CARD_INT		(XD_INT | MS_INT | SD_INT)
 #define NEED_COMPLETE_INT	(DATA_DONE_INT | TRANS_OK_INT | TRANS_FAIL_INT)
Signature · 1 line
2.7.4
#7 lore raw

PATCH 7/7 staging: rts5208: Remove space after cast

In reply to Rehas Sachdeva

Removes unnecessary space after a cast. Issue found by checkpatch.

---
 drivers/staging/rts5208/rtsx.h | 4 ++--
 drivers/staging/rts5208/xd.c   | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/staging/rts5208/rtsx.h +2 -2
index c0f513c..7a21e46 100644
@@ -135,12 +135,12 @@ typedef struct rtsx_dev rtsx_dev_t;
 /* Convert between rtsx_dev and the corresponding Scsi_Host */
 static inline struct Scsi_Host *rtsx_to_host(struct rtsx_dev *dev)
 {
-	return container_of((void *) dev, struct Scsi_Host, hostdata);
+	return container_of((void *)dev, struct Scsi_Host, hostdata);
 }
 
 static inline struct rtsx_dev *host_to_rtsx(struct Scsi_Host *host)
 {
-	return (struct rtsx_dev *) host->hostdata;
+	return (struct rtsx_dev *)host->hostdata;
 }
 
 static inline void get_current_time(u8 *timeval_buf, int buf_len)
drivers/staging/rts5208/xd.c +1 -1
index 2d6a606..bcac405 100644
@@ -937,7 +937,7 @@ static void xd_set_unused_block(struct rtsx_chip *chip, u32 phy_blk)
 	dev_dbg(rtsx_dev(chip), "Set unused block to index %d\n",
 		zone->set_index);
 
-	zone->free_table[zone->set_index++] = (u16) (phy_blk & 0x3ff);
+	zone->free_table[zone->set_index++] = (u16)(phy_blk & 0x3ff);
 	if (zone->set_index >= XD_FREE_TABLE_CNT)
 		zone->set_index = 0;
 	zone->unused_blk_cnt++;
Signature · 1 line
2.7.4