Date: Tue, 21 Apr 2026 22:27:08 +0000 From: Jean-=?utf-8?Q?S=C3=A9bast?==?utf-8?Q?ien P=C3=A9?=dron <dumbbell@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 2357de8ea14f - main - linuxkpi: Define `dev_err_probe*()` Message-ID: <69e7f9bc.38987.1b8fb735@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch main has been updated by dumbbell: URL: https://cgit.FreeBSD.org/src/commit/?id=2357de8ea14f9ee6193eb9e31a9c208e1541163a commit 2357de8ea14f9ee6193eb9e31a9c208e1541163a Author: Jean-Sébastien Pédron <dumbbell@FreeBSD.org> AuthorDate: 2026-04-11 09:40:39 +0000 Commit: Jean-Sébastien Pédron <dumbbell@FreeBSD.org> CommitDate: 2026-04-21 22:18:24 +0000 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 --- sys/compat/linuxkpi/common/include/linux/device.h | 24 +++++++++++++++++++++++ 1 file changed, 24 insertions(+) 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 *);home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69e7f9bc.38987.1b8fb735>
