public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Axel Lin <axel.lin@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Rajendra Nayak <rnayak@ti.com>, Balaji T K <balajitk@ti.com>,
	Santosh Shilimkar <santosh.shilimkar@ti.com>,
	Samuel Ortiz <sameo@linux.intel.com>
Subject: [PATCH] mfd: twl6030-irq: Make sure to call request_irq before using the irq_num
Date: Thu, 11 Aug 2011 15:21:00 +0800	[thread overview]
Message-ID: <1313047260.27089.1.camel@phoenix> (raw)

I was trying to fix the error handling part because in the case of
request_irq failure, it should call kthread_stop instead of free_irq.
But it seems more reasonable to do request_irq before calling kthread_run.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/mfd/twl6030-irq.c |   18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
index b57383b..e0baff8 100644
--- a/drivers/mfd/twl6030-irq.c
+++ b/drivers/mfd/twl6030-irq.c
@@ -332,12 +332,6 @@ int twl6030_init_irq(int irq_num, unsigned irq_base, unsigned irq_end)
 
 	/* install an irq handler to demultiplex the TWL6030 interrupt */
 	init_completion(&irq_event);
-	task = kthread_run(twl6030_irq_thread, (void *)irq_num, "twl6030-irq");
-	if (IS_ERR(task)) {
-		pr_err("twl6030: could not create irq %d thread!\n", irq_num);
-		status = PTR_ERR(task);
-		goto fail_kthread;
-	}
 
 	status = request_irq(irq_num, handle_twl6030_pih, IRQF_DISABLED,
 				"TWL6030-PIH", &irq_event);
@@ -345,11 +339,19 @@ int twl6030_init_irq(int irq_num, unsigned irq_base, unsigned irq_end)
 		pr_err("twl6030: could not claim irq%d: %d\n", irq_num, status);
 		goto fail_irq;
 	}
+
+	task = kthread_run(twl6030_irq_thread, (void *)irq_num, "twl6030-irq");
+	if (IS_ERR(task)) {
+		pr_err("twl6030: could not create irq %d thread!\n", irq_num);
+		status = PTR_ERR(task);
+		goto fail_kthread;
+	}
 	return status;
-fail_irq:
-	free_irq(irq_num, &irq_event);
 
 fail_kthread:
+	free_irq(irq_num, &irq_event);
+
+fail_irq:
 	for (i = irq_base; i < irq_end; i++)
 		irq_set_chip_and_handler(i, NULL, NULL);
 	return status;
-- 
1.7.4.1




             reply	other threads:[~2011-08-11  7:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-11  7:21 Axel Lin [this message]
2011-08-22 13:32 ` [PATCH] mfd: twl6030-irq: Make sure to call request_irq before using the irq_num 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=1313047260.27089.1.camel@phoenix \
    --to=axel.lin@gmail.com \
    --cc=balajitk@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rnayak@ti.com \
    --cc=sameo@linux.intel.com \
    --cc=santosh.shilimkar@ti.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