linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/6] mc13783: rename mc13783_{{un,}mask,ack_irq} to have a mc13783_irq prefix
@ 2010-03-01 10:53 Uwe Kleine-König
  2010-03-01 10:53 ` [PATCH 2/6] input/mc13783-ts: Don't use deprecated mc13783 API calls Uwe Kleine-König
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Uwe Kleine-König @ 2010-03-01 10:53 UTC (permalink / raw)
  To: linux-kernel, rtc-linux, linux-kernel
  Cc: Alessandro Zummo, Paul Gortmaker, Andrew Morton,
	Valentin Longchamp, Sascha Hauer, Samuel Ortiz, linux-input,
	Dmitry Torokhov, Luotao Fu

In the source file group these functions together.

The mc13783 header file provides fallback implementations for the old names
to prevent build failures.  When all users of the old names are fixed to
use the new names these can go away.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/mfd/mc13783-core.c  |   38 +++++++++++++++++++-------------------
 include/linux/mfd/mc13783.h |   24 +++++++++++++++++++++---
 2 files changed, 40 insertions(+), 22 deletions(-)

diff --git a/drivers/mfd/mc13783-core.c b/drivers/mfd/mc13783-core.c
index a1ade23..f89d12d 100644
--- a/drivers/mfd/mc13783-core.c
+++ b/drivers/mfd/mc13783-core.c
@@ -225,7 +225,7 @@ int mc13783_reg_rmw(struct mc13783 *mc13783, unsigned int offset,
 }
 EXPORT_SYMBOL(mc13783_reg_rmw);
 
-int mc13783_mask(struct mc13783 *mc13783, int irq)
+int mc13783_irq_mask(struct mc13783 *mc13783, int irq)
 {
 	int ret;
 	unsigned int offmask = irq < 24 ? MC13783_IRQMASK0 : MC13783_IRQMASK1;
@@ -245,9 +245,9 @@ int mc13783_mask(struct mc13783 *mc13783, int irq)
 
 	return mc13783_reg_write(mc13783, offmask, mask | irqbit);
 }
-EXPORT_SYMBOL(mc13783_mask);
+EXPORT_SYMBOL(mc13783_irq_mask);
 
-int mc13783_unmask(struct mc13783 *mc13783, int irq)
+int mc13783_irq_unmask(struct mc13783 *mc13783, int irq)
 {
 	int ret;
 	unsigned int offmask = irq < 24 ? MC13783_IRQMASK0 : MC13783_IRQMASK1;
@@ -267,7 +267,18 @@ int mc13783_unmask(struct mc13783 *mc13783, int irq)
 
 	return mc13783_reg_write(mc13783, offmask, mask & ~irqbit);
 }
-EXPORT_SYMBOL(mc13783_unmask);
+EXPORT_SYMBOL(mc13783_irq_unmask);
+
+int mc13783_irq_ack(struct mc13783 *mc13783, int irq)
+{
+	unsigned int offstat = irq < 24 ? MC13783_IRQSTAT0 : MC13783_IRQSTAT1;
+	unsigned int val = 1 << (irq < 24 ? irq : irq - 24);
+
+	BUG_ON(irq < 0 || irq >= MC13783_NUM_IRQ);
+
+	return mc13783_reg_write(mc13783, offstat, val);
+}
+EXPORT_SYMBOL(mc13783_irq_ack);
 
 int mc13783_irq_request_nounmask(struct mc13783 *mc13783, int irq,
 		irq_handler_t handler, const char *name, void *dev)
@@ -297,7 +308,7 @@ int mc13783_irq_request(struct mc13783 *mc13783, int irq,
 	if (ret)
 		return ret;
 
-	ret = mc13783_unmask(mc13783, irq);
+	ret = mc13783_irq_unmask(mc13783, irq);
 	if (ret) {
 		mc13783->irqhandler[irq] = NULL;
 		mc13783->irqdata[irq] = NULL;
@@ -317,7 +328,7 @@ int mc13783_irq_free(struct mc13783 *mc13783, int irq, void *dev)
 			mc13783->irqdata[irq] != dev)
 		return -EINVAL;
 
-	ret = mc13783_mask(mc13783, irq);
+	ret = mc13783_irq_mask(mc13783, irq);
 	if (ret)
 		return ret;
 
@@ -333,17 +344,6 @@ static inline irqreturn_t mc13783_irqhandler(struct mc13783 *mc13783, int irq)
 	return mc13783->irqhandler[irq](irq, mc13783->irqdata[irq]);
 }
 
-int mc13783_ackirq(struct mc13783 *mc13783, int irq)
-{
-	unsigned int offstat = irq < 24 ? MC13783_IRQSTAT0 : MC13783_IRQSTAT1;
-	unsigned int val = 1 << (irq < 24 ? irq : irq - 24);
-
-	BUG_ON(irq < 0 || irq >= MC13783_NUM_IRQ);
-
-	return mc13783_reg_write(mc13783, offstat, val);
-}
-EXPORT_SYMBOL(mc13783_ackirq);
-
 /*
  * returns: number of handled irqs or negative error
  * locking: holds mc13783->lock
@@ -422,7 +422,7 @@ static irqreturn_t mc13783_handler_adcdone(int irq, void *data)
 {
 	struct mc13783_adcdone_data *adcdone_data = data;
 
-	mc13783_ackirq(adcdone_data->mc13783, irq);
+	mc13783_irq_ack(adcdone_data->mc13783, irq);
 
 	complete_all(&adcdone_data->done);
 
@@ -486,7 +486,7 @@ int mc13783_adc_do_conversion(struct mc13783 *mc13783, unsigned int mode,
 	dev_dbg(&mc13783->spidev->dev, "%s: request irq\n", __func__);
 	mc13783_irq_request(mc13783, MC13783_IRQ_ADCDONE,
 			mc13783_handler_adcdone, __func__, &adcdone_data);
-	mc13783_ackirq(mc13783, MC13783_IRQ_ADCDONE);
+	mc13783_irq_ack(mc13783, MC13783_IRQ_ADCDONE);
 
 	mc13783_reg_write(mc13783, MC13783_REG_ADC_0, adc0);
 	mc13783_reg_write(mc13783, MC13783_REG_ADC_1, adc1);
diff --git a/include/linux/mfd/mc13783.h b/include/linux/mfd/mc13783.h
index 3568040..05619f0 100644
--- a/include/linux/mfd/mc13783.h
+++ b/include/linux/mfd/mc13783.h
@@ -26,10 +26,28 @@ int mc13783_irq_request(struct mc13783 *mc13783, int irq,
 int mc13783_irq_request_nounmask(struct mc13783 *mc13783, int irq,
 		irq_handler_t handler, const char *name, void *dev);
 int mc13783_irq_free(struct mc13783 *mc13783, int irq, void *dev);
-int mc13783_ackirq(struct mc13783 *mc13783, int irq);
 
-int mc13783_mask(struct mc13783 *mc13783, int irq);
-int mc13783_unmask(struct mc13783 *mc13783, int irq);
+int mc13783_irq_mask(struct mc13783 *mc13783, int irq);
+int mc13783_irq_unmask(struct mc13783 *mc13783, int irq);
+int mc13783_irq_ack(struct mc13783 *mc13783, int irq);
+
+static inline int mc13783_mask(struct mc13783 *mc13783, int irq) __deprecated;
+static inline int mc13783_mask(struct mc13783 *mc13783, int irq)
+{
+	return mc13783_irq_mask(mc13783, irq);
+}
+
+static inline int mc13783_unmask(struct mc13783 *mc13783, int irq) __deprecated;
+static inline int mc13783_unmask(struct mc13783 *mc13783, int irq)
+{
+	return mc13783_irq_unmask(mc13783, irq);
+}
+
+static inline int mc13783_ackirq(struct mc13783 *mc13783, int irq) __deprecated;
+static inline int mc13783_ackirq(struct mc13783 *mc13783, int irq)
+{
+	return mc13783_irq_ack(mc13783, irq);
+}
 
 #define MC13783_ADC0		43
 #define MC13783_ADC0_ADREFEN		(1 << 10)
-- 
1.7.0


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

* [PATCH 2/6] input/mc13783-ts: Don't use deprecated mc13783 API calls
  2010-03-01 10:53 [PATCH 1/6] mc13783: rename mc13783_{{un,}mask,ack_irq} to have a mc13783_irq prefix Uwe Kleine-König
@ 2010-03-01 10:53 ` Uwe Kleine-König
  2010-03-02  7:55   ` Dmitry Torokhov
  2010-03-01 10:53 ` [PATCH 3/6] rtc/mc13783: " Uwe Kleine-König
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 12+ messages in thread
From: Uwe Kleine-König @ 2010-03-01 10:53 UTC (permalink / raw)
  To: linux-kernel, rtc-linux, linux-input
  Cc: Dmitry Torokhov, Sascha Hauer, Luotao Fu

