lkml.org 
[lkml]   [2011]   [Jun]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 1/3] char drivers: ramoops default platform device for module parameter use
Date
The introduction of platform data in ramoops resulted in the need to
define a platform device in order to use the ramoops module with module
parameters (without setting any platform data). Sadly this is not clear or
properly documented.

This patch checks if the module parameters are set and declares a platform
device if they are so that the module can be used with module parameters
without any aditional declarations out of the module.

Change-Id: I3cdb0f8e27852ac79e327e526645c9859f19efa8
Signed-off-by: Sergiu Iordache <sergiu@chromium.org>
---
drivers/char/ramoops.c | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/drivers/char/ramoops.c b/drivers/char/ramoops.c
index 1a9f5f6..0c3cb42 100644
--- a/drivers/char/ramoops.c
+++ b/drivers/char/ramoops.c
@@ -177,13 +177,33 @@ static struct platform_driver ramoops_driver = {
},
};

+struct platform_device *ramoops_device;
+
static int __init ramoops_init(void)
{
+ /*
+ * If mem_address and mem_size are set (i.e. the module parameters
+ * are used) then a default platform driver is created
+ * as there is no need to configure the platform data elsewhere.
+ */
+ if (mem_address && mem_size) {
+ ramoops_device = platform_device_register_simple("ramoops",
+ -1, NULL, 0);
+
+ if (IS_ERR(ramoops_device)) {
+ printk(KERN_ERR "Unable to register platform device\n");
+ return PTR_ERR(ramoops_device);
+ }
+ }
+
return platform_driver_probe(&ramoops_driver, ramoops_probe);
}

static void __exit ramoops_exit(void)
{
+ /* Unregister the device if it was set */
+ if (ramoops_device)
+ platform_device_unregister(ramoops_device);
platform_driver_unregister(&ramoops_driver);
}

--
1.7.3.1


\
 
 \ /
  Last update: 2011-06-28 03:25    [W:0.199 / U:0.048 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site