diff options
-rw-r--r-- | drivers/char/ramoops.c | 30 | ||||
-rw-r--r-- | include/linux/ramoops.h | 15 |
2 files changed, 43 insertions, 2 deletions
diff --git a/drivers/char/ramoops.c b/drivers/char/ramoops.c index 74f00b5ffa36..73dcb0ee41fd 100644 --- a/drivers/char/ramoops.c +++ b/drivers/char/ramoops.c | |||
@@ -25,6 +25,8 @@ | |||
25 | #include <linux/time.h> | 25 | #include <linux/time.h> |
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> | ||
29 | #include <linux/ramoops.h> | ||
28 | 30 | ||
29 | #define RAMOOPS_KERNMSG_HDR "====" | 31 | #define RAMOOPS_KERNMSG_HDR "====" |
30 | #define RAMOOPS_HEADER_SIZE (5 + sizeof(struct timeval)) | 32 | #define RAMOOPS_HEADER_SIZE (5 + sizeof(struct timeval)) |
@@ -91,11 +93,17 @@ static void ramoops_do_dump(struct kmsg_dumper *dumper, | |||
91 | cxt->count = (cxt->count + 1) % cxt->max_count; | 93 | cxt->count = (cxt->count + 1) % cxt->max_count; |
92 | } | 94 | } |
93 | 95 | ||
94 | static int __init ramoops_init(void) | 96 | static int __init ramoops_probe(struct platform_device *pdev) |
95 | { | 97 | { |
98 | struct ramoops_platform_data *pdata = pdev->dev.platform_data; | ||
96 | struct ramoops_context *cxt = &oops_cxt; | 99 | struct ramoops_context *cxt = &oops_cxt; |
97 | int err = -EINVAL; | 100 | int err = -EINVAL; |
98 | 101 | ||
102 | if (pdata) { | ||
103 | mem_size = pdata->mem_size; | ||
104 | mem_address = pdata->mem_address; | ||
105 | } | ||
106 | |||
99 | if (!mem_size) { | 107 | if (!mem_size) { |
100 | printk(KERN_ERR "ramoops: invalid size specification"); | 108 | printk(KERN_ERR "ramoops: invalid size specification"); |
101 | goto fail3; | 109 | goto fail3; |
@@ -142,7 +150,7 @@ fail3: | |||
142 | return err; | 150 | return err; |
143 | } | 151 | } |
144 | 152 | ||
145 | static void __exit ramoops_exit(void) | 153 | static int __exit ramoops_remove(struct platform_device *pdev) |
146 | { | 154 | { |
147 | struct ramoops_context *cxt = &oops_cxt; | 155 | struct ramoops_context *cxt = &oops_cxt; |
148 | 156 | ||
@@ -151,8 +159,26 @@ static void __exit ramoops_exit(void) | |||
151 | 159 | ||
152 | iounmap(cxt->virt_addr); | 160 | iounmap(cxt->virt_addr); |
153 | release_mem_region(cxt->phys_addr, cxt->size); | 161 | release_mem_region(cxt->phys_addr, cxt->size); |
162 | return 0; | ||
154 | } | 163 | } |
155 | 164 | ||
165 | static struct platform_driver ramoops_driver = { | ||
166 | .remove = __exit_p(ramoops_remove), | ||
167 | .driver = { | ||
168 | .name = "ramoops", | ||
169 | .owner = THIS_MODULE, | ||
170 | }, | ||
171 | }; | ||
172 | |||
173 | static int __init ramoops_init(void) | ||
174 | { | ||
175 | return platform_driver_probe(&ramoops_driver, ramoops_probe); | ||
176 | } | ||
177 | |||
178 | static void __exit ramoops_exit(void) | ||
179 | { | ||
180 | platform_driver_unregister(&ramoops_driver); | ||
181 | } | ||
156 | 182 | ||
157 | module_init(ramoops_init); | 183 | module_init(ramoops_init); |
158 | module_exit(ramoops_exit); | 184 | module_exit(ramoops_exit); |
diff --git a/include/linux/ramoops.h b/include/linux/ramoops.h new file mode 100644 index 000000000000..0ae68a2c1212 --- /dev/null +++ b/include/linux/ramoops.h | |||
@@ -0,0 +1,15 @@ | |||
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 | ||