]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/i2c/chips/ds1374.c
[ARM] 4751/1: [AT91] ISI peripheral on SAM9263
[linux-2.6-omap-h63xx.git] / drivers / i2c / chips / ds1374.c
index 03d09ed5ec2c009d21a4816f85e82829f76e2706..8a2ff0c114d9db7460c3b8177d9dbec2472456fa 100644 (file)
@@ -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,12 +140,14 @@ ulong ds1374_get_rtc_time(void)
        return t1;
 }
 
-static void ds1374_set_tlet(ulong arg)
+static ulong new_time;
+
+static void ds1374_set_work(struct work_struct *work)
 {
        ulong t1, t2;
        int limit = 10;         /* arbitrary retry limit */
 
-       t1 = *(ulong *) arg;
+       t1 = new_time;
 
        mutex_lock(&ds1374_mutex);
 
@@ -166,19 +169,18 @@ static void ds1374_set_tlet(ulong arg)
                         "can't confirm time set from rtc chip\n");
 }
 
-static ulong new_time;
+static struct workqueue_struct *ds1374_workqueue;
 
-static DECLARE_TASKLET_DISABLED(ds1374_tasklet, ds1374_set_tlet,
-                               (ulong) & new_time);
+static DECLARE_WORK(ds1374_work, ds1374_set_work);
 
 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(NULL);
 
        return 0;
 }
@@ -204,6 +206,12 @@ 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 (!ds1374_workqueue) {
+               kfree(client);
+               return -ENOMEM; /* most expected reason */
+       }
+
        if ((rc = i2c_attach_client(client)) != 0) {
                kfree(client);
                return rc;
@@ -227,7 +235,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;
 }