Skip to content

Commit

Permalink
Merge branch 'fortglx/3.1/tip/timers/rtc' of git://git.linaro.org/peo…
Browse files Browse the repository at this point in the history
…ple/jstultz/linux into timers/urgent
  • Loading branch information
Thomas Gleixner committed Sep 2, 2011
2 parents 6af7e47 + 7e72c68 commit 4862571
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 45 deletions.
2 changes: 1 addition & 1 deletion drivers/rtc/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ int rtc_irq_set_freq(struct rtc_device *rtc, struct rtc_task *task, int freq)
int err = 0;
unsigned long flags;

if (freq <= 0 || freq > 5000)
if (freq <= 0 || freq > RTC_MAX_FREQ)
return -EINVAL;
retry:
spin_lock_irqsave(&rtc->irq_task_lock, flags);
Expand Down
16 changes: 8 additions & 8 deletions drivers/rtc/rtc-ep93xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
*/
struct ep93xx_rtc {
void __iomem *mmio_base;
struct rtc_device *rtc;
};

static int ep93xx_rtc_get_swcomp(struct device *dev, unsigned short *preload,
Expand Down Expand Up @@ -130,7 +131,6 @@ static int __init ep93xx_rtc_probe(struct platform_device *pdev)
{
struct ep93xx_rtc *ep93xx_rtc;
struct resource *res;
struct rtc_device *rtc;
int err;

ep93xx_rtc = devm_kzalloc(&pdev->dev, sizeof(*ep93xx_rtc), GFP_KERNEL);
Expand All @@ -151,12 +151,12 @@ static int __init ep93xx_rtc_probe(struct platform_device *pdev)
return -ENXIO;

pdev->dev.platform_data = ep93xx_rtc;
platform_set_drvdata(pdev, rtc);
platform_set_drvdata(pdev, ep93xx_rtc);

rtc = rtc_device_register(pdev->name,
ep93xx_rtc->rtc = rtc_device_register(pdev->name,
&pdev->dev, &ep93xx_rtc_ops, THIS_MODULE);
if (IS_ERR(rtc)) {
err = PTR_ERR(rtc);
if (IS_ERR(ep93xx_rtc->rtc)) {
err = PTR_ERR(ep93xx_rtc->rtc);
goto exit;
}

Expand All @@ -167,7 +167,7 @@ static int __init ep93xx_rtc_probe(struct platform_device *pdev)
return 0;

fail:
rtc_device_unregister(rtc);
rtc_device_unregister(ep93xx_rtc->rtc);
exit:
platform_set_drvdata(pdev, NULL);
pdev->dev.platform_data = NULL;
Expand All @@ -176,11 +176,11 @@ static int __init ep93xx_rtc_probe(struct platform_device *pdev)

static int __exit ep93xx_rtc_remove(struct platform_device *pdev)
{
struct rtc_device *rtc = platform_get_drvdata(pdev);
struct ep93xx_rtc *ep93xx_rtc = platform_get_drvdata(pdev);

sysfs_remove_group(&pdev->dev.kobj, &ep93xx_rtc_sysfs_files);
platform_set_drvdata(pdev, NULL);
rtc_device_unregister(rtc);
rtc_device_unregister(ep93xx_rtc->rtc);
pdev->dev.platform_data = NULL;

return 0;
Expand Down
2 changes: 2 additions & 0 deletions drivers/rtc/rtc-lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ void rtc_time_to_tm(unsigned long time, struct rtc_time *tm)
time -= tm->tm_hour * 3600;
tm->tm_min = time / 60;
tm->tm_sec = time - tm->tm_min * 60;

tm->tm_isdst = 0;
}
EXPORT_SYMBOL(rtc_time_to_tm);

Expand Down
60 changes: 24 additions & 36 deletions drivers/rtc/rtc-twl.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,14 +362,6 @@ static irqreturn_t twl_rtc_interrupt(int irq, void *rtc)
int res;
u8 rd_reg;

#ifdef CONFIG_LOCKDEP
/* WORKAROUND for lockdep forcing IRQF_DISABLED on us, which
* we don't want and can't tolerate. Although it might be
* friendlier not to borrow this thread context...
*/
local_irq_enable();
#endif

res = twl_rtc_read_u8(&rd_reg, REG_RTC_STATUS_REG);
if (res)
goto out;
Expand Down Expand Up @@ -428,24 +420,12 @@ static struct rtc_class_ops twl_rtc_ops = {
static int __devinit twl_rtc_probe(struct platform_device *pdev)
{
struct rtc_device *rtc;
int ret = 0;
int ret = -EINVAL;
int irq = platform_get_irq(pdev, 0);
u8 rd_reg;

if (irq <= 0)
return -EINVAL;

rtc = rtc_device_register(pdev->name,
&pdev->dev, &twl_rtc_ops, THIS_MODULE);
if (IS_ERR(rtc)) {
ret = PTR_ERR(rtc);
dev_err(&pdev->dev, "can't register RTC device, err %ld\n",
PTR_ERR(rtc));
goto out0;

}

platform_set_drvdata(pdev, rtc);
goto out1;

ret = twl_rtc_read_u8(&rd_reg, REG_RTC_STATUS_REG);
if (ret < 0)
Expand All @@ -462,14 +442,6 @@ static int __devinit twl_rtc_probe(struct platform_device *pdev)
if (ret < 0)
goto out1;

ret = request_irq(irq, twl_rtc_interrupt,
IRQF_TRIGGER_RISING,
dev_name(&rtc->dev), rtc);
if (ret < 0) {
dev_err(&pdev->dev, "IRQ is not free.\n");
goto out1;
}

if (twl_class_is_6030()) {
twl6030_interrupt_unmask(TWL6030_RTC_INT_MASK,
REG_INT_MSK_LINE_A);
Expand All @@ -480,28 +452,44 @@ static int __devinit twl_rtc_probe(struct platform_device *pdev)
/* Check RTC module status, Enable if it is off */
ret = twl_rtc_read_u8(&rd_reg, REG_RTC_CTRL_REG);
if (ret < 0)
goto out2;
goto out1;

if (!(rd_reg & BIT_RTC_CTRL_REG_STOP_RTC_M)) {
dev_info(&pdev->dev, "Enabling TWL-RTC.\n");
rd_reg = BIT_RTC_CTRL_REG_STOP_RTC_M;
ret = twl_rtc_write_u8(rd_reg, REG_RTC_CTRL_REG);
if (ret < 0)
goto out2;
goto out1;
}

/* init cached IRQ enable bits */
ret = twl_rtc_read_u8(&rtc_irq_bits, REG_RTC_INTERRUPTS_REG);
if (ret < 0)
goto out1;

rtc = rtc_device_register(pdev->name,
&pdev->dev, &twl_rtc_ops, THIS_MODULE);
if (IS_ERR(rtc)) {
ret = PTR_ERR(rtc);
dev_err(&pdev->dev, "can't register RTC device, err %ld\n",
PTR_ERR(rtc));
goto out1;
}

ret = request_threaded_irq(irq, NULL, twl_rtc_interrupt,
IRQF_TRIGGER_RISING,
dev_name(&rtc->dev), rtc);
if (ret < 0) {
dev_err(&pdev->dev, "IRQ is not free.\n");
goto out2;
}

return ret;
platform_set_drvdata(pdev, rtc);
return 0;

out2:
free_irq(irq, rtc);
out1:
rtc_device_unregister(rtc);
out0:
out1:
return ret;
}

Expand Down
3 changes: 3 additions & 0 deletions include/linux/rtc.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ struct rtc_pll_info {
#define RTC_AF 0x20 /* Alarm interrupt */
#define RTC_UF 0x10 /* Update interrupt for 1Hz RTC */


#define RTC_MAX_FREQ 8192

#ifdef __KERNEL__

#include <linux/types.h>
Expand Down

0 comments on commit 4862571

Please sign in to comment.