diff options
author | Arve Hjønnevåg <arve@android.com> | 2009-01-15 19:07:27 -0800 |
---|---|---|
committer | Dan Willemsen <dwillemsen@nvidia.com> | 2011-11-30 21:38:11 -0800 |
commit | c69e7f2ea7d1d77dc5b49c07b9a6fdabffa26d06 (patch) | |
tree | 678ddaace33128e14028141715da10d5bd626a8b /kernel | |
parent | 3fd3abf920901dfd1fb76393226c91ef3bbb90f1 (diff) |
Revert "printk: remove unused code from kernel/printk.c"
This reverts commit acff181d3574244e651913df77332e897b88bff4.
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/printk.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/kernel/printk.c b/kernel/printk.c index 3e565d1cd9da..4f3a6481e4d5 100644 --- a/kernel/printk.c +++ b/kernel/printk.c @@ -294,6 +294,45 @@ static inline void boot_delay_msec(void) } #endif +/* + * Return the number of unread characters in the log buffer. + */ +static int log_buf_get_len(void) +{ + return logged_chars; +} + +/* + * Copy a range of characters from the log buffer. + */ +int log_buf_copy(char *dest, int idx, int len) +{ + int ret, max; + bool took_lock = false; + + if (!oops_in_progress) { + spin_lock_irq(&logbuf_lock); + took_lock = true; + } + + max = log_buf_get_len(); + if (idx < 0 || idx >= max) { + ret = -1; + } else { + if (len > max) + len = max; + ret = len; + idx += (log_end - max); + while (len-- > 0) + dest[len] = LOG_BUF(idx + len); + } + + if (took_lock) + spin_unlock_irq(&logbuf_lock); + + return ret; +} + #ifdef CONFIG_SECURITY_DMESG_RESTRICT int dmesg_restrict = 1; #else |