rtc: tegra: cleanups to remove warning/code lines
Subsystems (2)
cover rtc: tegra: cleanups to remove warning/code lines
This patch series does the cleanups in the rtc driver as follows:
- Protect suspend/resume with CONFIG_PM_SLEEP.
- Use dev_pm_ops in place of legacy way for suspend/resume.
- Properly reflect teh irq name when doing cat /proc/interrupts.
- Use module_platform_probe() to remove boilerplate code.
- use devm_rtc_device_register.
Laxman Dewangan (5):
rtc: tegra: protect suspend/resume callbacks with CONFIG_PM_SLEEP
rtc: tegra: Use struct dev_pm_ops for power management
rtc: tegra: use module_platform_driver_probe for module init/exit
rtc: tegra: set irq name as device name
rtc: tegra: use managed rtc_device_register
drivers/rtc/rtc-tegra.c | 62 ++++++++++++---------------------------------- 1 files changed, 16 insertions(+), 46 deletions(-)
PATCH 1/5 rtc: tegra: protect suspend/resume callbacks with CONFIG_PM_SLEEP
The CONFIG_PM doesn't actually enable any of the PM callbacks, it only allows to enable CONFIG_PM_SLEEP and CONFIG_PM_RUNTIME. This means if CONFIG_PM is used to protect system sleep callbacks then it may end up unreferenced if only runtime PM is enabled. Hence protecting sleep callbacks with CONFIG_PM_SLEEP.
--- drivers/rtc/rtc-tegra.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/rtc/rtc-tegra.c +2 -2
@@ -390,7 +390,7 @@ static int __exit tegra_rtc_remove(struct platform_device *pdev)return 0 ; } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP static int tegra_rtc_suspend (struct platform_device *pdev,pm_message_t state) {struct device *dev = &pdev->dev;
@@ -446,7 +446,7 @@ static struct platform_driver tegra_rtc_driver = { .owner = THIS_MODULE, .of_match_table = tegra_rtc_dt_match, }, -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP .suspend = tegra_rtc_suspend, .resume = tegra_rtc_resume,#endif
Signature · 1 line
1.7.1.1
PATCH 2/5 rtc: tegra: Use struct dev_pm_ops for power management
In reply to Laxman DewanganMake the Tegra RTC controller driver define its PM callbacks through a struct dev_pm_ops object rather than by using legacy PM hooks in struct platform_driver.
--- drivers/rtc/rtc-tegra.c | 19 +++++++++---------- 1 files changed, 9 insertions(+), 10 deletions(-)
drivers/rtc/rtc-tegra.c +9 -10
@@ -391,10 +391,9 @@ static int __exit tegra_rtc_remove(struct platform_device *pdev) }#ifdef CONFIG_PM_SLEEP -static int tegra_rtc_suspend (struct platform_device *pdev,pm_message_t state) +static int tegra_rtc_suspend (struct device *dev) { -struct device *dev = &pdev->dev; -struct tegra_rtc_info *info =platform_get_drvdata (pdev); +struct tegra_rtc_info *info =dev_get_drvdata (dev);tegra_rtc_wait_while_busy (dev);
@@ -416,10 +415,9 @@ static int tegra_rtc_suspend(struct platform_device *pdev, pm_message_t state)return 0 ; } -static int tegra_rtc_resume (struct platform_device *pdev) +static int tegra_rtc_resume (struct device *dev) { -struct device *dev = &pdev->dev; -struct tegra_rtc_info *info =platform_get_drvdata (pdev); +struct tegra_rtc_info *info =dev_get_drvdata (dev);dev_vdbg (dev,"Resume (device_may_wakeup=%d)\n" ,device_may_wakeup (dev));
@@ -431,6 +429,10 @@ static int tegra_rtc_resume(struct platform_device *pdev) }#endif +static const struct dev_pm_ops tegra_rtc_pm_ops = { +SET_SYSTEM_SLEEP_PM_OPS (tegra_rtc_suspend, tegra_rtc_resume) +}; +static void tegra_rtc_shutdown (struct platform_device *pdev) {dev_vdbg (&pdev->dev,"disabling interrupts.\n" );
@@ -445,11 +447,8 @@ static struct platform_driver tegra_rtc_driver = { .name = "tegra_rtc", .owner = THIS_MODULE, .of_match_table = tegra_rtc_dt_match, + .pm = &tegra_rtc_pm_ops, }, -#ifdef CONFIG_PM_SLEEP - .suspend = tegra_rtc_suspend, - .resume = tegra_rtc_resume, -#endif };static int __init tegra_rtc_init (void )
Signature · 1 line
1.7.1.1
PATCH 3/5 rtc: tegra: use module_platform_driver_probe for module init/exit
In reply to Laxman DewanganUse macro module_platform_driver_probe() to reduce some of the boilerplate code in the driver.
--- drivers/rtc/rtc-tegra.c | 12 +----------- 1 files changed, 1 insertions(+), 11 deletions(-)
drivers/rtc/rtc-tegra.c +1 -11
@@ -451,17 +451,7 @@ static struct platform_driver tegra_rtc_driver = { }, }; -static int __init tegra_rtc_init (void ) -{ -return platform_driver_probe (&tegra_rtc_driver, tegra_rtc_probe); -} -module_init (tegra_rtc_init); - -static void __exit tegra_rtc_exit(void) -{ -platform_driver_unregister (&tegra_rtc_driver); -} -module_exit (tegra_rtc_exit); +module_platform_driver_probe (tegra_rtc_driver, tegra_rtc_probe);MODULE_AUTHOR ("Jon Mayo <[email protected]>" );MODULE_DESCRIPTION ("driver for Tegra internal RTC" );
Signature · 1 line
1.7.1.1
PATCH 4/5 rtc: tegra: set irq name as device name
In reply to Laxman DewanganWhen watching the irq name of tegra rtc, it shows as "rtc alarm" which actually does not reflect the name related to driver.
Passing the device name to have the irq names with driver name.
--- drivers/rtc/rtc-tegra.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/rtc/rtc-tegra.c +1 -1
@@ -361,7 +361,7 @@ static int __init tegra_rtc_probe(struct platform_device *pdev) ret =devm_request_irq (&pdev->dev, info->tegra_rtc_irq, tegra_rtc_irq_handler,IRQF_TRIGGER_HIGH , -"rtc alarm" , &pdev->dev); +dev_name (&pdev->dev), &pdev->dev);if (ret) { dev_err(&pdev->dev, "Unable to request interrupt for device (err=%d).\n",
Signature · 1 line
1.7.1.1
Re: [PATCH 1/5] rtc: tegra: protect suspend/resume callbacks with CONFIG_PM_SLEEP
In reply to Laxman DewanganQuoted 10 lines · Laxman Dewangan
The
CONFIG_PMdoesn't actually enable any of the PM callbacks, it only allows to enableCONFIG_PM_SLEEPandCONFIG_PM_RUNTIME. This means ifCONFIG_PMis used to protect system sleep callbacks then it may end up unreferenced if only runtime PM is enabled. Hence protecting sleep callbacks withCONFIG_PM_SLEEP.Signed-off-by Laxman Dewangan <[email protected]>--- drivers/rtc/rtc-tegra.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
Re: [PATCH 2/5] rtc: tegra: Use struct dev_pm_ops for power management
In reply to Laxman DewanganOn Sat, Mar 09, 2013 at 11:39:46PM +0530, Laxman Dewangan wrote:
[...]
drivers/rtc/rtc-tegra.c static int tegra_rtc_resume(struct platform_device *pdev) · line 434
Quoted 7 lines
drivers/rtc/rtc-tegra.c +3
-0@@ -431,6 +429,10 @@ static int tegra_rtc_resume(struct platform_device *pdev) }#endif +static const struct dev_pm_ops tegra_rtc_pm_ops = { +SET_SYSTEM_SLEEP_PM_OPS (tegra_rtc_suspend, tegra_rtc_resume) +};
SIMPLE_DEV_PM_OPS?
Re: [PATCH 3/5] rtc: tegra: use module_platform_driver_probe for module init/exit
In reply to Laxman DewanganQuoted 7 lines · Laxman Dewangan
Use macro
module_platform_driver_probe()to reduce some of the boilerplate code in the driver.Signed-off-by Laxman Dewangan <[email protected]>--- drivers/rtc/rtc-tegra.c | 12 +----------- 1 files changed, 1 insertions(+), 11 deletions(-)
Re: [PATCH 4/5] rtc: tegra: set irq name as device name
In reply to Laxman DewanganQuoted 9 lines · Laxman Dewangan
When watching the irq name of tegra rtc, it shows as "rtc alarm" which actually does not reflect the name related to driver.
Passing the device name to have the irq names with driver name.
Signed-off-by Laxman Dewangan <[email protected]>--- drivers/rtc/rtc-tegra.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
Re: [PATCH 3/5] rtc: tegra: use module_platform_driver_probe for module init/exit
In reply to Laxman DewanganQuoted 18 lines · Laxman Dewangan
Use macro
module_platform_driver_probe()to reduce some of the boilerplate code in the driver.Signed-off-by Laxman Dewangan <[email protected]>--- drivers/rtc/rtc-tegra.c | 12 +----------- 1 files changed, 1 insertions(+), 11 deletions(-)drivers/rtc/rtc-tegra.c +0
-2@@ -451,17 +451,7 @@ static struct platform_driver tegra_rtc_driver = { }, }; -static int __init tegra_rtc_init (void ) -{
drivers/rtc/rtc-tegra.c static struct platform_driver tegra_rtc_driver = { · line 454
Quoted 10 lines
drivers/rtc/rtc-tegra.c +1
-9-return platform_driver_probe (&tegra_rtc_driver, tegra_rtc_probe); -} -module_init (tegra_rtc_init); - -static void __exit tegra_rtc_exit(void) -{ -platform_driver_unregister (&tegra_rtc_driver); -} -module_exit (tegra_rtc_exit); +module_platform_driver_probe (tegra_rtc_driver, tegra_rtc_probe);
Out of curiosity here, why not just module_platform_driver(); can't the instantiation of the RTC device be driven by the presence of the DT node, and hence the creation of the platform device object, just like any other driver/device?
Re: [PATCH 3/5] rtc: tegra: use module_platform_driver_probe for module init/exit
Quoted 17 lines · Stephen Warren
Quoted 16 lines · Laxman Dewangan
Use macro
module_platform_driver_probe()to reduce some of the boilerplate code in the driver.Signed-off-by Laxman Dewangan <[email protected]>--- drivers/rtc/rtc-tegra.c | 12 +----------- 1 files changed, 1 insertions(+), 11 deletions(-)drivers/rtc/rtc-tegra.c +0
-0@@ -451,17 +451,7 @@ static struct platform_driver tegra_rtc_driver = { }, };
Quoted 16 lines
drivers/rtc/rtc-tegra.c static struct platform_driver tegra_rtc_driver = { · line 454
Quoted 12 lines
drivers/rtc/rtc-tegra.c +1
-11-static int __init tegra_rtc_init (void ) -{ -return platform_driver_probe (&tegra_rtc_driver, tegra_rtc_probe); -} -module_init (tegra_rtc_init); - -static void __exit tegra_rtc_exit(void) -{ -platform_driver_unregister (&tegra_rtc_driver); -} -module_exit (tegra_rtc_exit); +module_platform_driver_probe (tegra_rtc_driver, tegra_rtc_probe);Out of curiosity here, why not just
module_platform_driver(); can't the instantiation of the RTC device be driven by the presence of the DT node, and hence the creation of the platform device object, just like any other driver/device?
Theoretically it should work but I will work with John (original author) about using the platform_driver_probe(). If he agrees then I will send patch to convert it to module_platform_driver().
Re: [PATCH 3/5] rtc: tegra: use module_platform_driver_probe for module init/exit
Quoted 25 lines · Laxman Dewangan
Quoted 15 lines · Stephen Warren
Quoted 14 lines · Laxman Dewangan
Use macro
module_platform_driver_probe()to reduce some of the boilerplate code in the driver.drivers/rtc/rtc-tegra.c +0
-8-static int __init tegra_rtc_init(void) -{ -return platform_driver_probe (&tegra_rtc_driver, tegra_rtc_probe); -} -module_init (tegra_rtc_init); - -static void __exit tegra_rtc_exit(void) -{ -platform_driver_unregister (&tegra_rtc_driver);Quoted 8 lines
drivers/rtc/rtc-tegra.c static struct platform_driver tegra_rtc_driver = { · line 454
Quoted 3 lines
drivers/rtc/rtc-tegra.c +1
-2-} -module_exit (tegra_rtc_exit); +module_platform_driver_probe (tegra_rtc_driver, tegra_rtc_probe);Out of curiosity here, why not just
module_platform_driver(); can't the instantiation of the RTC device be driven by the presence of the DT node, and hence the creation of the platform device object, just like any other driver/device?
Quoted 4 lines
Theoretically it should work but I will work with John (original author) about using the
platform_driver_probe().
If he agrees then I will send patch to convert it tomodule_platform_driver().
OK, sounds good. Thanks.