Re: [PATCH 07/32] ide-tape: refactor the debug logging facility

From: Bartlomiej Zolnierkiewicz
Date: Sun Jan 27 2008 - 14:33:53 EST


On Sunday 27 January 2008, Borislav Petkov wrote:
> From: Borislav Petkov <bbpetkov@xxxxxxxx>
>
> Teach the debug logging macro to differentiate different log levels based on the
> type of debug level enabled specifically instead of a threshold-based one.
> Thus, convert tape->debug_level to a bitmask that is written to over /proc.

This warrants rename of the setting from "debug_level" to "debug_mask".

> Also,
> - Cleanup and simplify debug macro thus removing a lot of code lines,
> - Get rid of unused debug levels,
> - Adjust the loglevel at several places where it was simply missing (e.g.
> idetape_chrdev_open() etc.)
>
> Signed-off-by: Borislav Petkov <bbpetkov@xxxxxxxx>
> ---
> drivers/ide/ide-tape.c | 310 +++++++++++++++++-------------------------------
> 1 files changed, 107 insertions(+), 203 deletions(-)
>
> diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
> index efb9d25..a2e7df0 100644
> --- a/drivers/ide/ide-tape.c
> +++ b/drivers/ide/ide-tape.c
> @@ -103,24 +103,27 @@ typedef struct os_dat_s {
> #define IDETAPE_MAX_PIPELINE_STAGES 400
> #define IDETAPE_INCREASE_STAGES_RATE 20
>
> -/*
> - * The following are used to debug the driver:
> - *
> - * Setting IDETAPE_DEBUG_LOG to 1 will log driver flow control.
> - * some places.
> - *
> - * Setting them to 0 will restore normal operation mode:
> - *
> - * 1. Disable logging normal successful operations.
> - * 2. Disable self-sanity checks.
> - * 3. Errors will still be logged, of course.
> - *
> - * All the #if DEBUG code will be removed some day, when the driver
> - * is verified to be stable enough. This will make it much more
> - * esthetic.
> - */
> +enum {
> + DBG_ERR = (1 << 0),
> + DBG_SENSE = (1 << 1),
> + DBG_CHRDEV = (1 << 2),
> + DBG_PROCS = (1 << 3),
> + DBG_PCRQ_STACK = (1 << 4),
> +};
> +
> +/* define to see debug info */
> #define IDETAPE_DEBUG_LOG 0
>
> +#if IDETAPE_DEBUG_LOG
> +#define debug_log(lvl, fmt, args...) \
> +{ \
> + if (tape->debug_level & lvl) \
> + printk(KERN_INFO "ide-tape: " fmt, ## args) \
> +}
> +#else
> +#define debug_log(lvl, fmt, args...) do {} while (0)
> +#endif
> +

with IDETAPE_DEBUG_LOG defined to 1:

drivers/ide/ide-tape.c: In function âidetape_next_pc_storageâ:
drivers/ide/ide-tape.c:929: error: expected â;â before â}â token
drivers/ide/ide-tape.c: In function âidetape_next_rq_storageâ:
drivers/ide/ide-tape.c:953: error: expected â;â before â}â token
drivers/ide/ide-tape.c: In function âidetape_analyze_errorâ:
drivers/ide/ide-tape.c:988: error: expected â;â before â}â token
drivers/ide/ide-tape.c: In function âidetape_active_next_stageâ:
drivers/ide/ide-tape.c:1045: warning: format â%fâ expects type âdoubleâ, but argument 2 has type âconst char *â
drivers/ide/ide-tape.c:1045: error: expected â;â before â}â token
drivers/ide/ide-tape.c: In function âidetape_increase_max_pipeline_stagesâ:
drivers/ide/ide-tape.c:1073: error: expected â;â before â}â token
drivers/ide/ide-tape.c: In function âidetape_remove_stage_headâ:
drivers/ide/ide-tape.c:1119: error: expected â;â before â}â token
drivers/ide/ide-tape.c: In function âidetape_abort_pipelineâ:
drivers/ide/ide-tape.c:1154: error: expected â;â before â}â token
drivers/ide/ide-tape.c: In function âidetape_end_requestâ:
drivers/ide/ide-tape.c:1182: error: expected â;â before â}â token
drivers/ide/ide-tape.c: In function âidetape_request_sense_callbackâ:
drivers/ide/ide-tape.c:1247: error: expected â;â before â}â token
drivers/ide/ide-tape.c: In function âidetape_postpone_requestâ:
drivers/ide/ide-tape.c:1333: error: expected â;â before â}â token
drivers/ide/ide-tape.c: In function âidetape_pc_intrâ:
drivers/ide/ide-tape.c:1359: error: expected â;â before â}â token
drivers/ide/ide-tape.c:1392: error: expected â;â before â}â token
drivers/ide/ide-tape.c:1398: error: expected â;â before â}â token
drivers/ide/ide-tape.c:1418: error: expected â;â before â}â token
drivers/ide/ide-tape.c:1424: error: expected â;â before â}â token
drivers/ide/ide-tape.c:1481: error: expected â;â before â}â token
drivers/ide/ide-tape.c:1505: error: expected â;â before â}â token
drivers/ide/ide-tape.c: In function âidetape_issue_packet_commandâ:
drivers/ide/ide-tape.c:1640: error: expected â;â before â}â token
drivers/ide/ide-tape.c: In function âidetape_pc_callbackâ:
drivers/ide/ide-tape.c:1679: error: expected â;â before â}â token
drivers/ide/ide-tape.c: In function âidetape_rw_callbackâ:
drivers/ide/ide-tape.c:1810: error: expected â;â before â}â token
drivers/ide/ide-tape.c: In function âidetape_do_requestâ:
drivers/ide/ide-tape.c:1886: error: expected â;â before â}â token
drivers/ide/ide-tape.c: In function âidetape_kmalloc_stageâ:
drivers/ide/ide-tape.c:2079: error: expected â;â before â}â token
drivers/ide/ide-tape.c: In function âidetape_add_stage_tailâ:
drivers/ide/ide-tape.c:2179: error: expected â;â before â}â token
drivers/ide/ide-tape.c: In function âidetape_read_position_callbackâ:
drivers/ide/ide-tape.c:2224: error: expected â;â before â}â token
drivers/ide/ide-tape.c:2228: error: expected â;â before â}â token
drivers/ide/ide-tape.c:2229: error: expected â;â before â}â token
drivers/ide/ide-tape.c:2236: error: expected â;â before â}â token
drivers/ide/ide-tape.c: In function âidetape_read_positionâ:
drivers/ide/ide-tape.c:2378: error: expected â;â before â}â token
drivers/ide/ide-tape.c: In function âidetape_queue_rw_tailâ:
drivers/ide/ide-tape.c:2511: error: expected â;â before â}â token
drivers/ide/ide-tape.c: In function âidetape_add_chrdev_write_requestâ:
drivers/ide/ide-tape.c:2619: error: expected â;â before â}â token
drivers/ide/ide-tape.c: In function âidetape_add_chrdev_read_requestâ:
drivers/ide/ide-tape.c:2857: error: expected â;â before â}â token
drivers/ide/ide-tape.c: In function âidetape_rewind_tapeâ:
drivers/ide/ide-tape.c:2955: error: expected â;â before â}â token
drivers/ide/ide-tape.c: In function âidetape_blkdev_ioctlâ:
drivers/ide/ide-tape.c:2982: error: expected â;â before â}â token
drivers/ide/ide-tape.c: In function âidetape_chrdev_readâ:
drivers/ide/ide-tape.c:3114: error: expected â;â before â}â token
drivers/ide/ide-tape.c:3156: error: expected â;â before â}â token
drivers/ide/ide-tape.c: In function âidetape_chrdev_writeâ:
drivers/ide/ide-tape.c:3177: error: expected â;â before â}â token
drivers/ide/ide-tape.c: In function âidetape_mtioctopâ:
drivers/ide/ide-tape.c:3336: error: expected â;â before â}â token
drivers/ide/ide-tape.c: In function âidetape_chrdev_ioctlâ:
drivers/ide/ide-tape.c:3474: error: expected â;â before â}â token
drivers/ide/ide-tape.c: In function âidetape_chrdev_openâ:
drivers/ide/ide-tape.c:3534: error: expected â;â before â}â token
drivers/ide/ide-tape.c: In function âidetape_chrdev_releaseâ:
drivers/ide/ide-tape.c:3633: error: expected â;â before â}â token
make[1]: *** [drivers/ide/ide-tape.o] Error 1
make: *** [drivers/ide/ide-tape.o] Error 2

after adding missing ';' after printk()...

drivers/ide/ide-tape.c: In function âidetape_active_next_stageâ:
drivers/ide/ide-tape.c:1045: warning: format â%fâ expects type âdoubleâ, but argument 2 has type âconst char *â
drivers/ide/ide-tape.c: In function âidetape_chrdev_openâ:
drivers/ide/ide-tape.c:3534: warning: âtapeâ is used uninitialized in this function

> /*
> * After each failed packet command we issue a request sense command
> * and retry the packet command IDETAPE_MAX_PC_RETRIES times.
> @@ -557,7 +560,7 @@ typedef struct ide_tape_obj {
> * 5 : 4+include pc_stack rq_stack info
> * 6 : 5+USE_COUNT updates
> */

the above documentation needs to be updated/merged with DBG_* enums

> - int debug_level;
> + u32 debug_level;

debug_level -> debug_mask

also checkpatch.pl complaints about this line:

ERROR: use tabs not spaces
#72: FILE: drivers/ide/ide-tape.c:563:
+ u32 debug_level;$

[...]

the rest of the patch looks fine

Please recast/resubmit.

Thanks,
Bart
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/