Ramoops: use the platform data structure instead of module params
PATCH 1/1 Ramoops: use the platform data structure instead of module params
From: Kyungmin Park <[email protected]>
As each board and system has different memory for ramoops. It's better to define the platform data instead of module params.
---
drivers/char/ramoops.c +27 -2
@@ -25,6 +25,8 @@#include <linux/time.h> #include <linux/io.h> #include <linux/ioport.h> +#include <linux/platform_device.h> +#include <linux/ramoops.h> #define RAMOOPS_KERNMSG_HDR "===="#define RAMOOPS_HEADER_SIZE (5 + sizeof(struct timeval))
@@ -91,11 +93,17 @@ static void ramoops_do_dump(struct kmsg_dumper *dumper, cxt->count = (cxt->count +1 ) % cxt->max_count; } -static int __init ramoops_init (void ) +static int __init ramoops_probe (struct platform_device *pdev) { +struct ramoops_platform_data *pdata = pdev->dev.platform_data;struct ramoops_context *cxt = &oops_cxt;int err = -EINVAL ; +if (pdata) { + mem_size = pdata->mem_size; + mem_address = pdata->mem_address; + } +if (!mem_size) {printk (KERN_ERR "ramoops: invalid size specification" ); goto fail3;
@@ -142,7 +150,7 @@ fail3:return err; } -static void __exit ramoops_exit(void) +static void __exit ramoops_remove(void) {struct ramoops_context *cxt = &oops_cxt;
@@ -153,6 +161,23 @@ static void __exit ramoops_exit(void)release_mem_region (cxt->phys_addr, cxt->size); } +static struct platform_driver ramoops_driver = { + .remove =__exit_p (ramoops_remove), + .driver = { + .name ="ramoops" , + .owner =THIS_MODULE , + }, +}; + +static int __init ramoops_init (void ) +{ +return platform_driver_probe (&ramoops_driver, ramoops_probe); +} + +static void __exit ramoops_exit(void) +{ +platform_driver_unregister (&ramoops_driver); +}module_init (ramoops_init);module_exit (ramoops_exit);
include/linux/ramoops.h new file +15 -0
@@ -0,0 +1,15 @@ +#ifndef __RAMOOPS_H +#define __RAMOOPS_H + +/* +* Ramoops platform data +* @mem_size memory size for ramoops +* @mem_address physical memory address to contain ramoops +*/ + +struct ramoops_platform_data { +unsigned long mem_size; +unsigned long mem_address; +}; + +#endif
2010/8/18 Kyungmin Park <[email protected]>:
Quoted 6 lines
From: Kyungmin Park <[email protected]>
As each board and system has different memory for ramoops. It's better to define the platform data instead of module params.
Signed-off-by Kyungmin Park <[email protected]>---
It seems good. Currently there isn't any code that register a ramoops device, isn't it?
Quoted 10 lines · Marco Stornelli
2010/8/18 Kyungmin Park <[email protected]>:
Quoted 6 lines
From: Kyungmin Park <[email protected]>
As each board and system has different memory for ramoops. It's better to define the platform data instead of module params.
Signed-off-by Kyungmin Park <[email protected]>---
It seems good. Currently there isn't any code that register a ramoops device, isn't it?
At this time
I wrote it below
static struct ramoops_platform_data goni_ramoops_data = {
.mem_size = SZ_16K,
.mem_address = 0xED000000, /* MODEM SRAM */
};
static struct platform_device goni_ramoops = {
.name = "ramoops",
.dev = {
.platform_data = &goni_ramoops_data,
},
};Thank you,
Kyungmin Park