From patchwork Tue Oct 16 07:22:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 10643175 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 391BB1057 for ; Tue, 16 Oct 2018 07:24:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B61326E47 for ; Tue, 16 Oct 2018 07:24:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0F56827F60; Tue, 16 Oct 2018 07:24:41 +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 1F82726E47 for ; Tue, 16 Oct 2018 07:24: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=nOyM+lUFmYdVOk88NXoCpbFJpgbrLP14d/oMaqxYvP4=; b=eTGmH40jp/tuiUSRz3EicS8ri2 HF5qokvXa3L0ZC08tAkOA31u8WP2E7l4WGPARNQvYz9nlhSn1fZMPIfyxrbApZdd3u3XbYfQHyDbx XOiH0dEx5QskVv+9e7SszaQ2LBxRuHu5WRXgPD5Vtt762kmZxDr77Rkhpgza7Lst9Dav4U1rFq+er Sx5OoIsE0/5Iehr06chG7SyKuxe9ffit7ueTNxvhJK44cExkHh4Kq6ddUiJN1ku/bwJsJBMr9LtKx tDVdnu77G/ztzw2/9VrwQF8RjH7S3GgFj7VDU6N6qaIwuyrkpfYUm7HRowQyi4Ay4motwHnAA4dtv 60FPF3yQ==; 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 1gCJiR-0000mG-VT; Tue, 16 Oct 2018 07:24:32 +0000 Received: from mailout1.w1.samsung.com ([210.118.77.11]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gCJh4-00006U-DR for linux-arm-kernel@lists.infradead.org; Tue, 16 Oct 2018 07:23:10 +0000 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20181016072250euoutp017313bb9e2a877cf8f3acd7b03e5df45a~eBd1DaPzD1696916969euoutp01H; Tue, 16 Oct 2018 07:22:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20181016072250euoutp017313bb9e2a877cf8f3acd7b03e5df45a~eBd1DaPzD1696916969euoutp01H DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1539674570; bh=cZrZMaFu0XT+cQVHdRGBcBuXnsgaiFRRuci107vDojI=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=a7SvGwMwpz3clX2US2fHlrniQNOlUWjLg6JtfqOKvF4s4wnYjjJ6DUDqZaPFRpdp0 nBNu2INE8oJc4HWAPg+AS3p2vIj5kLIpPuGq3Ph658tJrPRuGcCSRWxExc8DC0jycw H/x0nL2HaPeBnBJfvxb2DE5Xt5f9HdC00czAvYjM= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20181016072250eucas1p164e60452bcdab760f51403ac619e00e6~eBd0nN_C11943519435eucas1p1i; Tue, 16 Oct 2018 07:22:50 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 00.CB.04441.9C195CB5; Tue, 16 Oct 2018 08:22:49 +0100 (BST) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20181016072249eucas1p2303b8c06a9f7c839a971fe065b0c752e~eBdz2Wwii1940019400eucas1p2o; Tue, 16 Oct 2018 07:22:49 +0000 (GMT) X-AuditID: cbfec7f2-a1ae89c000001159-74-5bc591c930bb Received: from eusync1.samsung.com ( [203.254.199.211]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 2D.F5.04284.9C195CB5; Tue, 16 Oct 2018 08:22:49 +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 <0PGO0048DKHZVR70@eusync1.samsung.com>; Tue, 16 Oct 2018 08:22:49 +0100 (BST) From: Andrzej Hajda To: Greg Kroah-Hartman Subject: [PATCH 1/3] driver core: add probe_err log helper Date: Tue, 16 Oct 2018 09:22:42 +0200 Message-id: <20181016072244.1216-2-a.hajda@samsung.com> X-Mailer: git-send-email 2.18.0 In-reply-to: <20181016072244.1216-1-a.hajda@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrIIsWRmVeSWpSXmKPExsWy7djPc7onJx6NNjjTpWVxa905VouXEw4z WmycsZ7VYurDJ2wWzYvXs1ksnLac0WLT42usFpd3zWGzWHvkLrvF3C9TmR24PHbOusvusWl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g1ngHZPErCcvGEESwgJWEvfXTmcBsVkEVCXezZ7KBGLzCphLnPv0iQVinbzEw+Pt YPWcAhYS1zdsZgaxhYBqbl9oY5/AyLOAkWEVo0hqaXFuem6xoV5xYm5xaV66XnJ+7iZGYLBt O/Zz8w7GSxuDDzEKcDAq8fD+uH4kWog1say4MvcQowQHs5IIr2zl0Wgh3pTEyqrUovz4otKc 1OJDjNIcLErivOcNKqOEBNITS1KzU1MLUotgskwcnFINjPoCl0OvbbCqEb/Aw8vqfGwd138W vy1XVVf1qN3vd5dTSj9lsN5Sx0huRdbnB5+Tp8icUNm285b0tV3ztmUaFetMPvniEG/HvBtv TKsPphjuNa37vuby9zsfY59Ev7Kd8vxTzFmu8K0vplw/uf7ZGpfKaPezlcWRgtwFj3a92hQa xj7XXD72WJwSS3FGoqEWc1FxIgCwJR4AMgIAAA== X-CMS-MailID: 20181016072249eucas1p2303b8c06a9f7c839a971fe065b0c752e X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20181016072249eucas1p2303b8c06a9f7c839a971fe065b0c752e References: <20181016072244.1216-1-a.hajda@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181016_002306_636523_4262BF66 X-CRM114-Status: GOOD ( 15.95 ) 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 , 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 seqences 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 --- drivers/base/core.c | 37 +++++++++++++++++++++++++++++++++++++ include/linux/device.h | 2 ++ 2 files changed, 39 insertions(+) diff --git a/drivers/base/core.c b/drivers/base/core.c index 04bbcd779e11..23fabefb217a 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -3067,6 +3067,43 @@ 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) { + va_start(args, fmt); + + vaf.fmt = fmt; + vaf.va = &args; + + __dev_printk(KERN_ERR, dev, &vaf); + va_end(args); + } + + return 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..06c2c797d132 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -1577,6 +1577,8 @@ do { \ WARN_ONCE(condition, "%s %s: " format, \ dev_driver_string(dev), dev_name(dev), ## arg) +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 Tue Oct 16 07:22:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 10643171 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 8D8EE109C for ; Tue, 16 Oct 2018 07:23:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 70281283BF for ; Tue, 16 Oct 2018 07:23:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 642BF286B0; Tue, 16 Oct 2018 07:23:16 +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 3933028435 for ; Tue, 16 Oct 2018 07:23:15 +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=HJKObpdgn6EzgyE5Ac/ZH0Lx8od984lkYAH7qVev1r0=; b=uSIGDKTOwvevZgOzChpfQTd6x6 BeusmA6blTJbNuZJxlCOnTQDLNMACTKnHJBc5EpR3x1Ur2/H4h1MkSgXbc7NxE1RHAg9sXTlqZRby piPvzJMQej2skPn/nEXmCidIbsOLccl0R41fghQ6ve9i7uqZuDGWXIqcvGfHaVgbRRz2SN+JYiyuu TtCkxKfL56vYNd/RDqV1T9p+1NKGeoLFNzcLGEYqiIbOMo5bfnZeeizXQDRkAHErFWro8Xv5DwfCR xNHYDXuKhMIm+8qDDofI4WY2bd1CRNCCd2xrvZoQGE5ynRjo+NDBmvKdHbXDSxmKM3UfE42pYfJyi l97wtcdw==; 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 1gCJh9-00009J-Qx; Tue, 16 Oct 2018 07:23:11 +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 1gCJh3-00006s-AO for linux-arm-kernel@lists.infradead.org; Tue, 16 Oct 2018 07:23:07 +0000 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20181016072251euoutp028054f81d8b6633c73bbb805aedf07bdb~eBd1qSgM81635816358euoutp02G; Tue, 16 Oct 2018 07:22:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20181016072251euoutp028054f81d8b6633c73bbb805aedf07bdb~eBd1qSgM81635816358euoutp02G DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1539674571; bh=n6s8ODfGLPqt06r2NaOTqEiqXV/ukN9zx/7Pm9IszQY=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=NWypIqF+yyM+Kpywi/RAx1LjeWf2aVwz6I3NDhDZkPp7w8l+It6nVY9Czk192+Um4 NfI8AEbk8RIjTPtUTwx2BBviorGR8XJ9OoVknibXevcfsnfn18LahvMzKXVj2FHh6l QTeF4NmfP36cuemuyV+XHvH1YYymjhhhP4xJKpMo= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20181016072250eucas1p1ebd0f93494648a7b2177c051a3e9124b~eBd1FnnA01687516875eucas1p1q; Tue, 16 Oct 2018 07:22:50 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 58.F8.04294.AC195CB5; Tue, 16 Oct 2018 08:22:50 +0100 (BST) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20181016072249eucas1p28855602564eb74a771fe521712962680~eBd0UM8Ui2131721317eucas1p2q; Tue, 16 Oct 2018 07:22:49 +0000 (GMT) X-AuditID: cbfec7f4-84fff700000010c6-c0-5bc591cabcce Received: from eusync1.samsung.com ( [203.254.199.211]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id DD.F5.04284.9C195CB5; Tue, 16 Oct 2018 08:22:49 +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 <0PGO0048DKHZVR70@eusync1.samsung.com>; Tue, 16 Oct 2018 08:22:49 +0100 (BST) From: Andrzej Hajda To: Greg Kroah-Hartman Subject: [PATCH 2/3] driver core: add deferring probe reason to devices_deferred property Date: Tue, 16 Oct 2018 09:22:43 +0200 Message-id: <20181016072244.1216-3-a.hajda@samsung.com> X-Mailer: git-send-email 2.18.0 In-reply-to: <20181016072244.1216-1-a.hajda@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrAIsWRmVeSWpSXmKPExsWy7djPc7qnJh6NNmjs5Le4te4cq8XLCYcZ LTbOWM9qMfXhEzaL5sXr2SwWTlvOaLHp8TVWi8u75rBZrD1yl91i7pepzA5cHjtn3WX32LSq k81j/9w17B6bl9R7vN93lc2jb8sqRo/Pm+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LSzMNgcQkBeYmH x9vBbE4BC4nrGzYzg9hCQDW3L7SxT2DkWcDIsIpRJLW0ODc9t9hQrzgxt7g0L10vOT93EyMw 2LYd+7l5B+OljcGHGAU4GJV4eH9cPxItxJpYVlyZe4hRgoNZSYRXtvJotBBvSmJlVWpRfnxR aU5q8SFGaQ4WJXHe8waVUUIC6YklqdmpqQWpRTBZJg5OqQZGbZ1rk2v8+Z1Ytz1OWL7zqP2O 1B/+CTwZ+76f+WWfuWn3c53uXYtbZtzgvJ+gFLuJ3/FFq0b+ySe3H64L+NNbXRXbyXrDfY1B g/v+2r0RNXreDGwi+00OlrLPqPrAZr40plrgn2u+1cslsWWbAh+e7VMsP5LAsH/elTn3LDI4 SyVm+TXXGd9UYinOSDTUYi4qTgQAdw6ryjICAAA= X-CMS-MailID: 20181016072249eucas1p28855602564eb74a771fe521712962680 X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20181016072249eucas1p28855602564eb74a771fe521712962680 References: <20181016072244.1216-1-a.hajda@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181016_002305_498326_2588D0E9 X-CRM114-Status: GOOD ( 21.81 ) 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 , 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: Javier Martinez Canillas --- drivers/base/base.h | 3 +++ drivers/base/core.c | 15 +++++++++------ drivers/base/dd.c | 34 +++++++++++++++++++++++++++++++++- 3 files changed, 45 insertions(+), 7 deletions(-) diff --git a/drivers/base/base.h b/drivers/base/base.h index 7a419a7a6235..6f9371bfe40b 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, const char *fmt, + va_list args); 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 23fabefb217a..df9895adf11b 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,15 +3092,17 @@ int probe_err(const struct device *dev, int err, const char *fmt, ...) struct va_format vaf; va_list args; - if (err != -EPROBE_DEFER) { - va_start(args, fmt); + va_start(args, fmt); - vaf.fmt = fmt; - vaf.va = &args; + vaf.fmt = fmt; + vaf.va = &args; + if (err != -EPROBE_DEFER) __dev_printk(KERN_ERR, dev, &vaf); - va_end(args); - } + else + __deferred_probe_set_msg(dev, fmt, args); + + va_end(args); return err; } diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 169412ee4ae8..e2f81e538d4b 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,32 @@ 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, const char *fmt, + va_list args) +{ + const int size = 128; + char **p; + int n; + + mutex_lock(&deferred_probe_mutex); + + p = &dev->p->deferred_probe_msg; + if (!*p) { + *p = kmalloc(size, GFP_KERNEL); + if (!*p) + goto end; + } + n = snprintf(*p, size, "%s %s: ", dev_driver_string(dev), dev_name(dev)); + if (n < size) + vsnprintf(*p + n, size - n, fmt, args); + +end: + mutex_unlock(&deferred_probe_mutex); +} + /* * deferred_devs_show() - Show the devices in the deferred probe pending list. */ @@ -212,7 +241,10 @@ 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)); + if (curr->device->p->deferred_probe_msg) + seq_puts(s, curr->device->p->deferred_probe_msg); + else + seq_printf(s, "%s\n", dev_name(curr->device)); mutex_unlock(&deferred_probe_mutex);