Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1352393imm; Wed, 17 Oct 2018 18:46:40 -0700 (PDT) X-Google-Smtp-Source: ACcGV614gZ1wIAjFIXuwxvADrAkys/+crWdPM6C4RuGWL/3Kq6cRhB3zND+o83SI/4/JyvaBsyY+ X-Received: by 2002:a17:902:50e3:: with SMTP id c32-v6mr15440587plj.215.1539827200074; Wed, 17 Oct 2018 18:46:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539827200; cv=none; d=google.com; s=arc-20160816; b=KJPmJ9A0SVzSyaF5yLZKjdCn2spHeLIMfHL2/uztpey51CBFpej1kSbd78fNN8S3m3 5r0BDbjoXdpoKz/4ou69BcRYfsu8NOLAz/zRGRxlWRfH7UbSvss0s04qMK5LfdsaB6hu YSox/jhKDUq66P7nfRmPdup4qp3eMblfek9y1OhhVWwODRAByvpOhvd4mQmwFdZFXVau pKGVYa0/BYd/MFWeOeWV6w/4XrnWrN1vN2SHQ9O5dh5MW9qt1/WVixjjyy44GpkPLtdQ /L/xKzmHuNXPw89UkA3iSTDk5xKK8CnOHFLAa19PpM5vb+jurX79pqN53It5Q7oCSNF+ Q8Bw== 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 :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=mPzLW50ZGVqpDJCGFAXsbwARoWV9nDRkfVlFfcab8eI=; b=gtYbH9fKzgkEbVraBNXS7gzkgcWvqCNHtgmmWhZu03TtYUeDg179sz9+b8FUzTGzkj HuAujGzX1PUzqrPDYV7eFXjnQ/sAg0ZoGdjI2GMTnWQtDgibdWuPsxt/1S0VdDF33iqQ K+4xZ1QT3KalT5b/ZaNm16ySzVALBxs8uoieV5sQqBojRPsoB2lVb5oUhU/2uraTQnfa EIjIXTS2/zRSeT4oHcmG43G+902+KP/ohcSpZMkvWNQx50EKPnrS1ZjzzE6G3jD+b91o SnnIFJtP3/SUfa5YiKkN8QWAE12RgoCUz9GfA+gDHs2TzZYyLL22MiwsuEAB6ZRhT9uO E8uQ== 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 m8-v6si20188039pgi.18.2018.10.17.18.46.23; Wed, 17 Oct 2018 18:46:40 -0700 (PDT) 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 S1727408AbeJRJoN (ORCPT + 99 others); Thu, 18 Oct 2018 05:44:13 -0400 Received: from smtprelay0054.hostedemail.com ([216.40.44.54]:59321 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727082AbeJRJoM (ORCPT ); Thu, 18 Oct 2018 05:44:12 -0400 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay05.hostedemail.com (Postfix) with ESMTP id B09C718029586; Thu, 18 Oct 2018 01:45:41 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::::::::,RULES_HIT:41:355:379:599:800:968:973:988:989:1260:1277:1311:1313:1314:1345:1359:1431:1437:1515:1516:1518:1534:1542:1593:1594:1605:1711:1730:1747:1777:1792:2393:2553:2559:2562:2693:2828:3138:3139:3140:3141:3142:3622:3865:3866:3867:3868:3870:3871:3872:3873:3874:4250:4321:4605:5007:6119:7903:8660:10004:10400:10848:11232:11233:11473:11658:11914:12296:12740:12760:12895:13095:13148:13230:13439:14181:14659:14721:21080:21121:21433:21451:21627:21740:21796:30012:30036:30054:30055:30060:30070:30090:30091,0,RBL:error,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:28,LUA_SUMMARY:none X-HE-Tag: laugh19_143359c92415c X-Filterd-Recvd-Size: 4292 Received: from XPS-9350 (unknown [172.58.22.135]) (Authenticated sender: joe@perches.com) by omf04.hostedemail.com (Postfix) with ESMTPA; Thu, 18 Oct 2018 01:45:38 +0000 (UTC) Message-ID: Subject: Re: [PATCH 1/3] driver core: add probe_err log helper From: Joe Perches To: Russell King - ARM Linux , Andy Shevchenko Cc: Andrzej Hajda , "Rafael J. Wysocki" , Greg Kroah-Hartman , Bartlomiej Zolnierkiewicz , Linux Kernel Mailing List , Javier Martinez Canillas , Mark Brown , linux-arm Mailing List , Marek Szyprowski Date: Wed, 17 Oct 2018 18:45:36 -0700 In-Reply-To: <20181017112914.GH30658@n2100.armlinux.org.uk> References: <20181016072244.1216-1-a.hajda@samsung.com> <20181016072244.1216-2-a.hajda@samsung.com> <605bd00e-ed0d-4259-bdc3-1784b2b3b16a@samsung.com> <20181016125543eucas1p1f23b3482179a9cd465f509e0abf782c1~eGAecmAv93038330383eucas1p1j@eucas1p1.samsung.com> <20181017112914.GH30658@n2100.armlinux.org.uk> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.30.1-1build1 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 Wed, 2018-10-17 at 12:29 +0100, Russell King - ARM Linux wrote: > On Tue, Oct 16, 2018 at 04:55:00PM +0300, Andy Shevchenko wrote: > > On Tue, Oct 16, 2018 at 3:55 PM Andrzej Hajda wrote: > > > On 16.10.2018 13:29, Andrzej Hajda wrote: > > > > On 16.10.2018 13:01, Andy Shevchenko wrote: > > > > > On Tue, Oct 16, 2018 at 10:22 AM Andrzej Hajda wrote: > > > > > > During probe every time driver gets resource it should usually check for error > > > > > > printk some message if it is not -EPROBE_DEFER and return the error. This > > > > > > pattern is simple but requires adding few lines after any resource acquisition > > > > > > code, as a result it is often omited or implemented only partially. > > > > > > probe_err helps to replace such code seqences with simple call, so code: > > > > > > if (err != -EPROBE_DEFER) > > > > > > dev_err(dev, ...); > > > > > > return err; > > > > > > becomes: > > > > > > return probe_err(dev, err, ...); > > > > > > + va_start(args, fmt); > > > > > > + > > > > > > + vaf.fmt = fmt; > > > > > > + vaf.va = &args; > > > > > > + > > > > > > + __dev_printk(KERN_ERR, dev, &vaf); > > > > > It would be nice to print an error code as well, wouldn't it? > > > > Hmm, on probe fail error is printed anyway (with exception of > > > > EPROBE_DEFER, ENODEV and ENXIO): > > > > "probe of %s failed with error %d\n" > > > > On the other side currently some drivers prints the error code anyway > > > > via dev_err or similar, so I guess during conversion to probe_err it > > > > should be removed then. > > > > > > > > If we add error code to probe_err is it OK to report it this way? > > > > dev_err(dev, "%V, %d\n", &vaf, err); > > > > > > Ups, I forgot that message passed to probe_err will contain already > > > newline character. > > > > You may consider not to pass it. > > It's normal to pass the '\n', so by doing this, we create the situation > where this function becomes the exception to the norm. That's not a > good idea - we will see people forget that appending '\n' should not > be done for this particular function. > > While we could add a checkpatch rule, that's hassle (extra rework). It would not be a simple checkpatch rule with high confidence because of pr_cont uses that may not be in the patch context. > In I think the message would be much better formatted if we did: > > dev_err(dev, "error %d: %V", err, &vaf); s/%V/%pV/