summaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-pcap.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/rtc/rtc-pcap.c')
-rw-r--r--drivers/rtc/rtc-pcap.c53
1 files changed, 16 insertions, 37 deletions
diff --git a/drivers/rtc/rtc-pcap.c b/drivers/rtc/rtc-pcap.c
index e0019cd0bf71..539a90b98bc5 100644
--- a/drivers/rtc/rtc-pcap.c
+++ b/drivers/rtc/rtc-pcap.c
@@ -139,13 +139,14 @@ static const struct rtc_class_ops pcap_rtc_ops = {
.alarm_irq_enable = pcap_rtc_alarm_irq_enable,
};
-static int pcap_rtc_probe(struct platform_device *pdev)
+static int __init pcap_rtc_probe(struct platform_device *pdev)
{
struct pcap_rtc *pcap_rtc;
int timer_irq, alarm_irq;
int err = -ENOMEM;
- pcap_rtc = kmalloc(sizeof(struct pcap_rtc), GFP_KERNEL);
+ pcap_rtc = devm_kzalloc(&pdev->dev, sizeof(struct pcap_rtc),
+ GFP_KERNEL);
if (!pcap_rtc)
return err;
@@ -153,68 +154,46 @@ static int pcap_rtc_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, pcap_rtc);
- pcap_rtc->rtc = rtc_device_register("pcap", &pdev->dev,
- &pcap_rtc_ops, THIS_MODULE);
+ pcap_rtc->rtc = devm_rtc_device_register(&pdev->dev, "pcap",
+ &pcap_rtc_ops, THIS_MODULE);
if (IS_ERR(pcap_rtc->rtc)) {
err = PTR_ERR(pcap_rtc->rtc);
- goto fail_rtc;
+ goto fail;
}
-
timer_irq = pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_1HZ);
alarm_irq = pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_TODA);
- err = request_irq(timer_irq, pcap_rtc_irq, 0, "RTC Timer", pcap_rtc);
+ err = devm_request_irq(&pdev->dev, timer_irq, pcap_rtc_irq, 0,
+ "RTC Timer", pcap_rtc);
if (err)
- goto fail_timer;
+ goto fail;
- err = request_irq(alarm_irq, pcap_rtc_irq, 0, "RTC Alarm", pcap_rtc);
+ err = devm_request_irq(&pdev->dev, alarm_irq, pcap_rtc_irq, 0,
+ "RTC Alarm", pcap_rtc);
if (err)
- goto fail_alarm;
+ goto fail;
return 0;
-fail_alarm:
- free_irq(timer_irq, pcap_rtc);
-fail_timer:
- rtc_device_unregister(pcap_rtc->rtc);
-fail_rtc:
+fail:
platform_set_drvdata(pdev, NULL);
- kfree(pcap_rtc);
return err;
}
-static int pcap_rtc_remove(struct platform_device *pdev)
+static int __exit pcap_rtc_remove(struct platform_device *pdev)
{
- struct pcap_rtc *pcap_rtc = platform_get_drvdata(pdev);
-
- free_irq(pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_1HZ), pcap_rtc);
- free_irq(pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_TODA), pcap_rtc);
- rtc_device_unregister(pcap_rtc->rtc);
- kfree(pcap_rtc);
-
return 0;
}
static struct platform_driver pcap_rtc_driver = {
- .remove = pcap_rtc_remove,
+ .remove = __exit_p(pcap_rtc_remove),
.driver = {
.name = "pcap-rtc",
.owner = THIS_MODULE,
},
};
-static int __init rtc_pcap_init(void)
-{
- return platform_driver_probe(&pcap_rtc_driver, pcap_rtc_probe);
-}
-
-static void __exit rtc_pcap_exit(void)
-{
- platform_driver_unregister(&pcap_rtc_driver);
-}
-
-module_init(rtc_pcap_init);
-module_exit(rtc_pcap_exit);
+module_platform_driver_probe(pcap_rtc_driver, pcap_rtc_probe);
MODULE_DESCRIPTION("Motorola pcap rtc driver");
MODULE_AUTHOR("guiming zhuo <gmzhuo@gmail.com>");
OpenPOWER on IntegriCloud