mc13783_ackirq is deprecated, use the drop in replacement mc13783_irq_ack.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
Hello,

note this obviously depends on patch 1/6.

Best regards
Uwe

 drivers/input/touchscreen/mc13783_ts.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/input/touchscreen/mc13783_ts.c b/drivers/input/touchscreen/mc13783_ts.c
index be115b3..be54fd6 100644
--- a/drivers/input/touchscreen/mc13783_ts.c
+++ b/drivers/input/touchscreen/mc13783_ts.c
@@ -44,7 +44,7 @@ static irqreturn_t mc13783_ts_handler(int irq, void *data)
 {
 	struct mc13783_ts_priv *priv = data;
 
-	mc13783_ackirq(priv->mc13783, irq);
+	mc13783_irq_ack(priv->mc13783, irq);
 
 	/*
 	 * Kick off reading coordinates. Note that if work happens already
@@ -135,7 +135,7 @@ static int mc13783_ts_open(struct input_dev *dev)
 
 	mc13783_lock(priv->mc13783);
 
-	mc13783_ackirq(priv->mc13783, MC13783_IRQ_TS);
+	mc13783_irq_ack(priv->mc13783, MC13783_IRQ_TS);
 
 	ret = mc13783_irq_request(priv->mc13783, MC13783_IRQ_TS,
 		mc13783_ts_handler, MC13783_TS_NAME, priv);
-- 
1.7.0


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

* [PATCH 3/6] rtc/mc13783: Don't use deprecated mc13783 API calls
  2010-03-01 10:53 [PATCH 1/6] mc13783: rename mc13783_{{un,}mask,ack_irq} to have a mc13783_irq prefix Uwe Kleine-König
  2010-03-01 10:53 ` [PATCH 2/6] input/mc13783-ts: Don't use deprecated mc13783 API calls Uwe Kleine-König
@ 2010-03-01 10:53 ` Uwe Kleine-König
  2010-03-01 10:53 ` [PATCH 4/6] mfd/mc13783: new function reading irq mask and status register Uwe Kleine-König
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 12+ messages in thread
From: Uwe Kleine-König @ 2010-03-01 10:53 UTC (permalink / raw)
  To: linux-kernel, rtc-linux, rtc-linux
  Cc: Alessandro Zummo, Paul Gortmaker, Andrew Morton,
	Valentin Longchamp, Sascha Hauer

mc13783_ackirq, mc13783_unmask and mc13783_mask are deprecated, use the
drop in replacements with the nicer names.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
Hello,

note this obviously depends on patch 1/6.

Best regards
Uwe

 drivers/rtc/rtc-mc13783.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/rtc/rtc-mc13783.c b/drivers/rtc/rtc-mc13783.c
index 850f983..0a978a0 100644
--- a/drivers/rtc/rtc-mc13783.c
+++ b/drivers/rtc/rtc-mc13783.c
@@ -101,11 +101,11 @@ static int mc13783_rtc_set_mmss(struct device *dev, unsigned long secs)
 	if (unlikely(ret))
 		goto out;
 
-	ret = mc13783_ackirq(priv->mc13783, MC13783_IRQ_RTCRST);
+	ret = mc13783_irq_ack(priv->mc13783, MC13783_IRQ_RTCRST);
 	if (unlikely(ret))
 		goto out;
 
-	ret = mc13783_unmask(priv->mc13783, MC13783_IRQ_RTCRST);
+	ret = mc13783_irq_unmask(priv->mc13783, MC13783_IRQ_RTCRST);
 out:
 	priv->valid = !ret;
 
@@ -123,7 +123,7 @@ static irqreturn_t mc13783_rtc_update_handler(int irq, void *dev)
 
 	rtc_update_irq(priv->rtc, 1, RTC_IRQF | RTC_UF);
 
-	mc13783_ackirq(mc13783, irq);
+	mc13783_irq_ack(mc13783, irq);
 
 	return IRQ_HANDLED;
 }
@@ -138,7 +138,7 @@ static int mc13783_rtc_update_irq_enable(struct device *dev,
 	if (!priv->valid)
 		goto out;
 
-	ret = (enabled ? mc13783_unmask : mc13783_mask)(priv->mc13783,
+	ret = (enabled ? mc13783_irq_unmask : mc13783_irq_mask)(priv->mc13783,
 			MC13783_IRQ_1HZ);
 out:
 	mc13783_unlock(priv->mc13783);
@@ -160,7 +160,7 @@ static irqreturn_t mc13783_rtc_reset_handler(int irq, void *dev)
 	dev_dbg(&priv->rtc->dev, "RTCRST\n");
 	priv->valid = 0;
 
-	mc13783_mask(mc13783, irq);
+	mc13783_irq_mask(mc13783, irq);
 
 	return IRQ_HANDLED;
 }
-- 
1.7.0


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

* [PATCH 4/6] mfd/mc13783: new function reading irq mask and status register
  2010-03-01 10:53 [PATCH 1/6] mc13783: rename mc13783_{{un,}mask,ack_irq} to have a mc13783_irq prefix Uwe Kleine-König
  2010-03-01 10:53 ` [PATCH 2/6] input/mc13783-ts: Don't use deprecated mc13783 API calls Uwe Kleine-König
  2010-03-01 10:53 ` [PATCH 3/6] rtc/mc13783: " Uwe Kleine-König
@ 2010-03-01 10:53 ` Uwe Kleine-König
  2010-03-01 10:53 ` [PATCH 5/6] rtc/mc13783: protect rtc {,un}registration by mc13783 lock Uwe Kleine-König
  2010-03-01 10:53 ` [PATCH 6/6] rtc/mc13783: implement alarm Uwe Kleine-König
  4 siblings, 0 replies; 12+ messages in thread
From: Uwe Kleine-König @ 2010-03-01 10:53 UTC (permalink / raw)
  To: linux-kernel, rtc-linux, linux-kernel
  Cc: Alessandro Zummo, Paul Gortmaker, Andrew Morton,
	Valentin Longchamp, Sascha Hauer, Samuel Ortiz

The driver for the mc13783 rtc needs to know if the TODA irq is pending.

Instead of tracking in the rtc driver if the irq is enabled provide that
information, too.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/mfd/mc13783-core.c  |   35 +++++++++++++++++++++++++++++++++++
 include/linux/mfd/mc13783.h |    2 ++
 2 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/drivers/mfd/mc13783-core.c b/drivers/mfd/mc13783-core.c
index f89d12d..2a5334a 100644
--- a/drivers/mfd/mc13783-core.c
+++ b/drivers/mfd/mc13783-core.c
@@ -269,6 +269,41 @@ int mc13783_irq_unmask(struct mc13783 *mc13783, int irq)
 }
 EXPORT_SYMBOL(mc13783_irq_unmask);
 
+int mc13783_irq_status(struct mc13783 *mc13783, int irq,
+		int *enabled, int *pending)
+{
+	int ret;
+	unsigned int offmask = irq < 24 ? MC13783_IRQMASK0 : MC13783_IRQMASK1;
+	unsigned int offstat = irq < 24 ? MC13783_IRQSTAT0 : MC13783_IRQSTAT1;
+	u32 irqbit = 1 << (irq < 24 ? irq : irq - 24);
+
+	if (irq < 0 || irq >= MC13783_NUM_IRQ)
+		return -EINVAL;
+
+	if (enabled) {
+		u32 mask;
+
+		ret = mc13783_reg_read(mc13783, offmask, &mask);
+		if (ret)
+			return ret;
+
+		*enabled = mask & irqbit;
+	}
+
+	if (pending) {
+		u32 stat;
+
+		ret = mc13783_reg_read(mc13783, offstat, &stat);
+		if (ret)
+			return ret;
+
+		*pending = stat & irqbit;
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL(mc13783_irq_status);
+
 int mc13783_irq_ack(struct mc13783 *mc13783, int irq)
 {
 	unsigned int offstat = irq < 24 ? MC13783_IRQSTAT0 : MC13783_IRQSTAT1;
diff --git a/include/linux/mfd/mc13783.h b/include/linux/mfd/mc13783.h
index 05619f0..9d1dbc9 100644
--- a/include/linux/mfd/mc13783.h
+++ b/include/linux/mfd/mc13783.h
@@ -29,6 +29,8 @@ int mc13783_irq_free(struct mc13783 *mc13783, int irq, void *dev);
 
 int mc13783_irq_mask(struct mc13783 *mc13783, int irq);
 int mc13783_irq_unmask(struct mc13783 *mc13783, int irq);
+int mc13783_irq_status(struct mc13783 *mc13783, int irq,
+		int *enabled, int *pending);
 int mc13783_irq_ack(struct mc13783 *mc13783, int irq);
 
 static inline int mc13783_mask(struct mc13783 *mc13783, int irq) __deprecated;
-- 
1.7.0


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

* [PATCH 5/6] rtc/mc13783: protect rtc {,un}registration by mc13783 lock
  2010-03-01 10:53 [PATCH 1/6] mc13783: rename mc13783_{{un,}mask,ack_irq} to have a mc13783_irq prefix Uwe Kleine-König
                   ` (2 preceding siblings ...)
  2010-03-01 10:53 ` [PATCH 4/6] mfd/mc13783: new function reading irq mask and status register Uwe Kleine-König
@ 2010-03-01 10:53 ` Uwe Kleine-König
  2010-03-01 10:53 ` [PATCH 6/6] rtc/mc13783: implement alarm Uwe Kleine-König
  4 siblings, 0 replies; 12+ messages in thread
From: Uwe Kleine-König @ 2010-03-01 10:53 UTC (permalink / raw)
  To: linux-kernel, rtc-linux, rtc-linux
  Cc: Alessandro Zummo, Paul Gortmaker, Andrew Morton,
	Valentin Longchamp, Sascha Hauer

This is to protect from interrupt handlers using an unregistered rtc
device.

To assert that the reset irq is considered now before the rtc is
registered the corresponding status is checked before.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
Hello,

this depends on patch 4/6 which added mc13783_irq_status.

Best regards
Uwe

 drivers/rtc/rtc-mc13783.c |   25 ++++++++++++++-----------
 1 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/drivers/rtc/rtc-mc13783.c b/drivers/rtc/rtc-mc13783.c
index 0a978a0..6a36201 100644
--- a/drivers/rtc/rtc-mc13783.c
+++ b/drivers/rtc/rtc-mc13783.c
@@ -169,6 +169,7 @@ static int __devinit mc13783_rtc_probe(struct platform_device *pdev)
 {
 	int ret;
 	struct mc13783_rtc *priv;
+	int rtcrst_pending;
 
 	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
 	if (!priv)
@@ -177,8 +178,6 @@ static int __devinit mc13783_rtc_probe(struct platform_device *pdev)
 	priv->mc13783 = dev_get_drvdata(pdev->dev.parent);
 	platform_set_drvdata(pdev, priv);
 
-	priv->valid = 1;
-
 	mc13783_lock(priv->mc13783);
 
 	ret = mc13783_irq_request(priv->mc13783, MC13783_IRQ_RTCRST,
@@ -186,33 +185,37 @@ static int __devinit mc13783_rtc_probe(struct platform_device *pdev)
 	if (ret)
 		goto err_reset_irq_request;
 
+	ret = mc13783_irq_status(priv->mc13783, MC13783_IRQ_RTCRST,
+			NULL, &rtcrst_pending);
+	if (ret)
+		goto err_reset_irq_status;
+
+	priv->valid = !rtcrst_pending;
+
 	ret = mc13783_irq_request_nounmask(priv->mc13783, MC13783_IRQ_1HZ,
 			mc13783_rtc_update_handler, DRIVER_NAME, priv);
 	if (ret)
 		goto err_update_irq_request;
 
-	mc13783_unlock(priv->mc13783);
-
 	priv->rtc = rtc_device_register(pdev->name,
 			&pdev->dev, &mc13783_rtc_ops, THIS_MODULE);
-
 	if (IS_ERR(priv->rtc)) {
 		ret = PTR_ERR(priv->rtc);
 
-		mc13783_lock(priv->mc13783);
-
 		mc13783_irq_free(priv->mc13783, MC13783_IRQ_1HZ, priv);
 err_update_irq_request:
 
+err_reset_irq_status:
+
 		mc13783_irq_free(priv->mc13783, MC13783_IRQ_RTCRST, priv);
 err_reset_irq_request:
 
-		mc13783_unlock(priv->mc13783);
-
 		platform_set_drvdata(pdev, NULL);
 		kfree(priv);
 	}
 
+	mc13783_unlock(priv->mc13783);
+
 	return ret;
 }
 
@@ -220,10 +223,10 @@ static int __devexit mc13783_rtc_remove(struct platform_device *pdev)
 {
 	struct mc13783_rtc *priv = platform_get_drvdata(pdev);
 
-	rtc_device_unregister(priv->rtc);
-
 	mc13783_lock(priv->mc13783);
 
+	rtc_device_unregister(priv->rtc);
+
 	mc13783_irq_free(priv->mc13783, MC13783_IRQ_1HZ, priv);
 	mc13783_irq_free(priv->mc13783, MC13783_IRQ_RTCRST, priv);
 
-- 
1.7.0


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

* [PATCH 6/6] rtc/mc13783: implement alarm
  2010-03-01 10:53 [PATCH 1/6] mc13783: rename mc13783_{{un,}mask,ack_irq} to have a mc13783_irq prefix Uwe Kleine-König
                   ` (3 preceding siblings ...)
  2010-03-01 10:53 ` [PATCH 5/6] rtc/mc13783: protect rtc {,un}registration by mc13783 lock Uwe Kleine-König
@ 2010-03-01 10:53 ` Uwe Kleine-König
  2010-03-01 10:56   ` [rtc-linux] " Alessandro Zummo
  4 siblings, 1 reply; 12+ messages in thread
From: Uwe Kleine-König @ 2010-03-01 10:53 UTC (permalink / raw)
  To: linux-kernel, rtc-linux, rtc-linux
  Cc: Alessandro Zummo, Paul Gortmaker, Andrew Morton,
	Valentin Longchamp, Sascha Hauer

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
Hello,

for now this just ignores the possible race to trigger an alarm when
setting the time.  Should I resolve that, if so, what is the prefered
way to do that?

Best regards
Uwe

 drivers/rtc/rtc-mc13783.c |  159 +++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 147 insertions(+), 12 deletions(-)

diff --git a/drivers/rtc/rtc-mc13783.c b/drivers/rtc/rtc-mc13783.c
index 6a36201..ae01217 100644
--- a/drivers/rtc/rtc-mc13783.c
+++ b/drivers/rtc/rtc-mc13783.c
@@ -28,6 +28,34 @@ struct mc13783_rtc {
 	int valid;
 };
 
+static int mc13783_rtc_irq_enable_unlocked(struct device *dev,
+		unsigned int enabled, int irq)
+{
+	struct mc13783_rtc *priv = dev_get_drvdata(dev);
+	int (*func)(struct mc13783 *mc13783, int irq);
+
+	if (!priv->valid)
+		return -ENODATA;
+
+	func = enabled ? mc13783_irq_unmask : mc13783_irq_mask;
+	return func(priv->mc13783, irq);
+}
+
+static int mc13783_rtc_irq_enable(struct device *dev,
+		unsigned int enabled, int irq)
+{
+	struct mc13783_rtc *priv = dev_get_drvdata(dev);
+	int ret;
+
+	mc13783_lock(priv->mc13783);
+
+	ret = mc13783_rtc_irq_enable_unlocked(dev, enabled, irq);
+
+	mc13783_unlock(priv->mc13783);
+
+	return ret;
+}
+
 static int mc13783_rtc_read_time(struct device *dev, struct rtc_time *tm)
 {
 	struct mc13783_rtc *priv = dev_get_drvdata(dev);
@@ -114,6 +142,107 @@ out:
 	return ret;
 }
 
+static int mc13783_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
+{
+	struct mc13783_rtc *priv = dev_get_drvdata(dev);
+	unsigned seconds, days;
+	unsigned long s1970;
+	int enabled, pending;
+	int ret;
+
+	mc13783_lock(priv->mc13783);
+
+	ret = mc13783_reg_read(priv->mc13783, MC13783_RTCTODA, &seconds);
+	if (unlikely(ret))
+		goto out;
+	if (seconds >= 86400) {
+		ret = -ENODATA;
+		goto out;
+	}
+
+	ret = mc13783_reg_read(priv->mc13783, MC13783_RTCDAY, &days);
+	if (unlikely(ret))
+		goto out;
+
+	ret = mc13783_irq_status(priv->mc13783, MC13783_IRQ_TODA,
+			&enabled, &pending);
+
+out:
+	mc13783_unlock(priv->mc13783);
+
+	if (ret)
+		return ret;
+
+	alarm->enabled = enabled;
+	alarm->pending = pending;
+
+	s1970 = days * 86400 + seconds;
+
+	rtc_time_to_tm(s1970, &alarm->time);
+	dev_dbg(dev, "%s: %lu\n", __func__, s1970);
+
+	return 0;
+}
+
+static int mc13783_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
+{
+	struct mc13783_rtc *priv = dev_get_drvdata(dev);
+	unsigned long s1970;
+	unsigned seconds, days;
+	int ret;
+
+	mc13783_lock(priv->mc13783);
+
+	/* disable alarm to prevent false triggering */
+	ret = mc13783_reg_write(priv->mc13783, MC13783_RTCTODA, 0x1ffff);
+	if (unlikely(ret))
+		goto out;
+
+	ret = mc13783_irq_ack(priv->mc13783, MC13783_IRQ_TODA);
+	if (unlikely(ret))
+		goto out;
+
+	ret = rtc_tm_to_time(&alarm->time, &s1970);
+	if (unlikely(ret))
+		goto out;
+
+	dev_dbg(dev, "%s: o%2.s %lu\n", __func__, alarm->enabled ? "n" : "ff",
+			s1970);
+
+	ret = mc13783_rtc_irq_enable_unlocked(dev, alarm->enabled,
+			MC13783_IRQ_TODA);
+	if (unlikely(ret))
+		goto out;
+
+	seconds = s1970 % 86400;
+	days = s1970 / 86400;
+
+	ret = mc13783_reg_write(priv->mc13783, MC13783_RTCDAYA, days);
+	if (unlikely(ret))
+		goto out;
+
+	ret = mc13783_reg_write(priv->mc13783, MC13783_RTCTODA, seconds);
+
+out:
+	mc13783_unlock(priv->mc13783);
+
+	return ret;
+}
+
+static irqreturn_t mc13783_rtc_alarm_handler(int irq, void *dev)
+{
+	struct mc13783_rtc *priv = dev;
+	struct mc13783 *mc13783 = priv->mc13783;
+
+	dev_dbg(&priv->rtc->dev, "Alarm\n");
+
+	rtc_update_irq(priv->rtc, 1, RTC_IRQF | RTC_AF);
+
+	mc13783_irq_ack(mc13783, irq);
+
+	return IRQ_HANDLED;
+}
+
 static irqreturn_t mc13783_rtc_update_handler(int irq, void *dev)
 {
 	struct mc13783_rtc *priv = dev;
@@ -131,24 +260,21 @@ static irqreturn_t mc13783_rtc_update_handler(int irq, void *dev)
 static int mc13783_rtc_update_irq_enable(struct device *dev,
 		unsigned int enabled)
 {
-	struct mc13783_rtc *priv = dev_get_drvdata(dev);
-	int ret = -ENODATA;
-
-	mc13783_lock(priv->mc13783);
-	if (!priv->valid)
-		goto out;
-
-	ret = (enabled ? mc13783_irq_unmask : mc13783_irq_mask)(priv->mc13783,
-			MC13783_IRQ_1HZ);
-out:
-	mc13783_unlock(priv->mc13783);
+	return mc13783_rtc_irq_enable(dev, enabled, MC13783_IRQ_1HZ);
+}
 
-	return ret;
+static int mc13783_rtc_alarm_irq_enable(struct device *dev,
+		unsigned int enabled)
+{
+	return mc13783_rtc_irq_enable(dev, enabled, MC13783_IRQ_TODA);
 }
 
 static const struct rtc_class_ops mc13783_rtc_ops = {
 	.read_time = mc13783_rtc_read_time,
 	.set_mmss = mc13783_rtc_set_mmss,
+	.read_alarm = mc13783_rtc_read_alarm,
+	.set_alarm = mc13783_rtc_set_alarm,
+	.alarm_irq_enable = mc13783_rtc_alarm_irq_enable,
 	.update_irq_enable = mc13783_rtc_update_irq_enable,
 };
 
@@ -197,11 +323,19 @@ static int __devinit mc13783_rtc_probe(struct platform_device *pdev)
 	if (ret)
 		goto err_update_irq_request;
 
+	ret = mc13783_irq_request_nounmask(priv->mc13783, MC13783_IRQ_TODA,
+			mc13783_rtc_alarm_handler, DRIVER_NAME, priv);
+	if (ret)
+		goto err_alarm_irq_request;
+
 	priv->rtc = rtc_device_register(pdev->name,
 			&pdev->dev, &mc13783_rtc_ops, THIS_MODULE);
 	if (IS_ERR(priv->rtc)) {
 		ret = PTR_ERR(priv->rtc);
 
+		mc13783_irq_free(priv->mc13783, MC13783_IRQ_TODA, priv);
+err_alarm_irq_request:
+
 		mc13783_irq_free(priv->mc13783, MC13783_IRQ_1HZ, priv);
 err_update_irq_request:
 
@@ -227,6 +361,7 @@ static int __devexit mc13783_rtc_remove(struct platform_device *pdev)
 
 	rtc_device_unregister(priv->rtc);
 
+	mc13783_irq_free(priv->mc13783, MC13783_IRQ_TODA, priv);
 	mc13783_irq_free(priv->mc13783, MC13783_IRQ_1HZ, priv);
 	mc13783_irq_free(priv->mc13783, MC13783_IRQ_RTCRST, priv);
 
-- 
1.7.0


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

* Re: [rtc-linux] [PATCH 6/6] rtc/mc13783: implement alarm
  2010-03-01 10:53 ` [PATCH 6/6] rtc/mc13783: implement alarm Uwe Kleine-König
@ 2010-03-01 10:56   ` Alessandro Zummo
  2010-03-01 11:10     ` Uwe Kleine-König
  0 siblings, 1 reply; 12+ messages in thread
From: Alessandro Zummo @ 2010-03-01 10:56 UTC (permalink / raw)
  To: rtc-linux
  Cc: u.kleine-koenig, linux-kernel, Paul Gortmaker, Andrew Morton,
	Valentin Longchamp, Sascha Hauer

On Mon,  1 Mar 2010 11:53:45 +0100
Uwe Kleine-König <u.kleine-koenig@pengutronix.de> wrote:

> for now this just ignores the possible race to trigger an alarm when
> setting the time.  Should I resolve that, if so, what is the prefered
> way to do that?

 I saw you email on the topic but I haven't had
 the time to answer appropriately. 

 I'd suggest to disable the alarm irq while setting
 the time.

-- 

 Best regards,

 Alessandro Zummo,
  Tower Technologies - Torino, Italy

  http://www.towertech.it


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

* Re: [rtc-linux] [PATCH 6/6] rtc/mc13783: implement alarm
  2010-03-01 10:56   ` [rtc-linux] " Alessandro Zummo
@ 2010-03-01 11:10     ` Uwe Kleine-König
  2010-03-01 11:45       ` Alessandro Zummo
  0 siblings, 1 reply; 12+ messages in thread
From: Uwe Kleine-König @ 2010-03-01 11:10 UTC (permalink / raw)
  To: Alessandro Zummo
  Cc: rtc-linux, linux-kernel, Paul Gortmaker, Andrew Morton,
	Valentin Longchamp, Sascha Hauer

On Mon, Mar 01, 2010 at 11:56:25AM +0100, Alessandro Zummo wrote:
> On Mon,  1 Mar 2010 11:53:45 +0100
> Uwe Kleine-König <u.kleine-koenig@pengutronix.de> wrote:
> 
> > for now this just ignores the possible race to trigger an alarm when
> > setting the time.  Should I resolve that, if so, what is the prefered
> > way to do that?
> 
>  I saw you email on the topic but I haven't had
>  the time to answer appropriately. 
> 
>  I'd suggest to disable the alarm irq while setting
>  the time.
I have two possibilities, I'm not sure if you mean the first or just any
of the two:

  1)
	pending = is_alarm_pending
	mask_alarm_irq
	set time and date
	if (!pending)
		ack_alarm_irq
	unmask_alarm_irq

  2)
	alarmtime = read_alaram
	program_alarm(invalid)
	set time and date
	program_alarm(alarmtime)

