[PATCH 2/2] ide-cd: add a debug_mask module parameter

Previous thread: none

Next thread: Random crashes with 2.6.27-rc3 on PPC by Michael Buesch on Saturday, August 23, 2008 - 7:10 am. (9 messages)
From: Borislav Petkov
Date: Saturday, August 23, 2008 - 6:08 am

Also,

- leave in the possibility for optimizing away all debugging macros
- add a PFX macro and prepend all printk calls with it for consistency
- add debug macro calls in important driver paths
- remove #if 0-ed code
- mv restore_request -> ide_cd_restore_request
- add a driver registration printk

There should be no functionality change resulting from this patch.

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
---
 drivers/ide/ide-cd.c |  181 +++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 144 insertions(+), 37 deletions(-)

diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 6ef9ba8..cca1011 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -23,6 +23,9 @@
  *	Documentation/ide/ChangeLog.ide-cd.1994-2004
  */
 
+#define DRV_NAME "ide-cd"
+#define PFX DRV_NAME ": "
+
 #define IDECD_VERSION "5.00"
 
 #include <linux/module.h>
@@ -50,6 +53,14 @@
 
 #include "ide-cd.h"
 
+#define IDECD_DEBUG_LOG		1
+
+#if IDECD_DEBUG_LOG
+#define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, args)
+#else
+#define ide_debug_log(lvl, fmt, args...) do {} while (0)
+#endif
+
 static DEFINE_MUTEX(idecd_ref_mutex);
 
 static void ide_cd_release(struct kref *);
@@ -97,6 +108,9 @@ static int cdrom_log_sense(ide_drive_t *drive, struct request *rq,
 {
 	int log = 0;
 
+	ide_debug_log(IDE_DBG_SENSE, "Call %s, sense_key: 0x%x\n", __func__,
+		      sense->sense_key);
+
 	if (!sense || !rq || (rq->cmd_flags & REQ_QUIET))
 		return 0;
 
@@ -145,6 +159,11 @@ static void cdrom_analyze_sense_data(ide_drive_t *drive,
 	unsigned long bio_sectors;
 	struct cdrom_info *info = drive->driver_data;
 
+	ide_debug_log(IDE_DBG_SENSE, "Call %s, failed cmd: 0x%x, "
+		      "error_code: 0x%x, sense_key: 0x%x\n",
+		      __func__, failed_command->cmd[0], sense->error_code,
+		      sense->sense_key);
+
 	if (!cdrom_log_sense(drive, failed_command, sense))
 		return;
 
@@ -214,6 +233,9 @@ static void ...
From: Borislav Petkov
Date: Saturday, August 23, 2008 - 6:08 am

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
---
 drivers/ide/ide-cd.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index cca1011..5e0b9cd 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -53,6 +53,8 @@
 
 #include "ide-cd.h"
 
+static unsigned long debug_mask = 0x0;
+
 #define IDECD_DEBUG_LOG		1
 
 #if IDECD_DEBUG_LOG
@@ -2192,8 +2194,9 @@ static struct block_device_operations idecd_ops = {
 
 /* module options */
 static char *ignore;
-
 module_param(ignore, charp, 0400);
+module_param(debug_mask, ulong, 0644);
+
 MODULE_DESCRIPTION("ATAPI CD-ROM Driver");
 
 static int ide_cd_probe(ide_drive_t *drive)
@@ -2220,6 +2223,9 @@ static int ide_cd_probe(ide_drive_t *drive)
 			goto failed;
 		}
 	}
+
+	drive->debug_mask = debug_mask;
+
 	info = kzalloc(sizeof(struct cdrom_info), GFP_KERNEL);
 	if (info == NULL) {
 		printk(KERN_ERR PFX "%s: Can't allocate a cdrom structure\n",
-- 
1.5.5.4

--

From: Bartlomiej Zolnierkiewicz
Date: Sunday, September 7, 2008 - 11:21 am

No need to zero it, I fixed it and moved debug_mask next to module_param().
--

From: Bartlomiej Zolnierkiewicz
Date: Sunday, September 7, 2008 - 11:19 am

applied
--

Previous thread: none

Next thread: Random crashes with 2.6.27-rc3 on PPC by Michael Buesch on Saturday, August 23, 2008 - 7:10 am. (9 messages)