Received: by 10.223.176.46 with SMTP id f43csp4124949wra; Tue, 23 Jan 2018 04:46:49 -0800 (PST) X-Google-Smtp-Source: AH8x225CFwXl77KyikdjuS9CsOcRK6/S9uRhYdzx6EJF4cHkxnPxmbZ7WKpf8wmGCxLxvnTBpfyr X-Received: by 10.99.168.76 with SMTP id i12mr8974192pgp.119.1516711609348; Tue, 23 Jan 2018 04:46:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516711609; cv=none; d=google.com; s=arc-20160816; b=C3KJV1Jlw3llBR5BWhsC6EVhBYYUs52l18ktxoWQtGI2N+3ePYA6d4z/EVWp8zlpgf M5/K+w3O38xKQtfWh5oqmikynsD0aSZXbFBAs7HmiSoNkYbaGSWx0K5o/QKF55fnu01L lulDm5PGuyEUkDv5QPabVcUkeWMRRD5GAD1eSdwn5BqxoPCvHD0PYPG7X92DaJUV40xD Tyuyewwx/t/+3drS2E2rf5XYIwwVseAdRlwjA0i+YIrhzDjn+fuF7DGDKDco7IW4LOOf I+vcATTzVmsUxZ1Bq6O+jM6rPY450L/x/5BjOZ/I8AEf3vDeRiz/l/IziDWGAKUqIX6Q V/4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :arc-authentication-results; bh=zAkGu4BleUWeeI5w16j8qT8wOJWZAC9hG92V6geVzIk=; b=VgprqZZU/c8TJ/Qh2/HUWRV7Ru5rD/2MGnmwpFwt6nr+KrW6KTvCGF/X3KdZpnrfze W7rZU0Q7tWUl/pDSpRbSl9UM57OVq2Mc1a+pDDo1L1+2IlCFkxxpRPiXKDJd5T+mZwxZ oTj/SwuPDAij8nch/G+NHHLvxqd95L8r+0JIduzUMUGDAs89Mkv/oEN9SZMHYUqJCLqW w3/sst+vxhiRW4DIs5bfNx0zDcjpawjTbp/CZO1WwYtcrw2cLhFhwVb+rSA4uLtV4bxC hevjHD+kuoZhlD0ISP+L0mMZxZY0BChH5mut+Xy+eCXTZTwnYxLm0Q0BaoqIqeW674GS wP+g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 5-v6si4739205plt.284.2018.01.23.04.46.32; Tue, 23 Jan 2018 04:46:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751661AbeAWMp6 (ORCPT + 99 others); Tue, 23 Jan 2018 07:45:58 -0500 Received: from smtprelay0142.hostedemail.com ([216.40.44.142]:46265 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751566AbeAWMp4 (ORCPT ); Tue, 23 Jan 2018 07:45:56 -0500 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay07.hostedemail.com (Postfix) with ESMTP id 05408181D341A; Tue, 23 Jan 2018 12:45:55 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::,RULES_HIT:2:41:69:355:379:541:599:800:960:966:973:982:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1535:1593:1594:1605:1730:1747:1777:1792:1981:2194:2196:2199:2200:2393:2559:2562:2828:3138:3139:3140:3141:3142:3622:3865:3866:3867:3868:3870:3871:3872:4049:4117:4250:4321:4385:5007:6119:6238:7903:8957:9010:10004:10848:11026:11232:11473:11658:11914:12043:12296:12438:12555:12683:12740:12760:12895:13161:13229:13439:13972:14659:21080:21324:21433:21451:21627:30022:30029:30046:30051:30054:30056:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:2,LUA_SUMMARY:none X-HE-Tag: lace22_509a6ae834e38 X-Filterd-Recvd-Size: 6898 Received: from XPS-9350 (unknown [47.151.150.235]) (Authenticated sender: joe@perches.com) by omf06.hostedemail.com (Postfix) with ESMTPA; Tue, 23 Jan 2018 12:45:53 +0000 (UTC) Message-ID: <1516711552.8378.30.camel@perches.com> Subject: Re: [PATCH v2] bsg: use pr_debug instead of hand craftet macros From: Joe Perches To: Johannes Thumshirn , Jens Axboe Cc: Linux Block Layer Mailinglist , Linux Kernel Mailinglist , Bart Van Assche Date: Tue, 23 Jan 2018 04:45:52 -0800 In-Reply-To: <20180123105538.24860-1-jthumshirn@suse.de> References: <20180123105538.24860-1-jthumshirn@suse.de> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.26.1-1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2018-01-23 at 11:55 +0100, Johannes Thumshirn wrote: > Use pr_debug instead of hand craftet 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. Perhaps the email subject could be improved to describe the new macro and as well, this macro, without a pr_fmt define somewhat above it loses the __func__ output too. Perhaps add a description of the capability of the dynamic debug facility to add the function name using +f. > Signed-off-by: Johannes Thumshirn > Cc: Joe Perches > Cc: Bart Van Assche > > --- > Changes to v1: > * Aligned arguments (Bart) > * Include bd->name in macro (Joe) > --- > block/bsg.c | 40 +++++++++++++++++----------------------- > 1 file 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 @@ > #define BSG_DESCRIPTION "Block layer SCSI generic (bsg) driver" > #define BSG_VERSION "0.4" > > +#define bsg_dbg(bd, fmt, ...) \ > + pr_debug("%s: " fmt, (bd)->name, ##__VA_ARGS__) > + > struct bsg_device { > struct request_queue *queue; > spinlock_t lock; > @@ -55,14 +58,6 @@ enum { > #define BSG_DEFAULT_CMDS 64 > #define BSG_MAX_DEVS 32768 > > -#undef BSG_DEBUG > - > -#ifdef BSG_DEBUG > -#define dprintk(fmt, args...) printk(KERN_ERR "%s: " fmt, __func__, ##args) > -#else > -#define dprintk(fmt, args...) > -#endif > - > static DEFINE_MUTEX(bsg_mutex); > static DEFINE_IDR(bsg_minor_idr); > > @@ -123,7 +118,7 @@ static struct bsg_command *bsg_alloc_command(struct bsg_device *bd) > > bc->bd = bd; > INIT_LIST_HEAD(&bc->list); > - dprintk("%s: returning free cmd %p\n", bd->name, bc); > + bsg_dbg(bd, "returning free cmd %p\n", bc); > return bc; > out: > spin_unlock_irq(&bd->lock); > @@ -222,7 +217,8 @@ bsg_map_hdr(struct bsg_device *bd, struct sg_io_v4 *hdr, fmode_t mode) > if (!bcd->class_dev) > return ERR_PTR(-ENXIO); > > - dprintk("map hdr %llx/%u %llx/%u\n", (unsigned long long) hdr->dout_xferp, > + bsg_dbg(bd, "map hdr %llx/%u %llx/%u\n", > + (unsigned long long) hdr->dout_xferp, > hdr->dout_xfer_len, (unsigned long long) hdr->din_xferp, > hdr->din_xfer_len); > > @@ -299,8 +295,8 @@ static void bsg_rq_end_io(struct request *rq, blk_status_t status) > struct bsg_device *bd = bc->bd; > unsigned long flags; > > - dprintk("%s: finished rq %p bc %p, bio %p\n", > - bd->name, rq, bc, bc->bio); > + bsg_dbg(bd, "finished rq %p bc %p, bio %p\n", > + rq, bc, bc->bio); > > bc->hdr.duration = jiffies_to_msecs(jiffies - bc->hdr.duration); > > @@ -333,7 +329,7 @@ static void bsg_add_command(struct bsg_device *bd, struct request_queue *q, > list_add_tail(&bc->list, &bd->busy_list); > spin_unlock_irq(&bd->lock); > > - dprintk("%s: queueing rq %p, bc %p\n", bd->name, rq, bc); > + bsg_dbg(bd, "queueing rq %p, bc %p\n", rq, bc); > > rq->end_io_data = bc; > 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) > } > } while (1); > > - dprintk("%s: returning done %p\n", bd->name, bc); > + bsg_dbg(bd, "returning done %p\n", bc); > > return bc; > } > @@ -390,7 +386,7 @@ static int blk_complete_sgv4_hdr_rq(struct request *rq, struct sg_io_v4 *hdr, > struct scsi_request *req = scsi_req(rq); > int ret = 0; > > - dprintk("rq %p bio %p 0x%x\n", rq, bio, req->result); > + pr_debug("rq %p bio %p 0x%x\n", rq, bio, req->result); > /* > * fill in all the output members > */ > @@ -469,7 +465,7 @@ static int bsg_complete_all_commands(struct bsg_device *bd) > struct bsg_command *bc; > int ret, tret; > > - dprintk("%s: entered\n", bd->name); > + bsg_dbg(bd, "entered\n"); > > /* > * wait for all commands to complete > @@ -572,7 +568,7 @@ bsg_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) > int ret; > ssize_t bytes_read; > > - dprintk("%s: read %zd bytes\n", bd->name, count); > + bsg_dbg(bd, "read %zd bytes\n", count); > > bsg_set_block(bd, file); > > @@ -646,7 +642,7 @@ bsg_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) > ssize_t bytes_written; > int ret; > > - dprintk("%s: write %zd bytes\n", bd->name, count); > + bsg_dbg(bd, "write %zd bytes\n", count); > > if (unlikely(uaccess_kernel())) > return -EINVAL; > @@ -664,7 +660,7 @@ bsg_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) > if (!bytes_written || err_block_err(ret)) > bytes_written = ret; > > - dprintk("%s: returning %zd\n", bd->name, bytes_written); > + bsg_dbg(bd, "returning %zd\n", bytes_written); > return bytes_written; > } > > @@ -717,7 +713,7 @@ static int bsg_put_device(struct bsg_device *bd) > hlist_del(&bd->dev_list); > mutex_unlock(&bsg_mutex); > > - dprintk("%s: tearing down\n", bd->name); > + bsg_dbg(bd, "tearing down\n"); > > /* > * close can always block > @@ -744,9 +740,7 @@ static struct bsg_device *bsg_add_device(struct inode *inode, > struct file *file) > { > struct bsg_device *bd; > -#ifdef BSG_DEBUG > unsigned char buf[32]; > -#endif > > if (!blk_queue_scsi_passthrough(rq)) { > 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, > hlist_add_head(&bd->dev_list, bsg_dev_idx_hash(iminor(inode))); > > strncpy(bd->name, dev_name(rq->bsg_dev.class_dev), sizeof(bd->name) - 1); > - dprintk("bound to <%s>, max queue %d\n", > + bsg_dbg(bd, "bound to <%s>, max queue %d\n", > format_dev_t(buf, inode->i_rdev), bd->max_queue); > > mutex_unlock(&bsg_mutex);