I'd prefer 2), is that OK for you, too?

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

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

* Re: [rtc-linux] [PATCH 6/6] rtc/mc13783: implement alarm
  2010-03-01 11:10     ` Uwe Kleine-König
@ 2010-03-01 11:45       ` Alessandro Zummo
  2010-03-02  9:47         ` [PATCH v2 " Uwe Kleine-König
  0 siblings, 1 reply; 12+ messages in thread
From: Alessandro Zummo @ 2010-03-01 11:45 UTC (permalink / raw)
  To: rtc-linux
  Cc: u.kleine-koenig, linux-kernel, Paul Gortmaker, Andrew Morton,
	Valentin Longchamp, Sascha Hauer

On Mon, 1 Mar 2010 12:10:07 +0100
Uwe Kleine-König <u.kleine-koenig@pengutronix.de> wrote:

>   2)
> 	alarmtime = read_alaram
> 	program_alarm(invalid)
> 	set time and date
> 	program_alarm(alarmtime)
> 
> I'd prefer 2), is that OK for you, too?

 seems fine to me.

-- 

 Best regards,

 Alessandro Zummo,
  Tower Technologies - Torino, Italy

  http://www.towertech.it


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

* Re: [PATCH 2/6] input/mc13783-ts: Don't use deprecated mc13783 API calls
  2010-03-01 10:53 ` [PATCH 2/6] input/mc13783-ts: Don't use deprecated mc13783 API calls Uwe Kleine-König
@ 2010-03-02  7:55   ` Dmitry Torokhov
  2010-03-02  8:54     ` Uwe Kleine-König
  0 siblings, 1 reply; 12+ messages in thread
From: Dmitry Torokhov @ 2010-03-02  7:55 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: linux-kernel, rtc-linux, linux-input, Sascha Hauer, Luotao Fu

On Mon, Mar 01, 2010 at 11:53:41AM +0100, Uwe Kleine-König wrote:
> mc13783_ackirq is deprecated, use the drop in replacement mc13783_irq_ack.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

I assume it will go thourgh MFD tree?

Acked-by: Dmitry Torokhov <dtor@mail.ru>

> ---
> Hello,
> 
> note this obviously depends on patch 1/6.
> 
> Best regards
> Uwe
> 
>  drivers/input/touchscreen/mc13783_ts.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/mc13783_ts.c b/drivers/input/touchscreen/mc13783_ts.c
> index be115b3..be54fd6 100644
> --- a/drivers/input/touchscreen/mc13783_ts.c
> +++ b/drivers/input/touchscreen/mc13783_ts.c
> @@ -44,7 +44,7 @@ static irqreturn_t mc13783_ts_handler(int irq, void *data)
>  {
>  	struct mc13783_ts_priv *priv = data;
>  
> -	mc13783_ackirq(priv->mc13783, irq);
> +	mc13783_irq_ack(priv->mc13783, irq);
>  
>  	/*
>  	 * Kick off reading coordinates. Note that if work happens already
> @@ -135,7 +135,7 @@ static int mc13783_ts_open(struct input_dev *dev)
>  
>  	mc13783_lock(priv->mc13783);
>  
> -	mc13783_ackirq(priv->mc13783, MC13783_IRQ_TS);
> +	mc13783_irq_ack(priv->mc13783, MC13783_IRQ_TS);
>  
>  	ret = mc13783_irq_request(priv->mc13783, MC13783_IRQ_TS,
>  		mc13783_ts_handler, MC13783_TS_NAME, priv);
> -- 
> 1.7.0
> 

-- 
Dmitry

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

* Re: [PATCH 2/6] input/mc13783-ts: Don't use deprecated mc13783 API calls
  2010-03-02  7:55   ` Dmitry Torokhov
@ 2010-03-02  8:54     ` Uwe Kleine-König
  0 siblings, 0 replies; 12+ messages in thread
From: Uwe Kleine-König @ 2010-03-02  8:54 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: linux-kernel, rtc-linux, linux-input, Sascha Hauer, Luotao Fu,
	Andrew Morton

On Mon, Mar 01, 2010 at 11:55:13PM -0800, Dmitry Torokhov wrote:
> On Mon, Mar 01, 2010 at 11:53:41AM +0100, Uwe Kleine-König wrote:
> > mc13783_ackirq is deprecated, use the drop in replacement mc13783_irq_ack.
> > 
> > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> 
> I assume it will go thourgh MFD tree?
I don't know.  I would have suggest to let it go via Andrew[1] as the
biggest changes in this series are rtc related and these usually go via
him.  But MFD would be OK for me, too.

Best regards
Uwe

[1] hmm, forgot to Cc: him.  This is done now.

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

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

* [PATCH v2 6/6] rtc/mc13783: implement alarm
  2010-03-01 11:45       ` Alessandro Zummo
@ 2010-03-02  9:47         ` Uwe Kleine-König
  0 siblings, 0 replies; 12+ messages in thread
From: Uwe Kleine-König @ 2010-03-02  9:47 UTC (permalink / raw)
  To: rtc-linux
  Cc: linux-kernel, Paul Gortmaker, Andrew Morton, Valentin Longchamp,
	Sascha Hauer

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
Hello,

changes since first submission:

  - implement race free time setting

Best regards
Uwe

 drivers/rtc/rtc-mc13783.c |  185 +++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 172 insertions(+), 13 deletions(-)

diff --git a/drivers/rtc/rtc-mc13783.c b/drivers/rtc/rtc-mc13783.c
index 6a36201..d60c81b 100644
--- a/drivers/rtc/rtc-mc13783.c
+++ b/drivers/rtc/rtc-mc13783.c
@@ -28,6 +28,34 @@ struct mc13783_rtc {
 	int valid;
 };
 
+static int mc13783_rtc_irq_enable_unlocked(struct device *dev,
+		unsigned int enabled, int irq)
+{
+	struct mc13783_rtc *priv = dev_get_drvdata(dev);
+	int (*func)(struct mc13783 *mc13783, int irq);
+
+	if (!priv->valid)
+		return -ENODATA;
+
+	func = enabled ? mc13783_irq_unmask : mc13783_irq_mask;
+	return func(priv->mc13783, irq);
+}
+
+static int mc13783_rtc_irq_enable(struct device *dev,
+		unsigned int enabled, int irq)
+{
+	struct mc13783_rtc *priv = dev_get_drvdata(dev);
+	int ret;
+
+	mc13783_lock(priv->mc13783);
+
+	ret = mc13783_rtc_irq_enable_unlocked(dev, enabled, irq);
+
+	mc13783_unlock(priv->mc13783);
+
+	return ret;
+}
+
 static int mc13783_rtc_read_time(struct device *dev, struct rtc_time *tm)
 {
 	struct mc13783_rtc *priv = dev_get_drvdata(dev);
@@ -78,6 +106,7 @@ static int mc13783_rtc_set_mmss(struct device *dev, unsigned long secs)
 {
 	struct mc13783_rtc *priv = dev_get_drvdata(dev);
 	unsigned int seconds, days;
+	unsigned int alarmseconds;
 	int ret;
 
 	seconds = secs % 86400;
@@ -86,7 +115,22 @@ static int mc13783_rtc_set_mmss(struct device *dev, unsigned long secs)
 	mc13783_lock(priv->mc13783);
 
 	/*
-	 * first write seconds=0 to prevent a day switch between writing days
+	 * temporarily invalidate alarm to prevent triggering it when the day is
+	 * already updated while the time isn't yet.
+	 */
+	ret = mc13783_reg_read(priv->mc13783, MC13783_RTCTODA, &alarmseconds);
+	if (unlikely(ret))
+		goto out;
+
+	if (alarmseconds < 86400) {
+		ret = mc13783_reg_write(priv->mc13783,
+				MC13783_RTCTODA, 0x1ffff);
+		if (unlikely(ret))
+			goto out;
+	}
+
+	/*
+	 * write seconds=0 to prevent a day switch between writing days
 	 * and seconds below
 	 */
 	ret = mc13783_reg_write(priv->mc13783, MC13783_RTCTOD, 0);
@@ -101,6 +145,14 @@ static int mc13783_rtc_set_mmss(struct device *dev, unsigned long secs)
 	if (unlikely(ret))
 		goto out;
 
+	/* restore alarm */
+	if (alarmseconds < 86400) {
+		ret = mc13783_reg_write(priv->mc13783,
+				MC13783_RTCTODA, alarmseconds);
+		if (unlikely(ret))
+			goto out;
+	}
+
 	ret = mc13783_irq_ack(priv->mc13783, MC13783_IRQ_RTCRST);
 	if (unlikely(ret))
 		goto out;
@@ -114,6 +166,107 @@ out:
 	return ret;
 }
 
