From patchwork Wed Jun 24 11:41:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 11622993 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4D66A913 for ; Wed, 24 Jun 2020 11:43:56 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 26A7020706 for ; Wed, 24 Jun 2020 11:43:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="E6FOMAiZ"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="XTlmQqsx" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 26A7020706 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=samsung.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.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=0/6DCUViVnyvp+VRo1033B958XKooI6HDju7VOV36jA=; b=E6FOMAiZ/TQFGXXAEq5wIMMnCS K0VUeTS3TigXg6+AmSqrIpxV681Va7JQpQRtMLBjf/Sw1rM7JPa35XNITMaSbrNe4P/pbSpLBAhGl pXC4drH0/OvZi4iJcYJMKn5KH8VivpTAUBrthzHaqCIuOi3uIVR/5UtfSCLrYqgudzYQrOln2LfyK XMwq8fewf+gWi9+ly4svUBPtr66vhU1JTGRm5zx6O3Y5TZ/fTHiZkg+RWhEdCJoxF2HxWtMTzy9lW qms6cpOllwz+hT2y+CqcjWd2EaaG3vduTB427OpL/RWBciMaautLlnMyASWcHAnBnI2CovR7p8/c6 dDdclPwg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jo3n5-0006hh-4P; Wed, 24 Jun 2020 11:42:07 +0000 Received: from mailout2.w1.samsung.com ([210.118.77.12]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jo3md-0006Ru-NQ for linux-arm-kernel@lists.infradead.org; Wed, 24 Jun 2020 11:41:42 +0000 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20200624114137euoutp02e57e9f294a82981aed68908b1a5ed6f7~beA6x5uAO1698916989euoutp02b for ; Wed, 24 Jun 2020 11:41:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20200624114137euoutp02e57e9f294a82981aed68908b1a5ed6f7~beA6x5uAO1698916989euoutp02b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1592998897; bh=528msPEeeKbk20X6ucIg/zFrY6Boo/jOU+18Jk7kUgA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XTlmQqsxqgPhToYxHb3ALKE8Fovmdx4CYIJg9ikt1tH7TgyqD/RbqvjBL1/kX2Gx4 XJD2ZgF6uAA89Um1ocvynSLdzY/kiPyCOFwzV2QuHKaRcBVL052yYbg/O7BlIpbEoR jBgV6fqykiyhcQNIs7h65DBdHeJfKh4NIe0FPs/M= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20200624114137eucas1p1a534acdb8d435a6cf47b1f66a846424f~beA6bu2uB2487924879eucas1p1K; Wed, 24 Jun 2020 11:41:37 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id E0.1A.06456.1FB33FE5; Wed, 24 Jun 2020 12:41:37 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20200624114136eucas1p1c84f81b1d78e2dbad7ac1b762f0a4b4f~beA6EzgEI2487924879eucas1p1J; Wed, 24 Jun 2020 11:41:36 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200624114136eusmtrp129f7028dd669bad7eb0477985e570453~beA6EEtO-0702007020eusmtrp1O; Wed, 24 Jun 2020 11:41:36 +0000 (GMT) X-AuditID: cbfec7f2-7efff70000001938-4d-5ef33bf1c91a Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 84.53.06017.0FB33FE5; Wed, 24 Jun 2020 12:41:36 +0100 (BST) Received: from AMDC3748.digital.local (unknown [106.120.51.74]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200624114136eusmtip219790ef495719a8f910be072e9f0316f~beA5amx7E2617226172eusmtip2l; Wed, 24 Jun 2020 11:41:36 +0000 (GMT) From: Andrzej Hajda To: Greg Kroah-Hartman Subject: [RESEND PATCH v5 3/5] drivers core: allow probe_err accept integer and pointer types Date: Wed, 24 Jun 2020 13:41:25 +0200 Message-Id: <20200624114127.3016-4-a.hajda@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200624114127.3016-1-a.hajda@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA0VSaUhUURjlzls1J55jNjeLpLF+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ofrD/HGay8bG5xa905VouXEw4z WmycsZ7VYurDJ2wW/7dNZLa48vU9m0Xz4vVsFle/v2S2OPnmKotF58Ql7BabHl9jtbi8aw6b xaGpexkt1h65y25xqC/aYu6XqcwOAh6Xr11k9nh/o5XdY++3BSweO2fdZfeY3TGT1WPTqk42 jxMTLjF57J+7ht3jfvdxJo/NS+o9+rasYvQ40DuZxePzJrkA3ig9m6L80pJUhYz84hJbpWhD CyM9Q0sLPSMTSz1DY/NYKyNTJX07m5TUnMyy1CJ9uwS9jBWnGxgLDkpVfDjxnL2B8bRoFyMn h4SAicTnn1sYuxi5OIQEljJKHPn6hA0iIS6xe/5bZghbWOLPtS42iKJPjBK/NkAk2AQ0Jf5u vgnWICJgLNF/dhY7SBGzQBurxNzzT9hBEsICsRKXW84zgtgsAqoSG9YdBIvzCphLHLu/AGqb vMTqDQfAhnIKWEhMarkIVi8EVHPo+mLWCYx8CxgZVjGKpJYW56bnFhvpFSfmFpfmpesl5+du YgRG17ZjP7fsYOx6F3yIUYCDUYmHd8ODj3FCrIllxZW5hxglOJiVRHidzp6OE+JNSaysSi3K jy8qzUktPsRoCnTURGYp0eR8YOTnlcQbmhqaW1gamhubG5tZKInzdggcjBESSE8sSc1OTS1I LYLpY+LglGpgzHyWe33Sr6odrDr9/Lpa3bwmxtEJK04yNRb1xlw+cCctITmh7U6Hr8thySjd TaKNN8xnyP1zZO9JeNhfd9P80M42s31Lrj4r+q0d+iLy8SWRC4ky8n45veH5NzznVn+8zvh5 inUcc8fd3P/Cf52ktxx1XVTmbbpNsfb293V8bX8Dl1b5LvFXYinOSDTUYi4qTgQAUptpfMQC AAA= X-CMS-MailID: 20200624114136eucas1p1c84f81b1d78e2dbad7ac1b762f0a4b4f X-Msg-Generator: CA X-RootMTR: 20200624114136eucas1p1c84f81b1d78e2dbad7ac1b762f0a4b4f X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200624114136eucas1p1c84f81b1d78e2dbad7ac1b762f0a4b4f References: <20200624114127.3016-1-a.hajda@samsung.com> X-Spam-Note: CRM114 invocation failed X-Spam-Score: -5.2 (-----) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-5.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [210.118.77.12 listed in wl.mailspike.net] -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at https://www.dnswl.org/, high trust [210.118.77.12 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jernej Skrabec , "Rafael J. Wysocki" , Jonas Karlman , Bartlomiej Zolnierkiewicz , linux-kernel@vger.kernel.org, "open list:DRM DRIVERS" , Russell King - ARM Linux , Neil Armstrong , Andrzej Hajda , andy.shevchenko@gmail.com, Mark Brown , Laurent Pinchart , Daniel Vetter , 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 Many resource acquisition functions return error value encapsulated in pointer instead of integer value. To simplify coding we can use macro which will accept both types of error. With this patch user can use: probe_err(dev, ptr, ...) instead of: probe_err(dev, PTR_ERR(ptr), ...) Without loosing old functionality: probe_err(dev, err, ...) Signed-off-by: Andrzej Hajda --- drivers/base/core.c | 25 ++----------------------- include/linux/device.h | 25 ++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index 2a96954d5460..df283c62d9c0 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -3953,28 +3953,7 @@ 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. - * In case of -EPROBE_DEFER it sets defer probe reason, which can be checked - * later by reading devices_deferred debugfs attribute. - * 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, ...) +int __probe_err(const struct device *dev, int err, const char *fmt, ...) { struct va_format vaf; va_list args; @@ -3992,7 +3971,7 @@ int probe_err(const struct device *dev, int err, const char *fmt, ...) return err; } -EXPORT_SYMBOL_GPL(probe_err); +EXPORT_SYMBOL_GPL(__probe_err); static inline bool fwnode_is_primary(struct fwnode_handle *fwnode) { diff --git a/include/linux/device.h b/include/linux/device.h index 40a90d9bf799..22d3c3d4f461 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -965,7 +965,30 @@ void device_links_supplier_sync_state_pause(void); void device_links_supplier_sync_state_resume(void); extern __printf(3, 4) -int probe_err(const struct device *dev, int err, const char *fmt, ...); +int __probe_err(const struct device *dev, int err, const char *fmt, ...); + +/** + * probe_err - probe error check and log helper + * @dev: the pointer to the struct device + * @err: error value to test, can be integer or pointer type + * @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. + * In case of -EPROBE_DEFER it sets defer probe reason, which can be checked + * later by reading devices_deferred debugfs attribute. + * It replaces code sequence: + * if (err != -EPROBE_DEFER) + * dev_err(dev, ...); + * return err; + * with + * return probe_err(dev, err, ...); + * + * Returns @err. + * + */ +#define probe_err(dev, err, args...) __probe_err(dev, (long)(err), args) /* Create alias, so I can be autoloaded. */ #define MODULE_ALIAS_CHARDEV(major,minor) \