From: Peter Ujfalusi <peter.ujfalusi@ti.com>
To: Samuel Ortiz <sameo@linux.intel.com>
Cc: <linux-kernel@vger.kernel.org>,
Mark Brown <broonie@opensource.wolfsonmicro.com>,
<peter.ujfalusi@ti.com>
Subject: [PATCH 4/6] MFD: twl6040: Correct Ready and Thermal interrupt handling
Date: Thu, 11 Oct 2012 13:55:31 +0200 [thread overview]
Message-ID: <1349956533-6374-5-git-send-email-peter.ujfalusi@ti.com> (raw)
In-Reply-To: <1349956533-6374-1-git-send-email-peter.ujfalusi@ti.com>
Create new irq handler for thermal events in order to be able to handle the
event and clean up the code regarding to interrupt handling:
Use proper function names for the irq handlers
No need to read the INTD register anymore.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
drivers/mfd/twl6040-core.c | 52 +++++++++++++++++++++++++++-------------------
1 file changed, 31 insertions(+), 21 deletions(-)
diff --git a/drivers/mfd/twl6040-core.c b/drivers/mfd/twl6040-core.c
index 6d9db27..5817bc6 100644
--- a/drivers/mfd/twl6040-core.c
+++ b/drivers/mfd/twl6040-core.c
@@ -193,27 +193,27 @@ static void twl6040_power_down_manual(struct twl6040 *twl6040)
twl6040_reg_write(twl6040, TWL6040_REG_LDOCTL, ldoctl);
}
-static irqreturn_t twl6040_naudint_handler(int irq, void *data)
+static irqreturn_t twl6040_readyint_handler(int irq, void *data)
{
struct twl6040 *twl6040 = data;
- u8 intid, status;
- intid = twl6040_reg_read(twl6040, TWL6040_REG_INTID);
+ complete(&twl6040->ready);
- if (intid & TWL6040_READYINT)
- complete(&twl6040->ready);
+ return IRQ_HANDLED;
+}
- if (intid & TWL6040_THINT) {
- status = twl6040_reg_read(twl6040, TWL6040_REG_STATUS);
- if (status & TWL6040_TSHUTDET) {
- dev_warn(twl6040->dev,
- "Thermal shutdown, powering-off");
- twl6040_power(twl6040, 0);
- } else {
- dev_warn(twl6040->dev,
- "Leaving thermal shutdown, powering-on");
- twl6040_power(twl6040, 1);
- }
+static irqreturn_t twl6040_thint_handler(int irq, void *data)
+{
+ struct twl6040 *twl6040 = data;
+ u8 status;
+
+ status = twl6040_reg_read(twl6040, TWL6040_REG_STATUS);
+ if (status & TWL6040_TSHUTDET) {
+ dev_warn(twl6040->dev, "Thermal shutdown, powering-off");
+ twl6040_power(twl6040, 0);
+ } else {
+ dev_warn(twl6040->dev, "Leaving thermal shutdown, powering-on");
+ twl6040_power(twl6040, 1);
}
return IRQ_HANDLED;
@@ -580,12 +580,19 @@ static int __devinit twl6040_probe(struct i2c_client *client,
goto irq_init_err;
ret = request_threaded_irq(twl6040->irq_base + TWL6040_IRQ_READY,
- NULL, twl6040_naudint_handler, IRQF_ONESHOT,
+ NULL, twl6040_readyint_handler, IRQF_ONESHOT,
"twl6040_irq_ready", twl6040);
if (ret) {
- dev_err(twl6040->dev, "READY IRQ request failed: %d\n",
- ret);
- goto irq_err;
+ dev_err(twl6040->dev, "READY IRQ request failed: %d\n", ret);
+ goto readyirq_err;
+ }
+
+ ret = request_threaded_irq(twl6040->irq_base + TWL6040_IRQ_TH,
+ NULL, twl6040_thint_handler, IRQF_ONESHOT,
+ "twl6040_irq_th", twl6040);
+ if (ret) {
+ dev_err(twl6040->dev, "Thermal IRQ request failed: %d\n", ret);
+ goto thirq_err;
}
/* dual-access registers controlled by I2C only */
@@ -650,8 +657,10 @@ static int __devinit twl6040_probe(struct i2c_client *client,
return 0;
mfd_err:
+ free_irq(twl6040->irq_base + TWL6040_IRQ_TH, twl6040);
+thirq_err:
free_irq(twl6040->irq_base + TWL6040_IRQ_READY, twl6040);
-irq_err:
+readyirq_err:
twl6040_irq_exit(twl6040);
irq_init_err:
if (gpio_is_valid(twl6040->audpwron))
@@ -677,6 +686,7 @@ static int __devexit twl6040_remove(struct i2c_client *client)
gpio_free(twl6040->audpwron);
free_irq(twl6040->irq_base + TWL6040_IRQ_READY, twl6040);
+ free_irq(twl6040->irq_base + TWL6040_IRQ_TH, twl6040);
twl6040_irq_exit(twl6040);
mfd_remove_devices(&client->dev);
--
1.7.12
next prev parent reply other threads:[~2012-10-11 11:56 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-11 11:55 [PATCH 0/6] MFD: twl6040: Conversion to use regmap_irq Peter Ujfalusi
2012-10-11 11:55 ` [PATCH 1/6] MFD: twl6040: Fix typo for power on failure Peter Ujfalusi
2012-10-11 11:55 ` [PATCH 2/6] MFD: twl6040: Remove unused parameter for twl6040_power_up_completion() Peter Ujfalusi
2012-10-11 11:55 ` [PATCH 3/6] MFD: twl6040: Restructure power up and down code Peter Ujfalusi
2012-10-11 11:55 ` Peter Ujfalusi [this message]
2012-10-11 11:55 ` [PATCH 5/6] MFD: twl6040: Convert to use regmap_irq Peter Ujfalusi
2012-10-16 6:20 ` Mark Brown
2012-10-11 11:55 ` [PATCH 6/6] MFD: twl6040: Rename the core driver Peter Ujfalusi
2012-11-12 14:52 ` [PATCH 0/6] MFD: twl6040: Conversion to use regmap_irq Peter Ujfalusi
2012-11-13 18:55 ` Samuel Ortiz
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=1349956533-6374-5-git-send-email-peter.ujfalusi@ti.com \
--to=peter.ujfalusi@ti.com \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=linux-kernel@vger.kernel.org \
--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®