All of lore.kernel.org
 help / color / mirror / Atom feed
* [rtc-linux] [PATCH v3] rtc: rtc-s3c: Set year, month, day value for setting alarm
@ 2015-11-01 11:49 ` Krzysztof Kozlowski
  0 siblings, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2015-11-01 11:49 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni, rtc-linux, linux-kernel
  Cc: Krzysztof Kozlowski, Donggeun Kim, MyungJoo Ham, KyungMin Park

This patch sets year, month, day value for set_alarm function.
The current driver omits to set the values.

This fixes setting wake alarm for dates different than current day.
Without the patch the alarm scheduled for tomorrow would fire today on
chosen time.

Signed-off-by: Donggeun Kim <dg77.kim@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.kim@samsung.com>
Signed-off-by: KyungMin Park <kyungmin.park@samsung.com>
[k.kozlowski: Rebase and test the patch, update commit message]
Signed-off-by: Krzysztof Kozlowski <k.kozlowski.k@gmail.com>

---

Changes since v2:
1. Emails dg77.kim@samsung.com and myungjoo.kim@samsung.com are no
   longer valid.
2. Remove debug code added by mistake.

Changes since v1:
1. Rebase, test, update.
---
 drivers/rtc/rtc-s3c.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c
index 7cc8f73a3fe8..ffb860d18701 100644
--- a/drivers/rtc/rtc-s3c.c
+++ b/drivers/rtc/rtc-s3c.c
@@ -302,6 +302,7 @@ static int s3c_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
 	struct s3c_rtc *info = dev_get_drvdata(dev);
 	struct rtc_time *tm = &alrm->time;
 	unsigned int alrm_en;
+	int year = tm->tm_year - 100;
 
 	dev_dbg(dev, "s3c_rtc_setalarm: %d, %04d.%02d.%02d %02d:%02d:%02d\n",
 		 alrm->enabled,
@@ -328,6 +329,21 @@ static int s3c_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
 		writeb(bin2bcd(tm->tm_hour), info->base + S3C2410_ALMHOUR);
 	}
 
+	if (year < 100 && year >= 0) {
+		alrm_en |= S3C2410_RTCALM_YEAREN;
+		writeb(bin2bcd(year), info->base + S3C2410_ALMYEAR);
+	}
+
+	if (tm->tm_mon < 12 && tm->tm_mon >= 0) {
+		alrm_en |= S3C2410_RTCALM_MONEN;
+		writeb(bin2bcd(tm->tm_mon + 1), info->base + S3C2410_ALMMON);
+	}
+
+	if (tm->tm_mday <= 31 && tm->tm_mday >= 1) {
+		alrm_en |= S3C2410_RTCALM_DAYEN;
+		writeb(bin2bcd(tm->tm_mday), info->base + S3C2410_ALMDATE);
+	}
+
 	dev_dbg(dev, "setting S3C2410_RTCALM to %08x\n", alrm_en);
 
 	writeb(alrm_en, info->base + S3C2410_RTCALM);
-- 
2.1.4

-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v3] rtc: rtc-s3c: Set year, month, day value for setting alarm
@ 2015-11-01 11:49 ` Krzysztof Kozlowski
  0 siblings, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2015-11-01 11:49 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni, rtc-linux, linux-kernel
  Cc: Krzysztof Kozlowski, Donggeun Kim, MyungJoo Ham, KyungMin Park

This patch sets year, month, day value for set_alarm function.
The current driver omits to set the values.

This fixes setting wake alarm for dates different than current day.
Without the patch the alarm scheduled for tomorrow would fire today on
chosen time.

Signed-off-by: Donggeun Kim <dg77.kim@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.kim@samsung.com>
Signed-off-by: KyungMin Park <kyungmin.park@samsung.com>
[k.kozlowski: Rebase and test the patch, update commit message]
Signed-off-by: Krzysztof Kozlowski <k.kozlowski.k@gmail.com>

---

Changes since v2:
1. Emails dg77.kim@samsung.com and myungjoo.kim@samsung.com are no
   longer valid.
2. Remove debug code added by mistake.

Changes since v1:
1. Rebase, test, update.
---
 drivers/rtc/rtc-s3c.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c
index 7cc8f73a3fe8..ffb860d18701 100644
--- a/drivers/rtc/rtc-s3c.c
+++ b/drivers/rtc/rtc-s3c.c
@@ -302,6 +302,7 @@ static int s3c_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
 	struct s3c_rtc *info = dev_get_drvdata(dev);
 	struct rtc_time *tm = &alrm->time;
 	unsigned int alrm_en;
