aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-ds1307.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/rtc/rtc-ds1307.c')
-rw-r--r--drivers/rtc/rtc-ds1307.c49
1 files changed, 13 insertions, 36 deletions
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index 0d559b6416dd..4724ba3acf1a 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -495,50 +495,27 @@ static int ds1337_set_alarm(struct device *dev, struct rtc_wkalrm *t)
495 return 0; 495 return 0;
496} 496}
497 497
498static int ds1307_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) 498static int ds1307_alarm_irq_enable(struct device *dev, unsigned int enabled)
499{ 499{
500 struct i2c_client *client = to_i2c_client(dev); 500 struct i2c_client *client = to_i2c_client(dev);
501 struct ds1307 *ds1307 = i2c_get_clientdata(client); 501 struct ds1307 *ds1307 = i2c_get_clientdata(client);
502 int ret; 502 int ret;
503 503
504 switch (cmd) { 504 if (!test_bit(HAS_ALARM, &ds1307->flags))
505 case RTC_AIE_OFF: 505 return -ENOTTY;
506 if (!test_bit(HAS_ALARM, &ds1307->flags))
507 return -ENOTTY;
508
509 ret = i2c_smbus_read_byte_data(client, DS1337_REG_CONTROL);
510 if (ret < 0)
511 return ret;
512
513 ret &= ~DS1337_BIT_A1IE;
514
515 ret = i2c_smbus_write_byte_data(client,
516 DS1337_REG_CONTROL, ret);
517 if (ret < 0)
518 return ret;
519
520 break;
521
522 case RTC_AIE_ON:
523 if (!test_bit(HAS_ALARM, &ds1307->flags))
524 return -ENOTTY;
525 506
526 ret = i2c_smbus_read_byte_data(client, DS1337_REG_CONTROL); 507 ret = i2c_smbus_read_byte_data(client, DS1337_REG_CONTROL);
527 if (ret < 0) 508 if (ret < 0)
528 return ret; 509 return ret;
529 510
511 if (enabled)
530 ret |= DS1337_BIT_A1IE; 512 ret |= DS1337_BIT_A1IE;
513 else
514 ret &= ~DS1337_BIT_A1IE;
531 515
532 ret = i2c_smbus_write_byte_data(client, 516 ret = i2c_smbus_write_byte_data(client, DS1337_REG_CONTROL, ret);
533 DS1337_REG_CONTROL, ret); 517 if (ret < 0)
534 if (ret < 0) 518 return ret;
535 return ret;
536
537 break;
538
539 default:
540 return -ENOIOCTLCMD;
541 }
542 519
543 return 0; 520 return 0;
544} 521}
@@ -548,7 +525,7 @@ static const struct rtc_class_ops ds13xx_rtc_ops = {
548 .set_time = ds1307_set_time, 525 .set_time = ds1307_set_time,
549 .read_alarm = ds1337_read_alarm, 526 .read_alarm = ds1337_read_alarm,
550 .set_alarm = ds1337_set_alarm, 527 .set_alarm = ds1337_set_alarm,
551 .ioctl = ds1307_ioctl, 528 .alarm_irq_enable = ds1307_alarm_irq_enable,
552}; 529};
553 530
554/*----------------------------------------------------------------------*/ 531/*----------------------------------------------------------------------*/