[PATCH] mfd: add workqueue thread into 88pm860x

From: Haojian Zhuang
Date: Mon Mar 07 2011 - 10:55:56 EST


Create workqueue thread in 88pm860x driver since 88pm860x driver
needs to handle event in workqueue.

Avoid to use system workqueue since i2c operation cost a lot of
time. It would impact system performance.

Signed-off-by: Haojian Zhuang <haojian.zhuang@xxxxxxxxxxx>
---
drivers/mfd/88pm860x-core.c | 12 ++++++++++++
include/linux/mfd/88pm860x.h | 1 +
2 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/drivers/mfd/88pm860x-core.c b/drivers/mfd/88pm860x-core.c
index 9c511c1..42c4fa2 100644
--- a/drivers/mfd/88pm860x-core.c
+++ b/drivers/mfd/88pm860x-core.c
@@ -766,11 +766,21 @@ static void __devinit device_8607_init(struct pm860x_chip *chip,
if (ret < 0)
goto out;

+ chip->monitor_wqueue = create_singlethread_workqueue("88pm860x");
+ if (!chip->monitor_wqueue) {
+ ret = -ESRCH;
+ goto out_work;
+ }
+
device_regulator_init(chip, i2c, pdata);
device_onkey_init(chip, i2c, pdata);
device_touch_init(chip, i2c, pdata);
device_power_init(chip, i2c, pdata);
device_codec_init(chip, i2c, pdata);
+ return;
+
+out_work:
+ device_irq_exit(chip);
out:
return;
}
@@ -807,6 +817,8 @@ int __devinit pm860x_device_init(struct pm860x_chip *chip,

void __devexit pm860x_device_exit(struct pm860x_chip *chip)
{
+ flush_workqueue(chip->monitor_wqueue);
+ destroy_workqueue(chip->monitor_wqueue);
device_irq_exit(chip);
mfd_remove_devices(chip->dev);
}
diff --git a/include/linux/mfd/88pm860x.h b/include/linux/mfd/88pm860x.h
index a6f6f81..87df510 100644
--- a/include/linux/mfd/88pm860x.h
+++ b/include/linux/mfd/88pm860x.h
@@ -301,6 +301,7 @@ struct pm860x_chip {
struct mutex irq_lock;
struct i2c_client *client;
struct i2c_client *companion; /* companion chip client */
+ struct workqueue_struct *monitor_wqueue;

int buck3_double; /* DVC ramp slope double */
unsigned short companion_addr;
--
1.5.6.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/