+	int year = tm->tm_year - 100;
 
 	dev_dbg(dev, "s3c_rtc_setalarm: %d, %04d.%02d.%02d %02d:%02d:%02d\n",
 		 alrm->enabled,
@@ -328,6 +329,21 @@ static int s3c_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
 		writeb(bin2bcd(tm->tm_hour), info->base + S3C2410_ALMHOUR);
 	}
 
+	if (year < 100 && year >= 0) {
+		alrm_en |= S3C2410_RTCALM_YEAREN;
+		writeb(bin2bcd(year), info->base + S3C2410_ALMYEAR);
+	}
+
+	if (tm->tm_mon < 12 && tm->tm_mon >= 0) {
+		alrm_en |= S3C2410_RTCALM_MONEN;
+		writeb(bin2bcd(tm->tm_mon + 1), info->base + S3C2410_ALMMON);
+	}
+
+	if (tm->tm_mday <= 31 && tm->tm_mday >= 1) {
+		alrm_en |= S3C2410_RTCALM_DAYEN;
+		writeb(bin2bcd(tm->tm_mday), info->base + S3C2410_ALMDATE);
+	}
+
 	dev_dbg(dev, "setting S3C2410_RTCALM to %08x\n", alrm_en);
 
 	writeb(alrm_en, info->base + S3C2410_RTCALM);
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [rtc-linux] Re: [PATCH v3] rtc: rtc-s3c: Set year, month, day value for setting alarm
  2015-11-01 11:49 ` Krzysztof Kozlowski
@ 2015-11-01 17:34   ` Alexandre Belloni
  -1 siblings, 0 replies; 4+ messages in thread
From: Alexandre Belloni @ 2015-11-01 17:34 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Alessandro Zummo, rtc-linux, linux-kernel, Donggeun Kim,
	MyungJoo Ham, KyungMin Park

On 01/11/2015 at 20:49:04 +0900, Krzysztof Kozlowski wrote :
> This patch sets year, month, day value for set_alarm function.
> The current driver omits to set the values.
> 
> This fixes setting wake alarm for dates different than current day.
> Without the patch the alarm scheduled for tomorrow would fire today on
> chosen time.
> 
> Signed-off-by: Donggeun Kim <dg77.kim@samsung.com>
> Signed-off-by: MyungJoo Ham <myungjoo.kim@samsung.com>
> Signed-off-by: KyungMin Park <kyungmin.park@samsung.com>
> [k.kozlowski: Rebase and test the patch, update commit message]
> Signed-off-by: Krzysztof Kozlowski <k.kozlowski.k@gmail.com>
> 
Applied, many thanks for your reviews.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] rtc: rtc-s3c: Set year, month, day value for setting alarm
@ 2015-11-01 17:34   ` Alexandre Belloni
  0 siblings, 0 replies; 4+ messages in thread
From: Alexandre Belloni @ 2015-11-01 17:34 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Alessandro Zummo, rtc-linux, linux-kernel, Donggeun Kim,
	MyungJoo Ham, KyungMin Park

On 01/11/2015 at 20:49:04 +0900, Krzysztof Kozlowski wrote :
> This patch sets year, month, day value for set_alarm function.
> The current driver omits to set the values.
> 
> This fixes setting wake alarm for dates different than current day.
> Without the patch the alarm scheduled for tomorrow would fire today on
> chosen time.
> 
> Signed-off-by: Donggeun Kim <dg77.kim@samsung.com>
> Signed-off-by: MyungJoo Ham <myungjoo.kim@samsung.com>
> Signed-off-by: KyungMin Park <kyungmin.park@samsung.com>
> [k.kozlowski: Rebase and test the patch, update commit message]
> Signed-off-by: Krzysztof Kozlowski <k.kozlowski.k@gmail.com>
> 
Applied, many thanks for your reviews.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-11-01 17:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-01 11:49 [rtc-linux] [PATCH v3] rtc: rtc-s3c: Set year, month, day value for setting alarm Krzysztof Kozlowski
2015-11-01 11:49 ` Krzysztof Kozlowski
2015-11-01 17:34 ` [rtc-linux] " Alexandre Belloni
2015-11-01 17:34   ` Alexandre Belloni

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.