diff options
author | Jean Delvare <khali@linux-fr.org> | 2006-03-31 23:05:01 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-04-14 11:18:33 -0700 |
commit | 524465df2accf54604cb89c04dbaab0c8aaa5bb4 (patch) | |
tree | 2fd935549b981ae0c60b7fe6a50aa71b9a377347 /drivers/i2c/chips | |
parent | f043ca43c1ae354346f72dc5826d820d5619f0b2 (diff) | |
download | linux-3.10-524465df2accf54604cb89c04dbaab0c8aaa5bb4.tar.gz linux-3.10-524465df2accf54604cb89c04dbaab0c8aaa5bb4.tar.bz2 linux-3.10-524465df2accf54604cb89c04dbaab0c8aaa5bb4.zip |
[PATCH] i2c: convert ds1374 to use a workqueue
A tasklet is not suitable for what the ds1374 driver does: neither sleeping
nor mutex operations are allowed in tasklets, and ds1374_set_tlet may do
both.
We can use a workqueue instead, where both sleeping and mutex operations
are allowed.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Acked-by: Randy Vinson <rvinson@mvista.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/i2c/chips')
-rw-r--r-- | drivers/i2c/chips/ds1374.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/drivers/i2c/chips/ds1374.c b/drivers/i2c/chips/ds1374.c index 03d09ed5ec2..4630f1969a0 100644 --- a/drivers/i2c/chips/ds1374.c +++ b/drivers/i2c/chips/ds1374.c @@ -27,6 +27,7 @@ #include <linux/rtc.h> #include <linux/bcd.h> #include <linux/mutex.h> +#include <linux/workqueue.h> #define DS1374_REG_TOD0 0x00 #define DS1374_REG_TOD1 0x01 @@ -139,7 +140,7 @@ ulong ds1374_get_rtc_time(void) return t1; } -static void ds1374_set_tlet(ulong arg) +static void ds1374_set_work(void *arg) { ulong t1, t2; int limit = 10; /* arbitrary retry limit */ @@ -168,17 +169,18 @@ static void ds1374_set_tlet(ulong arg) static ulong new_time; -static DECLARE_TASKLET_DISABLED(ds1374_tasklet, ds1374_set_tlet, - (ulong) & new_time); +static struct workqueue_struct *ds1374_workqueue; + +static DECLARE_WORK(ds1374_work, ds1374_set_work, &new_time); int ds1374_set_rtc_time(ulong nowtime) { new_time = nowtime; if (in_interrupt()) - tasklet_schedule(&ds1374_tasklet); + queue_work(ds1374_workqueue, &ds1374_work); else - ds1374_set_tlet((ulong) & new_time); + ds1374_set_work(&new_time); return 0; } @@ -204,6 +206,8 @@ static int ds1374_probe(struct i2c_adapter *adap, int addr, int kind) client->adapter = adap; client->driver = &ds1374_driver; + ds1374_workqueue = create_singlethread_workqueue("ds1374"); + if ((rc = i2c_attach_client(client)) != 0) { kfree(client); return rc; @@ -227,7 +231,7 @@ static int ds1374_detach(struct i2c_client *client) if ((rc = i2c_detach_client(client)) == 0) { kfree(i2c_get_clientdata(client)); - tasklet_kill(&ds1374_tasklet); + destroy_workqueue(ds1374_workqueue); } return rc; } |