diff --git a/drivers/base/core.c b/drivers/base/core.c index d325b9dab3ff44e64ec0fa143b06b6b97edbe6c1..dff94c8fb35093851be42bc3a18275698cb4b1e8 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -1913,6 +1913,33 @@ int create_syslog_header(const struct device *dev, char *hdr, size_t hdrlen) } EXPORT_SYMBOL(create_syslog_header); +int dev_vprintk_emit(int level, const struct device *dev, + const char *fmt, va_list args) +{ + char hdr[128]; + size_t hdrlen; + + hdrlen = create_syslog_header(dev, hdr, sizeof(hdr)); + + return vprintk_emit(0, level, hdrlen ? hdr : NULL, hdrlen, fmt, args); +} +EXPORT_SYMBOL(dev_vprintk_emit); + +int dev_printk_emit(int level, const struct device *dev, const char *fmt, ...) +{ + va_list args; + int r; + + va_start(args, fmt); + + r = dev_vprintk_emit(level, dev, fmt, args); + + va_end(args); + + return r; +} +EXPORT_SYMBOL(dev_printk_emit); + static int __dev_printk(const char *level, const struct device *dev, struct va_format *vaf) { diff --git a/include/linux/device.h b/include/linux/device.h index a1443b48ed4b08827aafd659067b2bfc6e52b3f2..0d9ba0c09791238fde3fe05720f230e962b4583e 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -897,6 +897,10 @@ extern const char *dev_driver_string(const struct device *dev); extern int create_syslog_header(const struct device *dev, char *hdr, size_t hdrlen); +extern int dev_vprintk_emit(int level, const struct device *dev, + const char *fmt, va_list args); +extern __printf(3, 4) +int dev_printk_emit(int level, const struct device *dev, const char *fmt, ...); extern __printf(3, 4) int dev_printk(const char *level, const struct device *dev, @@ -918,6 +922,13 @@ int _dev_info(const struct device *dev, const char *fmt, ...); #else +static int dev_vprintk_emit(int level, const struct device *dev, + const char *fmt, va_list args) +{ return 0; } +static inline __printf(3, 4) +int dev_printk_emit(int level, const struct device *dev, const char *fmt, ...) +{ return 0; } + static inline int __dev_printk(const char *level, const struct device *dev, struct va_format *vaf) { return 0; }