Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 281847
b: refs/heads/master
c: 4287475
h: refs/heads/master
i:
  281845: 7bfc774
  281843: 997f951
  281839: e2c9e49
v: v3
  • Loading branch information
Jett.Zhou authored and Arnd Bergmann committed Dec 28, 2011
1 parent 176ec50 commit c987fdf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 42 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9d2d94385327f98ea69c183bb6c1d27cac49abf0
refs/heads/master: 42874759d7494648e42e6e0465fc9c4f3752bba4
53 changes: 12 additions & 41 deletions trunk/drivers/rtc/rtc-sa1100.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,6 @@ static const unsigned long RTC_FREQ = 1024;
static struct rtc_time rtc_alarm;
static DEFINE_SPINLOCK(sa1100_rtc_lock);

static inline int rtc_periodic_alarm(struct rtc_time *tm)
{
return (tm->tm_year == -1) ||
((unsigned)tm->tm_mon >= 12) ||
((unsigned)(tm->tm_mday - 1) >= 31) ||
((unsigned)tm->tm_hour > 23) ||
((unsigned)tm->tm_min > 59) ||
((unsigned)tm->tm_sec > 59);
}

/*
* Calculate the next alarm time given the requested alarm time mask
* and the current time.
Expand Down Expand Up @@ -82,27 +72,6 @@ static void rtc_next_alarm_time(struct rtc_time *next, struct rtc_time *now,
}
}

static int rtc_update_alarm(struct rtc_time *alrm)
{
struct rtc_time alarm_tm, now_tm;
unsigned long now, time;
int ret;

do {
now = RCNR;
rtc_time_to_tm(now, &now_tm);
rtc_next_alarm_time(&alarm_tm, &now_tm, alrm);
ret = rtc_tm_to_time(&alarm_tm, &time);
if (ret != 0)
break;

RTSR = RTSR & (RTSR_HZE|RTSR_ALE|RTSR_AL);
RTAR = time;
} while (now != RCNR);

return ret;
}

static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id)
{
struct platform_device *pdev = to_platform_device(dev_id);
Expand Down Expand Up @@ -146,9 +115,6 @@ static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id)

rtc_update_irq(rtc, 1, events);

if (rtsr & RTSR_AL && rtc_periodic_alarm(&rtc_alarm))
rtc_update_alarm(&rtc_alarm);

spin_unlock(&sa1100_rtc_lock);

return IRQ_HANDLED;
Expand Down Expand Up @@ -234,16 +200,21 @@ static int sa1100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)

static int sa1100_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
{
struct rtc_time now_tm, alarm_tm;
int ret;

spin_lock_irq(&sa1100_rtc_lock);
ret = rtc_update_alarm(&alrm->time);
if (ret == 0) {
if (alrm->enabled)
RTSR |= RTSR_ALE;
else
RTSR &= ~RTSR_ALE;
}

now = RCNR;
rtc_time_to_tm(now, &now_tm);
rtc_next_alarm_time(&alarm_tm, &now_tm, alrm->time);
rtc_tm_to_time(&alarm_tm, &time);
RTAR = time;
if (alrm->enabled)
RTSR |= RTSR_ALE;
else
RTSR &= ~RTSR_ALE;

spin_unlock_irq(&sa1100_rtc_lock);

return ret;
Expand Down

0 comments on commit c987fdf

Please sign in to comment.