Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp5209805imm; Tue, 16 Oct 2018 06:56:03 -0700 (PDT) X-Google-Smtp-Source: ACcGV63USBNQ1lUYzTon0LQrNeyAakrlXC3mjxo0DJgWHr/13Kr9ftNOH6ZsHWytGGc2PM32Y63z X-Received: by 2002:a63:6f45:: with SMTP id k66-v6mr19753320pgc.360.1539698163296; Tue, 16 Oct 2018 06:56:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539698163; cv=none; d=google.com; s=arc-20160816; b=0IFOD+bNDVWhmwtVTJ2+ibDzPZYRZOBMt3ueEQy9dxBQfx1vxv9AYv2ROemiL4Ib/C 4Q5oISyK2svFwmAos0hXHk9TwjPuXijsBQKUqpOzS288TfuLBW128BknLyc49ZAy16ZQ PQoDwI5Os4HGACNfVxsQsYp40uG67h3ecgcdXupBc7GVZ5dvhOuZCsRLKVtrp6EeXXcp 5HIhvvZ+NViLyoVFvVpZCBMSdCAk8AapVv7GgpSgrULFuIgvuxdl9XV3msFl5cXJigwn mEW+KpBu0g9EvWSEjl3WDBuIn6PbXEFaXKpyYqEd5Fl3Vq05zWK/bwzqOelBl0GIgOE/ Gorw== 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=3GEVHFKwKK7CBWAyv1W3iG2CPRqjoY77JChN4qZEPEY=; b=nGBdnS5l8XpD+AWv8sk8vwuPUu1iTKLrh+ZSQ+LcARgiRjGebIY0gdao+1Np6vr5SO mbs5oQz1+wIU6DDjp7AAe3yJPRK7Uzqo2AVzQW6dAoDqjwF5XHpF+fFhKt0yN5ZGyPw2 TKDwFoRIamwm6pE7/zUSvgbgwRtnsTV6BPCs+hkP0KFSfMsnqoAqEqdSyP91Enk7f9DP L5YLXZnNp47Hy4flbhCQfGLyaI/YDJnxgQvQvk/dNxUhdXZTz6/pa18GeVWN2OzWiuI7 has3vz/1FvYvQFyxOdOwRJCGBvanUF20TMHQPjl+MvfmhzPWt44jt4gI29M52/7A22dA w0hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="eM/IeTVe"; 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 32-v6si300217pls.331.2018.10.16.06.55.46; Tue, 16 Oct 2018 06:56:03 -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="eM/IeTVe"; 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 S1727035AbeJPVpr (ORCPT + 99 others); Tue, 16 Oct 2018 17:45:47 -0400 Received: from mail-qk1-f196.google.com ([209.85.222.196]:46223 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726760AbeJPVpr (ORCPT ); Tue, 16 Oct 2018 17:45:47 -0400 Received: by mail-qk1-f196.google.com with SMTP id q12-v6so14113951qkl.13 for ; Tue, 16 Oct 2018 06:55:12 -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=3GEVHFKwKK7CBWAyv1W3iG2CPRqjoY77JChN4qZEPEY=; b=eM/IeTVeF0vdYaaL9+0ajrIoI/Gyd6OTgnLrJVvIoP3zc49in/2A404O25QzCgxhe8 w2daJZpzkv9+ho3qKepCsuqFSyOoap83iGVmqk42lJc+oedHR5tKf5K5aUGAYTDaK+QI s3L+1+w7MjsbR55pAWcS0p7Xz1kxZZRaz5FyvT4vBmfLw0bBCiioW5DUAfHwOwtx1D3b NASi6SP4qB/T3FUzzrK0MPAr8TS5E/nGnEak70Ew1uHWBWWke0POpslK5/QjTYc7Bfof JFa8Tl1H6oQvzrGNv7j9uXhdlPe2aPT8fw/ZtCaYhimCsI501yd94dbdNwv1buEkEPIq x1zA== 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=3GEVHFKwKK7CBWAyv1W3iG2CPRqjoY77JChN4qZEPEY=; b=azz5Yw2Ar/ROiKVqgU0PZGyZGQHyy7RjqCaQYAUla6esJdXLqjCghP8DB/IDFNvWbw fQv6IZ+rM2w7/Ue0RV4/tboZAVFnRErO4ayBqzSYXk3BEGxbeGInO4A8B7lPPkP4QHNJ DwGoX4DMo13+k82jzCn79Wt2cpqwMJZI+sqKaa+Dkd4yUAg1NrRGgwYV6GKhCxv2MDQc 3ddG1SW7JLHuwCFxmAV6vzhVS6vC1V7n/Pf/FYKx0uKaRKOq3d3lqd6N0oiZetBHh/rD XfG/ZEdPWvIg7+utBxXkAgKhqUs2en7uGo+HIQS9oXOMp4t0O9R5/vHEewvmEv0ImJ5/ pG7g== X-Gm-Message-State: ABuFfogbgVJvTqmPR6MFcMiGBc6N2NKboTFyisHqjfBJhFfyeKXy9WKi l6bBiADshclrd5VLMWMEucXiw+COg3Ril5pjyMg= X-Received: by 2002:ae9:f40b:: with SMTP id y11-v6mr20963056qkl.137.1539698111448; Tue, 16 Oct 2018 06:55:11 -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> In-Reply-To: <20181016125543eucas1p1f23b3482179a9cd465f509e0abf782c1~eGAecmAv93038330383eucas1p1j@eucas1p1.samsung.com> From: Andy Shevchenko Date: Tue, 16 Oct 2018 16:55:00 +0300 Message-ID: Subject: Re: [PATCH 1/3] driver core: add probe_err log helper To: Andrzej Hajda Cc: Greg Kroah-Hartman , Bartlomiej Zolnierkiewicz , Marek Szyprowski , "Rafael J. Wysocki" , Linux Kernel Mailing List , Javier Martinez Canillas , linux-arm Mailing List , Mark Brown 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 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. > So the err must be before message passed to probe_err, for example: > dev_err(dev, "err=%d: %V\n", err, &vaf); > Is it OK? For me would work either (no \n in the message, or err preceding the message). -- With Best Regards, Andy Shevchenko