mfd: Make sure to request twl6030 IRQ before using the irq_num
authorAxel Lin <axel.lin@gmail.com>
Thu, 11 Aug 2011 07:21:00 +0000 (15:21 +0800)
committerSamuel Ortiz <sameo@linux.intel.com>
Mon, 24 Oct 2011 12:09:10 +0000 (14:09 +0200)
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>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
drivers/mfd/twl6030-irq.c

index eb3b5f88e566c73e6599705649c83ec9b2758f2d..776402566c9e8994db18077fb897991e73ff0550 100644 (file)
@@ -331,12 +331,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);
@@ -344,11 +338,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;
This page took 0.025797 seconds and 5 git commands to generate.