Skip to contentSkip to conversation

RTC: rtc-twl: Convert to module_platform_driver() and relocate reg_map init

PATCH In review Peter Ujfalusi 2 participants 3 messages Apr 16, 2013 Real time clock (RTC)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RTC: rtc-twl: Convert to module_platform_driver() and relocate reg_map init

Convert the driver to use module_platform_driver() to register the platform driver and relocate the rtc_reg_map initialization to platform driver's probe function.
In this way we can make sure that the twl-core has been already probed since the core driver will create the device at the end of it's probe function.

---
Hi Tony, Alessandro, Christoph,

I think this patch is the correct solution for the issue Christoph reported:
http://www.spinics.net/lists/linux-omap/msg89980.html

We can make sure that the twl-core has been already probed and initialized when the RTC driver tries to pick the correct register map.

Regards,
Peter

 drivers/rtc/rtc-twl.c | 23 +++++++----------------
 1 file changed, 7 insertions(+), 16 deletions(-)
drivers/rtc/rtc-twl.c +7 -16
index 8bc6c80..22b2fd6 100644
@@ -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;
@@ -612,22 +618,7 @@ 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);
-
-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");
Signature · 1 line
1.8.1.5
#1 lore raw

Hi,

Quoted 8 lines · Peter Ujfalusi

Convert the driver to use module_platform_driver() to register the platform driver and relocate the rtc_reg_map initialization to platform driver's probe function.
In this way we can make sure that the twl-core has been already probed since the core driver will create the device at the end of it's probe function.

I think there are two distinct things here. The actual fix for the regmap, and a module_platform_driver cleanup. I would suggest having them in separate patches.

And even if these are combined, I think the patch subject and description should talk about fixing the regmap bug. Now it's rather unclear that an actual bug is being fixed.

Tomi

#2 lore raw

Hi Tomi,

Quoted 12 lines · Tomi Valkeinen

Hi,

Quoted 8 lines · Peter Ujfalusi

Convert the driver to use module_platform_driver() to register the platform driver and relocate the rtc_reg_map initialization to platform driver's probe function.
In this way we can make sure that the twl-core has been already probed since the core driver will create the device at the end of it's probe function.

Quoted 7 lines

I think there are two distinct things here. The actual fix for the regmap, and a module_platform_driver cleanup. I would suggest having them in separate patches.

And even if these are combined, I think the patch subject and description should talk about fixing the regmap bug. Now it's rather unclear that an actual bug is being fixed.

Good point. My thinking was that when I convert the driver to module_platform_driver() the reg map init must be moved to platform_driver's probe anyways.
I'll separate the patch and write a bit better commit message for the first.

Signature · 1 line
Péter