Skip to contentSkip to conversation

Staging: rts5208: Use dynamic debug feature

PATCH In review Fabio Falzoi 2 participants 8 messages Jul 6, 2014 Staging

lore
Share & tools
lore
#0 lore raw

cover Staging: rts5208: Use dynamic debug feature

Use standard dynamic debug features instead of relying on the custom configuration option CONFIG_RTS5208_DEBUG and a series of home grown macros.

Fabio Falzoi (4):
Use standard pr_debug instead of a custom macro Use standard print_hex_dump_debug instead of a custom macro Remove CONFIG_RTS5208_DEBUG option
Fix a format specifier for dev_err

 drivers/staging/rts5208/Kconfig          |   7 --
 drivers/staging/rts5208/debug.h          |  43 -------
 drivers/staging/rts5208/ms.c             | 146 ++++++++++++------------
 drivers/staging/rts5208/rtsx.c           |   8 +-
 drivers/staging/rts5208/rtsx.h           |   1 -
 drivers/staging/rts5208/rtsx_card.c      |  72 ++++++------
 drivers/staging/rts5208/rtsx_card.h      |   1 -
 drivers/staging/rts5208/rtsx_chip.c      | 136 +++++++++++-----------
 drivers/staging/rts5208/rtsx_scsi.c      |  46 ++++----
 drivers/staging/rts5208/rtsx_transport.c |  45 ++++----
 drivers/staging/rts5208/sd.c             | 189 ++++++++++++++++---------------
 drivers/staging/rts5208/spi.c            |   8 +-
 drivers/staging/rts5208/trace.h          |  12 +-
 drivers/staging/rts5208/xd.c             | 121 ++++++++++----------
 14 files changed, 396 insertions(+), 439 deletions(-)
 delete mode 100644 drivers/staging/rts5208/debug.h
Signature · 1 line
2.0.0
#1 lore raw

PATCH 1/4 Staging: rts5208: Use standard pr_debug macro

Use pr_debug macro to control tracing verbosity through dynamic debug facility.

---
 drivers/staging/rts5208/debug.h          |  43 --------
 drivers/staging/rts5208/ms.c             | 140 ++++++++++++------------
 drivers/staging/rts5208/rtsx.c           |   4 +-
 drivers/staging/rts5208/rtsx.h           |   1 -
 drivers/staging/rts5208/rtsx_card.c      |  72 +++++++------
 drivers/staging/rts5208/rtsx_card.h      |   1 -
 drivers/staging/rts5208/rtsx_chip.c      | 130 +++++++++++------------
 drivers/staging/rts5208/rtsx_scsi.c      |  42 ++++----
 drivers/staging/rts5208/rtsx_transport.c |  45 ++++----
 drivers/staging/rts5208/sd.c             | 177 ++++++++++++++++---------------
 drivers/staging/rts5208/spi.c            |   8 +-
 drivers/staging/rts5208/trace.h          |   8 +-
 drivers/staging/rts5208/xd.c             | 121 ++++++++++-----------
 13 files changed, 380 insertions(+), 412 deletions(-)
 delete mode 100644 drivers/staging/rts5208/debug.h
drivers/staging/rts5208/debug.h deleted +0 -43
deleted file mode 100644
index 5ba8a3a..0000000
@@ -1,43 +0,0 @@
-/* Driver for Realtek PCI-Express card reader
- * Header file
- *
- * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, see <http://www.gnu.org/licenses/>.
- *
- * Author:
- *   Wei WANG ([email protected])
- *   Micky Ching ([email protected])
- */
-
-#ifndef __REALTEK_RTSX_DEBUG_H
-#define __REALTEK_RTSX_DEBUG_H
-
-#include <linux/kernel.h>
-
-#define RTSX_STOR "rts5208: "
-
-#ifdef CONFIG_RTS5208_DEBUG
-#define RTSX_DEBUGP(x...) pr_debug(RTSX_STOR x)
-#define RTSX_DEBUGPN(x...) pr_debug(x)
-#define RTSX_DEBUGPX(x...) printk(x)
-#define RTSX_DEBUG(x) x
-#else
-#define RTSX_DEBUGP(x...)
-#define RTSX_DEBUGPN(x...)
-#define RTSX_DEBUGPX(x...)
-#define RTSX_DEBUG(x)
-#endif
-
-#endif   /* __REALTEK_RTSX_DEBUG_H */
drivers/staging/rts5208/ms.c +71 -69

