pcf50633: use a dedicated workqueue for irq processing
authorPaul Fertser <fercerpav@gmail.com>
Mon, 27 Jul 2009 20:41:15 +0000 (00:41 +0400)
committerPaul Fertser <fercerpav@gmail.com>
Sun, 2 Aug 2009 07:27:18 +0000 (11:27 +0400)
Using the default kernel "events" workqueue causes problems with
synchronous adc readings if initiated from some task on the same
workqueue.

I had a deadlock trying to use pcf50633_adc_sync_read from a
power_supply class driver because the reading was initiated from the
workqueue and it waited for the irq processing to complete (to get the
result) and that was put on the same workqueue.

Signed-off-by: Paul Fertser <fercerpav@gmail.com>
drivers/mfd/pcf50633-core.c
include/linux/mfd/pcf50633/core.h

index 29c9395..5006746 100644 (file)
@@ -448,7 +448,7 @@ static irqreturn_t pcf50633_irq(int irq, void *data)
        get_device(pcf->dev);
        disable_irq(pcf->irq);
 
-       schedule_work(&pcf->irq_work);
+       queue_work(pcf->work_queue, &pcf->irq_work);
 
        return IRQ_HANDLED;
 }
@@ -579,6 +579,7 @@ static int __devinit pcf50633_probe(struct i2c_client *client,
        pcf->dev = &client->dev;
        pcf->i2c_client = client;
        pcf->irq = client->irq;
+       pcf->work_queue = create_singlethread_workqueue("pcf50633");
 
        INIT_WORK(&pcf->irq_work, pcf50633_irq_worker);
 
@@ -656,6 +657,7 @@ static int __devinit pcf50633_probe(struct i2c_client *client,
        return 0;
 
 err:
+       destroy_workqueue(pcf->work_queue);
        kfree(pcf);
        return ret;
 }
@@ -666,6 +668,7 @@ static int __devexit pcf50633_remove(struct i2c_client *client)
        int i;
 
        free_irq(pcf->irq, pcf);
+       destroy_workqueue(pcf->work_queue);
 
        platform_device_unregister(pcf->input_pdev);
        platform_device_unregister(pcf->rtc_pdev);
index af67b4e..aed1fab 100644 (file)
@@ -138,6 +138,7 @@ struct pcf50633 {
        int irq;
        struct pcf50633_irq irq_handler[PCF50633_NUM_IRQ];
        struct work_struct irq_work;
+       struct workqueue_struct *work_queue;
        struct mutex lock;
 
        u8 mask_regs[5];