aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/chips/m41t00.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/i2c/chips/m41t00.c')
-rw-r--r--drivers/i2c/chips/m41t00.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/drivers/i2c/chips/m41t00.c b/drivers/i2c/chips/m41t00.c
index b5aabe7cf792..99ab4ec34390 100644
--- a/drivers/i2c/chips/m41t00.c
+++ b/drivers/i2c/chips/m41t00.c
@@ -25,6 +25,7 @@
25#include <linux/rtc.h> 25#include <linux/rtc.h>
26#include <linux/bcd.h> 26#include <linux/bcd.h>
27#include <linux/mutex.h> 27#include <linux/mutex.h>
28#include <linux/workqueue.h>
28 29
29#include <asm/time.h> 30#include <asm/time.h>
30#include <asm/rtc.h> 31#include <asm/rtc.h>
@@ -111,7 +112,7 @@ m41t00_get_rtc_time(void)
111} 112}
112 113
113static void 114static void
114m41t00_set_tlet(ulong arg) 115m41t00_set(void *arg)
115{ 116{
116 struct rtc_time tm; 117 struct rtc_time tm;
117 ulong nowtime = *(ulong *)arg; 118 ulong nowtime = *(ulong *)arg;
@@ -130,13 +131,13 @@ m41t00_set_tlet(ulong arg)
130 if ((i2c_smbus_write_byte_data(save_client, 0, tm.tm_sec & 0x7f) < 0) 131 if ((i2c_smbus_write_byte_data(save_client, 0, tm.tm_sec & 0x7f) < 0)
131 || (i2c_smbus_write_byte_data(save_client, 1, tm.tm_min & 0x7f) 132 || (i2c_smbus_write_byte_data(save_client, 1, tm.tm_min & 0x7f)
132 < 0) 133 < 0)
133 || (i2c_smbus_write_byte_data(save_client, 2, tm.tm_hour & 0x7f) 134 || (i2c_smbus_write_byte_data(save_client, 2, tm.tm_hour & 0x3f)
134 < 0) 135 < 0)
135 || (i2c_smbus_write_byte_data(save_client, 4, tm.tm_mday & 0x7f) 136 || (i2c_smbus_write_byte_data(save_client, 4, tm.tm_mday & 0x3f)
136 < 0) 137 < 0)
137 || (i2c_smbus_write_byte_data(save_client, 5, tm.tm_mon & 0x7f) 138 || (i2c_smbus_write_byte_data(save_client, 5, tm.tm_mon & 0x1f)
138 < 0) 139 < 0)
139 || (i2c_smbus_write_byte_data(save_client, 6, tm.tm_year & 0x7f) 140 || (i2c_smbus_write_byte_data(save_client, 6, tm.tm_year & 0xff)
140 < 0)) 141 < 0))
141 142
142 dev_warn(&save_client->dev,"m41t00: can't write to rtc chip\n"); 143 dev_warn(&save_client->dev,"m41t00: can't write to rtc chip\n");
@@ -145,9 +146,9 @@ m41t00_set_tlet(ulong arg)
145 return; 146 return;
146} 147}
147 148
148static ulong new_time; 149static ulong new_time;
149 150static struct workqueue_struct *m41t00_wq;
150DECLARE_TASKLET_DISABLED(m41t00_tasklet, m41t00_set_tlet, (ulong)&new_time); 151static DECLARE_WORK(m41t00_work, m41t00_set, &new_time);
151 152
152int 153int
153m41t00_set_rtc_time(ulong nowtime) 154m41t00_set_rtc_time(ulong nowtime)
@@ -155,9 +156,9 @@ m41t00_set_rtc_time(ulong nowtime)
155 new_time = nowtime; 156 new_time = nowtime;
156 157
157 if (in_interrupt()) 158 if (in_interrupt())
158 tasklet_schedule(&m41t00_tasklet); 159 queue_work(m41t00_wq, &m41t00_work);
159 else 160 else
160 m41t00_set_tlet((ulong)&new_time); 161 m41t00_set(&new_time);
161 162
162 return 0; 163 return 0;
163} 164}
@@ -189,6 +190,7 @@ m41t00_probe(struct i2c_adapter *adap, int addr, int kind)
189 return rc; 190 return rc;
190 } 191 }
191 192
193 m41t00_wq = create_singlethread_workqueue("m41t00");
192 save_client = client; 194 save_client = client;
193 return 0; 195 return 0;
194} 196}
@@ -206,7 +208,7 @@ m41t00_detach(struct i2c_client *client)
206 208
207 if ((rc = i2c_detach_client(client)) == 0) { 209 if ((rc = i2c_detach_client(client)) == 0) {
208 kfree(client); 210 kfree(client);
209 tasklet_kill(&m41t00_tasklet); 211 destroy_workqueue(m41t00_wq);
210 } 212 }
211 return rc; 213 return rc;
212} 214}