diff options
author | Johannes Thumshirn <jthumshirn@suse.de> | 2018-01-24 11:50:06 -0500 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2018-01-24 11:50:06 -0500 |
commit | 3124b65dad946c20feaaf08959ee38ec27361da9 (patch) | |
tree | 3004f99d4beac533635774ce0839fd0e71e426e6 | |
parent | 6b136a24b05c81a24e0b648a4bd938bcd0c4f69e (diff) |
bsg: use pr_debug instead of hand crafted macros
Use pr_debug instead of hand crafted macros. This way it is not needed to
re-compile the kernel to enable bsg debug outputs and it's possible to
selectively enable specific prints.
Cc: Joe Perches <joe@perches.com>
Reviewed-by: Bart Van Assche <bart.vanassche@wdc.com>
Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r-- | block/bsg.c | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/block/bsg.c b/block/bsg.c index 452f94f1c5d4..a1bcbb6ba50b 100644 --- a/block/bsg.c +++ b/block/bsg.c | |||
@@ -32,6 +32,9 @@ | |||
32 | #define BSG_DESCRIPTION "Block layer SCSI generic (bsg) driver" | 32 | #define BSG_DESCRIPTION "Block layer SCSI generic (bsg) driver" |
33 | #define BSG_VERSION "0.4" | 33 | #define BSG_VERSION "0.4" |
34 | 34 | ||
35 | #define bsg_dbg(bd, fmt, ...) \ | ||
36 | pr_debug("%s: " fmt, (bd)->name, ##__VA_ARGS__) | ||
37 | |||
35 | struct bsg_device { | 38 | struct bsg_device { |
36 | struct request_queue *queue; | 39 | struct request_queue *queue; |
37 | spinlock_t lock; | 40 | spinlock_t lock; |
@@ -55,14 +58,6 @@ enum { | |||
55 | #define BSG_DEFAULT_CMDS 64 | 58 | #define BSG_DEFAULT_CMDS 64 |
56 | #define BSG_MAX_DEVS 32768 | 59 | #define BSG_MAX_DEVS 32768 |
57 | 60 | ||
58 | #undef BSG_DEBUG | ||
59 | |||
60 | #ifdef BSG_DEBUG | ||
61 | #define dprintk(fmt, args...) printk(KERN_ERR "%s: " fmt, __func__, ##args) | ||
62 | #else | ||
63 | #define dprintk(fmt, args...) | ||
64 | #endif | ||
65 | |||
66 | static DEFINE_MUTEX(bsg_mutex); | 61 | static DEFINE_MUTEX(bsg_mutex); |
67 | static DEFINE_IDR(bsg_minor_idr); | 62 | static DEFINE_IDR(bsg_minor_idr); |
68 | 63 | ||
@@ -123,7 +118,7 @@ static struct bsg_command *bsg_alloc_command(struct bsg_device *bd) | |||
123 | 118 | ||
124 | bc->bd = bd; | 119 | bc->bd = bd; |
125 | INIT_LIST_HEAD(&bc->list); | 120 | INIT_LIST_HEAD(&bc->list); |
126 | dprintk("%s: returning free cmd %p\n", bd->name, bc); | 121 | bsg_dbg(bd, "returning free cmd %p\n", bc); |
127 | return bc; | 122 | return bc; |
128 | out: | 123 | out: |
129 | spin_unlock_irq(&bd->lock); | 124 | spin_unlock_irq(&bd->lock); |
@@ -222,7 +217,8 @@ bsg_map_hdr(struct bsg_device *bd, struct sg_io_v4 *hdr, fmode_t mode) | |||
222 | if (!bcd->class_dev) | 217 | if (!bcd->class_dev) |
223 | return ERR_PTR(-ENXIO); | 218 | return ERR_PTR(-ENXIO); |
224 | 219 | ||
225 | dprintk("map hdr %llx/%u %llx/%u\n", (unsigned long long) hdr->dout_xferp, | 220 | bsg_dbg(bd, "map hdr %llx/%u %llx/%u\n", |
221 | (unsigned long long) hdr->dout_xferp, | ||
226 | hdr->dout_xfer_len, (unsigned long long) hdr->din_xferp, | 222 | hdr->dout_xfer_len, (unsigned long long) hdr->din_xferp, |
227 | hdr->din_xfer_len); | 223 | hdr->din_xfer_len); |
228 | 224 | ||
@@ -299,8 +295,8 @@ static void bsg_rq_end_io(struct request *rq, blk_status_t status) | |||
299 | struct bsg_device *bd = bc->bd; | 295 | struct bsg_device *bd = bc->bd; |
300 | unsigned long flags; | 296 | unsigned long flags; |
301 | 297 | ||
302 | dprintk("%s: finished rq %p bc %p, bio %p\n", | 298 | bsg_dbg(bd, "finished rq %p bc %p, bio %p\n", |
303 | bd->name, rq, bc, bc->bio); | 299 | rq, bc, bc->bio); |
304 | 300 | ||
305 | bc->hdr.duration = jiffies_to_msecs(jiffies - bc->hdr.duration); | 301 | bc->hdr.duration = jiffies_to_msecs(jiffies - bc->hdr.duration); |
306 | 302 | ||
@@ -333,7 +329,7 @@ static void bsg_add_command(struct bsg_device *bd, struct request_queue *q, | |||
333 | list_add_tail(&bc->list, &bd->busy_list); | 329 | list_add_tail(&bc->list, &bd->busy_list); |
334 | spin_unlock_irq(&bd->lock); | 330 | spin_unlock_irq(&bd->lock); |
335 | 331 | ||
336 | dprintk("%s: queueing rq %p, bc %p\n", bd->name, rq, bc); | 332 | bsg_dbg(bd, "queueing rq %p, bc %p\n", rq, bc); |
337 | 333 | ||
338 | rq->end_io_data = bc; | 334 | rq->end_io_data = bc; |
339 | blk_execute_rq_nowait(q, NULL, rq, at_head, bsg_rq_end_io); | 335 | blk_execute_rq_nowait(q, NULL, rq, at_head, bsg_rq_end_io); |
@@ -379,7 +375,7 @@ static struct bsg_command *bsg_get_done_cmd(struct bsg_device *bd) | |||
379 | } | 375 | } |
380 | } while (1); | 376 | } while (1); |
381 | 377 | ||
382 | dprintk("%s: returning done %p\n", bd->name, bc); | 378 | bsg_dbg(bd, "returning done %p\n", bc); |
383 | 379 | ||
384 | return bc; | 380 | return bc; |
385 | } | 381 | } |
@@ -390,7 +386,7 @@ static int blk_complete_sgv4_hdr_rq(struct request *rq, struct sg_io_v4 *hdr, | |||
390 | struct scsi_request *req = scsi_req(rq); | 386 | struct scsi_request *req = scsi_req(rq); |
391 | int ret = 0; | 387 | int ret = 0; |
392 | 388 | ||
393 | dprintk("rq %p bio %p 0x%x\n", rq, bio, req->result); | 389 | pr_debug("rq %p bio %p 0x%x\n", rq, bio, req->result); |
394 | /* | 390 | /* |
395 | * fill in all the output members | 391 | * fill in all the output members |
396 | */ | 392 | */ |
@@ -469,7 +465,7 @@ static int bsg_complete_all_commands(struct bsg_device *bd) | |||
469 | struct bsg_command *bc; | 465 | struct bsg_command *bc; |
470 | int ret, tret; | 466 | int ret, tret; |
471 | 467 | ||
472 | dprintk("%s: entered\n", bd->name); | 468 | bsg_dbg(bd, "entered\n"); |
473 | 469 | ||
474 | /* | 470 | /* |
475 | * wait for all commands to complete | 471 | * wait for all commands to complete |
@@ -572,7 +568,7 @@ bsg_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) | |||
572 | int ret; | 568 | int ret; |
573 | ssize_t bytes_read; | 569 | ssize_t bytes_read; |
574 | 570 | ||
575 | dprintk("%s: read %zd bytes\n", bd->name, count); | 571 | bsg_dbg(bd, "read %zd bytes\n", count); |
576 | 572 | ||
577 | bsg_set_block(bd, file); | 573 | bsg_set_block(bd, file); |
578 | 574 | ||
@@ -646,7 +642,7 @@ bsg_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) | |||
646 | ssize_t bytes_written; | 642 | ssize_t bytes_written; |
647 | int ret; | 643 | int ret; |
648 | 644 | ||
649 | dprintk("%s: write %zd bytes\n", bd->name, count); | 645 | bsg_dbg(bd, "write %zd bytes\n", count); |
650 | 646 | ||
651 | if (unlikely(uaccess_kernel())) | 647 | if (unlikely(uaccess_kernel())) |
652 | return -EINVAL; | 648 | return -EINVAL; |
@@ -664,7 +660,7 @@ bsg_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) | |||
664 | if (!bytes_written || err_block_err(ret)) | 660 | if (!bytes_written || err_block_err(ret)) |
665 | bytes_written = ret; | 661 | bytes_written = ret; |
666 | 662 | ||
667 | dprintk("%s: returning %zd\n", bd->name, bytes_written); | 663 | bsg_dbg(bd, "returning %zd\n", bytes_written); |
668 | return bytes_written; | 664 | return bytes_written; |
669 | } | 665 | } |
670 | 666 | ||
@@ -717,7 +713,7 @@ static int bsg_put_device(struct bsg_device *bd) | |||
717 | hlist_del(&bd->dev_list); | 713 | hlist_del(&bd->dev_list); |
718 | mutex_unlock(&bsg_mutex); | 714 | mutex_unlock(&bsg_mutex); |
719 | 715 | ||
720 | dprintk("%s: tearing down\n", bd->name); | 716 | bsg_dbg(bd, "tearing down\n"); |
721 | 717 | ||
722 | /* | 718 | /* |
723 | * close can always block | 719 | * close can always block |
@@ -744,9 +740,7 @@ static struct bsg_device *bsg_add_device(struct inode *inode, | |||
744 | struct file *file) | 740 | struct file *file) |
745 | { | 741 | { |
746 | struct bsg_device *bd; | 742 | struct bsg_device *bd; |
747 | #ifdef BSG_DEBUG | ||
748 | unsigned char buf[32]; | 743 | unsigned char buf[32]; |
749 | #endif | ||
750 | 744 | ||
751 | if (!blk_queue_scsi_passthrough(rq)) { | 745 | if (!blk_queue_scsi_passthrough(rq)) { |
752 | WARN_ONCE(true, "Attempt to register a non-SCSI queue\n"); | 746 | WARN_ONCE(true, "Attempt to register a non-SCSI queue\n"); |
@@ -771,7 +765,7 @@ static struct bsg_device *bsg_add_device(struct inode *inode, | |||
771 | hlist_add_head(&bd->dev_list, bsg_dev_idx_hash(iminor(inode))); | 765 | hlist_add_head(&bd->dev_list, bsg_dev_idx_hash(iminor(inode))); |
772 | 766 | ||
773 | strncpy(bd->name, dev_name(rq->bsg_dev.class_dev), sizeof(bd->name) - 1); | 767 | strncpy(bd->name, dev_name(rq->bsg_dev.class_dev), sizeof(bd->name) - 1); |
774 | dprintk("bound to <%s>, max queue %d\n", | 768 | bsg_dbg(bd, "bound to <%s>, max queue %d\n", |
775 | format_dev_t(buf, inode->i_rdev), bd->max_queue); | 769 | format_dev_t(buf, inode->i_rdev), bd->max_queue); |
776 | 770 | ||
777 | mutex_unlock(&bsg_mutex); | 771 | mutex_unlock(&bsg_mutex); |