aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/base/core.c27
-rw-r--r--include/linux/device.h11
2 files changed, 38 insertions, 0 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c
index d325b9dab3ff..dff94c8fb350 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)
1913} 1913}
1914EXPORT_SYMBOL(create_syslog_header); 1914EXPORT_SYMBOL(create_syslog_header);
1915 1915
1916int dev_vprintk_emit(int level, const struct device *dev,
1917 const char *fmt, va_list args)
1918{
1919 char hdr[128];
1920 size_t hdrlen;
1921
1922 hdrlen = create_syslog_header(dev, hdr, sizeof(hdr));
1923
1924 return vprintk_emit(0, level, hdrlen ? hdr : NULL, hdrlen, fmt, args);
1925}
1926EXPORT_SYMBOL(dev_vprintk_emit);
1927
1928int dev_printk_emit(int level, const struct device *dev, const char *fmt, ...)
1929{
1930 va_list args;
1931 int r;
1932
1933 va_start(args, fmt);
1934
1935 r = dev_vprintk_emit(level, dev, fmt, args);
1936
1937 va_end(args);
1938
1939 return r;
1940}
1941EXPORT_SYMBOL(dev_printk_emit);
1942
1916static int __dev_printk(const char *level, const struct device *dev, 1943static int __dev_printk(const char *level, const struct device *dev,
1917 struct va_format *vaf) 1944 struct va_format *vaf)
1918{ 1945{
diff --git a/include/linux/device.h b/include/linux/device.h
index a1443b48ed4b..0d9ba0c09791 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);
897 897
898extern int create_syslog_header(const struct device *dev, 898extern int create_syslog_header(const struct device *dev,
899 char *hdr, size_t hdrlen); 899 char *hdr, size_t hdrlen);
900extern int dev_vprintk_emit(int level, const struct device *dev,
901 const char *fmt, va_list args);
902extern __printf(3, 4)
903int dev_printk_emit(int level, const struct device *dev, const char *fmt, ...);
900 904
901extern __printf(3, 4) 905extern __printf(3, 4)
902int dev_printk(const char *level, const struct device *dev, 906int dev_printk(const char *level, const struct device *dev,
@@ -918,6 +922,13 @@ int _dev_info(const struct device *dev, const char *fmt, ...);
918 922
919#else 923#else
920 924
925static int dev_vprintk_emit(int level, const struct device *dev,
926 const char *fmt, va_list args)
927{ return 0; }
928static inline __printf(3, 4)
929int dev_printk_emit(int level, const struct device *dev, const char *fmt, ...)
930{ return 0; }
931
921static inline int __dev_printk(const char *level, const struct device *dev, 932static inline int __dev_printk(const char *level, const struct device *dev,
922 struct va_format *vaf) 933 struct va_format *vaf)
923{ return 0; } 934{ return 0; }