Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 296057
b: refs/heads/master
c: 8e8bbcb
h: refs/heads/master
i:
  296055: 641bed9
v: v3
  • Loading branch information
Haojian Zhuang committed Feb 28, 2012
1 parent 239c9a8 commit 097de0a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3e12ec7714e77010539749bfed5ea11c166095d3
refs/heads/master: 8e8bbcb3685ab809348d300b8e2c1f1ea0294e81
17 changes: 17 additions & 0 deletions trunk/drivers/rtc/rtc-sa1100.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include <linux/platform_device.h>
#include <linux/module.h>
#include <linux/clk.h>
#include <linux/rtc.h>
#include <linux/init.h>
#include <linux/fs.h>
Expand All @@ -48,6 +49,7 @@ struct sa1100_rtc {
int irq_1hz;
int irq_alarm;
struct rtc_device *rtc;
struct clk *clk;
};

static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id)
Expand Down Expand Up @@ -104,6 +106,9 @@ static int sa1100_rtc_open(struct device *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, IRQF_DISABLED,
"rtc 1Hz", dev);
if (ret) {
Expand All @@ -124,6 +129,8 @@ static int sa1100_rtc_open(struct device *dev)
fail_ai:
free_irq(info->irq_1hz, dev);
fail_ui:
clk_disable_unprepare(info->clk);
fail_clk:
return ret;
}

Expand All @@ -137,6 +144,7 @@ static void sa1100_rtc_release(struct device *dev)

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)
Expand Down Expand Up @@ -234,6 +242,12 @@ static int sa1100_rtc_probe(struct platform_device *pdev)
info = kzalloc(sizeof(struct sa1100_rtc), GFP_KERNEL);
if (!info)
return -ENOMEM;
info->clk = clk_get(&pdev->dev, NULL);
if (IS_ERR(info->clk)) {
dev_err(&pdev->dev, "failed to find rtc clock source\n");
ret = PTR_ERR(info->clk);
goto err_clk;
}
info->irq_1hz = irq_1hz;
info->irq_alarm = irq_alarm;
spin_lock_init(&info->lock);
Expand Down Expand Up @@ -292,6 +306,8 @@ static int sa1100_rtc_probe(struct platform_device *pdev)
return 0;
err_dev:
platform_set_drvdata(pdev, NULL);
clk_put(info->clk);
err_clk:
kfree(info);
return ret;
}
Expand All @@ -302,6 +318,7 @@ static int sa1100_rtc_remove(struct platform_device *pdev)

if (info) {
rtc_device_unregister(info->rtc);
clk_put(info->clk);
platform_set_drvdata(pdev, NULL);
kfree(info);
}
Expand Down

0 comments on commit 097de0a

Please sign in to comment.