[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240423-dev-add_dev_errp_probe-v2-1-12f43c5d8b0d@analog.com>
Date: Tue, 23 Apr 2024 17:20:30 +0200
From: Nuno Sa via B4 Relay <devnull+nuno.sa.analog.com@...nel.org>
To: Petr Mladek <pmladek@...e.com>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Chris Down <chris@...isdown.name>, John Ogness <john.ogness@...utronix.de>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Jonathan Cameron <jic23@...nel.org>, Lars-Peter Clausen <lars@...afoo.de>,
Olivier Moysan <olivier.moysan@...s.st.com>,
Andi Shyti <andi.shyti@...nel.org>, Jyoti Bhayana <jbhayana@...gle.com>
Cc: linux-kernel@...r.kernel.org, linux-iio@...r.kernel.org,
Nuno Sa <nuno.sa@...log.com>
Subject: [PATCH v2 1/4] dev_printk: add new dev_err_probe() helpers
From: Nuno Sa <nuno.sa@...log.com>
This is similar to dev_err_probe() but for cases where an ERR_PTR() or
ERR_CAST() is to be returned simplifying patterns like:
dev_err_probe(dev, ret, ...);
return ERR_PTR(ret)
or
dev_err_probe(dev, PTR_ERR(ptr), ...);
return ERR_CAST(ptr)
Signed-off-by: Nuno Sa <nuno.sa@...log.com>
---
include/linux/dev_printk.h | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/include/linux/dev_printk.h b/include/linux/dev_printk.h
index ae80a303c216..b9623ec22350 100644
--- a/include/linux/dev_printk.h
+++ b/include/linux/dev_printk.h
@@ -277,4 +277,13 @@ do { \
__printf(3, 4) int dev_err_probe(const struct device *dev, int err, const char *fmt, ...);
+/* Simple helper for dev_err_probe() when ERR_PTR() is to be returned. */
+#define dev_err_ptr_probe(dev, ___err, fmt, ...) ({ \
+ ERR_PTR(dev_err_probe(dev, ___err, fmt, ##__VA_ARGS__)); \
+})
+
+/* Simple helper for dev_err_probe() when ERR_CAST() is to be returned. */
+#define dev_err_cast_probe(dev, ___err_ptr, fmt, ...) ({ \
+ ERR_PTR(dev_err_probe(dev, PTR_ERR(___err_ptr), fmt, ##__VA_ARGS__)); \
+})
#endif /* _DEVICE_PRINTK_H_ */
--
2.44.0
Powered by blists - more mailing lists