aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/ramoops.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/ramoops.c')
-rw-r--r--drivers/char/ramoops.c47
1 files changed, 35 insertions, 12 deletions
diff --git a/drivers/char/ramoops.c b/drivers/char/ramoops.c
index 1a9f5f6d6ac5..32aa233df300 100644
--- a/drivers/char/ramoops.c
+++ b/drivers/char/ramoops.c
@@ -26,6 +26,7 @@
26#include <linux/io.h> 26#include <linux/io.h>
27#include <linux/ioport.h> 27#include <linux/ioport.h>
28#include <linux/platform_device.h> 28#include <linux/platform_device.h>
29#include <linux/slab.h>
29#include <linux/ramoops.h> 30#include <linux/ramoops.h>
30 31
31#define RAMOOPS_KERNMSG_HDR "====" 32#define RAMOOPS_KERNMSG_HDR "===="
@@ -56,6 +57,9 @@ static struct ramoops_context {
56 int max_count; 57 int max_count;
57} oops_cxt; 58} oops_cxt;
58 59
60static struct platform_device *dummy;
61static struct ramoops_platform_data *dummy_data;
62
59static void ramoops_do_dump(struct kmsg_dumper *dumper, 63static void ramoops_do_dump(struct kmsg_dumper *dumper,
60 enum kmsg_dump_reason reason, const char *s1, unsigned long l1, 64 enum kmsg_dump_reason reason, const char *s1, unsigned long l1,
61 const char *s2, unsigned long l2) 65 const char *s2, unsigned long l2)
@@ -106,27 +110,22 @@ static int __init ramoops_probe(struct platform_device *pdev)
106 struct ramoops_context *cxt = &oops_cxt; 110 struct ramoops_context *cxt = &oops_cxt;
107 int err = -EINVAL; 111 int err = -EINVAL;
108 112
109 if (pdata) { 113 if (!pdata->mem_size) {
110 mem_size = pdata->mem_size;
111 mem_address = pdata->mem_address;
112 }
113
114 if (!mem_size) {
115 printk(KERN_ERR "ramoops: invalid size specification"); 114 printk(KERN_ERR "ramoops: invalid size specification");
116 goto fail3; 115 goto fail3;
117 } 116 }
118 117
119 rounddown_pow_of_two(mem_size); 118 rounddown_pow_of_two(pdata->mem_size);
120 119
121 if (mem_size < RECORD_SIZE) { 120 if (pdata->mem_size < RECORD_SIZE) {
122 printk(KERN_ERR "ramoops: size too small"); 121 printk(KERN_ERR "ramoops: size too small");
123 goto fail3; 122 goto fail3;
124 } 123 }
125 124
126 cxt->max_count = mem_size / RECORD_SIZE; 125 cxt->max_count = pdata->mem_size / RECORD_SIZE;
127 cxt->count = 0; 126 cxt->count = 0;
128 cxt->size = mem_size; 127 cxt->size = pdata->mem_size;
129 cxt->phys_addr = mem_address; 128 cxt->phys_addr = pdata->mem_address;
130 129
131 if (!request_mem_region(cxt->phys_addr, cxt->size, "ramoops")) { 130 if (!request_mem_region(cxt->phys_addr, cxt->size, "ramoops")) {
132 printk(KERN_ERR "ramoops: request mem region failed"); 131 printk(KERN_ERR "ramoops: request mem region failed");
@@ -179,12 +178,36 @@ static struct platform_driver ramoops_driver = {
179 178
180static int __init ramoops_init(void) 179static int __init ramoops_init(void)
181{ 180{
182 return platform_driver_probe(&ramoops_driver, ramoops_probe); 181 int ret;
182 ret = platform_driver_probe(&ramoops_driver, ramoops_probe);
183 if (ret == -ENODEV) {
184 /*
185 * If we didn't find a platform device, we use module parameters
186 * building platform data on the fly.
187 */
188 dummy_data = kzalloc(sizeof(struct ramoops_platform_data),
189 GFP_KERNEL);
190 if (!dummy_data)
191 return -ENOMEM;
192 dummy_data->mem_size = mem_size;
193 dummy_data->mem_address = mem_address;
194 dummy = platform_create_bundle(&ramoops_driver, ramoops_probe,
195 NULL, 0, dummy_data,
196 sizeof(struct ramoops_platform_data));
197
198 if (IS_ERR(dummy))
199 ret = PTR_ERR(dummy);
200 else
201 ret = 0;
202 }
203
204 return ret;
183} 205}
184 206
185static void __exit ramoops_exit(void) 207static void __exit ramoops_exit(void)
186{ 208{
187 platform_driver_unregister(&ramoops_driver); 209 platform_driver_unregister(&ramoops_driver);
210 kfree(dummy_data);
188} 211}
189 212
190module_init(ramoops_init); 213module_init(ramoops_init);