aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-ds1374.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/rtc/rtc-ds1374.c')
-rw-r--r--drivers/rtc/rtc-ds1374.c37
1 files changed, 10 insertions, 27 deletions
diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c
index 47fb6357c346..d834a63ec4b0 100644
--- a/drivers/rtc/rtc-ds1374.c
+++ b/drivers/rtc/rtc-ds1374.c
@@ -307,42 +307,25 @@ unlock:
307 mutex_unlock(&ds1374->mutex); 307 mutex_unlock(&ds1374->mutex);
308} 308}
309 309
310static int ds1374_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) 310static int ds1374_alarm_irq_enable(struct device *dev, unsigned int enabled)
311{ 311{
312 struct i2c_client *client = to_i2c_client(dev); 312 struct i2c_client *client = to_i2c_client(dev);
313 struct ds1374 *ds1374 = i2c_get_clientdata(client); 313 struct ds1374 *ds1374 = i2c_get_clientdata(client);
314 int ret = -ENOIOCTLCMD; 314 int ret;
315 315
316 mutex_lock(&ds1374->mutex); 316 mutex_lock(&ds1374->mutex);
317 317
318 switch (cmd) { 318 ret = i2c_smbus_read_byte_data(client, DS1374_REG_CR);
319 case RTC_AIE_OFF: 319 if (ret < 0)
320 ret = i2c_smbus_read_byte_data(client, DS1374_REG_CR); 320 goto out;
321 if (ret < 0)
322 goto out;
323
324 ret &= ~DS1374_REG_CR_WACE;
325
326 ret = i2c_smbus_write_byte_data(client, DS1374_REG_CR, ret);
327 if (ret < 0)
328 goto out;
329
330 break;
331
332 case RTC_AIE_ON:
333 ret = i2c_smbus_read_byte_data(client, DS1374_REG_CR);
334 if (ret < 0)
335 goto out;
336 321
322 if (enabled) {
337 ret |= DS1374_REG_CR_WACE | DS1374_REG_CR_AIE; 323 ret |= DS1374_REG_CR_WACE | DS1374_REG_CR_AIE;
338 ret &= ~DS1374_REG_CR_WDALM; 324 ret &= ~DS1374_REG_CR_WDALM;
339 325 } else {
340 ret = i2c_smbus_write_byte_data(client, DS1374_REG_CR, ret); 326 ret &= ~DS1374_REG_CR_WACE;
341 if (ret < 0)
342 goto out;
343
344 break;
345 } 327 }
328 ret = i2c_smbus_write_byte_data(client, DS1374_REG_CR, ret);
346 329
347out: 330out:
348 mutex_unlock(&ds1374->mutex); 331 mutex_unlock(&ds1374->mutex);
@@ -354,7 +337,7 @@ static const struct rtc_class_ops ds1374_rtc_ops = {
354 .set_time = ds1374_set_time, 337 .set_time = ds1374_set_time,
355 .read_alarm = ds1374_read_alarm, 338 .read_alarm = ds1374_read_alarm,
356 .set_alarm = ds1374_set_alarm, 339 .set_alarm = ds1374_set_alarm,
357 .ioctl = ds1374_ioctl, 340 .alarm_irq_enable = ds1374_alarm_irq_enable,
358}; 341};
359 342
360static int ds1374_probe(struct i2c_client *client, 343static int ds1374_probe(struct i2c_client *client,