From: Peter Ujfalusi <peter.ujfalusi@ti.com>
To: Samuel Ortiz <sameo@linux.intel.com>
Cc: linux-kernel@vger.kernel.org,
Misael Lopez Cruz <misael.lopez@ti.com>,
Benoit Cousson <b-cousson@ti.com>,
devicetree-discuss@lists.ozlabs.org, Liam Girdwood <lrg@ti.com>
Subject: [PATCH 2/3] MFD: twl6040: Allocate IRQ numbers dynamically
Date: Thu, 3 May 2012 15:54:24 +0300 [thread overview]
Message-ID: <1336049665-27777-3-git-send-email-peter.ujfalusi@ti.com> (raw)
In-Reply-To: <1336049665-27777-1-git-send-email-peter.ujfalusi@ti.com>
Use irq_alloc_descs() to get the IRQ number range dynamically instead of
the hardwired use if pdata->irq_base.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
drivers/mfd/twl6040-core.c | 3 +--
drivers/mfd/twl6040-irq.c | 13 +++++++++++--
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/drivers/mfd/twl6040-core.c b/drivers/mfd/twl6040-core.c
index 7a92d95..c50fba7 100644
--- a/drivers/mfd/twl6040-core.c
+++ b/drivers/mfd/twl6040-core.c
@@ -515,7 +515,7 @@ static int __devinit twl6040_probe(struct i2c_client *client,
}
/* In order to operate correctly we need valid interrupt config */
- if (!client->irq || !pdata->irq_base) {
+ if (!client->irq) {
dev_err(&client->dev, "Invalid IRQ configuration\n");
return -EINVAL;
}
@@ -552,7 +552,6 @@ static int __devinit twl6040_probe(struct i2c_client *client,
twl6040->dev = &client->dev;
twl6040->irq = client->irq;
- twl6040->irq_base = pdata->irq_base;
mutex_init(&twl6040->mutex);
mutex_init(&twl6040->io_mutex);
diff --git a/drivers/mfd/twl6040-irq.c b/drivers/mfd/twl6040-irq.c
index 008022c..914978e 100644
--- a/drivers/mfd/twl6040-irq.c
+++ b/drivers/mfd/twl6040-irq.c
@@ -23,6 +23,7 @@
#include <linux/kernel.h>
#include <linux/module.h>
+#include <linux/err.h>
#include <linux/irq.h>
#include <linux/interrupt.h>
#include <linux/mfd/core.h>
@@ -138,7 +139,7 @@ static irqreturn_t twl6040_irq_thread(int irq, void *data)
int twl6040_irq_init(struct twl6040 *twl6040)
{
- int i, nr_irqs, ret;
+ int i, nr_irqs, irq_base, ret;
u8 val;
mutex_init(&twl6040->irq_mutex);
@@ -149,8 +150,16 @@ int twl6040_irq_init(struct twl6040 *twl6040)
twl6040_reg_write(twl6040, TWL6040_REG_INTMR, TWL6040_ALLINT_MSK);
nr_irqs = ARRAY_SIZE(twl6040_irqs);
+
+ irq_base = irq_alloc_descs(-1, 0, nr_irqs, 0);
+ if (IS_ERR_VALUE(irq_base)) {
+ dev_err(twl6040->dev, "Fail to allocate IRQ descs\n");
+ return irq_base;
+ }
+ twl6040->irq_base = irq_base;
+
/* Register them with genirq */
- for (i = twl6040->irq_base; i < twl6040->irq_base + nr_irqs; i++) {
+ for (i = irq_base; i < irq_base + nr_irqs; i++) {
irq_set_chip_data(i, twl6040);
irq_set_chip_and_handler(i, &twl6040_irq_chip,
handle_level_irq);
--
1.7.8.6
next prev parent reply other threads:[~2012-05-03 12:54 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-03 12:54 [PATCH 0/3] MFD: twl6040: Device tree support Peter Ujfalusi
2012-05-03 12:54 ` [PATCH 1/3] MFD: twl6040: Code cleanup in interrupt initialization part Peter Ujfalusi
2012-05-03 12:54 ` Peter Ujfalusi [this message]
2012-05-03 13:20 ` [PATCH 2/3] MFD: twl6040: Allocate IRQ numbers dynamically Mark Brown
2012-05-03 13:28 ` Peter Ujfalusi
2012-05-03 14:52 ` Mark Brown
2012-05-03 15:13 ` Peter Ujfalusi
2012-05-03 15:26 ` Mark Brown
2012-05-04 8:38 ` Peter Ujfalusi
2012-05-04 9:08 ` Mark Brown
2012-05-04 10:37 ` Peter Ujfalusi
2012-05-04 11:22 ` Mark Brown
2012-05-04 11:55 ` Peter Ujfalusi
2012-05-04 12:17 ` Mark Brown
2012-05-04 12:33 ` Peter Ujfalusi
2012-05-04 12:47 ` Mark Brown
2012-05-07 6:49 ` Peter Ujfalusi
2012-05-07 9:49 ` Mark Brown
2012-05-03 12:54 ` [PATCH 3/3] MFD: twl6040: Support for DT Peter Ujfalusi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1336049665-27777-3-git-send-email-peter.ujfalusi@ti.com \
--to=peter.ujfalusi@ti.com \
--cc=b-cousson@ti.com \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lrg@ti.com \
--cc=misael.lopez@ti.com \
--cc=sameo@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®