diff options
author | Samuel Ortiz <sameo@openedhand.com> | 2008-12-18 11:38:02 +0100 |
---|---|---|
committer | Samuel Ortiz <samuel@sortiz.org> | 2009-01-04 12:17:42 +0100 |
commit | 94964f96a6b7018d68b7386cd8c0b8505d3cf69f (patch) | |
tree | cee94e998a901ffb9da336637cbade691bc0167f | |
parent | 342d765e011f9cbe4292119a9164f76ccf0b922a (diff) | |
download | kernel_samsung_smdk4412-94964f96a6b7018d68b7386cd8c0b8505d3cf69f.tar.gz kernel_samsung_smdk4412-94964f96a6b7018d68b7386cd8c0b8505d3cf69f.tar.bz2 kernel_samsung_smdk4412-94964f96a6b7018d68b7386cd8c0b8505d3cf69f.zip |
mfd: Use irq_to_desc in twl4030 code
The global irq_desc array is soon going to be accessible only with
!CONFIG_SPARSE_IRQ. We should start using the generic irq_to_desc()
routines instead.
Signed-off-by: Samuel Ortiz <sameo@openedhand.com>
-rw-r--r-- | drivers/mfd/twl4030-irq.c | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c index fae868a8d49..b1087603698 100644 --- a/drivers/mfd/twl4030-irq.c +++ b/drivers/mfd/twl4030-irq.c @@ -180,10 +180,15 @@ static struct completion irq_event; static int twl4030_irq_thread(void *data) { long irq = (long)data; - irq_desc_t *desc = irq_desc + irq; + struct irq_desc *desc = irq_to_desc(irq); static unsigned i2c_errors; const static unsigned max_i2c_errors = 100; + if (!desc) { + pr_err("twl4030: Invalid IRQ: %ld\n", irq); + return -EINVAL; + } + current->flags |= PF_NOFREEZE; while (!kthread_should_stop()) { @@ -215,7 +220,13 @@ static int twl4030_irq_thread(void *data) pih_isr; pih_isr >>= 1, module_irq++) { if (pih_isr & 0x1) { - irq_desc_t *d = irq_desc + module_irq; + struct irq_desc *d = irq_to_desc(module_irq); + + if (!d) { + pr_err("twl4030: Invalid SIH IRQ: %d\n", + module_irq); + return -EINVAL; + } /* These can't be masked ... always warn * if we get any surprises. @@ -452,10 +463,16 @@ static void twl4030_sih_do_edge(struct work_struct *work) /* Modify only the bits we know must change */ while (edge_change) { int i = fls(edge_change) - 1; - struct irq_desc *d = irq_desc + i + agent->irq_base; + struct irq_desc *d = irq_to_desc(i + agent->irq_base); int byte = 1 + (i >> 2); int off = (i & 0x3) * 2; + if (!d) { + pr_err("twl4030: Invalid IRQ: %d\n", + i + agent->irq_base); + return; + } + bytes[byte] &= ~(0x03 << off); spin_lock_irq(&d->lock); @@ -512,9 +529,14 @@ static void twl4030_sih_unmask(unsigned irq) static int twl4030_sih_set_type(unsigned irq, unsigned trigger) { struct sih_agent *sih = get_irq_chip_data(irq); - struct irq_desc *desc = irq_desc + irq; + struct irq_desc *desc = irq_to_desc(irq); unsigned long flags; + if (!desc) { + pr_err("twl4030: Invalid IRQ: %d\n", irq); + return -EINVAL; + } + if (trigger & ~(IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING)) return -EINVAL; |