+static int mc13783_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
+{
+	struct mc13783_rtc *priv = dev_get_drvdata(dev);
+	unsigned seconds, days;
+	unsigned long s1970;
+	int enabled, pending;
+	int ret;
+
+	mc13783_lock(priv->mc13783);
+
+	ret = mc13783_reg_read(priv->mc13783, MC13783_RTCTODA, &seconds);
+	if (unlikely(ret))
+		goto out;
+	if (seconds >= 86400) {
+		ret = -ENODATA;
+		goto out;
+	}
+
+	ret = mc13783_reg_read(priv->mc13783, MC13783_RTCDAY, &days);
+	if (unlikely(ret))
+		goto out;
+
+	ret = mc13783_irq_status(priv->mc13783, MC13783_IRQ_TODA,
+			&enabled, &pending);
+
+out:
+	mc13783_unlock(priv->mc13783);
+
+	if (ret)
+		return ret;
+
+	alarm->enabled = enabled;
+	alarm->pending = pending;
+
+	s1970 = days * 86400 + seconds;
+
+	rtc_time_to_tm(s1970, &alarm->time);
+	dev_dbg(dev, "%s: %lu\n", __func__, s1970);
+
+	return 0;
+}
+
+static int mc13783_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
+{
+	struct mc13783_rtc *priv = dev_get_drvdata(dev);
+	unsigned long s1970;
+	unsigned seconds, days;
+	int ret;
+
+	mc13783_lock(priv->mc13783);
+
+	/* disable alarm to prevent false triggering */
+	ret = mc13783_reg_write(priv->mc13783, MC13783_RTCTODA, 0x1ffff);
+	if (unlikely(ret))
+		goto out;
+
+	ret = mc13783_irq_ack(priv->mc13783, MC13783_IRQ_TODA);
+	if (unlikely(ret))
+		goto out;
+
+	ret = rtc_tm_to_time(&alarm->time, &s1970);
+	if (unlikely(ret))
+		goto out;
+
+	dev_dbg(dev, "%s: o%2.s %lu\n", __func__, alarm->enabled ? "n" : "ff",
+			s1970);
+
+	ret = mc13783_rtc_irq_enable_unlocked(dev, alarm->enabled,
+			MC13783_IRQ_TODA);
+	if (unlikely(ret))
+		goto out;
+
+	seconds = s1970 % 86400;
+	days = s1970 / 86400;
+
+	ret = mc13783_reg_write(priv->mc13783, MC13783_RTCDAYA, days);
+	if (unlikely(ret))
+		goto out;
+
+	ret = mc13783_reg_write(priv->mc13783, MC13783_RTCTODA, seconds);
+
+out:
+	mc13783_unlock(priv->mc13783);
+
+	return ret;
+}
+
+static irqreturn_t mc13783_rtc_alarm_handler(int irq, void *dev)
+{
+	struct mc13783_rtc *priv = dev;
+	struct mc13783 *mc13783 = priv->mc13783;
+
+	dev_dbg(&priv->rtc->dev, "Alarm\n");
+
+	rtc_update_irq(priv->rtc, 1, RTC_IRQF | RTC_AF);
+
+	mc13783_irq_ack(mc13783, irq);
+
+	return IRQ_HANDLED;
+}
+
 static irqreturn_t mc13783_rtc_update_handler(int irq, void *dev)
 {
 	struct mc13783_rtc *priv = dev;
@@ -131,24 +284,21 @@ static irqreturn_t mc13783_rtc_update_handler(int irq, void *dev)
 static int mc13783_rtc_update_irq_enable(struct device *dev,
 		unsigned int enabled)
 {
-	struct mc13783_rtc *priv = dev_get_drvdata(dev);
-	int ret = -ENODATA;
-
-	mc13783_lock(priv->mc13783);
-	if (!priv->valid)
-		goto out;
-
-	ret = (enabled ? mc13783_irq_unmask : mc13783_irq_mask)(priv->mc13783,
-			MC13783_IRQ_1HZ);
-out:
-	mc13783_unlock(priv->mc13783);
+	return mc13783_rtc_irq_enable(dev, enabled, MC13783_IRQ_1HZ);
+}
 
-	return ret;
+static int mc13783_rtc_alarm_irq_enable(struct device *dev,
+		unsigned int enabled)
+{
+	return mc13783_rtc_irq_enable(dev, enabled, MC13783_IRQ_TODA);
 }
 
 static const struct rtc_class_ops mc13783_rtc_ops = {
 	.read_time = mc13783_rtc_read_time,
 	.set_mmss = mc13783_rtc_set_mmss,
+	.read_alarm = mc13783_rtc_read_alarm,
+	.set_alarm = mc13783_rtc_set_alarm,
+	.alarm_irq_enable = mc13783_rtc_alarm_irq_enable,
 	.update_irq_enable = mc13783_rtc_update_irq_enable,
 };
 
@@ -197,11 +347,19 @@ static int __devinit mc13783_rtc_probe(struct platform_device *pdev)
 	if (ret)
 		goto err_update_irq_request;
 
+	ret = mc13783_irq_request_nounmask(priv->mc13783, MC13783_IRQ_TODA,
+			mc13783_rtc_alarm_handler, DRIVER_NAME, priv);
+	if (ret)
+		goto err_alarm_irq_request;
+
 	priv->rtc = rtc_device_register(pdev->name,
 			&pdev->dev, &mc13783_rtc_ops, THIS_MODULE);
 	if (IS_ERR(priv->rtc)) {
 		ret = PTR_ERR(priv->rtc);
 
+		mc13783_irq_free(priv->mc13783, MC13783_IRQ_TODA, priv);
+err_alarm_irq_request:
+
 		mc13783_irq_free(priv->mc13783, MC13783_IRQ_1HZ, priv);
 err_update_irq_request:
 
@@ -227,6 +385,7 @@ static int __devexit mc13783_rtc_remove(struct platform_device *pdev)
 
 	rtc_device_unregister(priv->rtc);
 
+	mc13783_irq_free(priv->mc13783, MC13783_IRQ_TODA, priv);
 	mc13783_irq_free(priv->mc13783, MC13783_IRQ_1HZ, priv);
 	mc13783_irq_free(priv->mc13783, MC13783_IRQ_RTCRST, priv);
 
-- 
1.7.0


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

end of thread, other threads:[~2010-03-02  9:48 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-01 10:53 [PATCH 1/6] mc13783: rename mc13783_{{un,}mask,ack_irq} to have a mc13783_irq prefix Uwe Kleine-König
2010-03-01 10:53 ` [PATCH 2/6] input/mc13783-ts: Don't use deprecated mc13783 API calls Uwe Kleine-König
2010-03-02  7:55   ` Dmitry Torokhov
2010-03-02  8:54     ` Uwe Kleine-König
2010-03-01 10:53 ` [PATCH 3/6] rtc/mc13783: " Uwe Kleine-König
2010-03-01 10:53 ` [PATCH 4/6] mfd/mc13783: new function reading irq mask and status register Uwe Kleine-König
2010-03-01 10:53 ` [PATCH 5/6] rtc/mc13783: protect rtc {,un}registration by mc13783 lock Uwe Kleine-König
2010-03-01 10:53 ` [PATCH 6/6] rtc/mc13783: implement alarm Uwe Kleine-König
2010-03-01 10:56   ` [rtc-linux] " Alessandro Zummo
2010-03-01 11:10     ` Uwe Kleine-König
2010-03-01 11:45       ` Alessandro Zummo
2010-03-02  9:47         ` [PATCH v2 " Uwe Kleine-König

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).