Commit 524465df authored by Jean Delvare's avatar Jean Delvare Committed by Greg Kroah-Hartman

[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: default avatarJean Delvare <khali@linux-fr.org>
Acked-by: default avatarRandy Vinson <rvinson@mvista.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent f043ca43
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <linux/rtc.h> #include <linux/rtc.h>
#include <linux/bcd.h> #include <linux/bcd.h>
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/workqueue.h>
#define DS1374_REG_TOD0 0x00 #define DS1374_REG_TOD0 0x00
#define DS1374_REG_TOD1 0x01 #define DS1374_REG_TOD1 0x01
...@@ -139,7 +140,7 @@ ulong ds1374_get_rtc_time(void) ...@@ -139,7 +140,7 @@ ulong ds1374_get_rtc_time(void)
return t1; return t1;
} }
static void ds1374_set_tlet(ulong arg) static void ds1374_set_work(void *arg)
{ {
ulong t1, t2; ulong t1, t2;
int limit = 10; /* arbitrary retry limit */ int limit = 10; /* arbitrary retry limit */
...@@ -168,17 +169,18 @@ static void ds1374_set_tlet(ulong arg) ...@@ -168,17 +169,18 @@ static void ds1374_set_tlet(ulong arg)
static ulong new_time; static ulong new_time;
static DECLARE_TASKLET_DISABLED(ds1374_tasklet, ds1374_set_tlet, static struct workqueue_struct *ds1374_workqueue;
(ulong) & new_time);
static DECLARE_WORK(ds1374_work, ds1374_set_work, &new_time);
int ds1374_set_rtc_time(ulong nowtime) int ds1374_set_rtc_time(ulong nowtime)
{ {
new_time = nowtime; new_time = nowtime;
if (in_interrupt()) if (in_interrupt())
tasklet_schedule(&ds1374_tasklet); queue_work(ds1374_workqueue, &ds1374_work);
else else
ds1374_set_tlet((ulong) & new_time); ds1374_set_work(&new_time);
return 0; return 0;
} }
...@@ -204,6 +206,8 @@ static int ds1374_probe(struct i2c_adapter *adap, int addr, int kind) ...@@ -204,6 +206,8 @@ static int ds1374_probe(struct i2c_adapter *adap, int addr, int kind)
client->adapter = adap; client->adapter = adap;
client->driver = &ds1374_driver; client->driver = &ds1374_driver;
ds1374_workqueue = create_singlethread_workqueue("ds1374");
if ((rc = i2c_attach_client(client)) != 0) { if ((rc = i2c_attach_client(client)) != 0) {
kfree(client); kfree(client);
return rc; return rc;
...@@ -227,7 +231,7 @@ static int ds1374_detach(struct i2c_client *client) ...@@ -227,7 +231,7 @@ static int ds1374_detach(struct i2c_client *client)
if ((rc = i2c_detach_client(client)) == 0) { if ((rc = i2c_detach_client(client)) == 0) {
kfree(i2c_get_clientdata(client)); kfree(i2c_get_clientdata(client));
tasklet_kill(&ds1374_tasklet); destroy_workqueue(ds1374_workqueue);
} }
return rc; return rc;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment