Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Colin Cross <ccross@android.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Colin Cross and committed by
Greg Kroah-Hartman
a6707f83 2b374956

+57 -10
+35 -10
drivers/staging/android/ram_console.c
··· 21 21 #include <linux/string.h> 22 22 #include <linux/uaccess.h> 23 23 #include <linux/io.h> 24 + #include "ram_console.h" 24 25 25 26 #ifdef CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION 26 27 #include <linux/rslib.h> ··· 156 155 } 157 156 158 157 static void __init 159 - ram_console_save_old(struct ram_console_buffer *buffer, char *dest) 158 + ram_console_save_old(struct ram_console_buffer *buffer, const char *bootinfo, 159 + char *dest) 160 160 { 161 161 size_t old_log_size = buffer->size; 162 + size_t bootinfo_size = 0; 163 + size_t total_size = old_log_size; 164 + char *ptr; 165 + const char *bootinfo_label = "Boot info:\n"; 166 + 162 167 #ifdef CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION 163 168 uint8_t *block; 164 169 uint8_t *par; 165 170 char strbuf[80]; 166 - int strbuf_len; 171 + int strbuf_len = 0; 167 172 168 173 block = buffer->data; 169 174 par = ram_console_par_buffer; ··· 204 197 "\nNo errors detected\n"); 205 198 if (strbuf_len >= sizeof(strbuf)) 206 199 strbuf_len = sizeof(strbuf) - 1; 207 - old_log_size += strbuf_len; 200 + total_size += strbuf_len; 208 201 #endif 209 202 203 + if (bootinfo) 204 + bootinfo_size = strlen(bootinfo) + strlen(bootinfo_label); 205 + total_size += bootinfo_size; 206 + 210 207 if (dest == NULL) { 211 - dest = kmalloc(old_log_size, GFP_KERNEL); 208 + dest = kmalloc(total_size, GFP_KERNEL); 212 209 if (dest == NULL) { 213 210 printk(KERN_ERR 214 211 "ram_console: failed to allocate buffer\n"); ··· 221 210 } 222 211 223 212 ram_console_old_log = dest; 224 - ram_console_old_log_size = old_log_size; 213 + ram_console_old_log_size = total_size; 225 214 memcpy(ram_console_old_log, 226 215 &buffer->data[buffer->start], buffer->size - buffer->start); 227 216 memcpy(ram_console_old_log + buffer->size - buffer->start, 228 217 &buffer->data[0], buffer->start); 218 + ptr = ram_console_old_log + old_log_size; 229 219 #ifdef CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION 230 - memcpy(ram_console_old_log + old_log_size - strbuf_len, 231 - strbuf, strbuf_len); 220 + memcpy(ptr, strbuf, strbuf_len); 221 + ptr += strbuf_len; 232 222 #endif 223 + if (bootinfo) { 224 + memcpy(ptr, bootinfo_label, strlen(bootinfo_label)); 225 + ptr += strlen(bootinfo_label); 226 + memcpy(ptr, bootinfo, bootinfo_size); 227 + ptr += bootinfo_size; 228 + } 233 229 } 234 230 235 231 static int __init ram_console_init(struct ram_console_buffer *buffer, 236 - size_t buffer_size, char *old_buf) 232 + size_t buffer_size, const char *bootinfo, 233 + char *old_buf) 237 234 { 238 235 #ifdef CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION 239 236 int numerr; ··· 308 289 printk(KERN_INFO "ram_console: found existing buffer, " 309 290 "size %d, start %d\n", 310 291 buffer->size, buffer->start); 311 - ram_console_save_old(buffer, old_buf); 292 + ram_console_save_old(buffer, bootinfo, old_buf); 312 293 } 313 294 } else { 314 295 printk(KERN_INFO "ram_console: no valid data in buffer " ··· 332 313 return ram_console_init((struct ram_console_buffer *) 333 314 CONFIG_ANDROID_RAM_CONSOLE_EARLY_ADDR, 334 315 CONFIG_ANDROID_RAM_CONSOLE_EARLY_SIZE, 316 + NULL, 335 317 ram_console_old_log_init_buffer); 336 318 } 337 319 #else ··· 342 322 size_t start; 343 323 size_t buffer_size; 344 324 void *buffer; 325 + const char *bootinfo = NULL; 326 + struct ram_console_platform_data *pdata = pdev->dev.platform_data; 345 327 346 328 if (res == NULL || pdev->num_resources != 1 || 347 329 !(res->flags & IORESOURCE_MEM)) { ··· 361 339 return -ENOMEM; 362 340 } 363 341 364 - return ram_console_init(buffer, buffer_size, NULL/* allocate */); 342 + if (pdata) 343 + bootinfo = pdata->bootinfo; 344 + 345 + return ram_console_init(buffer, buffer_size, bootinfo, NULL/* allocate */); 365 346 } 366 347 367 348 static struct platform_driver ram_console_driver = {
+22
drivers/staging/android/ram_console.h
··· 1 + /* 2 + * Copyright (C) 2010 Google, Inc. 3 + * 4 + * This software is licensed under the terms of the GNU General Public 5 + * License version 2, as published by the Free Software Foundation, and 6 + * may be copied, distributed, and modified under those terms. 7 + * 8 + * This program is distributed in the hope that it will be useful, 9 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 + * GNU General Public License for more details. 12 + * 13 + */ 14 + 15 + #ifndef _INCLUDE_LINUX_PLATFORM_DATA_RAM_CONSOLE_H_ 16 + #define _INCLUDE_LINUX_PLATFORM_DATA_RAM_CONSOLE_H_ 17 + 18 + struct ram_console_platform_data { 19 + const char *bootinfo; 20 + }; 21 + 22 + #endif /* _INCLUDE_LINUX_PLATFORM_DATA_RAM_CONSOLE_H_ */