From patchwork Wed Oct 17 13:22:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 10645615 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0E5CA15E2 for ; Wed, 17 Oct 2018 13:22:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF45F2B031 for ; Wed, 17 Oct 2018 13:22:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E19382B051; Wed, 17 Oct 2018 13:22:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 08AC42B031 for ; Wed, 17 Oct 2018 13:22:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-reply-to:Message-id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=171s1m5KSwHMRifqQh6se5u5GcXeep0KiBnSEy41ONA=; b=lpB/RXj+rjbDzS+uVnNnnTTwpT Kza5HVwmxNQx1EiUUkuRUjndc9pcsXAysn+A1NI2kmeZggnFonqeIEQNy3JyYvM/JBUXm0PM7q4Uk 5kOoMIM/hjBCZVUW/Qaxjtm1GcJndtCl844K+lDsGa35hwQHNIolJYpsELcKKfoN9/RJPNZAIzqGr AYcqsHE44rGBkBYYSYqGAjaNxgcbndXP3Pf/nHR/rLbI6ulHq0D0+hPRaLw8YjwNiyq86l8v48eYS UqiQXW2sfVzfiSusInaJ48Vrb4Vqh5DZCbqu8lHPQ3PztHiirsxFmFaqseKXNLMvi4Kx5AlXNUplv VEIgL9vg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gClmP-00056J-TR; Wed, 17 Oct 2018 13:22:29 +0000 Received: from mailout2.w1.samsung.com ([210.118.77.12]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gClmL-00055H-8d for linux-arm-kernel@lists.infradead.org; Wed, 17 Oct 2018 13:22:27 +0000 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20181017132211euoutp0298c7166dd56b4e3e370dc351bc453f37~eaA3Ow7L33232132321euoutp02W; Wed, 17 Oct 2018 13:22:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20181017132211euoutp0298c7166dd56b4e3e370dc351bc453f37~eaA3Ow7L33232132321euoutp02W DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1539782531; bh=AEQgS7jJhpFlYZlbHO3kE7SSEZ4yh2WZch0IlMydKtc=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=nGx4ELd8eNNVFdd1Pup1/bpPoCa2JbyIwqYrBLAi8s5TbyBi+8rDhWTQXEMQ1WGLb pQrIYOor7/Gs+RC0FnyzQCMn7eAyWneQ3jRfjJ3rUwUckalv+b0A2U/F53IuUbniuA 0coZuRpIW5T1qRMBes9qkNMKvlQtsPbVcUcEUjI4= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20181017132210eucas1p230ed694bb3524d672975e67d21652f00~eaA2rHiIT0677706777eucas1p2u; Wed, 17 Oct 2018 13:22:10 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id BC.0B.04441.28737CB5; Wed, 17 Oct 2018 14:22:10 +0100 (BST) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20181017132209eucas1p1d23615adc15663caaffb3c117dc61151~eaA13oOkA2705227052eucas1p16; Wed, 17 Oct 2018 13:22:09 +0000 (GMT) X-AuditID: cbfec7f2-5c9ff70000001159-02-5bc737826228 Received: from eusync1.samsung.com ( [203.254.199.211]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 87.FE.04284.18737CB5; Wed, 17 Oct 2018 14:22:09 +0100 (BST) Received: from AMDC2768.DIGITAL.local ([106.120.43.17]) by eusync1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0PGQ00409VSWEA00@eusync1.samsung.com>; Wed, 17 Oct 2018 14:22:09 +0100 (BST) From: Andrzej Hajda To: Greg Kroah-Hartman Subject: [PATCH v3 1/4] driver core: add probe_err log helper Date: Wed, 17 Oct 2018 15:22:05 +0200 Message-id: <20181017132205.5204-1-a.hajda@samsung.com> X-Mailer: git-send-email 2.18.0 In-reply-to: X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrFIsWRmVeSWpSXmKPExsWy7djPc7pN5sejDTZd5rG4te4cq8XLCYcZ LTbOWM9qMfXhEzaL5sXr2SwWTlvOaLHp8TVWi8u75rBZHJq6l9Fi7ZG77BZzv0xlduD2uHzt IrPHzll32T02repk89g/dw27x+Yl9R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q7bxwqSEBawlTg6ZzcjiM0ioCrxq/88mM0rYC7x +NYcJoh18hIPj7eDxTkFgiU+3pvNDmILCQRI/Fx8m20CI88CRoZVjCKppcW56bnFhnrFibnF pXnpesn5uZsYgQG47djPzTsYL20MPsQowMGoxMO7Q+xYtBBrYllxZe4hRgkOZiUR3irF49FC vCmJlVWpRfnxRaU5qcWHGKU5WJTEec8bVEYJCaQnlqRmp6YWpBbBZJk4OKUaGNtPT9d53//p yZIvE+oMa5nfS1/Q2WIe+frK1K2T5TxXaxQefXxHNSTr9OU5aQY/b36ZJcHbH3Mw0t7+Qfrh 4+pneAQX/nimmLYsZ+VJbTszi+7n35YmvGMtSatf5nLJcr5Ahk1wrVqZX3WPEsdudbeyScqn 585zjuqwmL1d8+OZ+w/izwvNNlNiKc5INNRiLipOBAAeL7woPAIAAA== X-CMS-MailID: 20181017132209eucas1p1d23615adc15663caaffb3c117dc61151 X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20181017132209eucas1p1d23615adc15663caaffb3c117dc61151 References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181017_062225_449545_6555FC9E X-CRM114-Status: GOOD ( 17.79 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Rafael J. Wysocki" , Bartlomiej Zolnierkiewicz , linux-kernel@vger.kernel.org, Javier Martinez Canillas , Andrzej Hajda , andy.shevchenko@gmail.com, Mark Brown , Russell King - ARM Linux , linux-arm-kernel@lists.infradead.org, Marek Szyprowski MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 sequences with simple call, so code: if (err != -EPROBE_DEFER) dev_err(dev, ...); return err; becomes: return probe_err(dev, err, ...); Signed-off-by: Andrzej Hajda Reviewed-by: Javier Martinez Canillas Reviewed-by: Mark Brown Reviewed-by: Andy Shevchenko --- v3: - added 'extern __printf(3, 4)' decorators to probe_err, - changed error logging format - newline at the end, - added empty lines in probe_err around dev_err, - added R-b by Mark and Andy. v2: - added error value to log message, - fixed code style, - added EXPORT_SYMBOL_GPL, - Added R-B by Javier (I hope the changes did not invalidate it). --- drivers/base/core.c | 39 +++++++++++++++++++++++++++++++++++++++ include/linux/device.h | 3 +++ 2 files changed, 42 insertions(+) diff --git a/drivers/base/core.c b/drivers/base/core.c index 04bbcd779e11..1f3e99c2ef03 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -3067,6 +3067,45 @@ define_dev_printk_level(_dev_info, KERN_INFO); #endif +/** + * probe_err - probe error check and log helper + * @dev: the pointer to the struct device + * @err: error value to test + * @fmt: printf-style format string + * @...: arguments as specified in the format string + * + * This helper implements common pattern present in probe functions for error + * checking: print message if the error is not -EPROBE_DEFER and propagate it. + * It replaces code sequence: + * if (err != -EPROBE_DEFER) + * dev_err(dev, ...); + * return err; + * with + * return probe_err(dev, err, ...); + * + * Returns @err. + * + */ +int probe_err(const struct device *dev, int err, const char *fmt, ...) +{ + struct va_format vaf; + va_list args; + + if (err == -EPROBE_DEFER) + return err; + + va_start(args, fmt); + vaf.fmt = fmt; + vaf.va = &args; + + dev_err(dev, "error %d: %pV", err, &vaf); + + va_end(args); + + return err; +} +EXPORT_SYMBOL_GPL(probe_err); + static inline bool fwnode_is_primary(struct fwnode_handle *fwnode) { return fwnode && !IS_ERR(fwnode->secondary); diff --git a/include/linux/device.h b/include/linux/device.h index 90224e75ade4..6831677d5278 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -1577,6 +1577,9 @@ do { \ WARN_ONCE(condition, "%s %s: " format, \ dev_driver_string(dev), dev_name(dev), ## arg) +extern __printf(3, 4) +int probe_err(const struct device *dev, int err, const char *fmt, ...); + /* Create alias, so I can be autoloaded. */ #define MODULE_ALIAS_CHARDEV(major,minor) \ MODULE_ALIAS("char-major-" __stringify(major) "-" __stringify(minor)) From patchwork Wed Oct 17 13:24:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 10645617 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2F19A13B0 for ; Wed, 17 Oct 2018 13:24:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B2752AF89 for ; Wed, 17 Oct 2018 13:24:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 08F322B01D; Wed, 17 Oct 2018 13:24:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 738362AF89 for ; Wed, 17 Oct 2018 13:24:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-reply-to:Message-id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=q0Smm1wOQ/3OYG/OyGq6v+uQtiLJ4ZfNcgxQDBBuoc0=; b=LFs0ocOsP6dltho3OG82yiVIN+ aABBy9Q9J3HR8pfDG6814ZL/zY7/SX0Se6ld1LvRaquRH/XyT792u60x7nS+rzAEs2Qn69EoJD652 rCj2hV2oBNqHoZXX7WyMMsZghxVaRmlchFYEV4eSNfrwBWuZ5fgRJwULh7hmh66QHNjLDVPoqw7Bn RIvrWgpa3VY4lptDob9tNhfQFQxZyKEb0q5rdelkj92n4wgtd1ZXuVzBBPKgpKqvsgaYVhoxC3n3M aCltWANbOVaOia5d9A/aJR8Gm6od2jKM4nHAbERIWM1cl1u7hgh3qgs2bdSY3jyG6gIX4CKAve7+V qcqoG9tw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gCloX-0005nJ-SW; Wed, 17 Oct 2018 13:24:41 +0000 Received: from mailout2.w1.samsung.com ([210.118.77.12]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gClo9-0005kP-0I for linux-arm-kernel@lists.infradead.org; Wed, 17 Oct 2018 13:24:39 +0000 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20181017132405euoutp02005d68ab1e0ef2ca264267500000b78c~eaCh62nEj0173801738euoutp02n; Wed, 17 Oct 2018 13:24:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20181017132405euoutp02005d68ab1e0ef2ca264267500000b78c~eaCh62nEj0173801738euoutp02n DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1539782645; bh=GjM3hXLpGpu2oLx0y/QxqDKTrt2I5BaXddjRV+9RukY=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=pPA9OO6W0HBaEG5kfKHSoOYGCm/rdxkGWb70B2J715tBhcm11QSV44Ibm93n7Cj7Z SQVS1i9A7E4BMxJY/N/D0W5njoJ8UBFS2z05LYK05IlfDyIUI+jTepJA7ijkuOKKWM 9nInjC6SMODKKBQg+xSSs8a69KiHvLJmbd9F0uIA= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20181017132405eucas1p2aad685ce534a2bf2915e154781498620~eaChUXMkH2955629556eucas1p20; Wed, 17 Oct 2018 13:24:05 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 3D.0A.04294.4F737CB5; Wed, 17 Oct 2018 14:24:04 +0100 (BST) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20181017132404eucas1p2a413f6853af8f11a874650b6289d56cf~eaCgnAlOV1251312513eucas1p2D; Wed, 17 Oct 2018 13:24:04 +0000 (GMT) X-AuditID: cbfec7f4-835ff700000010c6-c1-5bc737f41b86 Received: from eusync1.samsung.com ( [203.254.199.211]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 15.4F.04284.4F737CB5; Wed, 17 Oct 2018 14:24:04 +0100 (BST) Received: from AMDC2768.DIGITAL.local ([106.120.43.17]) by eusync1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0PGQ00EGYVW3RX40@eusync1.samsung.com>; Wed, 17 Oct 2018 14:24:04 +0100 (BST) From: Andrzej Hajda To: Greg Kroah-Hartman Subject: [PATCH v3 2/4] driver core: add deferring probe reason to devices_deferred property Date: Wed, 17 Oct 2018 15:24:00 +0200 Message-id: <20181017132400.5300-1-a.hajda@samsung.com> X-Mailer: git-send-email 2.18.0 In-reply-to: X-Brightmail-T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fpnK7MDtcfna RWaPnbPusntsWtXJ5rF/7hp2j81L6j3e77vK5tG3ZRWjx+dNcgEcUVw2Kak5mWWpRfp2CVwZ K7oeshYcVa1oarrN3MA4Vb6LkZNDQsBE4vyXY4xdjFwcQgJLGCXuLDrHCuE0Mkn0/3vFBFLF JqAp8XfzTTYQW0TAWKL/7Cx2kCJmgUXMEnvX7WMFSQgLxEmcO7kerIhFQFWi49NmsGZeAXOJ CbNPsEOsk5d4eLydEcTmFAiWOPxmCguILSQQIHFrbhPzBEaeBYwMqxhFUkuLc9Nziw31ihNz i0vz0vWS83M3MQJDcNuxn5t3MF7aGHyIUYCDUYmHd4fYsWgh1sSy4srcQ4wSHMxKIrxVisej hXhTEiurUovy44tKc1KLDzFKc7AoifOeN6iMEhJITyxJzU5NLUgtgskycXBKNTCWR3muPvRt 75aln+Y9O+N1+Kbmj9Jvq/eZXIv60X843M4poX5th+acv+5f9uUf+m/weOeUhX5+6fnT1PUe GW3d3h2/QWynQ+KzYKXGkqVM83jKbt2KV1Jwrhb4cWvyoz+bwm9Ib5z+O81n29RKR5mqt1ve aG50Zmk8GGa7/MCtLx+un2i7/dC4TYmlOCPRUIu5qDgRAOvtZiQ9AgAA X-CMS-MailID: 20181017132404eucas1p2a413f6853af8f11a874650b6289d56cf X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20181017132404eucas1p2a413f6853af8f11a874650b6289d56cf References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181017_062417_219839_409EBC08 X-CRM114-Status: GOOD ( 22.39 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Rafael J. Wysocki" , Bartlomiej Zolnierkiewicz , linux-kernel@vger.kernel.org, Javier Martinez Canillas , Andrzej Hajda , andy.shevchenko@gmail.com, Mark Brown , Russell King - ARM Linux , linux-arm-kernel@lists.infradead.org, Marek Szyprowski MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP /sys/kernel/debug/devices_deferred property contains list of deferred devices. This list does not contain reason why the driver deferred probe, the patch improves it. The natural place to set the reason is probe_err function introduced recently, ie. if probe_err will be called with -EPROBE_DEFER instead of printk the message will be attached to deferred device and printed when user read devices_deferred property. Signed-off-by: Andrzej Hajda Reviewed-by: Mark Brown Reviewed-by: Javier Martinez Canillas Reviewed-by: Andy Shevchenko --- v3: - adjusted deferred_devs_show, to accept newline ended messages, - changed conditonal check to positive, - added R-b by Andy. v2: - changed __deferred_probe_set_msg args - like in __dev_printk, fits better, - use kasprintf instead of bunch of code, - keep consistent format of devices_deferred lines, - added R-Bs (again I hope changes above are not against it). --- drivers/base/base.h | 3 +++ drivers/base/core.c | 9 +++++---- drivers/base/dd.c | 21 ++++++++++++++++++++- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/drivers/base/base.h b/drivers/base/base.h index 7a419a7a6235..effbd5e7f9f1 100644 --- a/drivers/base/base.h +++ b/drivers/base/base.h @@ -75,6 +75,7 @@ struct device_private { struct klist_node knode_driver; struct klist_node knode_bus; struct list_head deferred_probe; + char *deferred_probe_msg; struct device *device; }; #define to_device_private_parent(obj) \ @@ -113,6 +114,8 @@ extern void device_release_driver_internal(struct device *dev, extern void driver_detach(struct device_driver *drv); extern int driver_probe_device(struct device_driver *drv, struct device *dev); extern void driver_deferred_probe_del(struct device *dev); +extern void __deferred_probe_set_msg(const struct device *dev, + struct va_format *vaf); static inline int driver_match_device(struct device_driver *drv, struct device *dev) { diff --git a/drivers/base/core.c b/drivers/base/core.c index 1f3e99c2ef03..27990110fb24 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -3076,6 +3076,7 @@ define_dev_printk_level(_dev_info, KERN_INFO); * * This helper implements common pattern present in probe functions for error * checking: print message if the error is not -EPROBE_DEFER and propagate it. + * In case of -EPROBE_DEFER it sets defer probe reason. * It replaces code sequence: * if (err != -EPROBE_DEFER) * dev_err(dev, ...); @@ -3091,14 +3092,14 @@ int probe_err(const struct device *dev, int err, const char *fmt, ...) struct va_format vaf; va_list args; - if (err == -EPROBE_DEFER) - return err; - va_start(args, fmt); vaf.fmt = fmt; vaf.va = &args; - dev_err(dev, "error %d: %pV", err, &vaf); + if (err == -EPROBE_DEFER) + __deferred_probe_set_msg(dev, &vaf); + else + dev_err(dev, "error %d: %pV", err, &vaf); va_end(args); diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 169412ee4ae8..6e488146b328 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "base.h" #include "power/power.h" @@ -132,6 +133,8 @@ void driver_deferred_probe_del(struct device *dev) if (!list_empty(&dev->p->deferred_probe)) { dev_dbg(dev, "Removed from deferred list\n"); list_del_init(&dev->p->deferred_probe); + kfree(dev->p->deferred_probe_msg); + dev->p->deferred_probe_msg = NULL; } mutex_unlock(&deferred_probe_mutex); } @@ -202,6 +205,21 @@ void device_unblock_probing(void) driver_deferred_probe_trigger(); } +/* + * __deferred_probe_set_msg() - Set defer probe reason message for device + */ +void __deferred_probe_set_msg(const struct device *dev, struct va_format *vaf) +{ + mutex_lock(&deferred_probe_mutex); + + if (dev->p->deferred_probe_msg) + kfree(dev->p->deferred_probe_msg); + dev->p->deferred_probe_msg = kasprintf(GFP_KERNEL, "%s: %pV", + dev_driver_string(dev), vaf); + + mutex_unlock(&deferred_probe_mutex); +} + /* * deferred_devs_show() - Show the devices in the deferred probe pending list. */ @@ -212,7 +230,8 @@ static int deferred_devs_show(struct seq_file *s, void *data) mutex_lock(&deferred_probe_mutex); list_for_each_entry(curr, &deferred_probe_pending_list, deferred_probe) - seq_printf(s, "%s\n", dev_name(curr->device)); + seq_printf(s, "%s\t%s", dev_name(curr->device), + curr->device->p->deferred_probe_msg ?: "\n"); mutex_unlock(&deferred_probe_mutex);