From 1168105523cb73c8a411e58fc604c912d806de01 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Tue, 25 Oct 2011 14:31:58 -0700 Subject: ram_console: pass in a boot info string Allow the board file to pass a boot info string through the platform data that is appended to the /proc/last_kmsg file. Change-Id: I37065fafb09676085465c93384d8e176fdd942d6 Signed-off-by: Colin Cross --- drivers/staging/android/ram_console.c | 45 +++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 10 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/android/ram_console.c b/drivers/staging/android/ram_console.c index 53f736b0ec83..cb42d899822e 100644 --- a/drivers/staging/android/ram_console.c +++ b/drivers/staging/android/ram_console.c @@ -21,6 +21,7 @@ #include #include #include +#include #ifdef CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION #include @@ -155,14 +156,20 @@ void ram_console_enable_console(int enabled) } static void __init -ram_console_save_old(struct ram_console_buffer *buffer, char *dest) +ram_console_save_old(struct ram_console_buffer *buffer, const char *bootinfo, + char *dest) { size_t old_log_size = buffer->size; + size_t bootinfo_size = 0; + size_t total_size = old_log_size; + char *ptr; + const char *bootinfo_label = "Boot info:\n"; + #ifdef CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION uint8_t *block; uint8_t *par; char strbuf[80]; - int strbuf_len; + int strbuf_len = 0; block = buffer->data; par = ram_console_par_buffer; @@ -197,11 +204,15 @@ ram_console_save_old(struct ram_console_buffer *buffer, char *dest) "\nNo errors detected\n"); if (strbuf_len >= sizeof(strbuf)) strbuf_len = sizeof(strbuf) - 1; - old_log_size += strbuf_len; + total_size += strbuf_len; #endif + if (bootinfo) + bootinfo_size = strlen(bootinfo) + strlen(bootinfo_label); + total_size += bootinfo_size; + if (dest == NULL) { - dest = kmalloc(old_log_size, GFP_KERNEL); + dest = kmalloc(total_size, GFP_KERNEL); if (dest == NULL) { printk(KERN_ERR "ram_console: failed to allocate buffer\n"); @@ -210,19 +221,27 @@ ram_console_save_old(struct ram_console_buffer *buffer, char *dest) } ram_console_old_log = dest; - ram_console_old_log_size = old_log_size; + ram_console_old_log_size = total_size; memcpy(ram_console_old_log, &buffer->data[buffer->start], buffer->size - buffer->start); memcpy(ram_console_old_log + buffer->size - buffer->start, &buffer->data[0], buffer->start); + ptr = ram_console_old_log + old_log_size; #ifdef CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION - memcpy(ram_console_old_log + old_log_size - strbuf_len, - strbuf, strbuf_len); + memcpy(ptr, strbuf, strbuf_len); + ptr += strbuf_len; #endif + if (bootinfo) { + memcpy(ptr, bootinfo_label, strlen(bootinfo_label)); + ptr += strlen(bootinfo_label); + memcpy(ptr, bootinfo, bootinfo_size); + ptr += bootinfo_size; + } } static int __init ram_console_init(struct ram_console_buffer *buffer, - size_t buffer_size, char *old_buf) + size_t buffer_size, const char *bootinfo, + char *old_buf) { #ifdef CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION int numerr; @@ -289,7 +308,7 @@ static int __init ram_console_init(struct ram_console_buffer *buffer, printk(KERN_INFO "ram_console: found existing buffer, " "size %d, start %d\n", buffer->size, buffer->start); - ram_console_save_old(buffer, old_buf); + ram_console_save_old(buffer, bootinfo, old_buf); } } else { printk(KERN_INFO "ram_console: no valid data in buffer " @@ -313,6 +332,7 @@ static int __init ram_console_early_init(void) return ram_console_init((struct ram_console_buffer *) CONFIG_ANDROID_RAM_CONSOLE_EARLY_ADDR, CONFIG_ANDROID_RAM_CONSOLE_EARLY_SIZE, + NULL, ram_console_old_log_init_buffer); } #else @@ -322,6 +342,8 @@ static int ram_console_driver_probe(struct platform_device *pdev) size_t start; size_t buffer_size; void *buffer; + const char *bootinfo = NULL; + struct ram_console_platform_data *pdata = pdev->dev.platform_data; if (res == NULL || pdev->num_resources != 1 || !(res->flags & IORESOURCE_MEM)) { @@ -339,7 +361,10 @@ static int ram_console_driver_probe(struct platform_device *pdev) return -ENOMEM; } - return ram_console_init(buffer, buffer_size, NULL/* allocate */); + if (pdata) + bootinfo = pdata->bootinfo; + + return ram_console_init(buffer, buffer_size, bootinfo, NULL/* allocate */); } static struct platform_driver ram_console_driver = { -- cgit v1.2.3