From: Marco Stornelli <marco.stornelli@gmail.com>
To: Linux Kernel <linux-kernel@vger.kernel.org>
Cc: kyungmin.park@samsung.com, stevie.trujillo@gmail.com,
xiyou.wangcong@gmail.com
Subject: [PATCH] ramoops: use module parameters instead of platform data if not available
Date: Sat, 28 May 2011 11:01:12 +0200 [thread overview]
Message-ID: <4DE0B9D8.3020405@gmail.com> (raw)
From: Marco Stornelli <marco.stornelli@gmail.com>
Use generic module parameters instead of platform data, if platform
data are not available. This limitation has been introduced with
commit c3b92ce9e75f6353104fc7f8e32fb9fdb2550ad0.
Signed-off-by: Marco Stornelli <marco.stornelli@gmail.com>
CC: Kyungmin Park <kyungmin.park@samsung.com>
Reported-by: Stevie Trujillo <stevie.trujillo@gmail.com>
---
diff --git a/drivers/char/ramoops.c b/drivers/char/ramoops.c
index 1a9f5f6..a201f81 100644
--- a/drivers/char/ramoops.c
+++ b/drivers/char/ramoops.c
@@ -26,6 +26,7 @@
#include <linux/io.h>
#include <linux/ioport.h>
#include <linux/platform_device.h>
+#include <linux/slab.h>
#include <linux/ramoops.h>
#define RAMOOPS_KERNMSG_HDR "===="
@@ -56,6 +57,9 @@ static struct ramoops_context {
int max_count;
} oops_cxt;
+static struct platform_device *dummy;
+static struct ramoops_platform_data *dummy_data;
+
static void ramoops_do_dump(struct kmsg_dumper *dumper,
enum kmsg_dump_reason reason, const char *s1, unsigned long l1,
const char *s2, unsigned long l2)
@@ -106,27 +110,22 @@ static int __init ramoops_probe(struct platform_device *pdev)
struct ramoops_context *cxt = &oops_cxt;
int err = -EINVAL;
- if (pdata) {
- mem_size = pdata->mem_size;
- mem_address = pdata->mem_address;
- }
-
- if (!mem_size) {
+ if (!pdata->mem_size) {
printk(KERN_ERR "ramoops: invalid size specification");
goto fail3;
}
- rounddown_pow_of_two(mem_size);
+ rounddown_pow_of_two(pdata->mem_size);
- if (mem_size < RECORD_SIZE) {
+ if (pdata->mem_size < RECORD_SIZE) {
printk(KERN_ERR "ramoops: size too small");
goto fail3;
}
- cxt->max_count = mem_size / RECORD_SIZE;
+ cxt->max_count = pdata->mem_size / RECORD_SIZE;
cxt->count = 0;
- cxt->size = mem_size;
- cxt->phys_addr = mem_address;
+ cxt->size = pdata->mem_size;
+ cxt->phys_addr = pdata->mem_address;
if (!request_mem_region(cxt->phys_addr, cxt->size, "ramoops")) {
printk(KERN_ERR "ramoops: request mem region failed");
@@ -179,12 +178,34 @@ static struct platform_driver ramoops_driver = {
static int __init ramoops_init(void)
{
- return platform_driver_probe(&ramoops_driver, ramoops_probe);
+ int ret;
+ ret = platform_driver_probe(&ramoops_driver, ramoops_probe);
+ if (ret == -ENODEV)
+ {
+ /*
+ * if we didn't find a platform device, we use module parameters
+ * building platform data on the fly.
+ */
+ dummy_data = (struct ramoops_platform_data *)
+ kzalloc(sizeof(struct ramoops_platform_data), GFP_KERNEL);
+ dummy_data->mem_size = mem_size;
+ dummy_data->mem_address = mem_address;
+ dummy = platform_create_bundle(&ramoops_driver, ramoops_probe, NULL,
+ 0, dummy_data, sizeof(struct ramoops_platform_data));
+
+ if (IS_ERR(dummy))
+ ret = PTR_ERR(dummy);
+ else
+ ret = 0;
+ }
+
+ return ret;
}
static void __exit ramoops_exit(void)
{
platform_driver_unregister(&ramoops_driver);
+ kfree(dummy_data);
}
module_init(ramoops_init);
next reply other threads:[~2011-05-28 9:07 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-28 9:01 Marco Stornelli [this message]
2011-05-28 10:05 ` [PATCH] ramoops: use module parameters instead of platform data if not available Stevie Trujillo
2011-05-28 14:18 ` Marco Stornelli
2011-05-28 14:48 ` [PATCH 1/2 v2] " Marco Stornelli
2011-06-06 16:02 ` Américo Wang
2011-06-07 16:49 ` [PATCH 1/2 v3] " Marco Stornelli
2011-06-08 16:01 ` Américo Wang
2011-06-08 19:52 ` Marco Stornelli
2011-06-09 0:59 ` Stephen Rothwell
2011-06-09 1:02 ` Américo Wang
2011-06-09 6:46 ` Marco Stornelli
2011-06-18 14:01 ` Marco Stornelli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4DE0B9D8.3020405@gmail.com \
--to=marco.stornelli@gmail.com \
--cc=kyungmin.park@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stevie.trujillo@gmail.com \
--cc=xiyou.wangcong@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox