aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-ds1305.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/rtc/rtc-ds1305.c')
-rw-r--r--drivers/rtc/rtc-ds1305.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/drivers/rtc/rtc-ds1305.c b/drivers/rtc/rtc-ds1305.c
index d8df2e9e14ad..2d502fc85698 100644
--- a/drivers/rtc/rtc-ds1305.c
+++ b/drivers/rtc/rtc-ds1305.c
@@ -203,8 +203,7 @@ static int ds1305_get_time(struct device *dev, struct rtc_time *time)
203 time->tm_hour, time->tm_mday, 203 time->tm_hour, time->tm_mday,
204 time->tm_mon, time->tm_year, time->tm_wday); 204 time->tm_mon, time->tm_year, time->tm_wday);
205 205
206 /* Time may not be set */ 206 return 0;
207 return rtc_valid_tm(time);
208} 207}
209 208
210static int ds1305_set_time(struct device *dev, struct rtc_time *time) 209static int ds1305_set_time(struct device *dev, struct rtc_time *time)
@@ -544,15 +543,6 @@ static int ds1305_nvram_write(void *priv, unsigned int off, void *buf,
544 return spi_sync(spi, &m); 543 return spi_sync(spi, &m);
545} 544}
546 545
547static struct nvmem_config ds1305_nvmem_cfg = {
548 .name = "ds1305_nvram",
549 .word_size = 1,
550 .stride = 1,
551 .size = DS1305_NVRAM_LEN,
552 .reg_read = ds1305_nvram_read,
553 .reg_write = ds1305_nvram_write,
554};
555
556/*----------------------------------------------------------------------*/ 546/*----------------------------------------------------------------------*/
557 547
558/* 548/*
@@ -566,6 +556,14 @@ static int ds1305_probe(struct spi_device *spi)
566 u8 addr, value; 556 u8 addr, value;
567 struct ds1305_platform_data *pdata = dev_get_platdata(&spi->dev); 557 struct ds1305_platform_data *pdata = dev_get_platdata(&spi->dev);
568 bool write_ctrl = false; 558 bool write_ctrl = false;
559 struct nvmem_config ds1305_nvmem_cfg = {
560 .name = "ds1305_nvram",
561 .word_size = 1,
562 .stride = 1,
563 .size = DS1305_NVRAM_LEN,
564 .reg_read = ds1305_nvram_read,
565 .reg_write = ds1305_nvram_write,
566 };
569 567
570 /* Sanity check board setup data. This may be hooked up 568 /* Sanity check board setup data. This may be hooked up
571 * in 3wire mode, but we don't care. Note that unless 569 * in 3wire mode, but we don't care. Note that unless
@@ -703,15 +701,15 @@ static int ds1305_probe(struct spi_device *spi)
703 ds1305->rtc->ops = &ds1305_ops; 701 ds1305->rtc->ops = &ds1305_ops;
704 702
705 ds1305_nvmem_cfg.priv = ds1305; 703 ds1305_nvmem_cfg.priv = ds1305;
706 ds1305->rtc->nvmem_config = &ds1305_nvmem_cfg;
707 ds1305->rtc->nvram_old_abi = true; 704 ds1305->rtc->nvram_old_abi = true;
708
709 status = rtc_register_device(ds1305->rtc); 705 status = rtc_register_device(ds1305->rtc);
710 if (status) { 706 if (status) {
711 dev_dbg(&spi->dev, "register rtc --> %d\n", status); 707 dev_dbg(&spi->dev, "register rtc --> %d\n", status);
712 return status; 708 return status;
713 } 709 }
714 710
711 rtc_nvmem_register(ds1305->rtc, &ds1305_nvmem_cfg);
712
715 /* Maybe set up alarm IRQ; be ready to handle it triggering right 713 /* Maybe set up alarm IRQ; be ready to handle it triggering right
716 * away. NOTE that we don't share this. The signal is active low, 714 * away. NOTE that we don't share this. The signal is active low,
717 * and we can't ack it before a SPI message delay. We temporarily 715 * and we can't ack it before a SPI message delay. We temporarily