mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] include: linux/printk: import Linux dev_err_ptr/case_probe helpers
@ 2025-05-06  6:21 Ahmad Fatoum
  2025-05-06  7:22 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2025-05-06  6:21 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

For compatibility with Linux, add two helpers for dev_err_probe that
return an error pointer and take either an error pointer or an error
code.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 include/linux/printk.h | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/include/linux/printk.h b/include/linux/printk.h
index 1c717a6f6676..d4aafc84e2dd 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -113,7 +113,17 @@ static inline int dev_err_probe(struct device *dev, int err, const char *fmt,
 }
 #endif
 
-#define dev_errp_probe(dev, errptr, args...) dev_err_probe((dev), PTR_ERR(errptr), args)
+/* Simple helper for dev_err_probe() when error is already a pointer. */
+#define dev_errp_probe(dev, errptr, args...) \
+	dev_err_probe((dev), PTR_ERR(errptr), args)
+
+/* 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__))
 
 #define __pr_printk(level, format, args...) \
 	({	\
-- 
2.39.5




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-05-06  7:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-05-06  6:21 [PATCH] include: linux/printk: import Linux dev_err_ptr/case_probe helpers Ahmad Fatoum
2025-05-06  7:22 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox