aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorAlex Elder <elder@linaro.org>2014-08-06 19:09:08 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-08-06 21:01:24 -0400
commit249771b8307e7a91659d8b273f8b70d48c3a7bfc (patch)
treee58ae3f8709079eb6cb10999ac42dcd85ae79c8f /kernel
parente99aa461660a6413b11da887fb499e04a0f46803 (diff)
printk: miscellaneous cleanups
Some small cleanups to kernel/printk/printk.c. None of them should cause any change in behavior. - When CONFIG_PRINTK is defined, parenthesize the value of LOG_LINE_MAX. - When CONFIG_PRINTK is *not* defined, there is an extra LOG_LINE_MAX definition; delete it. - Pull an assignment out of a conditional expression in console_setup(). - Use isdigit() in console_setup() rather than open coding it. - In update_console_cmdline(), drop a NUL-termination assignment; the strlcpy() call that precedes it guarantees it's not needed. - Simplify some logic in printk_timed_ratelimit(). Signed-off-by: Alex Elder <elder@linaro.org> Reviewed-by: Petr Mladek <pmladek@suse.cz> Cc: Andi Kleen <ak@linux.intel.com> Cc: Borislav Petkov <bp@suse.de> Cc: Jan Kara <jack@suse.cz> Cc: John Stultz <john.stultz@linaro.org> Cc: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/printk/printk.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index ac86838227ed..5eb0e6c800bb 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -45,6 +45,7 @@
45#include <linux/poll.h> 45#include <linux/poll.h>
46#include <linux/irq_work.h> 46#include <linux/irq_work.h>
47#include <linux/utsname.h> 47#include <linux/utsname.h>
48#include <linux/ctype.h>
48 49
49#include <asm/uaccess.h> 50#include <asm/uaccess.h>
50 51
@@ -257,7 +258,7 @@ static u64 clear_seq;
257static u32 clear_idx; 258static u32 clear_idx;
258 259
259#define PREFIX_MAX 32 260#define PREFIX_MAX 32
260#define LOG_LINE_MAX 1024 - PREFIX_MAX 261#define LOG_LINE_MAX (1024 - PREFIX_MAX)
261 262
262/* record buffer */ 263/* record buffer */
263#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) 264#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
@@ -1835,7 +1836,7 @@ EXPORT_SYMBOL(printk);
1835 1836
1836#define LOG_LINE_MAX 0 1837#define LOG_LINE_MAX 0
1837#define PREFIX_MAX 0 1838#define PREFIX_MAX 0
1838#define LOG_LINE_MAX 0 1839
1839static u64 syslog_seq; 1840static u64 syslog_seq;
1840static u32 syslog_idx; 1841static u32 syslog_idx;
1841static u64 console_seq; 1842static u64 console_seq;
@@ -1936,7 +1937,8 @@ static int __init console_setup(char *str)
1936 strncpy(buf, str, sizeof(buf) - 1); 1937 strncpy(buf, str, sizeof(buf) - 1);
1937 } 1938 }
1938 buf[sizeof(buf) - 1] = 0; 1939 buf[sizeof(buf) - 1] = 0;
1939 if ((options = strchr(str, ',')) != NULL) 1940 options = strchr(str, ',');
1941 if (options)
1940 *(options++) = 0; 1942 *(options++) = 0;
1941#ifdef __sparc__ 1943#ifdef __sparc__
1942 if (!strcmp(str, "ttya")) 1944 if (!strcmp(str, "ttya"))
@@ -1945,7 +1947,7 @@ static int __init console_setup(char *str)
1945 strcpy(buf, "ttyS1"); 1947 strcpy(buf, "ttyS1");
1946#endif 1948#endif
1947 for (s = buf; *s; s++) 1949 for (s = buf; *s; s++)
1948 if ((*s >= '0' && *s <= '9') || *s == ',') 1950 if (isdigit(*s) || *s == ',')
1949 break; 1951 break;
1950 idx = simple_strtoul(s, NULL, 10); 1952 idx = simple_strtoul(s, NULL, 10);
1951 *s = 0; 1953 *s = 0;
@@ -1984,7 +1986,6 @@ int update_console_cmdline(char *name, int idx, char *name_new, int idx_new, cha
1984 i++, c++) 1986 i++, c++)
1985 if (strcmp(c->name, name) == 0 && c->index == idx) { 1987 if (strcmp(c->name, name) == 0 && c->index == idx) {
1986 strlcpy(c->name, name_new, sizeof(c->name)); 1988 strlcpy(c->name, name_new, sizeof(c->name));
1987 c->name[sizeof(c->name) - 1] = 0;
1988 c->options = options; 1989 c->options = options;
1989 c->index = idx_new; 1990 c->index = idx_new;
1990 return i; 1991 return i;
@@ -2652,14 +2653,13 @@ EXPORT_SYMBOL(__printk_ratelimit);
2652bool printk_timed_ratelimit(unsigned long *caller_jiffies, 2653bool printk_timed_ratelimit(unsigned long *caller_jiffies,
2653 unsigned int interval_msecs) 2654 unsigned int interval_msecs)
2654{ 2655{
2655 if (*caller_jiffies == 0 2656 unsigned long elapsed = jiffies - *caller_jiffies;
2656 || !time_in_range(jiffies, *caller_jiffies, 2657
2657 *caller_jiffies 2658 if (*caller_jiffies && elapsed <= msecs_to_jiffies(interval_msecs))
2658 + msecs_to_jiffies(interval_msecs))) { 2659 return false;
2659 *caller_jiffies = jiffies; 2660
2660 return true; 2661 *caller_jiffies = jiffies;
2661 } 2662 return true;
2662 return false;
2663} 2663}
2664EXPORT_SYMBOL(printk_timed_ratelimit); 2664EXPORT_SYMBOL(printk_timed_ratelimit);
2665 2665