2013-06-06 08:14:18

by Peter Ujfalusi

[permalink] [raw]
Subject: [PATCH v3 1/2] RTC: rtc-twl: Fix rtc_reg_map initialization

Initialize the rtc_reg_map in platform_driver's probe function instead at
module_init time. This way we can make sure that the twl-core has been already
probed and initialized (twl_priv->twl_id is valid) since the platform device
for the RTC driver will be created by the twl-core after it finished it's
init.

Reported-by: Christoph Fritz <[email protected]>
Signed-off-by: Peter Ujfalusi <[email protected]>
Tested-by: Kevin Hilman <[email protected]>
Tested-by: Grygorii Strashko <[email protected]>
---
Hi,

Changes since v2:
- Acked-by and Tested-by added to patches
- Recreated on top of 3.10-rc4

Regards,
Peter

drivers/rtc/rtc-twl.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/rtc/rtc-twl.c b/drivers/rtc/rtc-twl.c
index 8751a52..c9060e9 100644
--- a/drivers/rtc/rtc-twl.c
+++ b/drivers/rtc/rtc-twl.c
@@ -469,6 +469,12 @@ static int twl_rtc_probe(struct platform_device *pdev)
if (irq <= 0)
goto out1;

+ /* Initialize the register map */
+ if (twl_class_is_4030())
+ rtc_reg_map = (u8 *)twl4030_rtc_reg_map;
+ else
+ rtc_reg_map = (u8 *)twl6030_rtc_reg_map;
+
ret = twl_rtc_read_u8(&rd_reg, REG_RTC_STATUS_REG);
if (ret < 0)
goto out1;
@@ -610,11 +616,6 @@ static struct platform_driver twl4030rtc_driver = {

static int __init twl_rtc_init(void)
{
- if (twl_class_is_4030())
- rtc_reg_map = (u8 *) twl4030_rtc_reg_map;
- else
- rtc_reg_map = (u8 *) twl6030_rtc_reg_map;
-
return platform_driver_register(&twl4030rtc_driver);
}
module_init(twl_rtc_init);
--
1.8.2.1


2013-06-06 08:14:26

by Peter Ujfalusi

[permalink] [raw]
Subject: [PATCH v3 2/2] RTC: rtc-twl: Cleanup with module_platform_driver() conversion

Use module_platform_driver() to register the platform driver.

Signed-off-by: Peter Ujfalusi <[email protected]>
Acked-by: Kevin Hilman <[email protected]>
---
drivers/rtc/rtc-twl.c | 12 +-----------
1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/rtc/rtc-twl.c b/drivers/rtc/rtc-twl.c
index c9060e9..e1776fd 100644
--- a/drivers/rtc/rtc-twl.c
+++ b/drivers/rtc/rtc-twl.c
@@ -614,17 +614,7 @@ static struct platform_driver twl4030rtc_driver = {
},
};

-static int __init twl_rtc_init(void)
-{
- return platform_driver_register(&twl4030rtc_driver);
-}
-module_init(twl_rtc_init);
-
-static void __exit twl_rtc_exit(void)
-{
- platform_driver_unregister(&twl4030rtc_driver);
-}
-module_exit(twl_rtc_exit);
+module_platform_driver(twl4030rtc_driver);

MODULE_AUTHOR("Texas Instruments, MontaVista Software");
MODULE_LICENSE("GPL");
--
1.8.2.1