Staging: rts5208: Use standard debug features
v4 cover Staging: rts5208: Use standard debug features
Use standard debug features instead of relying on the custom configuration option CONFIG_RTS5208_DEBUG and a series of home grown macros.
Changes in v4:
* use dev_dbg instead of pr_debug
* use dev_dbg with %*ph modifier instead of print_hex_dump_bytes
Changes in v3:
* defined rtsx_hex_dump as a static inline function to avoid checkpatch errors
Changes in v2:
* defined rtsx_hex_dump macro to produce output only if DEBUG is defined
Fabio Falzoi (3):
Staging: rts5208: Replace custom macro with dev_dbg
Staging: rts5208: Use dev_dbg and %*ph specifier to dump memory
Staging: rts5208: Remove CONFIG_RTS5208_DEBUG option
drivers/staging/rts5208/Kconfig | 7 -- drivers/staging/rts5208/debug.h | 43 ------- drivers/staging/rts5208/ms.c | 130 +++++++++++---------- drivers/staging/rts5208/rtsx.c | 6 +- drivers/staging/rts5208/rtsx.h | 1 - drivers/staging/rts5208/rtsx_card.c | 73 ++++++------ drivers/staging/rts5208/rtsx_card.h | 1 - drivers/staging/rts5208/rtsx_chip.c | 139 ++++++++++++---------- drivers/staging/rts5208/rtsx_chip.h | 5 + drivers/staging/rts5208/rtsx_scsi.c | 47 ++++---- drivers/staging/rts5208/rtsx_scsi.h | 2 +- drivers/staging/rts5208/rtsx_transport.c | 55 +++++---- drivers/staging/rts5208/sd.c | 194 +++++++++++++++++-------------- drivers/staging/rts5208/spi.c | 7 +- drivers/staging/rts5208/trace.h | 14 +-- drivers/staging/rts5208/xd.c | 113 ++++++++++-------- 16 files changed, 424 insertions(+), 413 deletions(-) delete mode 100644 drivers/staging/rts5208/debug.h
Signature · 1 line
2.0.0
PATCH v4 1/3 Staging: rts5208: Replace custom macro with dev_dbg
Use dev_dbg macro to control tracing verbosity through dynamic debug facility.
--- drivers/staging/rts5208/debug.h | 43 ------- drivers/staging/rts5208/ms.c | 126 +++++++++++---------- drivers/staging/rts5208/rtsx.c | 6 +- drivers/staging/rts5208/rtsx.h | 1 - drivers/staging/rts5208/rtsx_card.c | 73 ++++++------ drivers/staging/rts5208/rtsx_card.h | 1 - drivers/staging/rts5208/rtsx_chip.c | 135 ++++++++++++---------- drivers/staging/rts5208/rtsx_chip.h | 5 + drivers/staging/rts5208/rtsx_scsi.c | 44 ++++---- drivers/staging/rts5208/rtsx_scsi.h | 2 +- drivers/staging/rts5208/rtsx_transport.c | 55 +++++---- drivers/staging/rts5208/sd.c | 185 +++++++++++++++++-------------- drivers/staging/rts5208/spi.c | 7 +- drivers/staging/rts5208/trace.h | 10 +- drivers/staging/rts5208/xd.c | 113 ++++++++++--------- 15 files changed, 418 insertions(+), 388 deletions(-) delete mode 100644 drivers/staging/rts5208/debug.h
drivers/staging/rts5208/debug.h deleted +0 -43
@@ -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 +67 -59
434 lines not on this page · raw message
drivers/staging/rts5208/rtsx.c +2 -4
@@ -20,8 +20,6 @@* Micky Ching ([email protected]) */ -#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt -#include <linux/blkdev.h> #include <linux/kthread.h> #include <linux/sched.h>
@@ -478,7 +476,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);rtsx_invoke_transport (chip->srb, chip); }
@@ -864,7 +862,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" ); +dev_dbg (&pci->dev,"Realtek PCI-E card reader detected\n" ); err =pci_enable_device (pci);if (err <0 ) {
drivers/staging/rts5208/rtsx.h +0 -1
@@ -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 +38 -35
240 lines not on this page · raw message
drivers/staging/rts5208/rtsx_card.h +0 -1
@@ -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 +75 -60
389 lines not on this page · raw message
drivers/staging/rts5208/rtsx_chip.h +5 -0
@@ -920,6 +920,11 @@ struct rtsx_chip {u32 sd_ctl; }; +static inline struct device *rtsx_dev (const struct rtsx_chip *chip) +{ +return &chip->rtsx->pci->dev; +} +#define rtsx_set_stat (chip, stat) \ do { \ if ((stat) != RTSX_STAT_IDLE) { \
drivers/staging/rts5208/rtsx_scsi.c +23 -21
145 lines not on this page · raw message
drivers/staging/rts5208/rtsx_scsi.h +1 -1
@@ -133,7 +133,7 @@#define SENSE_TYPE_MEDIA_READ_FORBIDDEN 0x10#endif -void scsi_show_command (struct scsi_cmnd *srb); +void scsi_show_command (struct rtsx_chip *chip);void set_sense_type (struct rtsx_chip *chip,unsigned int lun,int sense_type); void set_sense_data(struct rtsx_chip *chip, unsigned int lun, u8 err_code, u8 sense_key, u32 info, u8 asc, u8 ascq,
drivers/staging/rts5208/rtsx_transport.c +33 -22
139 lines not on this page · raw message
drivers/staging/rts5208/sd.c +102 -83
535 lines not on this page · raw message
drivers/staging/rts5208/spi.c +4 -3
@@ -409,7 +409,8 @@ 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); +dev_dbg (rtsx_dev (chip),"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 +432,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); +dev_dbg (rtsx_dev (chip),"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 +6 -4
@@ -49,7 +49,8 @@ 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__); \ + dev_dbg(rtsx_dev(chip), "[%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 +66,8 @@ 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__); \ + dev_dbg(rtsx_dev(chip), "[%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 +86,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 -51
343 lines not on this page · raw message
Signature · 1 line
2.0.0
Re: [PATCH v4 1/3] Staging: rts5208: Replace custom macro with dev_dbg
drivers/staging/rts5208/ms.c static int mg_set_tpc_para_sub(struct rtsx_chip *chip, int type, · line 3675
Quoted 6 lines · Fabio Falzoi
drivers/staging/rts5208/ms.c +1
-1@@ -3664,7 +3672,7 @@ static int mg_set_tpc_para_sub(struct rtsx_chip *chip, int type,int retval;u8 buf[6 ]; -RTSX_DEBUGP ("--%s--\n" , __func__); +dev_dbg (rtsx_dev (chip),"--%s--\n" , __func__);
All of these debug printks to mark when we have called a function should be deleted. We have ftrace for that.
drivers/staging/rts5208/xd.c static int xd_init_l2p_tbl(struct rtsx_chip *chip) · line 770
Quoted 9 lines
drivers/staging/rts5208/xd.c +3
-2-static inline void free_zone (struct zone_entry *zone) +static inline void free_zone (const struct rtsx_chip *chip, +struct zone_entry *zone) { -RTSX_DEBUGP ("free_zone\n" ); +dev_dbg (rtsx_dev (chip),"free_zone\n" );if (!zone)return ;
Don't add a parameter to free_zone() just for this debug printk which should be deleted.
regards,
dan carpenter
PATCH v4 2/3 Staging: rts5208: Use dev_dbg and %*ph specifier to dump memory
In reply to Fabio FalzoiUse dev_dbg with %*ph format specifier to dump memory instead of relying on custom macro.
--- drivers/staging/rts5208/ms.c | 4 ++-- drivers/staging/rts5208/rtsx_chip.c | 4 ++-- drivers/staging/rts5208/rtsx_scsi.c | 7 +++---- drivers/staging/rts5208/sd.c | 6 +++--- drivers/staging/rts5208/trace.h | 8 -------- 5 files changed, 10 insertions(+), 19 deletions(-)
drivers/staging/rts5208/ms.c +2 -2
@@ -305,7 +305,7 @@ static int ms_read_bytes(struct rtsx_chip *chip,if ((tpc ==PRO_READ_SHORT_DATA ) && (data_len ==8 )) {dev_dbg (rtsx_dev (chip),"Read format progress:\n" ); -RTSX_DUMP (ptr, cnt); +dev_dbg (rtsx_dev (chip),"%*ph\n" , cnt, ptr); }return STATUS_SUCCESS ;
@@ -1913,7 +1913,7 @@ RE_SEARCH: ptr =rtsx_get_cmd_data (chip);dev_dbg (rtsx_dev (chip),"Boot block data:\n" ); -RTSX_DUMP (ptr,16 ); +dev_dbg (rtsx_dev (chip),"%*ph\n" ,16 , ptr);/* Block ID error * HEADER_ID0, HEADER_ID1
drivers/staging/rts5208/rtsx_chip.c +2 -2
@@ -1311,8 +1311,8 @@ 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 ); +dev_dbg (rtsx_dev (chip),"%*ph\n" , dw_len *4 , mask); +dev_dbg (rtsx_dev (chip),"%*ph\n" , dw_len *4 , data);for (i =0 ; i < dw_len; i++) { retval = rtsx_write_cfg_dw(chip, func, aligned_addr + i * 4,
drivers/staging/rts5208/rtsx_scsi.c +3 -4
@@ -39,7 +39,7 @@ void scsi_show_command(struct rtsx_chip *chip) {struct scsi_cmnd *srb = chip->srb;char *what =NULL ; -int i, unknown_cmd =0 ; +int unknown_cmd =0 , len;switch (srb->cmnd[0 ]) {case TEST_UNIT_READY :
@@ -319,9 +319,8 @@ void scsi_show_command(struct rtsx_chip *chip) what, srb->cmd_len);if (unknown_cmd) { -for (i =0 ; i < srb->cmd_len && i <16 ; i++) -dev_dbg (rtsx_dev (chip)," %02x" , srb->cmnd[i]); -dev_dbg (rtsx_dev (chip),"\n" ); + len = min_t(unsigned short, srb->cmd_len, 16); +dev_dbg (rtsx_dev (chip),"%*ph\n" , len, srb->cmnd); } }
drivers/staging/rts5208/sd.c +3 -3
@@ -427,7 +427,7 @@ static int sd_check_csd(struct rtsx_chip *chip, char check_wp)memcpy (sd_card->raw_csd, rsp +1 ,15 );dev_dbg (rtsx_dev (chip),"CSD Response:\n" ); -RTSX_DUMP (sd_card->raw_csd,16 ); +dev_dbg (rtsx_dev (chip),"%*ph\n" ,16 , sd_card->raw_csd); csd_ver = (rsp[1 ] &0xc0 ) >>6 ;dev_dbg (rtsx_dev (chip),"csd_ver = %d\n" , csd_ver);
@@ -1060,7 +1060,7 @@ static int sd_check_switch_mode(struct rtsx_chip *chip, u8 mode,TRACE_RET (chip,STATUS_FAIL ); } -RTSX_DUMP (buf,64 ); +dev_dbg (rtsx_dev (chip),"%*ph\n" ,64 , buf);if (func_group ==NO_ARGUMENT ) { sd_card->func_group1_mask = buf[0x0D ];
@@ -2119,7 +2119,7 @@ static int sd_check_wp_state(struct rtsx_chip *chip) }dev_dbg (rtsx_dev (chip),"ACMD13:\n" ); -RTSX_DUMP (buf,64 ); +dev_dbg (rtsx_dev (chip),"%*ph\n" ,64 , buf); sd_card_type = ((u16 )buf[2 ] <<8 ) | buf[3 ];dev_dbg (rtsx_dev (chip),"sd_card_type = 0x%04x\n" , sd_card_type);
drivers/staging/rts5208/trace.h +0 -8
@@ -84,12 +84,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
PATCH v4 3/3 Staging: rts5208: Remove CONFIG_RTS5208_DEBUG option
In reply to Fabio FalzoiCONFIG_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
@@ -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
@@ -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);dev_dbg (rtsx_dev (chip),"SD_VP_CTL: 0x%x\n" , val);rtsx_read_register (chip,SD_DCMPS_CTL , &val);dev_dbg (rtsx_dev (chip),"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);dev_dbg (rtsx_dev (chip),"SD_VP_CTL: 0x%x\n" , val);rtsx_read_register (chip,SD_DCMPS_CTL , &val);dev_dbg (rtsx_dev (chip),"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