diff options
author | Joe Perches <joe@perches.com> | 2012-09-12 23:13:37 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-09-17 09:10:05 -0400 |
commit | 05e4e5b87aab74f994acf9dd4bed4a8f1367cd09 (patch) | |
tree | e40c6ba66ea821556abbf73a71fa8b55ef73cb63 /drivers/base | |
parent | c2c5a7051c556036b7beb8f4a89eefdc91c3245b (diff) |
dev: Add dev_vprintk_emit and dev_printk_emit
Add utility functions to consolidate the use of
create_syslog_header and vprintk_emit.
This allows conversion of logging functions that
call create_syslog_header and then call vprintk_emit
or printk_emit to the dev_ equivalents.
Signed-off-by: Joe Perches <joe@perches.com>
Acked-by: David S. Miller <davem@davemloft.net>
Tested-by: Jim Cromie <jim.cromie@gmail.com>
Acked-by: Jason Baron <jbaron@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/core.c | 27 |
1 files changed, 27 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 | { |