Commit a6707f83 authored by Colin Cross's avatar Colin Cross Committed by Greg Kroah-Hartman

staging: android: 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.

[moved the .h file to drivers/staging/android/ to be self-contained - gregkh]
Signed-off-by: default avatarColin Cross <ccross@android.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 2b374956
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <linux/string.h> #include <linux/string.h>
#include <linux/uaccess.h> #include <linux/uaccess.h>
#include <linux/io.h> #include <linux/io.h>
#include "ram_console.h"
#ifdef CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION #ifdef CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION
#include <linux/rslib.h> #include <linux/rslib.h>
...@@ -155,14 +156,20 @@ void ram_console_enable_console(int enabled) ...@@ -155,14 +156,20 @@ void ram_console_enable_console(int enabled)
} }
static void __init 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 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 #ifdef CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION
uint8_t *block; uint8_t *block;
uint8_t *par; uint8_t *par;
char strbuf[80]; char strbuf[80];
int strbuf_len; int strbuf_len = 0;
block = buffer->data; block = buffer->data;
par = ram_console_par_buffer; par = ram_console_par_buffer;
...@@ -197,11 +204,15 @@ ram_console_save_old(struct ram_console_buffer *buffer, char *dest) ...@@ -197,11 +204,15 @@ ram_console_save_old(struct ram_console_buffer *buffer, char *dest)
"\nNo errors detected\n"); "\nNo errors detected\n");
if (strbuf_len >= sizeof(strbuf)) if (strbuf_len >= sizeof(strbuf))
strbuf_len = sizeof(strbuf) - 1; strbuf_len = sizeof(strbuf) - 1;
old_log_size += strbuf_len; total_size += strbuf_len;
#endif #endif
if (bootinfo)
bootinfo_size = strlen(bootinfo) + strlen(bootinfo_label);
total_size += bootinfo_size;
if (dest == NULL) { if (dest == NULL) {
dest = kmalloc(old_log_size, GFP_KERNEL); dest = kmalloc(total_size, GFP_KERNEL);
if (dest == NULL) { if (dest == NULL) {
printk(KERN_ERR printk(KERN_ERR
"ram_console: failed to allocate buffer\n"); "ram_console: failed to allocate buffer\n");
...@@ -210,19 +221,27 @@ ram_console_save_old(struct ram_console_buffer *buffer, char *dest) ...@@ -210,19 +221,27 @@ ram_console_save_old(struct ram_console_buffer *buffer, char *dest)
} }
ram_console_old_log = 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, memcpy(ram_console_old_log,
&buffer->data[buffer->start], buffer->size - buffer->start); &buffer->data[buffer->start], buffer->size - buffer->start);
memcpy(ram_console_old_log + buffer->size - buffer->start, memcpy(ram_console_old_log + buffer->size - buffer->start,
&buffer->data[0], buffer->start); &buffer->data[0], buffer->start);
ptr = ram_console_old_log + old_log_size;
#ifdef CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION #ifdef CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION
memcpy(ram_console_old_log + old_log_size - strbuf_len, memcpy(ptr, strbuf, strbuf_len);
strbuf, strbuf_len); ptr += strbuf_len;
#endif #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, 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 #ifdef CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION
int numerr; int numerr;
...@@ -289,7 +308,7 @@ static int __init ram_console_init(struct ram_console_buffer *buffer, ...@@ -289,7 +308,7 @@ static int __init ram_console_init(struct ram_console_buffer *buffer,
printk(KERN_INFO "ram_console: found existing buffer, " printk(KERN_INFO "ram_console: found existing buffer, "
"size %d, start %d\n", "size %d, start %d\n",
buffer->size, buffer->start); buffer->size, buffer->start);
ram_console_save_old(buffer, old_buf); ram_console_save_old(buffer, bootinfo, old_buf);
} }
} else { } else {
printk(KERN_INFO "ram_console: no valid data in buffer " printk(KERN_INFO "ram_console: no valid data in buffer "
...@@ -313,6 +332,7 @@ static int __init ram_console_early_init(void) ...@@ -313,6 +332,7 @@ static int __init ram_console_early_init(void)
return ram_console_init((struct ram_console_buffer *) return ram_console_init((struct ram_console_buffer *)
CONFIG_ANDROID_RAM_CONSOLE_EARLY_ADDR, CONFIG_ANDROID_RAM_CONSOLE_EARLY_ADDR,
CONFIG_ANDROID_RAM_CONSOLE_EARLY_SIZE, CONFIG_ANDROID_RAM_CONSOLE_EARLY_SIZE,
NULL,
ram_console_old_log_init_buffer); ram_console_old_log_init_buffer);
} }
#else #else
...@@ -322,6 +342,8 @@ static int ram_console_driver_probe(struct platform_device *pdev) ...@@ -322,6 +342,8 @@ static int ram_console_driver_probe(struct platform_device *pdev)
size_t start; size_t start;
size_t buffer_size; size_t buffer_size;
void *buffer; void *buffer;
const char *bootinfo = NULL;
struct ram_console_platform_data *pdata = pdev->dev.platform_data;
if (res == NULL || pdev->num_resources != 1 || if (res == NULL || pdev->num_resources != 1 ||
!(res->flags & IORESOURCE_MEM)) { !(res->flags & IORESOURCE_MEM)) {
...@@ -339,7 +361,10 @@ static int ram_console_driver_probe(struct platform_device *pdev) ...@@ -339,7 +361,10 @@ static int ram_console_driver_probe(struct platform_device *pdev)
return -ENOMEM; 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 = { static struct platform_driver ram_console_driver = {
......
/*
* 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_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment