Commit e972d702 authored by Borislav Petkov's avatar Borislav Petkov Committed by David S. Miller

ide-tape: convert to ide_debug_log macro

Remove tape->debug_mask and use drive->debug_mask instead.

There should be no functional change resulting from this patch.
Signed-off-by: default avatarBorislav Petkov <petkovbb@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 37bbe084
...@@ -47,28 +47,13 @@ ...@@ -47,28 +47,13 @@
#include <asm/unaligned.h> #include <asm/unaligned.h>
#include <linux/mtio.h> #include <linux/mtio.h>
enum {
/* output errors only */
DBG_ERR = (1 << 0),
/* output all sense key/asc */
DBG_SENSE = (1 << 1),
/* info regarding all chrdev-related procedures */
DBG_CHRDEV = (1 << 2),
/* all remaining procedures */
DBG_PROCS = (1 << 3),
};
/* define to see debug info */ /* define to see debug info */
#define IDETAPE_DEBUG_LOG 0 #undef IDETAPE_DEBUG_LOG
#if IDETAPE_DEBUG_LOG #ifdef IDETAPE_DEBUG_LOG
#define debug_log(lvl, fmt, args...) \ #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, ## args)
{ \
if (tape->debug_mask & lvl) \
printk(KERN_INFO "ide-tape: " fmt, ## args); \
}
#else #else
#define debug_log(lvl, fmt, args...) do {} while (0) #define ide_debug_log(lvl, fmt, args...) do {} while (0)
#endif #endif
/**************************** Tunable parameters *****************************/ /**************************** Tunable parameters *****************************/
...@@ -230,8 +215,6 @@ typedef struct ide_tape_obj { ...@@ -230,8 +215,6 @@ typedef struct ide_tape_obj {
char drv_write_prot; char drv_write_prot;
/* the tape is write protected (hardware or opened as read-only) */ /* the tape is write protected (hardware or opened as read-only) */
char write_prot; char write_prot;
u32 debug_mask;
} idetape_tape_t; } idetape_tape_t;
static DEFINE_MUTEX(idetape_ref_mutex); static DEFINE_MUTEX(idetape_ref_mutex);
...@@ -290,8 +273,9 @@ static void idetape_analyze_error(ide_drive_t *drive) ...@@ -290,8 +273,9 @@ static void idetape_analyze_error(ide_drive_t *drive)
tape->asc = sense[12]; tape->asc = sense[12];
tape->ascq = sense[13]; tape->ascq = sense[13];
debug_log(DBG_ERR, "pc = %x, sense key = %x, asc = %x, ascq = %x\n", ide_debug_log(IDE_DBG_FUNC,
pc->c[0], tape->sense_key, tape->asc, tape->ascq); "cmd: 0x%x, sense key = %x, asc = %x, ascq = %x",
rq->cmd[0], tape->sense_key, tape->asc, tape->ascq);
/* correct remaining bytes to transfer */ /* correct remaining bytes to transfer */
if (pc->flags & PC_FLAG_DMA_ERROR) if (pc->flags & PC_FLAG_DMA_ERROR)
...@@ -344,7 +328,8 @@ static int ide_tape_callback(ide_drive_t *drive, int dsc) ...@@ -344,7 +328,8 @@ static int ide_tape_callback(ide_drive_t *drive, int dsc)
int uptodate = pc->error ? 0 : 1; int uptodate = pc->error ? 0 : 1;
int err = uptodate ? 0 : IDE_DRV_ERROR_GENERAL; int err = uptodate ? 0 : IDE_DRV_ERROR_GENERAL;
debug_log(DBG_PROCS, "Enter %s\n", __func__); ide_debug_log(IDE_DBG_FUNC, "cmd: 0x%x, dsc: %d, err: %d", rq->cmd[0],
dsc, err);
if (dsc) if (dsc)
ide_tape_handle_dsc(drive); ide_tape_handle_dsc(drive);
...@@ -390,10 +375,12 @@ static int ide_tape_callback(ide_drive_t *drive, int dsc) ...@@ -390,10 +375,12 @@ static int ide_tape_callback(ide_drive_t *drive, int dsc)
static void idetape_postpone_request(ide_drive_t *drive) static void idetape_postpone_request(ide_drive_t *drive)
{ {
idetape_tape_t *tape = drive->driver_data; idetape_tape_t *tape = drive->driver_data;
struct request *rq = drive->hwif->rq;
debug_log(DBG_PROCS, "Enter %s\n", __func__); ide_debug_log(IDE_DBG_FUNC, "cmd: 0x%x, dsc_poll_freq: %lu",
rq->cmd[0], tape->dsc_poll_freq);
tape->postponed_rq = drive->hwif->rq; tape->postponed_rq = rq;
ide_stall_queue(drive, tape->dsc_poll_freq); ide_stall_queue(drive, tape->dsc_poll_freq);
} }
...@@ -488,7 +475,8 @@ static ide_startstop_t ide_tape_issue_pc(ide_drive_t *drive, ...@@ -488,7 +475,8 @@ static ide_startstop_t ide_tape_issue_pc(ide_drive_t *drive,
ide_complete_rq(drive, -EIO, blk_rq_bytes(rq)); ide_complete_rq(drive, -EIO, blk_rq_bytes(rq));
return ide_stopped; return ide_stopped;
} }
debug_log(DBG_SENSE, "Retry #%d, cmd = %02X\n", pc->retries, pc->c[0]); ide_debug_log(IDE_DBG_SENSE, "retry #%d, cmd: 0x%02x", pc->retries,
pc->c[0]);
pc->retries++; pc->retries++;
...@@ -583,8 +571,9 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, ...@@ -583,8 +571,9 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
struct ide_cmd cmd; struct ide_cmd cmd;
u8 stat; u8 stat;
debug_log(DBG_SENSE, "sector: %llu, nr_sectors: %u\n", ide_debug_log(IDE_DBG_RQ, "cmd: 0x%x, sector: %llu, nr_sectors: %u",
(unsigned long long)blk_rq_pos(rq), blk_rq_sectors(rq)); rq->cmd[0], (unsigned long long)blk_rq_pos(rq),
blk_rq_sectors(rq));
BUG_ON(!(blk_special_request(rq) || blk_sense_request(rq))); BUG_ON(!(blk_special_request(rq) || blk_sense_request(rq)));
...@@ -745,7 +734,7 @@ static int ide_tape_read_position(ide_drive_t *drive) ...@@ -745,7 +734,7 @@ static int ide_tape_read_position(ide_drive_t *drive)
struct ide_atapi_pc pc; struct ide_atapi_pc pc;
u8 buf[20]; u8 buf[20];
debug_log(DBG_PROCS, "Enter %s\n", __func__); ide_debug_log(IDE_DBG_FUNC, "enter");
/* prep cmd */ /* prep cmd */
ide_init_pc(&pc); ide_init_pc(&pc);
...@@ -756,9 +745,9 @@ static int ide_tape_read_position(ide_drive_t *drive) ...@@ -756,9 +745,9 @@ static int ide_tape_read_position(ide_drive_t *drive)
return -1; return -1;
if (!pc.error) { if (!pc.error) {
debug_log(DBG_SENSE, "BOP - %s\n", ide_debug_log(IDE_DBG_FUNC, "BOP - %s",
(buf[0] & 0x80) ? "Yes" : "No"); (buf[0] & 0x80) ? "Yes" : "No");
debug_log(DBG_SENSE, "EOP - %s\n", ide_debug_log(IDE_DBG_FUNC, "EOP - %s",
(buf[0] & 0x40) ? "Yes" : "No"); (buf[0] & 0x40) ? "Yes" : "No");
if (buf[0] & 0x4) { if (buf[0] & 0x4) {
...@@ -768,7 +757,7 @@ static int ide_tape_read_position(ide_drive_t *drive) ...@@ -768,7 +757,7 @@ static int ide_tape_read_position(ide_drive_t *drive)
&drive->atapi_flags); &drive->atapi_flags);
return -1; return -1;
} else { } else {
debug_log(DBG_SENSE, "Block Location - %u\n", ide_debug_log(IDE_DBG_FUNC, "Block Location: %u",
be32_to_cpup((__be32 *)&buf[4])); be32_to_cpup((__be32 *)&buf[4]));
tape->partition = buf[1]; tape->partition = buf[1];
...@@ -866,7 +855,8 @@ static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int size) ...@@ -866,7 +855,8 @@ static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int size)
struct request *rq; struct request *rq;
int ret; int ret;
debug_log(DBG_SENSE, "%s: cmd=%d\n", __func__, cmd); ide_debug_log(IDE_DBG_FUNC, "cmd: 0x%x, size: %d", cmd, size);
BUG_ON(cmd != REQ_IDETAPE_READ && cmd != REQ_IDETAPE_WRITE); BUG_ON(cmd != REQ_IDETAPE_READ && cmd != REQ_IDETAPE_WRITE);
BUG_ON(size < 0 || size % tape->blk_size); BUG_ON(size < 0 || size % tape->blk_size);
...@@ -1029,7 +1019,7 @@ static int idetape_rewind_tape(ide_drive_t *drive) ...@@ -1029,7 +1019,7 @@ static int idetape_rewind_tape(ide_drive_t *drive)
struct ide_atapi_pc pc; struct ide_atapi_pc pc;
int ret; int ret;
debug_log(DBG_SENSE, "Enter %s\n", __func__); ide_debug_log(IDE_DBG_FUNC, "enter");
idetape_create_rewind_cmd(drive, &pc); idetape_create_rewind_cmd(drive, &pc);
ret = ide_queue_pc_tail(drive, disk, &pc, NULL, 0); ret = ide_queue_pc_tail(drive, disk, &pc, NULL, 0);
...@@ -1055,7 +1045,7 @@ static int idetape_blkdev_ioctl(ide_drive_t *drive, unsigned int cmd, ...@@ -1055,7 +1045,7 @@ static int idetape_blkdev_ioctl(ide_drive_t *drive, unsigned int cmd,
int nr_stages; int nr_stages;
} config; } config;
debug_log(DBG_PROCS, "Enter %s\n", __func__); ide_debug_log(IDE_DBG_FUNC, "cmd: 0x%04x", cmd);
switch (cmd) { switch (cmd) {
case 0x0340: case 0x0340:
...@@ -1085,6 +1075,9 @@ static int idetape_space_over_filemarks(ide_drive_t *drive, short mt_op, ...@@ -1085,6 +1075,9 @@ static int idetape_space_over_filemarks(ide_drive_t *drive, short mt_op,
int retval, count = 0; int retval, count = 0;
int sprev = !!(tape->caps[4] & 0x20); int sprev = !!(tape->caps[4] & 0x20);
ide_debug_log(IDE_DBG_FUNC, "mt_op: %d, mt_count: %d", mt_op, mt_count);
if (mt_count == 0) if (mt_count == 0)
return 0; return 0;
if (MTBSF == mt_op || MTBSFM == mt_op) { if (MTBSF == mt_op || MTBSFM == mt_op) {
...@@ -1148,7 +1141,7 @@ static ssize_t idetape_chrdev_read(struct file *file, char __user *buf, ...@@ -1148,7 +1141,7 @@ static ssize_t idetape_chrdev_read(struct file *file, char __user *buf,
ssize_t ret = 0; ssize_t ret = 0;
int rc; int rc;
debug_log(DBG_CHRDEV, "Enter %s, count %Zd\n", __func__, count); ide_debug_log(IDE_DBG_FUNC, "count %Zd", count);
if (tape->chrdev_dir != IDETAPE_DIR_READ) { if (tape->chrdev_dir != IDETAPE_DIR_READ) {
if (test_bit(ilog2(IDE_AFLAG_DETECT_BS), &drive->atapi_flags)) if (test_bit(ilog2(IDE_AFLAG_DETECT_BS), &drive->atapi_flags))
...@@ -1187,8 +1180,6 @@ static ssize_t idetape_chrdev_read(struct file *file, char __user *buf, ...@@ -1187,8 +1180,6 @@ static ssize_t idetape_chrdev_read(struct file *file, char __user *buf,
} }
if (!done && test_bit(ilog2(IDE_AFLAG_FILEMARK), &drive->atapi_flags)) { if (!done && test_bit(ilog2(IDE_AFLAG_FILEMARK), &drive->atapi_flags)) {
debug_log(DBG_SENSE, "%s: spacing over filemark\n", tape->name);
idetape_space_over_filemarks(drive, MTFSF, 1); idetape_space_over_filemarks(drive, MTFSF, 1);
return 0; return 0;
} }
...@@ -1209,7 +1200,7 @@ static ssize_t idetape_chrdev_write(struct file *file, const char __user *buf, ...@@ -1209,7 +1200,7 @@ static ssize_t idetape_chrdev_write(struct file *file, const char __user *buf,
if (tape->write_prot) if (tape->write_prot)
return -EACCES; return -EACCES;
debug_log(DBG_CHRDEV, "Enter %s, count %Zd\n", __func__, count); ide_debug_log(IDE_DBG_FUNC, "count %Zd", count);
/* Initialize write operation */ /* Initialize write operation */
rc = idetape_init_rw(drive, IDETAPE_DIR_WRITE); rc = idetape_init_rw(drive, IDETAPE_DIR_WRITE);
...@@ -1273,7 +1264,7 @@ static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count) ...@@ -1273,7 +1264,7 @@ static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count)
struct ide_atapi_pc pc; struct ide_atapi_pc pc;
int i, retval; int i, retval;
debug_log(DBG_ERR, "Handling MTIOCTOP ioctl: mt_op=%d, mt_count=%d\n", ide_debug_log(IDE_DBG_FUNC, "MTIOCTOP ioctl: mt_op: %d, mt_count: %d",
mt_op, mt_count); mt_op, mt_count);
switch (mt_op) { switch (mt_op) {
...@@ -1393,7 +1384,7 @@ static int idetape_chrdev_ioctl(struct inode *inode, struct file *file, ...@@ -1393,7 +1384,7 @@ static int idetape_chrdev_ioctl(struct inode *inode, struct file *file,
int block_offset = 0, position = tape->first_frame; int block_offset = 0, position = tape->first_frame;
void __user *argp = (void __user *)arg; void __user *argp = (void __user *)arg;
debug_log(DBG_CHRDEV, "Enter %s, cmd=%u\n", __func__, cmd); ide_debug_log(IDE_DBG_FUNC, "cmd: 0x%x", cmd);
if (tape->chrdev_dir == IDETAPE_DIR_WRITE) { if (tape->chrdev_dir == IDETAPE_DIR_WRITE) {
ide_tape_flush_merge_buffer(drive); ide_tape_flush_merge_buffer(drive);
...@@ -1461,6 +1452,9 @@ static void ide_tape_get_bsize_from_bdesc(ide_drive_t *drive) ...@@ -1461,6 +1452,9 @@ static void ide_tape_get_bsize_from_bdesc(ide_drive_t *drive)
(buf[4 + 6] << 8) + (buf[4 + 6] << 8) +
buf[4 + 7]; buf[4 + 7];
tape->drv_write_prot = (buf[2] & 0x80) >> 7; tape->drv_write_prot = (buf[2] & 0x80) >> 7;
ide_debug_log(IDE_DBG_FUNC, "blk_size: %d, write_prot: %d",
tape->blk_size, tape->drv_write_prot);
} }
static int idetape_chrdev_open(struct inode *inode, struct file *filp) static int idetape_chrdev_open(struct inode *inode, struct file *filp)
...@@ -1480,7 +1474,10 @@ static int idetape_chrdev_open(struct inode *inode, struct file *filp) ...@@ -1480,7 +1474,10 @@ static int idetape_chrdev_open(struct inode *inode, struct file *filp)
return -ENXIO; return -ENXIO;
} }
debug_log(DBG_CHRDEV, "Enter %s\n", __func__); drive = tape->drive;
filp->private_data = tape;
ide_debug_log(IDE_DBG_FUNC, "enter");
/* /*
* We really want to do nonseekable_open(inode, filp); here, but some * We really want to do nonseekable_open(inode, filp); here, but some
...@@ -1489,9 +1486,6 @@ static int idetape_chrdev_open(struct inode *inode, struct file *filp) ...@@ -1489,9 +1486,6 @@ static int idetape_chrdev_open(struct inode *inode, struct file *filp)
*/ */
filp->f_mode &= ~(FMODE_PREAD | FMODE_PWRITE); filp->f_mode &= ~(FMODE_PREAD | FMODE_PWRITE);
drive = tape->drive;
filp->private_data = tape;
if (test_and_set_bit(ilog2(IDE_AFLAG_BUSY), &drive->atapi_flags)) { if (test_and_set_bit(ilog2(IDE_AFLAG_BUSY), &drive->atapi_flags)) {
retval = -EBUSY; retval = -EBUSY;
...@@ -1570,7 +1564,7 @@ static int idetape_chrdev_release(struct inode *inode, struct file *filp) ...@@ -1570,7 +1564,7 @@ static int idetape_chrdev_release(struct inode *inode, struct file *filp)
lock_kernel(); lock_kernel();
tape = drive->driver_data; tape = drive->driver_data;
debug_log(DBG_CHRDEV, "Enter %s\n", __func__); ide_debug_log(IDE_DBG_FUNC, "enter");
if (tape->chrdev_dir == IDETAPE_DIR_WRITE) if (tape->chrdev_dir == IDETAPE_DIR_WRITE)
idetape_write_release(drive, minor); idetape_write_release(drive, minor);
...@@ -1707,7 +1701,6 @@ static int divf_buffer_size(ide_drive_t *drive) { return 1024; } ...@@ -1707,7 +1701,6 @@ static int divf_buffer_size(ide_drive_t *drive) { return 1024; }
ide_devset_rw_flag(dsc_overlap, IDE_DFLAG_DSC_OVERLAP); ide_devset_rw_flag(dsc_overlap, IDE_DFLAG_DSC_OVERLAP);
ide_tape_devset_rw_field(debug_mask, debug_mask);
ide_tape_devset_rw_field(tdsc, best_dsc_rw_freq); ide_tape_devset_rw_field(tdsc, best_dsc_rw_freq);
ide_tape_devset_r_field(avg_speed, avg_speed); ide_tape_devset_r_field(avg_speed, avg_speed);
...@@ -1719,7 +1712,6 @@ static const struct ide_proc_devset idetape_settings[] = { ...@@ -1719,7 +1712,6 @@ static const struct ide_proc_devset idetape_settings[] = {
__IDE_PROC_DEVSET(avg_speed, 0, 0xffff, NULL, NULL), __IDE_PROC_DEVSET(avg_speed, 0, 0xffff, NULL, NULL),
__IDE_PROC_DEVSET(buffer, 0, 0xffff, NULL, divf_buffer), __IDE_PROC_DEVSET(buffer, 0, 0xffff, NULL, divf_buffer),
__IDE_PROC_DEVSET(buffer_size, 0, 0xffff, NULL, divf_buffer_size), __IDE_PROC_DEVSET(buffer_size, 0, 0xffff, NULL, divf_buffer_size),
__IDE_PROC_DEVSET(debug_mask, 0, 0xffff, NULL, NULL),
__IDE_PROC_DEVSET(dsc_overlap, 0, 1, NULL, NULL), __IDE_PROC_DEVSET(dsc_overlap, 0, 1, NULL, NULL),
__IDE_PROC_DEVSET(speed, 0, 0xffff, NULL, NULL), __IDE_PROC_DEVSET(speed, 0, 0xffff, NULL, NULL),
__IDE_PROC_DEVSET(tdsc, IDETAPE_DSC_RW_MIN, IDETAPE_DSC_RW_MAX, __IDE_PROC_DEVSET(tdsc, IDETAPE_DSC_RW_MIN, IDETAPE_DSC_RW_MAX,
...@@ -1746,6 +1738,8 @@ static void idetape_setup(ide_drive_t *drive, idetape_tape_t *tape, int minor) ...@@ -1746,6 +1738,8 @@ static void idetape_setup(ide_drive_t *drive, idetape_tape_t *tape, int minor)
int buffer_size; int buffer_size;
u16 *ctl = (u16 *)&tape->caps[12]; u16 *ctl = (u16 *)&tape->caps[12];
ide_debug_log(IDE_DBG_FUNC, "minor: %d", minor);
drive->pc_callback = ide_tape_callback; drive->pc_callback = ide_tape_callback;
drive->dev_flags |= IDE_DFLAG_DSC_OVERLAP; drive->dev_flags |= IDE_DFLAG_DSC_OVERLAP;
...@@ -1932,7 +1926,9 @@ static int ide_tape_probe(ide_drive_t *drive) ...@@ -1932,7 +1926,9 @@ static int ide_tape_probe(ide_drive_t *drive)
struct gendisk *g; struct gendisk *g;
int minor; int minor;
if (!strstr("ide-tape", drive->driver_req)) ide_debug_log(IDE_DBG_FUNC, "enter");
if (!strstr(DRV_NAME, drive->driver_req))
goto failed; goto failed;
if (drive->media != ide_tape) if (drive->media != ide_tape)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment