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

ramoops: use the platform data structure instead of module params

As each board and system has different memory for ramoops. It's better to
define the platform data instead of module params.

[akpm@linux-foundation.org: fix ramoops_remove() return type]
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Marco Stornelli <marco.stornelli@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Kyungmin Park and committed by
Linus Torvalds
c3b92ce9 5de1cb2d

+43 -2
+28 -2
drivers/char/ramoops.c
··· 25 25 #include <linux/time.h> 26 26 #include <linux/io.h> 27 27 #include <linux/ioport.h> 28 + #include <linux/platform_device.h> 29 + #include <linux/ramoops.h> 28 30 29 31 #define RAMOOPS_KERNMSG_HDR "====" 30 32 #define RAMOOPS_HEADER_SIZE (5 + sizeof(struct timeval)) ··· 93 91 cxt->count = (cxt->count + 1) % cxt->max_count; 94 92 } 95 93 96 - static int __init ramoops_init(void) 94 + static int __init ramoops_probe(struct platform_device *pdev) 97 95 { 96 + struct ramoops_platform_data *pdata = pdev->dev.platform_data; 98 97 struct ramoops_context *cxt = &oops_cxt; 99 98 int err = -EINVAL; 99 + 100 + if (pdata) { 101 + mem_size = pdata->mem_size; 102 + mem_address = pdata->mem_address; 103 + } 100 104 101 105 if (!mem_size) { 102 106 printk(KERN_ERR "ramoops: invalid size specification"); ··· 150 142 return err; 151 143 } 152 144 153 - static void __exit ramoops_exit(void) 145 + static int __exit ramoops_remove(struct platform_device *pdev) 154 146 { 155 147 struct ramoops_context *cxt = &oops_cxt; 156 148 ··· 159 151 160 152 iounmap(cxt->virt_addr); 161 153 release_mem_region(cxt->phys_addr, cxt->size); 154 + return 0; 162 155 } 163 156 157 + static struct platform_driver ramoops_driver = { 158 + .remove = __exit_p(ramoops_remove), 159 + .driver = { 160 + .name = "ramoops", 161 + .owner = THIS_MODULE, 162 + }, 163 + }; 164 + 165 + static int __init ramoops_init(void) 166 + { 167 + return platform_driver_probe(&ramoops_driver, ramoops_probe); 168 + } 169 + 170 + static void __exit ramoops_exit(void) 171 + { 172 + platform_driver_unregister(&ramoops_driver); 173 + } 164 174 165 175 module_init(ramoops_init); 166 176 module_exit(ramoops_exit);
+15
include/linux/ramoops.h
··· 1 + #ifndef __RAMOOPS_H 2 + #define __RAMOOPS_H 3 + 4 + /* 5 + * Ramoops platform data 6 + * @mem_size memory size for ramoops 7 + * @mem_address physical memory address to contain ramoops 8 + */ 9 + 10 + struct ramoops_platform_data { 11 + unsigned long mem_size; 12 + unsigned long mem_address; 13 + }; 14 + 15 + #endif