From patchwork Thu Dec 20 10:22:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 10738745 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 70F07161F for ; Thu, 20 Dec 2018 10:23:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5EC5B28744 for ; Thu, 20 Dec 2018 10:23:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4F5BD2874A; Thu, 20 Dec 2018 10:23:34 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 D001128744 for ; Thu, 20 Dec 2018 10:23:33 +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=AWBftXW4iyskwQC+1pamVb++/Ym0XAK+vYtttE8xe10=; b=RGuSHSdwkbRYdoFOjv4qrsCqS1 JROQ3gQDUD45DQfY3HSEOSbdNdCbS50/23HBPCrEDlRO86gk/hU9anTmIbIsXna5euUUNX7im8Sj5 werEddE9bzFaGyNZ3CDCyaWjBfuJltEJK8ESGRPNLpKp7rOSYBkBVdRf+Q8QVuynyL7kdDefm5LiM voYeA3NO49MoMCmYeRbZWejNv/fq597lCM+GJrn6Gbx9J1OIC/pEoqZ5OBErFqqEFSAJtxDZ++ow0 gQfhj2wcMStbh6mSlBlFQ3PsUBmgZ8Uz9xcN5M6ism+kuJuY/yFBJxyEpg/1H7s82Aqhiuxu+nIqO 57s2GH+A==; 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 1gZvUE-0000ZL-NI; Thu, 20 Dec 2018 10:23:26 +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 1gZvU2-0000Nb-MQ for linux-arm-kernel@lists.infradead.org; Thu, 20 Dec 2018 10:23:16 +0000 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20181220102300euoutp02bd13ef2129f8493fe8c117a4d537d63a~yA2sYwgAG2917329173euoutp02P; Thu, 20 Dec 2018 10:23:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20181220102300euoutp02bd13ef2129f8493fe8c117a4d537d63a~yA2sYwgAG2917329173euoutp02P DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1545301380; bh=l9d5HR9T6mV0e4nZXjL57B2jHBVvBxDzB99xvEwtm8c=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=ruB6XXfXRZAcjz+C8TFurXYD4itDHEySfiRmamCWZuY0zGAWJaaEaEC4Wa+ozGoJD gQ2VmVEvL+1n1rDmZVlejb0GMFj84iLCWMHphjgZR1q2HCT960Lr1qwbOb0xrCMz+h CoOpzjdQcq3HoHR8M6axJ/+U0GZrUr929sLWCfMo= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20181220102300eucas1p12b22c221d4489e7e5f6bd4bc22bd95ca~yA2r_CL9T1463714637eucas1p1K; Thu, 20 Dec 2018 10:23:00 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 53.BC.04441.38D6B1C5; Thu, 20 Dec 2018 10:22:59 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20181220102259eucas1p2f748c68e01cd4e09a266da879722e218~yA2rN1C_n0445704457eucas1p25; Thu, 20 Dec 2018 10:22:59 +0000 (GMT) X-AuditID: cbfec7f2-5e3ff70000001159-c0-5c1b6d83f23a Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id B2.49.04284.38D6B1C5; Thu, 20 Dec 2018 10:22:59 +0000 (GMT) Received: from AMDC3748.DIGITAL.local ([106.120.43.17]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0PK100480669SP10@eusync3.samsung.com>; Thu, 20 Dec 2018 10:22:59 +0000 (GMT) From: Andrzej Hajda To: Greg Kroah-Hartman Subject: [PATCH v4 1/3] driver core: add probe_err log helper Date: Thu, 20 Dec 2018 11:22:45 +0100 Message-id: <20181220102247.4911-2-a.hajda@samsung.com> X-Mailer: git-send-email 2.17.1 In-reply-to: <20181220102247.4911-1-a.hajda@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrJIsWRmVeSWpSXmKPExsWy7djP87rNudIxBldmmFncWneO1eLlhMOM FhtnrGe1mPrwCZtF8+L1bBYLpy1ntNj0+BqrxeVdc9gsDk3dy2ix9shddou5X6YyO3B7XL52 kdlj56y77B6bVnWyeeyfu4bdY/OSeo/3+66yefRtWcXo8XmTXABHFJdNSmpOZllqkb5dAlfG 3oXrmQsWS1Rs7LvD1sB4SbiLkYNDQsBE4sPGwC5GLg4hgRWMEn3fG1khnM+MEs0NjSxdjJxg RYuuNLNAJJYxSmy8fI4RJCEk8J9R4uJRGRCbTUBT4u/mm2wgtoiAsUT/2VnsIA3MAvOYJV6+ usMEsk5YwFbi0G0lkBoWAVWJtlnvWUFsXgFzieNHO1khlslLrN5wgBmknFPAQuLnSrAxEgJ7 2CQampqhDnKR2L+7jQnCFpZ4dXwLO4QtI9HZcRAqXi/RNPMKM0RzB6PEicXL2SAS1hKHj18E W8YswCcxadt0ZkhQ8Ep0tAlBlHhInHl7BOrhbqDervPsExglFzAyrGIUTy0tzk1PLTbMSy3X K07MLS7NS9dLzs/dxAiM4NP/jn/awfj1UtIhRgEORiUe3hlRUjFCrIllxZW5hxglOJiVRHgf Z0nHCPGmJFZWpRblxxeV5qQWH2KU5mBREuetZngQLSSQnliSmp2aWpBaBJNl4uCUamAUffn5 f+nkl9YRirX3H/87G/Hz+Jpb9oynLyXLBJq1J946lXTU/JeG6FKbX9f+Xu2esKOgw2PBo8x5 0Vc38jGLJV3gd+r7bxu2eOnV6G3ap5+8zbyo+qiP+9hZ9ecTTZkUX597HvkhIXy/wT2ZHKs+ 74SEEoeC8vaGecGygfciEk4q6RbKGz1SYinOSDTUYi4qTgQAy3NdBNwCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrOLMWRmVeSWpSXmKPExsVy+t/xq7rNudIxBnMucVjcWneO1eLlhMOM FhtnrGe1mPrwCZtF8+L1bBYLpy1ntNj0+BqrxeVdc9gsDk3dy2ix9shddou5X6YyO3B7XL52 kdlj56y77B6bVnWyeeyfu4bdY/OSeo/3+66yefRtWcXo8XmTXABHFJdNSmpOZllqkb5dAlfG 3oXrmQsWS1Rs7LvD1sB4SbiLkZNDQsBEYtGVZpYuRi4OIYEljBJbDl9jBUkICTQySRw7WQNi swloSvzdfJMNxBYRMJboPzuLHaSBWWARs8TedfuAGjg4hAVsJQ7dVgKpYRFQlWib9R5sDq+A ucTxo52sEMvkJVZvOMAMUs4pYCHxcyU7xCpziT93prNNYORZwMiwilEktbQ4Nz232FCvODG3 uDQvXS85P3cTIzD4th37uXkH46WNwYcYBTgYlXh4Z0RJxQixJpYVV+YeYpTgYFYS4X2cJR0j xJuSWFmVWpQfX1Sak1p8iFGag0VJnPe8QWWUkEB6YklqdmpqQWoRTJaJg1OqgXFmYvPJCx1L WDZePq3zoNoyc5Gqz7KgzssZnn1LL81cderUlfvXi1T0dsv9Xn/r4s5XQYbTxZjCHzJ+u2m8 6i0f/3UDT1F+Q02xqWvWz0w1C/0by7FuSs3naK+o26qnDeyXW62YM2PqNSOzRI/Qzjtmq/IV Gv0CIj/4XjfjVNmadCOupH2S+D0lluKMREMt5qLiRAA0/KqdOgIAAA== X-CMS-MailID: 20181220102259eucas1p2f748c68e01cd4e09a266da879722e218 X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20181220102259eucas1p2f748c68e01cd4e09a266da879722e218 References: <20181220102247.4911-1-a.hajda@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181220_022314_922840_5846CADF X-CRM114-Status: GOOD ( 16.94 ) 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 Reviewed-by: Rafael J. Wysocki --- 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 0073b09bb99f..7f644f3c41d3 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -3099,6 +3099,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 6cb4640b6160..2d3a1cc6f5da 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -1591,6 +1591,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 Thu Dec 20 10:22:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 10738747 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 A19DD161F for ; Thu, 20 Dec 2018 10:23:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8B03528734 for ; Thu, 20 Dec 2018 10:23:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7AA3C28749; Thu, 20 Dec 2018 10:23:58 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 1644F28734 for ; Thu, 20 Dec 2018 10:23:58 +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=XV7QCVo2/MdX8guutdr8nEZQjquoB9dYyvU+A5OPSLA=; b=J7rJ4rVD3HFzDMcbUuizIzAItx jRK5jwaLNQFAat6bqO+KdUmax7+guZVASAPyJeje9vyFeWd8hjyx2SQIdzkxVmAitBegLBszmcDe5 P38i5zuyXkQ19h8q2xVrYS2JNRhPzeWsK/7NB5Qsu4On4L4Ay5cU8xkZOtu1hkXUUA3xQ6cjrw6mW F6k/F40EdV9bWWYAR+Wx05XxLCQpfawDSrqguK0apZ6fOZWfKYG4v42RlypzoO6TUBOwV3+Tx2PpZ DeYJl7Lm+xAgI36EhPU+nWbK1OPuqvfFD79O7nGunz6hu8aJ9RUX1wAFDPXOtvaE0BXnoFziepocI 6XvA4oXQ==; 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 1gZvUj-0000zw-0H; Thu, 20 Dec 2018 10:23:57 +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 1gZvU3-0000Ne-Ua for linux-arm-kernel@lists.infradead.org; Thu, 20 Dec 2018 10:23:18 +0000 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20181220102301euoutp011d2f8fa81597595e91faf4c075aef9fd~yA2s7z1h71726317263euoutp01C; Thu, 20 Dec 2018 10:23:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20181220102301euoutp011d2f8fa81597595e91faf4c075aef9fd~yA2s7z1h71726317263euoutp01C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1545301381; bh=xiRdmEIjOQ4EiEDf+t5yeCMyixU5eUBvPbNazTa7hqM=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=pWzG0FXzJIQVwYsxGZlr6+9ofFku2EJ6LpGNB7Futel5If04FYse9mPCihyH4tvLo HWBxYbT/kM2VyB/jKCcSL+h7MsEpHrgF8DNXBPSm0z1gKJRdLzrA/gelE51mQ+Xj1b jm+yctrVbetmtcPOR97M9zJ8o8dConj1wJb5jyY4= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20181220102300eucas1p2be6910aca112870eb95bf44d54f87d75~yA2sdmyvI0424004240eucas1p2B; Thu, 20 Dec 2018 10:23:00 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id B1.78.04806.48D6B1C5; Thu, 20 Dec 2018 10:23:00 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20181220102259eucas1p1884a0b68ce342239c2a43a74cc50725a~yA2rdSQbY1464414644eucas1p1Q; Thu, 20 Dec 2018 10:22:59 +0000 (GMT) X-AuditID: cbfec7f5-367ff700000012c6-b5-5c1b6d84646f Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 78.6E.04128.38D6B1C5; Thu, 20 Dec 2018 10:22:59 +0000 (GMT) Received: from AMDC3748.DIGITAL.local ([106.120.43.17]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0PK100480669SP10@eusync3.samsung.com>; Thu, 20 Dec 2018 10:22:59 +0000 (GMT) From: Andrzej Hajda To: Greg Kroah-Hartman Subject: [PATCH v4 2/3] driver core: add deferring probe reason to devices_deferred property Date: Thu, 20 Dec 2018 11:22:46 +0100 Message-id: <20181220102247.4911-3-a.hajda@samsung.com> X-Mailer: git-send-email 2.17.1 In-reply-to: <20181220102247.4911-1-a.hajda@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrJIsWRmVeSWpSXmKPExsWy7djP87otudIxBtNWCFvcWneO1eLlhMOM FhtnrGe1mPrwCZtF8+L1bBYLpy1ntNj0+BqrxeVdc9gsDk3dy2ix9shddou5X6YyO3B7XL52 kdlj56y77B6bVnWyeeyfu4bdY/OSeo/3+66yefRtWcXo8XmTXABHFJdNSmpOZllqkb5dAlfG j/2PWQv+qFa07vrJ3MB4UL6LkZNDQsBE4srVg8xdjFwcQgIrGCVeHPjMCOF8ZpR4e/o1axcj B1jV5w5eiPgyRolzGxrZQbqFBP4zSlw8KgNiswloSvzdfJMNxBYRMJboPzuLHaSBWWAes8TL V3eYQBLCAnES527OAxvKIqAq8fReCUiYV8BcouHYLVaIi+QlVm84wAxSwilgIfFzJdgYCYEd bBInVl5lhKhxkej/MZUJwhaWeHV8CzuELSNxeXI3C4RdL9E08wozRHMHo8SJxcvZIBLWEoeP XwRbxizAJzFp23RmiCd5JTrahCBKPCS2fnvGBPFwN6PEo12bGScwSi5gZFjFKJ5aWpybnlps nJdarlecmFtcmpeul5yfu4kRGMGn/x3/uoNx35+kQ4wCHIxKPLwzoqRihFgTy4orcw8xSnAw K4nwPs6SjhHiTUmsrEotyo8vKs1JLT7EKM3BoiTOW83wIFpIID2xJDU7NbUgtQgmy8TBKdXA mOnxZyfHwScrPnnYvJ6aqv9s3cSqti2GFZvtl9qtuLA6ycBTPnnp/yVljmx+H5ZNEqjWfVPe d77o4iuRv61/7dddWBf0/u2G3wyvsh1iWKO3/LovUu11pkhEh/WPkohN9b7L81qC4pNSzdZs vnI8YVHMnRthX69zfFof8bdfbZGRuMts79J2DSWW4oxEQy3mouJEAMNGbc/cAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGLMWRmVeSWpSXmKPExsVy+t/xq7rNudIxBo8OqlncWneO1eLlhMOM FhtnrGe1mPrwCZtF8+L1bBYLpy1ntNj0+BqrxeVdc9gsDk3dy2ix9shddou5X6YyO3B7XL52 kdlj56y77B6bVnWyeeyfu4bdY/OSeo/3+66yefRtWcXo8XmTXABHFJdNSmpOZllqkb5dAlfG j/2PWQv+qFa07vrJ3MB4UL6LkYNDQsBE4nMHbxcjF4eQwBJGiTeXnzB1MXICOY1MEsdO1oDY bAKaEn8332QDsUUEjCX6z85iB2lgFljELLF33T5WkISwQJzEuZvzWEGGsgioSjy9VwIS5hUw l2g4dgusREJAXmL1hgPMICWcAhYSP1eyQ6wyl/hzZzrbBEaeBYwMqxhFUkuLc9Nzi430ihNz i0vz0vWS83M3MQJDb9uxn1t2MHa9Cz7EKMDBqMTDOyNKKkaINbGsuDL3EKMEB7OSCO/jLOkY Id6UxMqq1KL8+KLSnNTiQ4zSHCxK4rznDSqjhATSE0tSs1NTC1KLYLJMHJxSDYyipatk5P42 eTDn91kwLj5Qu2lVO6Mz+xmWsArPtXbifn11WyY7yKac/5C49u6E9hRZz6vNPapHEy5/l3+6 kzfz0NIUb/ZN08yym1zOa7lrvHTbGnNB3tZq25ObcSIx3/9y9Nff4lGOT/8+rTF9H/9k0yt3 JBrVM9dac2pl/qxpVmP2Tpm+UYmlOCPRUIu5qDgRACwsLNo5AgAA X-CMS-MailID: 20181220102259eucas1p1884a0b68ce342239c2a43a74cc50725a X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20181220102259eucas1p1884a0b68ce342239c2a43a74cc50725a References: <20181220102247.4911-1-a.hajda@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181220_022316_127003_1E639442 X-CRM114-Status: GOOD ( 21.34 ) 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 --- v4: - removed NULL check before kfree, - coding style tweaking. 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 7f644f3c41d3..d3eb5aeeaa28 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -3108,6 +3108,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, ...); @@ -3123,14 +3124,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 88713f182086..857aa4d1d45d 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) +{ + const char *drv = dev_driver_string(dev); + + mutex_lock(&deferred_probe_mutex); + + kfree(dev->p->deferred_probe_msg); + dev->p->deferred_probe_msg = kasprintf(GFP_KERNEL, "%s: %pV", drv, 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); From patchwork Thu Dec 20 10:22:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 10738743 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 0BEE013AD for ; Thu, 20 Dec 2018 10:23:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE15028744 for ; Thu, 20 Dec 2018 10:23:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E15C52874A; Thu, 20 Dec 2018 10:23:27 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 F159C28744 for ; Thu, 20 Dec 2018 10:23:26 +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=MMgGE9bjS1DcPN4kMgqhlbnscvGo7/uI8UKzaMIjPhg=; b=OfOsmv0IXFRKTC1UaBBG3AF4g5 L6No4L3Qh/ZiX+/L9KVtMt3C5GFnPWgGrSQiXSlcyPyrV4QT/IvDXf/oGz1io1k5uYk8IdkNMAFk3 ovmbyjch/cqzX7jQNJZuDBLb6gWqjGH6yf6JbI7BgAO1L/u5hHut1enrdcVwGkEoQBAeMZQl0Z3Bi d9b2YPaOay++TSgrtOb71x2f194AY2pKdrVmJOwwwBBm2fzonsLnkjv3E/KfIL7CBNSwkg5EkcjRy o2/8MCteq1UATOWJ/0j1cccRGnzgWBE82k06aX92JgrhAvt3OkRPCy7vSXSkRlRS8Ko2y4KkJ0JlC 8LOr0Xng==; 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 1gZvU5-0000Qp-TD; Thu, 20 Dec 2018 10:23:17 +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 1gZvU2-0000Ng-MP for linux-arm-kernel@lists.infradead.org; Thu, 20 Dec 2018 10:23:16 +0000 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20181220102301euoutp02946de47b5a5910b4504eeb5369660c25~yA2tHY7wr2917329173euoutp02Q; Thu, 20 Dec 2018 10:23:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20181220102301euoutp02946de47b5a5910b4504eeb5369660c25~yA2tHY7wr2917329173euoutp02Q DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1545301381; bh=CBPDEPRhCP+eGDy87/DSZ8I0za3vfuRv7qu8KqplgR8=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=qbfQtYy0HYqJlG3+IoKG69DlmOZ7axWTW9X4f9ET2XXOMVEikElh4VB0kWmXXQYpi iA3qqjg2/Mgwqt6PSbYYEPB2a7jDNSNBu69ttEztC3RP/agFjck/F59Fl93dasHyro KxWByT8tMhjE7GPq7RYARxHBC6xiaK+yaGVRDtCw= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20181220102300eucas1p1da6fd45b5f00a847189cd3aa25ac8528~yA2sqlKFc1464414644eucas1p1S; Thu, 20 Dec 2018 10:23:00 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 3C.A2.04294.48D6B1C5; Thu, 20 Dec 2018 10:23:00 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20181220102300eucas1p210735c7753688a52a73ccf026884dd11~yA2r_0frK0421304213eucas1p2E; Thu, 20 Dec 2018 10:23:00 +0000 (GMT) X-AuditID: cbfec7f4-84fff700000010c6-7c-5c1b6d842770 Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 24.49.04284.48D6B1C5; Thu, 20 Dec 2018 10:23:00 +0000 (GMT) Received: from AMDC3748.DIGITAL.local ([106.120.43.17]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0PK100480669SP10@eusync3.samsung.com>; Thu, 20 Dec 2018 10:23:00 +0000 (GMT) From: Andrzej Hajda To: Greg Kroah-Hartman Subject: [PATCH v4 3/3] driver core: add probe_err_ptr helper Date: Thu, 20 Dec 2018 11:22:47 +0100 Message-id: <20181220102247.4911-4-a.hajda@samsung.com> X-Mailer: git-send-email 2.17.1 In-reply-to: <20181220102247.4911-1-a.hajda@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrFIsWRmVeSWpSXmKPExsWy7djPc7otudIxBmevaFjcWneO1eLlhMOM FhtnrGe1mPrwCZtF8+L1bBYLpy1ntNj0+BqrxeVdc9gsDk3dy2ix9shddou5X6YyO3B7XL52 kdlj56y77B6bVnWyeeyfu4bdY/OSeo/3+66yefRtWcXo8XmTXABHFJdNSmpOZllqkb5dAlfG o2NiBZfYKno3fmFqYDzC2sXIySEhYCJx7NZrIJuLQ0hgBaPEusWP2CGcz4wSXxduYoepun12 AVRiGaPE/NbvLBDOfyDn1SKwWWwCmhJ/N99kA7FFBIwl+s/OAutgFpjHLPHy1R0mkISwgK3E u4kPwIpYBFQljjX8YgSxeQXMJbrmPWKBWCcvsXrDAeYuRg4OTgELiZ8rweZICGxhk/j7cg0L SFxCwEVi4l5LiHJhiVfHt0BdKiPR2XGQCcKul2iaeYUZoreDUeLE4uVsEAlricPHL4IdzSzA JzFp23RmiJm8Eh1tQhAlHhI3Zq5jgniym1GiZfEe9gmMkgsYGVYxiqeWFuempxYb5aWW6xUn 5haX5qXrJefnbmIExvDpf8e/7GDc9SfpEKMAB6MSD++MKKkYIdbEsuLK3EOMEhzMSiK8j7Ok Y4R4UxIrq1KL8uOLSnNSiw8xSnOwKInzVjM8iBYSSE8sSc1OTS1ILYLJMnFwSjUwcjHfLHhj sPd2vDjvwzXnTgp7B7A4lWTltkebsiVNSTBZo3pf/XeJWnKH2iqu3VpPN8U8nOjiek7i+q+5 fze4aPyyY99WZbni0JOnwosnyHU9XpBxV+BxwLraxFVXuIoC1POWMnR9u5a826J7ovKGguRV hS57vyV9DrMQF/1/ZKXrnsWtPQHmSizFGYmGWsxFxYkAWcn2It0CAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrOLMWRmVeSWpSXmKPExsVy+t/xq7otudIxBmePc1jcWneO1eLlhMOM FhtnrGe1mPrwCZtF8+L1bBYLpy1ntNj0+BqrxeVdc9gsDk3dy2ix9shddou5X6YyO3B7XL52 kdlj56y77B6bVnWyeeyfu4bdY/OSeo/3+66yefRtWcXo8XmTXABHFJdNSmpOZllqkb5dAlfG o2NiBZfYKno3fmFqYDzC2sXIySEhYCJx++wCdhBbSGAJo8S250A2F5DdyCRxcsI8sCI2AU2J v5tvsoHYIgLGEv1nZ4EVMQssYpbYu24fWJGwgK3Eu4kPwIpYBFQljjX8YgSxeQXMJbrmPWKB 2CYvsXrDAeYuRg4OTgELiZ8roRabS/y5M51tAiPPAkaGVYwiqaXFuem5xYZ6xYm5xaV56XrJ +bmbGIHBt+3Yz807GC9tDD7EKMDBqMTDOyNKKkaINbGsuDL3EKMEB7OSCO/jLOkYId6UxMqq 1KL8+KLSnNTiQ4zSHCxK4rznDSqjhATSE0tSs1NTC1KLYLJMHJxSDYxZvgwG2Te3fHpyNnyb 1cSFj8+kx96J2HZr1axJbCIaNb3PH086zSqqapdq8n+t2IbPRfJNRlv0rHhVOXXF+wtZtih+ vVYyJbplwbklouUe9osOdV0wf3M4lsetLcE9UOh0X8m8W/3vnwoei9WQ0FvyMWG+48K6fMO6 etuGKc1WyhsPq16Nuq7EUpyRaKjFXFScCAD12L3MOgIAAA== X-CMS-MailID: 20181220102300eucas1p210735c7753688a52a73ccf026884dd11 X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20181220102300eucas1p210735c7753688a52a73ccf026884dd11 References: <20181220102247.4911-1-a.hajda@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181220_022314_874515_D9B34701 X-CRM114-Status: GOOD ( 13.18 ) 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 probe_err is useful in multiple contexts where error is encoded in pointer. Adding helper performing conversion to error value should simplify code further. Signed-off-by: Andrzej Hajda Reviewed-by: Rafael J. Wysocki --- include/linux/device.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/device.h b/include/linux/device.h index 2d3a1cc6f5da..50632414c363 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -1594,6 +1594,8 @@ do { \ extern __printf(3, 4) int probe_err(const struct device *dev, int err, const char *fmt, ...); +#define probe_err_ptr(dev, ptr, args...) probe_err(dev, PTR_ERR(ptr), args) + /* Create alias, so I can be autoloaded. */ #define MODULE_ALIAS_CHARDEV(major,minor) \ MODULE_ALIAS("char-major-" __stringify(major) "-" __stringify(minor))