diff --git a/drivers/staging/android/ram_console.c b/drivers/staging/android/ram_console.c index 53f736b0ec83..6d4d67924f22 100644 --- a/drivers/staging/android/ram_console.c +++ b/drivers/staging/android/ram_console.c @@ -21,6 +21,7 @@ #include #include #include +#include "ram_console.h" #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 = { diff --git a/drivers/staging/android/ram_console.h b/drivers/staging/android/ram_console.h new file mode 100644 index 000000000000..9f1125c11066 --- /dev/null +++ b/drivers/staging/android/ram_console.h @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2010 Google, Inc. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#ifndef _INCLUDE_LINUX_PLATFORM_DATA_RAM_CONSOLE_H_ +#define _INCLUDE_LINUX_PLATFORM_DATA_RAM_CONSOLE_H_ + +struct ram_console_platform_data { + const char *bootinfo; +}; + +#endif /* _INCLUDE_LINUX_PLATFORM_DATA_RAM_CONSOLE_H_ */