[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1267440825-14694-4-git-send-email-u.kleine-koenig@pengutronix.de>
Date: Mon, 1 Mar 2010 11:53:43 +0100
From: Uwe Kleine-König
<u.kleine-koenig@...gutronix.de>
To: linux-kernel@...r.kernel.org
Cc: Alessandro Zummo <a.zummo@...ertech.it>,
Paul Gortmaker <p_gortmaker@...oo.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Valentin Longchamp <valentin.longchamp@...l.ch>,
Sascha Hauer <s.hauer@...gutronix.de>,
Samuel Ortiz <sameo@...ux.intel.com>
Subject: [PATCH 4/6] mfd/mc13783: new function reading irq mask and status register
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@...gutronix.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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists