[PATCH v2 2/9] include: linux/printk: define new dev_errp_probe
Ahmad Fatoum
a.fatoum at pengutronix.de
Thu Jun 22 00:23:22 PDT 2023
We have a number of APIs like regulator, clocks or reset, which return
an error pointer. To format that pointer for dev_err_probe, we need to
pass it through PTR_ERR(). Let's make such code more concise by defining
dev_errp_probe, which calls PTR_ERR() on its second argument.
Reviewed-by: Marco Felsch <m.felsch at pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
include/linux/printk.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/include/linux/printk.h b/include/linux/printk.h
index 057b355aa129..978e853bab48 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -3,6 +3,7 @@
#define __LINUX_PRINTK_H
#include <linux/list.h>
+#include <linux/err.h>
#include <printk.h>
#include <stdarg.h>
@@ -89,6 +90,8 @@ 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)
+
#define __pr_printk(level, format, args...) \
({ \
(level) <= LOGLEVEL ? pr_print((level), (format), ##args) : 0; \
--
2.39.2
More information about the barebox
mailing list