Skip to contentSkip to conversation

rtc: pcf50633 fixes (is rtc maintainer around?)

PATCH In review Paul Fertser 2 participants 5 messages Nov 4, 2009 – Nov 10, 2009 Real time clock (RTC)

lore
Share & tools
lore
#0 lore raw

cover rtc: pcf50633 fixes (is rtc maintainer around?)

Hi,

This patch series contains (~obvious) fixes for the rtc part of pcf50633 MFD.

Unfortunately, my previous posting seemingly didn't reach the target, i received no reply from Alessandro Zummo and also [email protected] ML seems to be dead or at least unsuitable (lots of spam, weird way of viewing archives). I omitted LKML the previous time because i thought that since these fixes are so small and not interesting there's no sense in bothering anybody with them.

[PATCH 1/3] rtc: pcf50633: Fix month off-by-one error
[PATCH 2/3] rtc: pcf50633: consider alrm->enable in pcf50633_rtc_set_alarm [PATCH 3/3] rtc: pcf50633: manage RTC alarm "pending" flag

TIA

#1 lore raw

PATCH 1/3 rtc: pcf50633: Fix month off-by-one error

From: Rask Ingemann Lambertsen <[email protected]>

The PCF50633 stores a month value of 1-12, but the kernel wants 0-11.

---
 drivers/rtc/rtc-pcf50633.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/rtc/rtc-pcf50633.c +2 -2
index f4dd87e..77b40dd 100644
@@ -70,7 +70,7 @@ static void pcf2rtc_time(struct rtc_time *rtc, struct pcf50633_time *pcf)
 	rtc->tm_hour = bcd2bin(pcf->time[PCF50633_TI_HOUR]);
 	rtc->tm_wday = bcd2bin(pcf->time[PCF50633_TI_WKDAY]);
 	rtc->tm_mday = bcd2bin(pcf->time[PCF50633_TI_DAY]);
-	rtc->tm_mon = bcd2bin(pcf->time[PCF50633_TI_MONTH]);
+	rtc->tm_mon = bcd2bin(pcf->time[PCF50633_TI_MONTH]) - 1;
 	rtc->tm_year = bcd2bin(pcf->time[PCF50633_TI_YEAR]) + 100;
 }
 
@@ -81,7 +81,7 @@ static void rtc2pcf_time(struct pcf50633_time *pcf, struct rtc_time *rtc)
 	pcf->time[PCF50633_TI_HOUR] = bin2bcd(rtc->tm_hour);
 	pcf->time[PCF50633_TI_WKDAY] = bin2bcd(rtc->tm_wday);
 	pcf->time[PCF50633_TI_DAY] = bin2bcd(rtc->tm_mday);
-	pcf->time[PCF50633_TI_MONTH] = bin2bcd(rtc->tm_mon);
+	pcf->time[PCF50633_TI_MONTH] = bin2bcd(rtc->tm_mon + 1);
 	pcf->time[PCF50633_TI_YEAR] = bin2bcd(rtc->tm_year % 100);
 }
 
Signature · 1 line
1.6.0.6
#2 lore raw

PATCH 2/3 rtc: pcf50633: consider alrm->enable in pcf50633_rtc_set_alarm

From: Werner Almesberger <[email protected]>

According to Documentation/rtc.txt, RTC_WKALM_SET sets the alarm time and enables/disables the alarm. We implement RTC_WKALM_SET through pcf50633_rtc_set_alarm. The enabling/disabling part was missing.

---
 drivers/rtc/rtc-pcf50633.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/rtc/rtc-pcf50633.c +2 -1
index 77b40dd..33a10c4 100644
@@ -245,8 +245,9 @@ static int pcf50633_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
 	ret = pcf50633_write_block(rtc->pcf, PCF50633_REG_RTCSCA,
 				PCF50633_TI_EXTENT, &pcf_tm.time[0]);
 
-	if (!alarm_masked)
+	if (!alarm_masked || alrm->enabled)
 		pcf50633_irq_unmask(rtc->pcf, PCF50633_IRQ_ALARM);
+	rtc->alarm_enabled = alrm->enabled;
 
 	return ret;
 }
Signature · 1 line
1.6.0.6
#3 lore raw

PATCH 3/3 rtc: pcf50633: manage RTC alarm "pending" flag

From: Werner Almesberger <[email protected]>

This patch adds setting and clearing of the "pending" flag of the RTC alarm. The semantics follow the UEFI specification 2.2 available at http://www.uefi.org/specs/, i.e., the "pending" flag is cleared by disabling the alarm, but not by any other condition (such as the passing of time, a successful wakeup, or setting of a new alarm.)

---
 drivers/rtc/rtc-pcf50633.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
drivers/rtc/rtc-pcf50633.c +5 -0
index 33a10c4..8669815 100644
@@ -58,6 +58,7 @@ struct pcf50633_time {
 struct pcf50633_rtc {
 	int alarm_enabled;
 	int second_enabled;
+	int alarm_pending;
 
 	struct pcf50633 *pcf;
 	struct rtc_device *rtc_dev;
@@ -209,6 +210,7 @@ static int pcf50633_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
 	rtc = dev_get_drvdata(dev);
 
 	alrm->enabled = rtc->alarm_enabled;
+	alrm->pending = rtc->alarm_pending;
 
 	ret = pcf50633_read_block(rtc->pcf, PCF50633_REG_RTCSCA,
 				PCF50633_TI_EXTENT, &pcf_tm.time[0]);
@@ -244,6 +246,8 @@ static int pcf50633_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
 	/* Returns 0 on success */
 	ret = pcf50633_write_block(rtc->pcf, PCF50633_REG_RTCSCA,
 				PCF50633_TI_EXTENT, &pcf_tm.time[0]);
+	if (!alrm->enabled)
+		rtc->alarm_pending = 0;
 
 	if (!alarm_masked || alrm->enabled)
 		pcf50633_irq_unmask(rtc->pcf, PCF50633_IRQ_ALARM);
@@ -268,6 +272,7 @@ static void pcf50633_rtc_irq(int irq, void *data)
 	switch (irq) {
 	case PCF50633_IRQ_ALARM:
 		rtc_update_irq(rtc->rtc_dev, 1, RTC_AF | RTC_IRQF);
+		rtc->alarm_pending = 1;
 		break;
 	case PCF50633_IRQ_SECOND:
 		rtc_update_irq(rtc->rtc_dev, 1, RTC_UF | RTC_IRQF);
Signature · 1 line
1.6.0.6
#4 lore raw
In reply to Paul Fertser
Quoted 3 lines · On Thu, 5 Nov 2009 00:55:14 +0300 Paul Fertser <[email protected]> wrote:

[PATCH 1/3] rtc: pcf50633: Fix month off-by-one error
[PATCH 2/3] rtc: pcf50633: consider alrm->enable in pcf50633_rtc_set_alarm [PATCH 3/3] rtc: pcf50633: manage RTC alarm "pending" flag

I queued 1 and 2 for 2.6.32 (but not 2.6.31.x or earlier). I queued 3 for 2.6.33.

If that was inappropriate then please let me know, with the reasons.