diff options
-rw-r--r-- | drivers/base/core.c | 27 | ||||
-rw-r--r-- | include/linux/device.h | 11 |
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 | } |
1914 | EXPORT_SYMBOL(create_syslog_header); | 1914 | EXPORT_SYMBOL(create_syslog_header); |
1915 | 1915 | ||
1916 | int 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 | } | ||
1926 | EXPORT_SYMBOL(dev_vprintk_emit); | ||
1927 | |||
1928 | int 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 | } | ||
1941 | EXPORT_SYMBOL(dev_printk_emit); | ||
1942 | |||
1916 | static int __dev_printk(const char *level, const struct device *dev, | 1943 | static 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 | ||
898 | extern int create_syslog_header(const struct device *dev, | 898 | extern int create_syslog_header(const struct device *dev, |
899 | char *hdr, size_t hdrlen); | 899 | char *hdr, size_t hdrlen); |
900 | extern int dev_vprintk_emit(int level, const struct device *dev, | ||
901 | const char *fmt, va_list args); | ||
902 | extern __printf(3, 4) | ||
903 | int dev_printk_emit(int level, const struct device *dev, const char *fmt, ...); | ||
900 | 904 | ||
901 | extern __printf(3, 4) | 905 | extern __printf(3, 4) |
902 | int dev_printk(const char *level, const struct device *dev, | 906 | int 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 | ||
925 | static int dev_vprintk_emit(int level, const struct device *dev, | ||
926 | const char *fmt, va_list args) | ||
927 | { return 0; } | ||
928 | static inline __printf(3, 4) | ||
929 | int dev_printk_emit(int level, const struct device *dev, const char *fmt, ...) | ||
930 | { return 0; } | ||
931 | |||
921 | static inline int __dev_printk(const char *level, const struct device *dev, | 932 | static 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; } |