Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp540966imm; Wed, 17 Oct 2018 04:34:01 -0700 (PDT) X-Google-Smtp-Source: ACcGV626CT6AXiLENAwPTwUioOASGkyxQyTyMW9OjD78Wfbury8EJ3VYOytuGiNGncly0mdNUwzI X-Received: by 2002:a62:36c3:: with SMTP id d186-v6mr25522879pfa.133.1539776041079; Wed, 17 Oct 2018 04:34:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539776041; cv=none; d=google.com; s=arc-20160816; b=K5CdHNntcURNn5oI81RI5voihkcHWw0TAFVXFFhNmazUiMGLl4rjpNw3h630dCKfZA d7QCtB4p4+D44d8V5teLl9L+xlXcy4naf4I/dnY7D0YhRh7I6Uy/pE1FMZtZ5IwSfjZk A8zAUX9VdLJwVb5NePCSB4MqaLfLyrd8JdbT4Unk3WBOM7B3h5AUoDW30Z8KDG/m9lsR RKjwmHmDl7+gve2LRcmrgnYH3Bhb8Li2P3KnT5eUdvgWWhAaZO47fPsVRque9Y1v7GHB pKKCStK2NBo3T17eVorEXFYmtGuEKvGCdLzCzer5RMU6oyS/h2UFMdg3Qcht42ZH051N ww4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=mHNQy+TtQ0F8MQ5t2Kb6nCFPUjzCI8OsSYuq57JXksE=; b=daZHoBgz3lxC/eGblW4kI8jEOwT+NpVicOnJ4/fp6B1MaeSVGu04pAjtAkz/oos91k bm7Bo6mC9OpMU1jmCbu6JmX8ru6xBNIr+Q79MMPVSqtO4/f2kPLcWCalguCaQ5D7/Qlk 7lTJ7qKdXG9dgW4y87BJxqeHsp6pmvbs8i0DsIdY4K7yKglrEdGwgbRMZ8OPgbv0lE2a IPBLCqwmEXt4Wz7MMLCnOoELnURtWEwZKxjycIJ4//ixoLjotXSNEiMDVpZpr7bVwMF9 25pzF5PG1a4As6amYbwAdkfwGMK/8+ljzB1p+owLx7X4iQU6NZj+SGPHo5bdwCOZIPG1 v69w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="thrbiJF/"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r25-v6si18271842pfk.83.2018.10.17.04.33.45; Wed, 17 Oct 2018 04:34:01 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b="thrbiJF/"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727245AbeJQT2i (ORCPT + 99 others); Wed, 17 Oct 2018 15:28:38 -0400 Received: from mail-qt1-f193.google.com ([209.85.160.193]:42291 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726990AbeJQT2h (ORCPT ); Wed, 17 Oct 2018 15:28:37 -0400 Received: by mail-qt1-f193.google.com with SMTP id j46-v6so29495695qtc.9 for ; Wed, 17 Oct 2018 04:33:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=mHNQy+TtQ0F8MQ5t2Kb6nCFPUjzCI8OsSYuq57JXksE=; b=thrbiJF/GbFBIt06Q1f4P2IyS2FXw2+4t/WuWu8TLLaAXB7nBpaNCUvw7hu2f36laz RLz3tLGXeE4coGRryi5ywEEpPxcI9ZOtfk2jp2Od7pXZH0atd7FZTA8Z1cJQjTc57GHa 1yLdbiJjZWZGememSHfKV9ANbu0k7iAkQGcqkuCei+uOemooMHDxq/Moid5CPMG4susp 6Eig8sW5CULQ3tQ4iKwOJwARgVP6vCObpYlYCgZfUW2CZ/+HOhKFXIsHuM+S/JR+zybf 3Qgl0IqmLtheO7RTp9RkUT43IRQuGdWW1og6rtzZk5E3SUXaL9kZSIib5pcJ4OniRtSj crJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=mHNQy+TtQ0F8MQ5t2Kb6nCFPUjzCI8OsSYuq57JXksE=; b=aaL6ynsGoxSKtKYJ2TKt0JZ+jk+JPy0li73yi8lchs3jHuWWHhBdE00ijr2saa3k5x yKPHx0NziCMGDdTE/v2SnNmAwh4UiIlQvbeLb6jT07+Z8pXJqL0mJly6Q0NB0ga0qkse fFbBDcfD1uRSwWFRo+NeqSAtSaT3F2iLZlwrjYLozJ47UVBom6CQh8Lt9hJuWpUu0rOg 8SrR/vcqjmTST3PxjOFahH2ZVoGdre753h9M1CnMH2IxVYABiq4vab/rZZLjEo8iPuqB VsTf1D6Lgex2wvZJCTDWKA0QBOlmgaa7feV8Ml3/PSQhdJWanMdjybePnOAQyOGePpFY TJcg== X-Gm-Message-State: ABuFfoiA28Ceznl4mp5EDtfQjLYU9Vne1UzfE06wRXKI6I8UrrJSNq2a Sr28Hqbe2XfZ5rfXUelSKcO49n1zkXgsnq5CsHc= X-Received: by 2002:aed:2de3:: with SMTP id i90-v6mr5618806qtd.229.1539775999909; Wed, 17 Oct 2018 04:33:19 -0700 (PDT) MIME-Version: 1.0 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> In-Reply-To: <20181017112914.GH30658@n2100.armlinux.org.uk> From: Andy Shevchenko Date: Wed, 17 Oct 2018 14:33:08 +0300 Message-ID: Subject: Re: [PATCH 1/3] driver core: add probe_err log helper To: Russell King - ARM Linux 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 17, 2018 at 2:29 PM 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). In > any case, I think the message would be much better formatted if we did: > > dev_err(dev, "error %d: %V", err, &vaf); > > which means we end up with (eg): > > error -5: request_irq failed for irq 9 > > rather than: > > request_irq failed for irq 9, -5 > > which is more confusing. As I said earlier, I'm fine to either variant and I see your point here, so, I tend to agree to this variant. P.S. Andrzej, in any case my Rb tag, which I just gave, stays. -- With Best Regards, Andy Shevchenko