From patchwork Thu Nov 8 12:41:33 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [1/2] rtc: sa1100: enable clk and request irq when probe From: Leo Song X-Patchwork-Id: 197833 Message-Id: <1352378494-23942-1-git-send-email-liangs@marvell.com> To: Alessandro Zummo , Cc: Leo Song , Yi Zhang Date: Thu, 8 Nov 2012 20:41:33 +0800 From: Yi Zhang remove the open(), add clk enable and irq request to probe(); remove the function of release() to remove() Change-Id: I18b0e6e3c1fc0e393161e0b47cc2df9985665efb Signed-off-by: Yi Zhang --- drivers/rtc/Makefile | 2 +- drivers/rtc/rtc-sa1100.c | 78 ++++++++++++++++++--------------------------- 2 files changed, 32 insertions(+), 48 deletions(-) diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile index 56297f0..ecbb21b 100644 --- a/drivers/rtc/Makefile +++ b/drivers/rtc/Makefile @@ -15,6 +15,7 @@ rtc-core-$(CONFIG_RTC_INTF_SYSFS) += rtc-sysfs.o # Keep the list ordered. +obj-$(CONFIG_RTC_DRV_SA1100) += rtc-sa1100.o obj-$(CONFIG_RTC_DRV_88PM860X) += rtc-88pm860x.o obj-$(CONFIG_RTC_DRV_88PM80X) += rtc-88pm80x.o obj-$(CONFIG_RTC_DRV_AB3100) += rtc-ab3100.o @@ -97,7 +98,6 @@ obj-$(CONFIG_RTC_DRV_RX8025) += rtc-rx8025.o obj-$(CONFIG_RTC_DRV_RX8581) += rtc-rx8581.o obj-$(CONFIG_RTC_DRV_S35390A) += rtc-s35390a.o obj-$(CONFIG_RTC_DRV_S3C) += rtc-s3c.o -obj-$(CONFIG_RTC_DRV_SA1100) += rtc-sa1100.o obj-$(CONFIG_RTC_DRV_SH) += rtc-sh.o obj-$(CONFIG_RTC_DRV_SNVS) += rtc-snvs.o obj-$(CONFIG_RTC_DRV_SPEAR) += rtc-spear.o diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c index 50a5c4a..25ac904 100644 --- a/drivers/rtc/rtc-sa1100.c +++ b/drivers/rtc/rtc-sa1100.c @@ -102,51 +102,6 @@ static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id) return IRQ_HANDLED; } -static int sa1100_rtc_open(struct device *dev) -{ - struct sa1100_rtc *info = dev_get_drvdata(dev); - struct rtc_device *rtc = info->rtc; - int ret; - - ret = clk_prepare_enable(info->clk); - if (ret) - goto fail_clk; - ret = request_irq(info->irq_1hz, sa1100_rtc_interrupt, 0, "rtc 1Hz", dev); - if (ret) { - dev_err(dev, "IRQ %d already in use.\n", info->irq_1hz); - goto fail_ui; - } - ret = request_irq(info->irq_alarm, sa1100_rtc_interrupt, 0, "rtc Alrm", dev); - if (ret) { - dev_err(dev, "IRQ %d already in use.\n", info->irq_alarm); - goto fail_ai; - } - rtc->max_user_freq = RTC_FREQ; - rtc_irq_set_freq(rtc, NULL, RTC_FREQ); - - return 0; - - fail_ai: - free_irq(info->irq_1hz, dev); - fail_ui: - clk_disable_unprepare(info->clk); - fail_clk: - return ret; -} - -static void sa1100_rtc_release(struct device *dev) -{ - struct sa1100_rtc *info = dev_get_drvdata(dev); - - spin_lock_irq(&info->lock); - RTSR = 0; - spin_unlock_irq(&info->lock); - - free_irq(info->irq_alarm, dev); - free_irq(info->irq_1hz, dev); - clk_disable_unprepare(info->clk); -} - static int sa1100_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) { struct sa1100_rtc *info = dev_get_drvdata(dev); @@ -218,8 +173,6 @@ static int sa1100_rtc_proc(struct device *dev, struct seq_file *seq) } static const struct rtc_class_ops sa1100_rtc_ops = { - .open = sa1100_rtc_open, - .release = sa1100_rtc_release, .read_time = sa1100_rtc_read_time, .set_time = sa1100_rtc_set_time, .read_alarm = sa1100_rtc_read_alarm, @@ -303,7 +256,30 @@ static int sa1100_rtc_probe(struct platform_device *pdev) * the corresponding bits in RTSR. */ RTSR = RTSR_AL | RTSR_HZ; + ret = clk_prepare_enable(info->clk); + if (ret) + goto err_nortc; + ret = request_irq(info->irq_1hz, sa1100_rtc_interrupt, 0, "rtc 1Hz", &pdev->dev); + if (ret) { + dev_err(&pdev->dev, "IRQ %d already in use.\n", info->irq_1hz); + goto err_ui; + } + ret = request_irq(info->irq_alarm, sa1100_rtc_interrupt, 0, "rtc Alrm", &pdev->dev); + if (ret) { + dev_err(&pdev->dev, "IRQ %d already in use.\n", info->irq_alarm); + goto err_ai; + } + rtc->max_user_freq = RTC_FREQ; + rtc_irq_set_freq(rtc, NULL, RTC_FREQ); + return 0; + +err_ai: + free_irq(info->irq_1hz, &pdev->dev); +err_ui: + clk_disable_unprepare(info->clk); +err_nortc: + rtc_device_unregister(info->rtc); err_dev: platform_set_drvdata(pdev, NULL); clk_put(info->clk); @@ -317,6 +293,14 @@ static int sa1100_rtc_remove(struct platform_device *pdev) struct sa1100_rtc *info = platform_get_drvdata(pdev); if (info) { + spin_lock_irq(&info->lock); + RTSR = 0; + spin_unlock_irq(&info->lock); + + free_irq(info->irq_alarm, &pdev->dev); + free_irq(info->irq_1hz, &pdev->dev); + clk_disable_unprepare(info->clk); + rtc_device_unregister(info->rtc); clk_put(info->clk); platform_set_drvdata(pdev, NULL);