Skip to contentSkip to conversation

staging: mt7621-mmc: Fix debug macros in dbg.h

PATCH In review Nishad Kamdar 2 participants 3 messages Aug 18, 2018 – Aug 19, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 staging: mt7621-mmc: Fix debug macros in dbg.h

Fixed four debug macros by replacing printk with dev_<level> without __func__ or __LINE__ or current->comm and current->pid. Further removed the do {} while(0) loop for single statement macro. Issues found by checkpatch.

---
Changes in v2:
- Replace printk with dev_<level>.
- Remove __func__, __LINE__, current->comm, current->pid from arguments.
- Remove the do {} while(0) loop from these macros.
- Modify commit message to include other changes.

---
 drivers/staging/mt7621-mmc/dbg.h | 26 +++++++-------------------
 1 file changed, 7 insertions(+), 19 deletions(-)
drivers/staging/mt7621-mmc/dbg.h +7 -19
index 2f2c56b73987..e8091db3c1d6 100644
@@ -104,19 +104,13 @@ do { \
 
 #define N_MSG(evt, fmt, args...)
 /*
-do {    \
-    if ((DBG_EVT_##evt) & sd_debug_zone[host->id]) { \
-        printk(KERN_ERR TAG"%d -> "fmt" <- %s() : L<%d> PID<%s><0x%x>\n", \
-            host->id,  ##args , __FUNCTION__, __LINE__, current->comm, current->pid);	\
-    } \
-} while(0)
-*/
+ *if ((DBG_EVT_##evt) & sd_debug_zone[host->id]) { \
+ *    dev_err(mmc_dev(host->mmc), "%d -> " fmt "\n", host->id, ##args) \
+ *}
+ */
 
 #define ERR_MSG(fmt, args...) \
-do { \
-	printk(KERN_ERR TAG"%d -> "fmt" <- %s() : L<%d> PID<%s><0x%x>\n", \
-	       host->id,  ##args, __FUNCTION__, __LINE__, current->comm, current->pid); \
-} while (0);
+dev_err(mmc_dev(host->mmc), "%d -> " fmt "\n", host->id, ##args)
 
 #if 1
 //defined CONFIG_MTK_MMC_CD_POLL
@@ -124,17 +118,11 @@ do { \
 #define IRQ_MSG(fmt, args...)
 #else
 #define INIT_MSG(fmt, args...) \
-do { \
-	printk(KERN_ERR TAG"%d -> "fmt" <- %s() : L<%d> PID<%s><0x%x>\n", \
-	       host->id,  ##args, __FUNCTION__, __LINE__, current->comm, current->pid); \
-} while (0);
+dev_err(mmc_dev(host->mmc), "%d -> " fmt "\n", host->id, ##args)
 
 /* PID in ISR in not corrent */
 #define IRQ_MSG(fmt, args...) \
-do { \
-	printk(KERN_ERR TAG"%d -> "fmt" <- %s() : L<%d>\n",	\
-	       host->id,  ##args, __FUNCTION__, __LINE__);	\
-} while (0);
+dev_err(mmc_dev(host->mmc), "%d -> " fmt "\n", host->id, ##args)
 #endif
 
 void msdc_debug_proc_init(void);
Signature · 1 line
2.17.1
#1 lore raw
Quoted 25 lines · Nishad Kamdar

Fixed four debug macros by replacing printk with dev_<level> without __func__ or __LINE__ or current->comm and current->pid. Further removed the do {} while(0) loop for single statement macro. Issues found by checkpatch.

---
Changes in v2:
- Replace printk with dev_<level>.
- Remove __func__, __LINE__, current->comm, current->pid from arguments.
- Remove the do {} while(0) loop from these macros.
- Modify commit message to include other changes.

---
 drivers/staging/mt7621-mmc/dbg.h | 26 +++++++-------------------
 1 file changed, 7 insertions(+), 19 deletions(-)
drivers/staging/mt7621-mmc/dbg.h +0 -1
index 2f2c56b73987..e8091db3c1d6 100644
@@ -104,19 +104,13 @@ do { \
 
 #define N_MSG(evt, fmt, args...)
 /*
-do {    \

drivers/staging/mt7621-mmc/dbg.h do { \ · line 110

Quoted 10 lines
drivers/staging/mt7621-mmc/dbg.h +4 -6
-    if ((DBG_EVT_##evt) & sd_debug_zone[host->id]) { \
-        printk(KERN_ERR TAG"%d -> "fmt" <- %s() : L<%d> PID<%s><0x%x>\n", \
-            host->id,  ##args , __FUNCTION__, __LINE__, current->comm, current->pid);	\
-    } \
-} while(0)
-*/
+ *if ((DBG_EVT_##evt) & sd_debug_zone[host->id]) { \
+ *    dev_err(mmc_dev(host->mmc), "%d -> " fmt "\n", host->id, ##args) \
+ *}
+ */

This can just be deleted, just drop it.

drivers/staging/mt7621-mmc/dbg.h do { \ · line 113

Quoted 7 lines
drivers/staging/mt7621-mmc/dbg.h +1 -4
 #define ERR_MSG(fmt, args...) \
-do { \
-	printk(KERN_ERR TAG"%d -> "fmt" <- %s() : L<%d> PID<%s><0x%x>\n", \
-	       host->id,  ##args, __FUNCTION__, __LINE__, current->comm, current->pid); \
-} while (0);
+dev_err(mmc_dev(host->mmc), "%d -> " fmt "\n", host->id, ##args)

No, please just replace all usages of ERR_MSG with dev_err() in the code itself, and then drop ERR_MSG. No driver/subsystem should have special macros just for it.

drivers/staging/mt7621-mmc/dbg.h do { \ · line 121

Quoted 11 lines
drivers/staging/mt7621-mmc/dbg.h +1 -4
 #if 1
 //defined CONFIG_MTK_MMC_CD_POLL
@@ -124,17 +118,11 @@ do { \
 #define IRQ_MSG(fmt, args...)
 #else
 #define INIT_MSG(fmt, args...) \
-do { \
-	printk(KERN_ERR TAG"%d -> "fmt" <- %s() : L<%d> PID<%s><0x%x>\n", \
-	       host->id,  ##args, __FUNCTION__, __LINE__, current->comm, current->pid); \
-} while (0);
+dev_err(mmc_dev(host->mmc), "%d -> " fmt "\n", host->id, ##args)

Same here. Actually I bet all INIT_MSG can just be removed :)

drivers/staging/mt7621-mmc/dbg.h do { \ · line 125

Quoted 8 lines
drivers/staging/mt7621-mmc/dbg.h +1 -4
 /* PID in ISR in not corrent */
 #define IRQ_MSG(fmt, args...) \
-do { \
-	printk(KERN_ERR TAG"%d -> "fmt" <- %s() : L<%d>\n",	\
-	       host->id,  ##args, __FUNCTION__, __LINE__);	\
-} while (0);
+dev_err(mmc_dev(host->mmc), "%d -> " fmt "\n", host->id, ##args)

Same here, just replace the usage of these macros with the real thing.

thanks,

greg k-h

#2 lore raw
Quoted 76 lines · Greg Kroah-Hartman
Quoted 25 lines · Nishad Kamdar

Fixed four debug macros by replacing printk with dev_<level> without __func__ or __LINE__ or current->comm and current->pid. Further removed the do {} while(0) loop for single statement macro. Issues found by checkpatch.

---
Changes in v2:
- Replace printk with dev_<level>.
- Remove __func__, __LINE__, current->comm, current->pid from arguments.
- Remove the do {} while(0) loop from these macros.
- Modify commit message to include other changes.

---
 drivers/staging/mt7621-mmc/dbg.h | 26 +++++++-------------------
 1 file changed, 7 insertions(+), 19 deletions(-)
drivers/staging/mt7621-mmc/dbg.h +0 -1
index 2f2c56b73987..e8091db3c1d6 100644
@@ -104,19 +104,13 @@ do { \
 
 #define N_MSG(evt, fmt, args...)
 /*
-do {    \

drivers/staging/mt7621-mmc/dbg.h do { \ · line 110

Quoted 10 lines
drivers/staging/mt7621-mmc/dbg.h +4 -6
-    if ((DBG_EVT_##evt) & sd_debug_zone[host->id]) { \
-        printk(KERN_ERR TAG"%d -> "fmt" <- %s() : L<%d> PID<%s><0x%x>\n", \
-            host->id,  ##args , __FUNCTION__, __LINE__, current->comm, current->pid);	\
-    } \
-} while(0)
-*/
+ *if ((DBG_EVT_##evt) & sd_debug_zone[host->id]) { \
+ *    dev_err(mmc_dev(host->mmc), "%d -> " fmt "\n", host->id, ##args) \
+ *}
+ */

This can just be deleted, just drop it.

drivers/staging/mt7621-mmc/dbg.h do { \ · line 113

Quoted 7 lines
drivers/staging/mt7621-mmc/dbg.h +1 -4
 #define ERR_MSG(fmt, args...) \
-do { \
-	printk(KERN_ERR TAG"%d -> "fmt" <- %s() : L<%d> PID<%s><0x%x>\n", \
-	       host->id,  ##args, __FUNCTION__, __LINE__, current->comm, current->pid); \
-} while (0);
+dev_err(mmc_dev(host->mmc), "%d -> " fmt "\n", host->id, ##args)

No, please just replace all usages of ERR_MSG with dev_err() in the code itself, and then drop ERR_MSG. No driver/subsystem should have special macros just for it.

drivers/staging/mt7621-mmc/dbg.h do { \ · line 121

Quoted 11 lines
drivers/staging/mt7621-mmc/dbg.h +1 -4
 #if 1
 //defined CONFIG_MTK_MMC_CD_POLL
@@ -124,17 +118,11 @@ do { \
 #define IRQ_MSG(fmt, args...)
 #else
 #define INIT_MSG(fmt, args...) \
-do { \
-	printk(KERN_ERR TAG"%d -> "fmt" <- %s() : L<%d> PID<%s><0x%x>\n", \
-	       host->id,  ##args, __FUNCTION__, __LINE__, current->comm, current->pid); \
-} while (0);
+dev_err(mmc_dev(host->mmc), "%d -> " fmt "\n", host->id, ##args)

Same here. Actually I bet all INIT_MSG can just be removed :)

drivers/staging/mt7621-mmc/dbg.h do { \ · line 125

Quoted 8 lines
drivers/staging/mt7621-mmc/dbg.h +1 -4
 /* PID in ISR in not corrent */
 #define IRQ_MSG(fmt, args...) \
-do { \
-	printk(KERN_ERR TAG"%d -> "fmt" <- %s() : L<%d>\n",	\
-	       host->id,  ##args, __FUNCTION__, __LINE__);	\
-} while (0);
+dev_err(mmc_dev(host->mmc), "%d -> " fmt "\n", host->id, ##args)

Same here, just replace the usage of these macros with the real thing.

Quoted 3 lines

thanks,

greg k-h

Ok, I will make the changes in the next version.

thanks for the review.

regards,
nishad