451 lines not on this page · raw message

drivers/staging/rts5208/rtsx.c +2 -2
index c0a0e60..4f5f7a3 100644
@@ -478,7 +478,7 @@ static int rtsx_control_thread(void *__dev)
 
 		/* we've got a command, let's do it! */
 		else {
-			RTSX_DEBUG(scsi_show_command(chip->srb));
+			scsi_show_command(chip->srb);
 			rtsx_invoke_transport(chip->srb, chip);
 		}
 
@@ -864,7 +864,7 @@ static int rtsx_probe(struct pci_dev *pci,
 	int err = 0;
 	struct task_struct *th;
 
-	RTSX_DEBUGP("Realtek PCI-E card reader detected\n");
+	pr_debug("Realtek PCI-E card reader detected\n");
 
 	err = pci_enable_device(pci);
 	if (err < 0) {
drivers/staging/rts5208/rtsx.h +0 -1
index 37eab56..9e6ecb7 100644
@@ -46,7 +46,6 @@
 #include <scsi/scsi_eh.h>
 #include <scsi/scsi_host.h>
 
-#include "debug.h"
 #include "trace.h"
 #include "general.h"
 
drivers/staging/rts5208/rtsx_card.c +37 -35

245 lines not on this page · raw message

drivers/staging/rts5208/rtsx_card.h +0 -1
index 4528b61..b19239e 100644
@@ -24,7 +24,6 @@
 #ifndef __REALTEK_RTSX_CARD_H
 #define __REALTEK_RTSX_CARD_H
 
-#include "debug.h"
 #include "rtsx.h"
 #include "rtsx_chip.h"
 #include "rtsx_transport.h"
drivers/staging/rts5208/rtsx_chip.c +65 -65

389 lines not on this page · raw message

drivers/staging/rts5208/rtsx_scsi.c +22 -20

142 lines not on this page · raw message

drivers/staging/rts5208/rtsx_transport.c +23 -22

135 lines not on this page · raw message

drivers/staging/rts5208/sd.c +89 -88

532 lines not on this page · raw message

drivers/staging/rts5208/spi.c +5 -3
index 312b9f9..7876dc0 100644
@@ -20,6 +20,8 @@
  *   Micky Ching ([email protected])
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/blkdev.h>
 #include <linux/kthread.h>
 #include <linux/sched.h>
@@ -409,7 +411,7 @@ int spi_get_status(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 {
 	struct spi_info *spi = &(chip->spi);
 
-	RTSX_DEBUGP("spi_get_status: err_code = 0x%x\n", spi->err_code);
+	pr_debug("spi_get_status: err_code = 0x%x\n", spi->err_code);
 	rtsx_stor_set_xfer_buf(&(spi->err_code),
 			min_t(int, scsi_bufflen(srb), 1), srb);
 	scsi_set_resid(srb, scsi_bufflen(srb) - 1);
@@ -431,8 +433,8 @@ int spi_set_parameter(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 	spi->clk_div = ((u16)(srb->cmnd[4]) << 8) | srb->cmnd[5];
 	spi->write_en = srb->cmnd[6];
 
-	RTSX_DEBUGP("spi_set_parameter: spi_clock = %d, clk_div = %d, write_en = %d\n",
-		     spi->spi_clock, spi->clk_div, spi->write_en);
+	pr_debug("spi_set_parameter: spi_clock = %d, clk_div = %d, write_en = %d\n",
+		 spi->spi_clock, spi->clk_div, spi->write_en);
 
 	return STATUS_SUCCESS;
 }
drivers/staging/rts5208/trace.h +4 -4
index 0f177fb..7fcb459 100644
@@ -49,7 +49,7 @@ static inline char *filename(char *path)
 #define TRACE_RET(chip, ret)						\
 	do {								\
 		char *_file = filename(__FILE__);			\
-		RTSX_DEBUGP("[%s][%s]:[%d]\n", _file, __func__, __LINE__); \
+		pr_debug("[%s][%s]:[%d]\n", _file, __func__, __LINE__); \
 		(chip)->trace_msg[(chip)->msg_idx].line = (u16)(__LINE__); \
 		strncpy((chip)->trace_msg[(chip)->msg_idx].func, __func__, MSG_FUNC_LEN-1); \
 		strncpy((chip)->trace_msg[(chip)->msg_idx].file, _file, MSG_FILE_LEN-1); \
@@ -65,7 +65,7 @@ static inline char *filename(char *path)
 #define TRACE_GOTO(chip, label)						\
 	do {								\
 		char *_file = filename(__FILE__);			\
-		RTSX_DEBUGP("[%s][%s]:[%d]\n", _file, __func__, __LINE__); \
+		pr_debug("[%s][%s]:[%d]\n", _file, __func__, __LINE__); \
 		(chip)->trace_msg[(chip)->msg_idx].line = (u16)(__LINE__); \
 		strncpy((chip)->trace_msg[(chip)->msg_idx].func, __func__, MSG_FUNC_LEN-1); \
 		strncpy((chip)->trace_msg[(chip)->msg_idx].file, _file, MSG_FILE_LEN-1); \
@@ -84,8 +84,8 @@ static inline char *filename(char *path)
 
 #ifdef CONFIG_RTS5208_DEBUG
 #define RTSX_DUMP(buf, buf_len)					\
-	print_hex_dump(KERN_DEBUG, RTSX_STOR, DUMP_PREFIX_NONE,	\
-				16, 1, (buf), (buf_len), false)
+	print_hex_dump(KERN_DEBUG, KBUILD_MODNAME ": ",		\
+		       DUMP_PREFIX_NONE, 16, 1, (buf), (buf_len), false)
 #else
 #define RTSX_DUMP(buf, buf_len)
 #endif
drivers/staging/rts5208/xd.c +62 -59

353 lines not on this page · raw message

Signature · 1 line
2.0.0
#2 lore raw

PATCH 2/4 Staging: rts5208: Use standard print_hex_dump_debug

In reply to Fabio Falzoi

Use print_hex_dump_debug to have memory properly dumped only when dynamic debug is enabled.

---
 drivers/staging/rts5208/ms.c        |  6 ++++--
 drivers/staging/rts5208/rtsx_chip.c |  6 ++++--
 drivers/staging/rts5208/rtsx_scsi.c | 10 +++++-----
 drivers/staging/rts5208/sd.c        |  9 ++++++---
 drivers/staging/rts5208/trace.h     |  8 --------
 5 files changed, 19 insertions(+), 20 deletions(-)
drivers/staging/rts5208/ms.c +4 -2
index 2476d22..e153b65 100644
@@ -307,7 +307,8 @@ static int ms_read_bytes(struct rtsx_chip *chip,
 
 	if ((tpc == PRO_READ_SHORT_DATA) && (data_len == 8)) {
 		pr_debug("Read format progress:\n");
-		RTSX_DUMP(ptr, cnt);
+		print_hex_dump_debug(KBUILD_MODNAME ": ", DUMP_PREFIX_NONE, 16,
+				     1, ptr, cnt, false);
 	}
 
 	return STATUS_SUCCESS;
@@ -1910,7 +1911,8 @@ RE_SEARCH:
 	ptr = rtsx_get_cmd_data(chip);
 
 	pr_debug("Boot block data:\n");
-	RTSX_DUMP(ptr, 16);
+	print_hex_dump_debug(KBUILD_MODNAME ": ", DUMP_PREFIX_NONE, 16, 1,
+			     ptr, 16, false);
 
 	/* Block ID error
 	 * HEADER_ID0, HEADER_ID1
drivers/staging/rts5208/rtsx_chip.c +4 -2
index 8f447ef..5908baa 100644
@@ -1299,8 +1299,10 @@ int rtsx_write_cfg_seq(struct rtsx_chip *chip, u8 func, u16 addr, u8 *buf,
 		}
 	}
 
-	RTSX_DUMP(mask, dw_len * 4);
-	RTSX_DUMP(data, dw_len * 4);
+	print_hex_dump_debug(KBUILD_MODNAME ": ", DUMP_PREFIX_NONE, 16, 1,
+			     mask, dw_len * 4, false);
+	print_hex_dump_debug(KBUILD_MODNAME ": ", DUMP_PREFIX_NONE, 16, 1,
+			     data, dw_len * 4, false);
 
 	for (i = 0; i < dw_len; i++) {
 		retval = rtsx_write_cfg_dw(chip, func, aligned_addr + i * 4,
drivers/staging/rts5208/rtsx_scsi.c +5 -5
index fd3c2e7..7ae08c3 100644
@@ -40,7 +40,8 @@
 void scsi_show_command(struct scsi_cmnd *srb)
 {
 	char *what = NULL;
-	int i, unknown_cmd = 0;
+	int unknown_cmd = 0;
+	size_t len;
 
 	switch (srb->cmnd[0]) {
 	case TEST_UNIT_READY:
@@ -319,10 +320,9 @@ void scsi_show_command(struct scsi_cmnd *srb)
 		pr_debug("Command %s (%d bytes)\n", what, srb->cmd_len);
 
 	if (unknown_cmd) {
-		pr_debug("");
-		for (i = 0; i < srb->cmd_len && i < 16; i++)
-			pr_debug(" %02x", srb->cmnd[i]);
-		pr_debug("\n");
+		len = min_t(size_t, srb->cmd_len, 16);
+		print_hex_dump_debug(KBUILD_MODNAME ": ", DUMP_PREFIX_NONE, 16,
+				     1, srb->cmnd, len, false);
 	}
 }
 
drivers/staging/rts5208/sd.c +6 -3
index 96acd39..7daa230 100644
@@ -426,7 +426,8 @@ static int sd_check_csd(struct rtsx_chip *chip, char check_wp)
 	memcpy(sd_card->raw_csd, rsp + 1, 15);
 
 	pr_debug("CSD Response:\n");
-	RTSX_DUMP(sd_card->raw_csd, 16);
+	print_hex_dump_debug(KBUILD_MODNAME ": ", DUMP_PREFIX_NONE, 16, 1,
+			     sd_card->raw_csd, 16, false);
 
 	csd_ver = (rsp[1] & 0xc0) >> 6;
 	pr_debug("csd_ver = %d\n", csd_ver);
@@ -1059,7 +1060,8 @@ static int sd_check_switch_mode(struct rtsx_chip *chip, u8 mode,
 		TRACE_RET(chip, STATUS_FAIL);
 	}
 
-	RTSX_DUMP(buf, 64);
+	print_hex_dump_debug(KBUILD_MODNAME ": ", DUMP_PREFIX_NONE, 16, 1,
+			     buf, 64, false);
 
 	if (func_group == NO_ARGUMENT) {
 		sd_card->func_group1_mask = buf[0x0D];
@@ -2107,7 +2109,8 @@ static int sd_check_wp_state(struct rtsx_chip *chip)
 	}
 
 	pr_debug("ACMD13:\n");
-	RTSX_DUMP(buf, 64);
+	print_hex_dump_debug(KBUILD_MODNAME ": ", DUMP_PREFIX_NONE, 16, 1,
+			     buf, 64, false);
 
 	sd_card_type = ((u16)buf[2] << 8) | buf[3];
 	pr_debug("sd_card_type = 0x%04x\n", sd_card_type);
drivers/staging/rts5208/trace.h +0 -8
index 7fcb459..44e8597 100644
@@ -82,12 +82,4 @@ static inline char *filename(char *path)
 #define TRACE_GOTO(chip, label)	goto label
 #endif
 
-#ifdef CONFIG_RTS5208_DEBUG
-#define RTSX_DUMP(buf, buf_len)					\
-	print_hex_dump(KERN_DEBUG, KBUILD_MODNAME ": ",		\
-		       DUMP_PREFIX_NONE, 16, 1, (buf), (buf_len), false)
-#else
-#define RTSX_DUMP(buf, buf_len)
-#endif
-
 #endif  /* __REALTEK_RTSX_TRACE_H */
Signature · 1 line
2.0.0
#3 lore raw

Re: [PATCH 2/4] Staging: rts5208: Use standard print_hex_dump_debug

Quoted 2 lines · Fabio Falzoi

Use print_hex_dump_debug to have memory properly dumped only when dynamic debug is enabled.

Not true.
Now it prints all the time when !CONFIG_DYNAMIC_DEBUG and CONFIG_PRINTK.

drivers/staging/rts5208/trace.h

Quoted 1 line
drivers/staging/rts5208/trace.h +0 -0

[]

drivers/staging/rts5208/trace.h static inline char *filename(char *path) · line 85

Quoted 9 lines
drivers/staging/rts5208/trace.h +0 -8
-#ifdef CONFIG_RTS5208_DEBUG
-#define RTSX_DUMP(buf, buf_len)					\
-	print_hex_dump(KERN_DEBUG, KBUILD_MODNAME ": ",		\
-		       DUMP_PREFIX_NONE, 16, 1, (buf), (buf_len), false)
-#else
-#define RTSX_DUMP(buf, buf_len)
-#endif
-
 #endif  /* __REALTEK_RTSX_TRACE_H */

Before it would not print at all if !CONFIG_RTS5208_DEBUG.

#4 lore raw

Re: [PATCH 2/4] Staging: rts5208: Use standard print_hex_dump_debug

Have I to fix just the commit message or is this behaviour not suitable? In the latter case, could you please suggest a way to fix this?

Thank you,
Fabio

Quoted 22 lines · Joe Perches
Quoted 2 lines · Fabio Falzoi

Use print_hex_dump_debug to have memory properly dumped only when dynamic debug is enabled.

Not true.
Now it prints all the time when !CONFIG_DYNAMIC_DEBUG and CONFIG_PRINTK.

drivers/staging/rts5208/trace.h

Quoted 1 line
drivers/staging/rts5208/trace.h +0 -0

[]

drivers/staging/rts5208/trace.h static inline char *filename(char *path) · line 85

Quoted 9 lines
drivers/staging/rts5208/trace.h +0 -8
-#ifdef CONFIG_RTS5208_DEBUG
-#define RTSX_DUMP(buf, buf_len)                                      \
-     print_hex_dump(KERN_DEBUG, KBUILD_MODNAME ": ",         \
-                    DUMP_PREFIX_NONE, 16, 1, (buf), (buf_len), false)
-#else
-#define RTSX_DUMP(buf, buf_len)
-#endif
-
 #endif  /* __REALTEK_RTSX_TRACE_H */

Before it would not print at all if !CONFIG_RTS5208_DEBUG.

#5 lore raw

Re: [PATCH 2/4] Staging: rts5208: Use standard print_hex_dump_debug

Quoted 2 lines · Fabio Falzoi

Have I to fix just the commit message or is this behaviour not suitable? In the latter case, could you please suggest a way to fix this?

Hi Fabio.

I think it's not appropriate.
I'd've changed it to something like:

#if DEBUG

#define rtsx_hex_dump(buf, len)						\
	print_hex_dump_bytes(KBUILD_MODNAME ": ", DUMP_PREFIX_NONE,	\
			     buf, len)
#else
#define rtsx_hex_dump(buf, len)
	do {;} while (0)

#endif

#6 lore raw

PATCH 3/4 Staging: rts5208: Remove CONFIG_RTS5208_DEBUG option

In reply to Fabio Falzoi

CONFIG_RTS5208_DEBUG is no more needed, we rely on dynamic debug config options instead.

---
 drivers/staging/rts5208/Kconfig | 7 -------
 drivers/staging/rts5208/sd.c    | 5 +----
 2 files changed, 1 insertion(+), 11 deletions(-)
drivers/staging/rts5208/Kconfig +0 -7
index 055655c..05c990f 100644
@@ -6,10 +6,3 @@ config RTS5208
 	  PCI-E card reader rts5208/rts5288.
 
 	  If this driver is compiled as a module, it will be named rts5208.
-
-config RTS5208_DEBUG
-	bool "Realtek PCI-E Card Reader RTS5208/5288 verbose debug"
-	depends on RTS5208
-	help
-	  Say Y here in order to have the rts5208 code generate
-	  verbose debugging messages.
drivers/staging/rts5208/sd.c +1 -4
index 7daa230..94003a3 100644
@@ -812,12 +812,10 @@ static int sd_change_phase(struct rtsx_chip *chip, u8 sample_point, u8 tune_dir)
 			PHASE_NOT_RESET);
 		RTSX_WRITE_REG(chip, CLK_CTL, CHANGE_CLK, 0);
 	} else {
-#ifdef CONFIG_RTS5208_DEBUG
 		rtsx_read_register(chip, SD_VP_CTL, &val);
 		pr_debug("SD_VP_CTL: 0x%x\n", val);
 		rtsx_read_register(chip, SD_DCMPS_CTL, &val);
 		pr_debug("SD_DCMPS_CTL: 0x%x\n", val);
-#endif
 
 		if (ddr_rx) {
 			RTSX_WRITE_REG(chip, SD_VP_CTL, PHASE_CHANGE,
@@ -863,12 +861,11 @@ static int sd_change_phase(struct rtsx_chip *chip, u8 sample_point, u8 tune_dir)
 	return STATUS_SUCCESS;
 
 Fail:
-#ifdef CONFIG_RTS5208_DEBUG
 	rtsx_read_register(chip, SD_VP_CTL, &val);
 	pr_debug("SD_VP_CTL: 0x%x\n", val);
 	rtsx_read_register(chip, SD_DCMPS_CTL, &val);
 	pr_debug("SD_DCMPS_CTL: 0x%x\n", val);
-#endif
+
 	rtsx_write_register(chip, SD_DCMPS_CTL, DCMPS_CHANGE, 0);
 	rtsx_write_register(chip, SD_VP_CTL, PHASE_CHANGE, 0);
 	wait_timeout(10);
Signature · 1 line
2.0.0
#7 lore raw

PATCH 4/4 Staging: rts5208: Fix a format specifier for dev_err

In reply to Fabio Falzoi

Fix an incorrect use of the %d format specifier in dev_err that caused a warning.

---
 drivers/staging/rts5208/rtsx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/rts5208/rtsx.c +2 -2
index 4f5f7a3..9aae7ac 100644
@@ -463,14 +463,14 @@ static int rtsx_control_thread(void *__dev)
 		 * the maximum known LUN
 		 */
 		else if (chip->srb->device->id) {
-			dev_err(&dev->pci->dev, "Bad target number (%d:%d)\n",
+			dev_err(&dev->pci->dev, "Bad target number (%d:%llu)\n",
 				chip->srb->device->id,
 				chip->srb->device->lun);
 			chip->srb->result = DID_BAD_TARGET << 16;
 		}
 
 		else if (chip->srb->device->lun > chip->max_lun) {
-			dev_err(&dev->pci->dev, "Bad LUN (%d:%d)\n",
+			dev_err(&dev->pci->dev, "Bad LUN (%d:%llu)\n",
 				chip->srb->device->id,
 				chip->srb->device->lun);
 			chip->srb->result = DID_BAD_TARGET << 16;
Signature · 1 line
2.0.0