History

ramoops: use module parameters instead of platform data if not available

Use generic module parameters instead of platform data, if platform data are not available. This limitation has been introduced with commit c3b92ce9e75 ("ramoops: use the platform data structure instead of module params"). [akpm@linux-foundation.org: coding-style fixes] Signed-off-by: Marco Stornelli <marco.stornelli@gmail.com> Cc: Kyungmin Park <kyungmin.park@samsung.com> Cc: Américo Wang <xiyou.wangcong@gmail.com> Reported-by: Stevie Trujillo <stevie.trujillo@gmail.com> Cc: Joe Perches <joe@perches.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Marco Stornelli committed 15 years ago

Commit 13aefd71 parent beda94d1 file · +35 −12Browse files

Showing the changes to drivers/char (1 of 1 file). Show all

Unified · Split

drivers/char/ramoops.c+35−12
@@ -26,6 +26,7 @@ · 25 unmodified lines
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 { · 24 unmodified lines
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) · 44 unmodified lines
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 = { · 46 unmodified lines
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);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t