[PATCH 2/3] drivers/core: use va_format_call helper

Andrzej Hajda
2025-11-26T11:37:38Z

It simplifies the code and makes it more clear.

Signed-off-by: Andrzej Hajda <andrzej.hajda@intel.com>
---
drivers/base/core.c | 32 ++++++--------------------------
1 file changed, 6 insertions(+), 26 deletions(-)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index f69dc9c8595455d85bf7eda5d4abce1ed7cb5166..513e5ef8a6dabaec0aee0778c1338a9d72e66892 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -4943,35 +4943,15 @@ static void __dev_printk(const char *level, const struct device *dev,
void _dev_printk(const char *level, const struct device *dev,
const char *fmt, ...)
{
- struct va_format vaf;
- va_list args;
-
- va_start(args, fmt);
-
- vaf.fmt = fmt;
- vaf.va = &args;
-
- __dev_printk(level, dev, &vaf);
-
- va_end(args);
+ va_format_call(fmt, __dev_printk, level, dev, va_format_arg);
}
EXPORT_SYMBOL(_dev_printk);

-#define define_dev_printk_level(func, kern_level) \
-void func(const struct device *dev, const char *fmt, ...) \
-{ \
- struct va_format vaf; \
- va_list args; \
- \
- va_start(args, fmt); \
- \
- vaf.fmt = fmt; \
- vaf.va = &args; \
- \
- __dev_printk(kern_level, dev, &vaf); \
- \
- va_end(args); \
-} \
+#define define_dev_printk_level(func, kern_level) \
+void func(const struct device *dev, const char *fmt, ...) \
+{ \
+ va_format_call(fmt, __dev_printk, kern_level, dev, va_format_arg); \
+} \
EXPORT_SYMBOL(func);

define_dev_printk_level(_dev_emerg, KERN_EMERG);

--
2.43.0