aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2014-12-10 18:50:15 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-12-10 20:41:11 -0500
commita39d4a857d4bb0a62d6655c0d69f7387fe1ad160 (patch)
treea10a09dd5750a654992d9cd72e940a7c8d0f707a
parentf80e696854c95725cf7faf9776e02f00600780d3 (diff)
printk: add and use LOGLEVEL_<level> defines for KERN_<LEVEL> equivalents
Use #defines instead of magic values. Signed-off-by: Joe Perches <joe@perches.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Jason Baron <jbaron@akamai.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--drivers/usb/storage/debug.c2
-rw-r--r--include/linux/kern_levels.h13
-rw-r--r--kernel/printk/printk.c28
-rw-r--r--lib/dynamic_debug.c4
4 files changed, 29 insertions, 18 deletions
diff --git a/drivers/usb/storage/debug.c b/drivers/usb/storage/debug.c
index 66a684a29938..2d81e1d8ee30 100644
--- a/drivers/usb/storage/debug.c
+++ b/drivers/usb/storage/debug.c
@@ -188,7 +188,7 @@ int usb_stor_dbg(const struct us_data *us, const char *fmt, ...)
188 188
189 va_start(args, fmt); 189 va_start(args, fmt);
190 190
191 r = dev_vprintk_emit(7, &us->pusb_dev->dev, fmt, args); 191 r = dev_vprintk_emit(LOGLEVEL_DEBUG, &us->pusb_dev->dev, fmt, args);
192 192
193 va_end(args); 193 va_end(args);
194 194
diff --git a/include/linux/kern_levels.h b/include/linux/kern_levels.h
index 866caaa9e2bb..c2ce155d83cc 100644
--- a/include/linux/kern_levels.h
+++ b/include/linux/kern_levels.h
@@ -22,4 +22,17 @@
22 */ 22 */
23#define KERN_CONT "" 23#define KERN_CONT ""
24 24
25/* integer equivalents of KERN_<LEVEL> */
26#define LOGLEVEL_SCHED -2 /* Deferred messages from sched code
27 * are set to this special level */
28#define LOGLEVEL_DEFAULT -1 /* default (or last) loglevel */
29#define LOGLEVEL_EMERG 0 /* system is unusable */
30#define LOGLEVEL_ALERT 1 /* action must be taken immediately */
31#define LOGLEVEL_CRIT 2 /* critical conditions */
32#define LOGLEVEL_ERR 3 /* error conditions */
33#define LOGLEVEL_WARNING 4 /* warning conditions */
34#define LOGLEVEL_NOTICE 5 /* normal but significant condition */
35#define LOGLEVEL_INFO 6 /* informational */
36#define LOGLEVEL_DEBUG 7 /* debug-level messages */
37
25#endif 38#endif
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 4815c98ae175..1b7092dbb590 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -62,9 +62,6 @@ int console_printk[4] = {
62 CONSOLE_LOGLEVEL_DEFAULT, /* default_console_loglevel */ 62 CONSOLE_LOGLEVEL_DEFAULT, /* default_console_loglevel */
63}; 63};
64 64
65/* Deferred messaged from sched code are marked by this special level */
66#define SCHED_MESSAGE_LOGLEVEL -2
67
68/* 65/*
69 * Low level drivers may need that to know if they can schedule in 66 * Low level drivers may need that to know if they can schedule in
70 * their unblank() callback or not. So let's export it. 67 * their unblank() callback or not. So let's export it.
@@ -1259,7 +1256,7 @@ static int syslog_print_all(char __user *buf, int size, bool clear)
1259int do_syslog(int type, char __user *buf, int len, bool from_file) 1256int do_syslog(int type, char __user *buf, int len, bool from_file)
1260{ 1257{
1261 bool clear = false; 1258 bool clear = false;
1262 static int saved_console_loglevel = -1; 1259 static int saved_console_loglevel = LOGLEVEL_DEFAULT;
1263 int error; 1260 int error;
1264 1261
1265 error = check_syslog_permissions(type, from_file); 1262 error = check_syslog_permissions(type, from_file);
@@ -1316,15 +1313,15 @@ int do_syslog(int type, char __user *buf, int len, bool from_file)
1316 break; 1313 break;
1317 /* Disable logging to console */ 1314 /* Disable logging to console */
1318 case SYSLOG_ACTION_CONSOLE_OFF: 1315 case SYSLOG_ACTION_CONSOLE_OFF:
1319 if (saved_console_loglevel == -1) 1316 if (saved_console_loglevel == LOGLEVEL_DEFAULT)
1320 saved_console_loglevel = console_loglevel; 1317 saved_console_loglevel = console_loglevel;
1321 console_loglevel = minimum_console_loglevel; 1318 console_loglevel = minimum_console_loglevel;
1322 break; 1319 break;
1323 /* Enable logging to console */ 1320 /* Enable logging to console */
1324 case SYSLOG_ACTION_CONSOLE_ON: 1321 case SYSLOG_ACTION_CONSOLE_ON:
1325 if (saved_console_loglevel != -1) { 1322 if (saved_console_loglevel != LOGLEVEL_DEFAULT) {
1326 console_loglevel = saved_console_loglevel; 1323 console_loglevel = saved_console_loglevel;
1327 saved_console_loglevel = -1; 1324 saved_console_loglevel = LOGLEVEL_DEFAULT;
1328 } 1325 }
1329 break; 1326 break;
1330 /* Set level of messages printed to console */ 1327 /* Set level of messages printed to console */
@@ -1336,7 +1333,7 @@ int do_syslog(int type, char __user *buf, int len, bool from_file)
1336 len = minimum_console_loglevel; 1333 len = minimum_console_loglevel;
1337 console_loglevel = len; 1334 console_loglevel = len;
1338 /* Implicitly re-enable logging to console */ 1335 /* Implicitly re-enable logging to console */
1339 saved_console_loglevel = -1; 1336 saved_console_loglevel = LOGLEVEL_DEFAULT;
1340 error = 0; 1337 error = 0;
1341 break; 1338 break;
1342 /* Number of chars in the log buffer */ 1339 /* Number of chars in the log buffer */
@@ -1629,8 +1626,8 @@ asmlinkage int vprintk_emit(int facility, int level,
1629 /* cpu currently holding logbuf_lock in this function */ 1626 /* cpu currently holding logbuf_lock in this function */
1630 static volatile unsigned int logbuf_cpu = UINT_MAX; 1627 static volatile unsigned int logbuf_cpu = UINT_MAX;
1631 1628
1632 if (level == SCHED_MESSAGE_LOGLEVEL) { 1629 if (level == LOGLEVEL_SCHED) {
1633 level = -1; 1630 level = LOGLEVEL_DEFAULT;
1634 in_sched = true; 1631 in_sched = true;
1635 } 1632 }
1636 1633
@@ -1695,8 +1692,9 @@ asmlinkage int vprintk_emit(int facility, int level,
1695 const char *end_of_header = printk_skip_level(text); 1692 const char *end_of_header = printk_skip_level(text);
1696 switch (kern_level) { 1693 switch (kern_level) {
1697 case '0' ... '7': 1694 case '0' ... '7':
1698 if (level == -1) 1695 if (level == LOGLEVEL_DEFAULT)
1699 level = kern_level - '0'; 1696 level = kern_level - '0';
1697 /* fallthrough */
1700 case 'd': /* KERN_DEFAULT */ 1698 case 'd': /* KERN_DEFAULT */
1701 lflags |= LOG_PREFIX; 1699 lflags |= LOG_PREFIX;
1702 } 1700 }
@@ -1710,7 +1708,7 @@ asmlinkage int vprintk_emit(int facility, int level,
1710 } 1708 }
1711 } 1709 }
1712 1710
1713 if (level == -1) 1711 if (level == LOGLEVEL_DEFAULT)
1714 level = default_message_loglevel; 1712 level = default_message_loglevel;
1715 1713
1716 if (dict) 1714 if (dict)
@@ -1788,7 +1786,7 @@ EXPORT_SYMBOL(vprintk_emit);
1788 1786
1789asmlinkage int vprintk(const char *fmt, va_list args) 1787asmlinkage int vprintk(const char *fmt, va_list args)
1790{ 1788{
1791 return vprintk_emit(0, -1, NULL, 0, fmt, args); 1789 return vprintk_emit(0, LOGLEVEL_DEFAULT, NULL, 0, fmt, args);
1792} 1790}
1793EXPORT_SYMBOL(vprintk); 1791EXPORT_SYMBOL(vprintk);
1794 1792
@@ -1842,7 +1840,7 @@ asmlinkage __visible int printk(const char *fmt, ...)
1842 } 1840 }
1843#endif 1841#endif
1844 va_start(args, fmt); 1842 va_start(args, fmt);
1845 r = vprintk_emit(0, -1, NULL, 0, fmt, args); 1843 r = vprintk_emit(0, LOGLEVEL_DEFAULT, NULL, 0, fmt, args);
1846 va_end(args); 1844 va_end(args);
1847 1845
1848 return r; 1846 return r;
@@ -2631,7 +2629,7 @@ int printk_deferred(const char *fmt, ...)
2631 2629
2632 preempt_disable(); 2630 preempt_disable();
2633 va_start(args, fmt); 2631 va_start(args, fmt);
2634 r = vprintk_emit(0, SCHED_MESSAGE_LOGLEVEL, NULL, 0, fmt, args); 2632 r = vprintk_emit(0, LOGLEVEL_SCHED, NULL, 0, fmt, args);
2635 va_end(args); 2633 va_end(args);
2636 2634
2637 __this_cpu_or(printk_pending, PRINTK_PENDING_OUTPUT); 2635 __this_cpu_or(printk_pending, PRINTK_PENDING_OUTPUT);
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index dfba05521748..527799d44476 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -576,7 +576,7 @@ void __dynamic_dev_dbg(struct _ddebug *descriptor,
576 } else { 576 } else {
577 char buf[PREFIX_SIZE]; 577 char buf[PREFIX_SIZE];
578 578
579 dev_printk_emit(7, dev, "%s%s %s: %pV", 579 dev_printk_emit(LOGLEVEL_DEBUG, dev, "%s%s %s: %pV",
580 dynamic_emit_prefix(descriptor, buf), 580 dynamic_emit_prefix(descriptor, buf),
581 dev_driver_string(dev), dev_name(dev), 581 dev_driver_string(dev), dev_name(dev),
582 &vaf); 582 &vaf);
@@ -605,7 +605,7 @@ void __dynamic_netdev_dbg(struct _ddebug *descriptor,
605 if (dev && dev->dev.parent) { 605 if (dev && dev->dev.parent) {
606 char buf[PREFIX_SIZE]; 606 char buf[PREFIX_SIZE];
607 607
608 dev_printk_emit(7, dev->dev.parent, 608 dev_printk_emit(LOGLEVEL_DEBUG, dev->dev.parent,
609 "%s%s %s %s%s: %pV", 609 "%s%s %s %s%s: %pV",
610 dynamic_emit_prefix(descriptor, buf), 610 dynamic_emit_prefix(descriptor, buf),
611 dev_driver_string(dev->dev.parent), 611 dev_driver_string(dev->dev.parent),