256 cr &= ~DS1374_REG_CR_WDALM;
257
258 ret = i2c_smbus_write_byte_data(client, DS1374_REG_CR, cr);
259 }
260
261out:
262 mutex_unlock(&ds1374->mutex);
263 return ret;
264}
265
266static irqreturn_t ds1374_irq(int irq, void *dev_id)
267{
268 struct i2c_client *client = dev_id;
269 struct ds1374 *ds1374 = i2c_get_clientdata(client);
270
271 disable_irq_nosync(irq);
272 schedule_work(&ds1374->work);
273 return IRQ_HANDLED;
274}
275
276static void ds1374_work(struct work_struct *work)
277{
278 struct ds1374 *ds1374 = container_of(work, struct ds1374, work);
279 struct i2c_client *client = ds1374->client;
280 int stat, control;
281
282 mutex_lock(&ds1374->mutex);
283
284 stat = i2c_smbus_read_byte_data(client, DS1374_REG_SR);
285 if (stat < 0)
286 return;
287
288 if (stat & DS1374_REG_SR_AF) {
289 stat &= ~DS1374_REG_SR_AF;
290 i2c_smbus_write_byte_data(client, DS1374_REG_SR, stat);
291
292 control = i2c_smbus_read_byte_data(client, DS1374_REG_CR);
293 if (control < 0)
294 goto out;
295
296 control &= ~(DS1374_REG_CR_WACE | DS1374_REG_CR_AIE);