diff options
Diffstat (limited to 'drivers/rtc/rtc-stmp3xxx.c')
-rw-r--r-- | drivers/rtc/rtc-stmp3xxx.c | 57 |
1 files changed, 21 insertions, 36 deletions
diff --git a/drivers/rtc/rtc-stmp3xxx.c b/drivers/rtc/rtc-stmp3xxx.c index 98f0d3c3073..483ce086990 100644 --- a/drivers/rtc/rtc-stmp3xxx.c +++ b/drivers/rtc/rtc-stmp3xxx.c @@ -30,8 +30,6 @@ #include <linux/stmp_device.h> #include <linux/stmp3xxx_rtc_wdt.h> -#include <mach/common.h> - #define STMP3XXX_RTC_CTRL 0x0 #define STMP3XXX_RTC_CTRL_SET 0x4 #define STMP3XXX_RTC_CTRL_CLR 0x8 @@ -227,11 +225,7 @@ static int stmp3xxx_rtc_remove(struct platform_device *pdev) writel(STMP3XXX_RTC_CTRL_ALARM_IRQ_EN, rtc_data->io + STMP3XXX_RTC_CTRL_CLR); - free_irq(rtc_data->irq_alarm, &pdev->dev); - rtc_device_unregister(rtc_data->rtc); platform_set_drvdata(pdev, NULL); - iounmap(rtc_data->io); - kfree(rtc_data); return 0; } @@ -242,22 +236,20 @@ static int stmp3xxx_rtc_probe(struct platform_device *pdev) struct resource *r; int err; - rtc_data = kzalloc(sizeof *rtc_data, GFP_KERNEL); + rtc_data = devm_kzalloc(&pdev->dev, sizeof(*rtc_data), GFP_KERNEL); if (!rtc_data) return -ENOMEM; r = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!r) { dev_err(&pdev->dev, "failed to get resource\n"); - err = -ENXIO; - goto out_free; + return -ENXIO; } - rtc_data->io = ioremap(r->start, resource_size(r)); + rtc_data->io = devm_ioremap(&pdev->dev, r->start, resource_size(r)); if (!rtc_data->io) { dev_err(&pdev->dev, "ioremap failed\n"); - err = -EIO; - goto out_free; + return -EIO; } rtc_data->irq_alarm = platform_get_irq(pdev, 0); @@ -265,13 +257,12 @@ static int stmp3xxx_rtc_probe(struct platform_device *pdev) if (!(readl(STMP3XXX_RTC_STAT + rtc_data->io) & STMP3XXX_RTC_STAT_RTC_PRESENT)) { dev_err(&pdev->dev, "no device onboard\n"); - err = -ENODEV; - goto out_remap; + return -ENODEV; } platform_set_drvdata(pdev, rtc_data); - mxs_reset_block(rtc_data->io); + stmp_reset_block(rtc_data->io); writel(STMP3XXX_RTC_PERSISTENT0_ALARM_EN | STMP3XXX_RTC_PERSISTENT0_ALARM_WAKE_EN | STMP3XXX_RTC_PERSISTENT0_ALARM_WAKE, @@ -281,56 +272,51 @@ static int stmp3xxx_rtc_probe(struct platform_device *pdev) STMP3XXX_RTC_CTRL_ALARM_IRQ_EN, rtc_data->io + STMP3XXX_RTC_CTRL_CLR); - rtc_data->rtc = rtc_device_register(pdev->name, &pdev->dev, + rtc_data->rtc = devm_rtc_device_register(&pdev->dev, pdev->name, &stmp3xxx_rtc_ops, THIS_MODULE); if (IS_ERR(rtc_data->rtc)) { err = PTR_ERR(rtc_data->rtc); - goto out_remap; + goto out; } - err = request_irq(rtc_data->irq_alarm, stmp3xxx_rtc_interrupt, 0, - "RTC alarm", &pdev->dev); + err = devm_request_irq(&pdev->dev, rtc_data->irq_alarm, + stmp3xxx_rtc_interrupt, 0, "RTC alarm", &pdev->dev); if (err) { dev_err(&pdev->dev, "Cannot claim IRQ%d\n", rtc_data->irq_alarm); - goto out_irq_alarm; + goto out; } stmp3xxx_wdt_register(pdev); return 0; -out_irq_alarm: - rtc_device_unregister(rtc_data->rtc); -out_remap: +out: platform_set_drvdata(pdev, NULL); - iounmap(rtc_data->io); -out_free: - kfree(rtc_data); return err; } -#ifdef CONFIG_PM -static int stmp3xxx_rtc_suspend(struct platform_device *dev, pm_message_t state) +#ifdef CONFIG_PM_SLEEP +static int stmp3xxx_rtc_suspend(struct device *dev) { return 0; } -static int stmp3xxx_rtc_resume(struct platform_device *dev) +static int stmp3xxx_rtc_resume(struct device *dev) { - struct stmp3xxx_rtc_data *rtc_data = platform_get_drvdata(dev); + struct stmp3xxx_rtc_data *rtc_data = dev_get_drvdata(dev); - mxs_reset_block(rtc_data->io); + stmp_reset_block(rtc_data->io); writel(STMP3XXX_RTC_PERSISTENT0_ALARM_EN | STMP3XXX_RTC_PERSISTENT0_ALARM_WAKE_EN | STMP3XXX_RTC_PERSISTENT0_ALARM_WAKE, rtc_data->io + STMP3XXX_RTC_PERSISTENT0_CLR); return 0; } -#else -#define stmp3xxx_rtc_suspend NULL -#define stmp3xxx_rtc_resume NULL #endif +static SIMPLE_DEV_PM_OPS(stmp3xxx_rtc_pm_ops, stmp3xxx_rtc_suspend, + stmp3xxx_rtc_resume); + static const struct of_device_id rtc_dt_ids[] = { { .compatible = "fsl,stmp3xxx-rtc", }, { /* sentinel */ } @@ -340,11 +326,10 @@ MODULE_DEVICE_TABLE(of, rtc_dt_ids); static struct platform_driver stmp3xxx_rtcdrv = { .probe = stmp3xxx_rtc_probe, .remove = stmp3xxx_rtc_remove, - .suspend = stmp3xxx_rtc_suspend, - .resume = stmp3xxx_rtc_resume, .driver = { .name = "stmp3xxx-rtc", .owner = THIS_MODULE, + .pm = &stmp3xxx_rtc_pm_ops, .of_match_table = of_match_ptr(rtc_dt_ids), }, }; |