aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Sébastien Pédron <dumbbell@FreeBSD.org>2026-04-11 09:40:39 +0000
committerJean-Sébastien Pédron <dumbbell@FreeBSD.org>2026-04-21 22:18:24 +0000
commit2357de8ea14f9ee6193eb9e31a9c208e1541163a (patch)
tree16b95f827e5a5917995955c2331077aa46ea1be1
parentad528a6b174e7090cb06062867e9a146b017205d (diff)
linuxkpi: Define `dev_err_probe*()`
They differ from other `dev_*()` logging functions by returning the passed error code. The error code is also used to determine if the message should be logged in the first place and at which log level. The DRM generic code started to use it in Linux 6.12. Reviewed by: bz Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D56435
-rw-r--r--sys/compat/linuxkpi/common/include/linux/device.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/sys/compat/linuxkpi/common/include/linux/device.h b/sys/compat/linuxkpi/common/include/linux/device.h
index 030e9b127540..2913810923f1 100644
--- a/sys/compat/linuxkpi/common/include/linux/device.h
+++ b/sys/compat/linuxkpi/common/include/linux/device.h
@@ -267,6 +267,30 @@ show_class_attr_string(struct class *class,
dev_dbg(dev, __VA_ARGS__); \
} while (0)
+static inline int
+dev_err_probe(const struct device *dev, int err, const char *fmt, ...)
+{
+ va_list args;
+
+ va_start(args, fmt);
+
+ /*
+ * On Linux, they look at the error code to determine if the message
+ * should be logged (not logged if -ENOMEM) and at which log level.
+ */
+ device_printf(dev->bsddev, fmt, args);
+
+ va_end(args);
+
+ return (err);
+}
+
+#define dev_err_ptr_probe(dev, err, fmt, ...) \
+ ERR_PTR(dev_err_probe((dev), (err), fmt, ##__VA_ARGS__)
+
+#define dev_err_cast_probe(dev, err, fmt, ...) \
+ ERR_PTR(dev_err_probe((dev), PTR_ERR(err), fmt, ##__VA_ARGS__)
+
/* Public and LinuxKPI internal devres functions. */
void *lkpi_devres_alloc(void(*release)(struct device *, void *), size_t, gfp_t);
void lkpi_devres_add(struct device *, void *);