From d25a5ed37d5fdd25f3cfbffc2f9a0f62e58f884c Mon Sep 17 00:00:00 2001 From: Sergey Yanovich Date: Tue, 23 Feb 2016 13:54:57 +0300 Subject: rtc: ds1302: rewrite using SPI DS1302 is an half-duplex SPI device. The driver respects this fact now. Pin configurations should be implemented using SPI subsystem. Signed-off-by: Sergei Ianovich Acked-by: Rob Herring Signed-off-by: Alexandre Belloni --- drivers/rtc/rtc-ds1302.c | 348 +++++++++++++++++++++-------------------------- 1 file changed, 157 insertions(+), 191 deletions(-) (limited to 'drivers/rtc/rtc-ds1302.c') diff --git a/drivers/rtc/rtc-ds1302.c b/drivers/rtc/rtc-ds1302.c index 6bef7a5233c4..5cdc0f201b34 100644 --- a/drivers/rtc/rtc-ds1302.c +++ b/drivers/rtc/rtc-ds1302.c @@ -9,16 +9,17 @@ * this archive for more details. */ +#include #include -#include +#include #include -#include +#include +#include #include -#include -#include +#include #define DRV_NAME "rtc-ds1302" -#define DRV_VERSION "0.1.1" +#define DRV_VERSION "1.0.0" #define RTC_CMD_READ 0x81 /* Read command */ #define RTC_CMD_WRITE 0x80 /* Write command */ @@ -28,6 +29,8 @@ #define RTC_ADDR_RAM0 0x20 /* Address of RAM0 */ #define RTC_ADDR_TCR 0x08 /* Address of trickle charge register */ +#define RTC_CLCK_BURST 0x1F /* Address of clock burst */ +#define RTC_CLCK_LEN 0x08 /* Size of clock burst */ #define RTC_ADDR_CTRL 0x07 /* Address of control register */ #define RTC_ADDR_YEAR 0x06 /* Address of year register */ #define RTC_ADDR_DAY 0x05 /* Address of day of week register */ @@ -37,217 +40,180 @@ #define RTC_ADDR_MIN 0x01 /* Address of minute register */ #define RTC_ADDR_SEC 0x00 /* Address of second register */ -#ifdef CONFIG_SH_SECUREEDGE5410 -#include -#include - -#define RTC_RESET 0x1000 -#define RTC_IODATA 0x0800 -#define RTC_SCLK 0x0400 - -#define set_dp(x) SECUREEDGE_WRITE_IOPORT(x, 0x1c00) -#define get_dp() SECUREEDGE_READ_IOPORT() -#define ds1302_set_tx() -#define ds1302_set_rx() - -static inline int ds1302_hw_init(void) +static int ds1302_rtc_set_time(struct device *dev, struct rtc_time *time) { - return 0; + struct spi_device *spi = dev_get_drvdata(dev); + u8 buf[1 + RTC_CLCK_LEN]; + u8 *bp = buf; + int status; + + /* Enable writing */ + bp = buf; + *bp++ = RTC_ADDR_CTRL << 1 | RTC_CMD_WRITE; + *bp++ = RTC_CMD_WRITE_ENABLE; + + status = spi_write_then_read(spi, buf, 2, + NULL, 0); + if (!status) + return status; + + /* Write registers starting at the first time/date address. */ + bp = buf; + *bp++ = RTC_CLCK_BURST << 1 | RTC_CMD_WRITE; + + *bp++ = bin2bcd(time->tm_sec); + *bp++ = bin2bcd(time->tm_min); + *bp++ = bin2bcd(time->tm_hour); + *bp++ = bin2bcd(time->tm_mday); + *bp++ = bin2bcd(time->tm_mon + 1); + *bp++ = time->tm_wday; + *bp++ = bin2bcd(time->tm_year % 100); + *bp++ = RTC_CMD_WRITE_DISABLE; + + /* use write-then-read since dma from stack is nonportable */ + return spi_write_then_read(spi, buf, sizeof(buf), + NULL, 0); } -static inline void ds1302_reset(void) +static int ds1302_rtc_get_time(struct device *dev, struct rtc_time *time) { - set_dp(get_dp() & ~(RTC_RESET | RTC_IODATA | RTC_SCLK)); + struct spi_device *spi = dev_get_drvdata(dev); + u8 addr = RTC_CLCK_BURST << 1 | RTC_CMD_READ; + u8 buf[RTC_CLCK_LEN - 1]; + int status; + + /* Use write-then-read to get all the date/time registers + * since dma from stack is nonportable + */ + status = spi_write_then_read(spi, &addr, sizeof(addr), + buf, sizeof(buf)); + if (status < 0) + return status; + + /* Decode the registers */ + time->tm_sec = bcd2bin(buf[RTC_ADDR_SEC]); + time->tm_min = bcd2bin(buf[RTC_ADDR_MIN]); + time->tm_hour = bcd2bin(buf[RTC_ADDR_HOUR]); + time->tm_wday = buf[RTC_ADDR_DAY] - 1; + time->tm_mday = bcd2bin(buf[RTC_ADDR_DATE]); + time->tm_mon = bcd2bin(buf[RTC_ADDR_MON]) - 1; + time->tm_year = bcd2bin(buf[RTC_ADDR_YEAR]) + 100; + + /* Time may not be set */ + return rtc_valid_tm(time); } -static inline void ds1302_clock(void) -{ - set_dp(get_dp() | RTC_SCLK); /* clock high */ - set_dp(get_dp() & ~RTC_SCLK); /* clock low */ -} - -static inline void ds1302_start(void) -{ - set_dp(get_dp() | RTC_RESET); -} - -static inline void ds1302_stop(void) -{ - set_dp(get_dp() & ~RTC_RESET); -} - -static inline void ds1302_txbit(int bit) -{ - set_dp((get_dp() & ~RTC_IODATA) | (bit ? RTC_IODATA : 0)); -} - -static inline int ds1302_rxbit(void) -{ - return !!(get_dp() & RTC_IODATA); -} - -#else -#error "Add support for your platform" -#endif +static struct rtc_class_ops ds1302_rtc_ops = { + .read_time = ds1302_rtc_get_time, + .set_time = ds1302_rtc_set_time, +}; -static void ds1302_sendbits(unsigned int val) +static int ds1302_probe(struct spi_device *spi) { - int i; - - ds1302_set_tx(); - - for (i = 8; (i); i--, val >>= 1) { - ds1302_txbit(val & 0x1); - ds1302_clock(); + struct rtc_device *rtc; + u8 addr; + u8 buf[4]; + u8 *bp = buf; + int status; + + /* Sanity check board setup data. This may be hooked up + * in 3wire mode, but we don't care. Note that unless + * there's an inverter in place, this needs SPI_CS_HIGH! + */ + if (spi->bits_per_word && (spi->bits_per_word != 8)) { + dev_err(&spi->dev, "bad word length\n"); + return -EINVAL; + } else if (spi->max_speed_hz > 2000000) { + dev_err(&spi->dev, "speed is too high\n"); + return -EINVAL; + } else if (spi->mode & SPI_CPHA) { + dev_err(&spi->dev, "bad mode\n"); + return -EINVAL; } -} - -static unsigned int ds1302_recvbits(void) -{ - unsigned int val; - int i; - - ds1302_set_rx(); - for (i = 0, val = 0; (i < 8); i++) { - val |= (ds1302_rxbit() << i); - ds1302_clock(); + addr = RTC_ADDR_CTRL << 1 | RTC_CMD_READ; + status = spi_write_then_read(spi, &addr, sizeof(addr), buf, 1); + if (status < 0) { + dev_err(&spi->dev, "control register read error %d\n", + status); + return status; } - return val; -} - -static unsigned int ds1302_readbyte(unsigned int addr) -{ - unsigned int val; - - ds1302_reset(); - - ds1302_start(); - ds1302_sendbits(((addr & 0x3f) << 1) | RTC_CMD_READ); - val = ds1302_recvbits(); - ds1302_stop(); - - return val; -} - -static void ds1302_writebyte(unsigned int addr, unsigned int val) -{ - ds1302_reset(); - - ds1302_start(); - ds1302_sendbits(((addr & 0x3f) << 1) | RTC_CMD_WRITE); - ds1302_sendbits(val); - ds1302_stop(); -} - -static int ds1302_rtc_read_time(struct device *dev, struct rtc_time *tm) -{ - tm->tm_sec = bcd2bin(ds1302_readbyte(RTC_ADDR_SEC)); - tm->tm_min = bcd2bin(ds1302_readbyte(RTC_ADDR_MIN)); - tm->tm_hour = bcd2bin(ds1302_readbyte(RTC_ADDR_HOUR)); - tm->tm_wday = bcd2bin(ds1302_readbyte(RTC_ADDR_DAY)); - tm->tm_mday = bcd2bin(ds1302_readbyte(RTC_ADDR_DATE)); - tm->tm_mon = bcd2bin(ds1302_readbyte(RTC_ADDR_MON)) - 1; - tm->tm_year = bcd2bin(ds1302_readbyte(RTC_ADDR_YEAR)); - - if (tm->tm_year < 70) - tm->tm_year += 100; - - dev_dbg(dev, "%s: tm is secs=%d, mins=%d, hours=%d, " - "mday=%d, mon=%d, year=%d, wday=%d\n", - __func__, - tm->tm_sec, tm->tm_min, tm->tm_hour, - tm->tm_mday, tm->tm_mon + 1, tm->tm_year, tm->tm_wday); - - return rtc_valid_tm(tm); -} - -static int ds1302_rtc_set_time(struct device *dev, struct rtc_time *tm) -{ - ds1302_writebyte(RTC_ADDR_CTRL, RTC_CMD_WRITE_ENABLE); - /* Stop RTC */ - ds1302_writebyte(RTC_ADDR_SEC, ds1302_readbyte(RTC_ADDR_SEC) | 0x80); - - ds1302_writebyte(RTC_ADDR_SEC, bin2bcd(tm->tm_sec)); - ds1302_writebyte(RTC_ADDR_MIN, bin2bcd(tm->tm_min)); - ds1302_writebyte(RTC_ADDR_HOUR, bin2bcd(tm->tm_hour)); - ds1302_writebyte(RTC_ADDR_DAY, bin2bcd(tm->tm_wday)); - ds1302_writebyte(RTC_ADDR_DATE, bin2bcd(tm->tm_mday)); - ds1302_writebyte(RTC_ADDR_MON, bin2bcd(tm->tm_mon + 1)); - ds1302_writebyte(RTC_ADDR_YEAR, bin2bcd(tm->tm_year % 100)); + if ((buf[0] & ~RTC_CMD_WRITE_DISABLE) != 0) { + status = spi_write_then_read(spi, &addr, sizeof(addr), buf, 1); + if (status < 0) { + dev_err(&spi->dev, "control register read error %d\n", + status); + return status; + } + + if ((buf[0] & ~RTC_CMD_WRITE_DISABLE) != 0) { + dev_err(&spi->dev, "junk in control register\n"); + return -ENODEV; + } + } + if (buf[0] == 0) { + bp = buf; + *bp++ = RTC_ADDR_CTRL << 1 | RTC_CMD_WRITE; + *bp++ = RTC_CMD_WRITE_DISABLE; + + status = spi_write_then_read(spi, buf, 2, NULL, 0); + if (status < 0) { + dev_err(&spi->dev, "control register write error %d\n", + status); + return status; + } + + addr = RTC_ADDR_CTRL << 1 | RTC_CMD_READ; + status = spi_write_then_read(spi, &addr, sizeof(addr), buf, 1); + if (status < 0) { + dev_err(&spi->dev, + "error %d reading control register\n", + status); + return status; + } + + if (buf[0] != RTC_CMD_WRITE_DISABLE) { + dev_err(&spi->dev, "failed to detect chip\n"); + return -ENODEV; + } + } - /* Start RTC */ - ds1302_writebyte(RTC_ADDR_SEC, ds1302_readbyte(RTC_ADDR_SEC) & ~0x80); + spi_set_drvdata(spi, spi); - ds1302_writebyte(RTC_ADDR_CTRL, RTC_CMD_WRITE_DISABLE); + rtc = devm_rtc_device_register(&spi->dev, "ds1302", + &ds1302_rtc_ops, THIS_MODULE); + if (IS_ERR(rtc)) { + status = PTR_ERR(rtc); + dev_err(&spi->dev, "error %d registering rtc\n", status); + return status; + } return 0; } -static int ds1302_rtc_ioctl(struct device *dev, unsigned int cmd, - unsigned long arg) +static int ds1302_remove(struct spi_device *spi) { - switch (cmd) { -#ifdef RTC_SET_CHARGE - case RTC_SET_CHARGE: - { - int tcs_val; - - if (copy_from_user(&tcs_val, (int __user *)arg, sizeof(int))) - return -EFAULT; - - ds1302_writebyte(RTC_ADDR_TCR, (0xa0 | tcs_val * 0xf)); - return 0; - } -#endif - } - - return -ENOIOCTLCMD; + spi_set_drvdata(spi, NULL); + return 0; } -static struct rtc_class_ops ds1302_rtc_ops = { - .read_time = ds1302_rtc_read_time, - .set_time = ds1302_rtc_set_time, - .ioctl = ds1302_rtc_ioctl, +#ifdef CONFIG_OF +static const struct of_device_id ds1302_dt_ids[] = { + { .compatible = "maxim,ds1302", }, + { /* sentinel */ } }; +MODULE_DEVICE_TABLE(of, ds1302_dt_ids); +#endif -static int __init ds1302_rtc_probe(struct platform_device *pdev) -{ - struct rtc_device *rtc; - - if (ds1302_hw_init()) { - dev_err(&pdev->dev, "Failed to init communication channel"); - return -EINVAL; - } - - /* Reset */ - ds1302_reset(); - - /* Write a magic value to the DS1302 RAM, and see if it sticks. */ - ds1302_writebyte(RTC_ADDR_RAM0, 0x42); - if (ds1302_readbyte(RTC_ADDR_RAM0) != 0x42) { - dev_err(&pdev->dev, "Failed to probe"); - return -ENODEV; - } - - rtc = devm_rtc_device_register(&pdev->dev, "ds1302", - &ds1302_rtc_ops, THIS_MODULE); - if (IS_ERR(rtc)) - return PTR_ERR(rtc); - - platform_set_drvdata(pdev, rtc); - - return 0; -} - -static struct platform_driver ds1302_platform_driver = { - .driver = { - .name = DRV_NAME, - }, +static struct spi_driver ds1302_driver = { + .driver.name = "rtc-ds1302", + .driver.of_match_table = of_match_ptr(ds1302_dt_ids), + .probe = ds1302_probe, + .remove = ds1302_remove, }; -module_platform_driver_probe(ds1302_platform_driver, ds1302_rtc_probe); +module_spi_driver(ds1302_driver); MODULE_DESCRIPTION("Dallas DS1302 RTC driver"); MODULE_VERSION(DRV_VERSION); -- cgit From fa5691131a87a36ee2d535aa3e8886e4e4f1e9f3 Mon Sep 17 00:00:00 2001 From: Alexandre Belloni Date: Thu, 31 Mar 2016 15:07:26 +0200 Subject: rtc: remove useless DRV_VERSION Many drivers are defining a DRV_VERSION. This is often only used for MODULE_VERSION and sometimes to print an info message at probe time. This is kind of pointless as they are all versionned with the kernel anyway. Also the core will print a message when a new rtc is found. Signed-off-by: Alexandre Belloni --- drivers/rtc/rtc-ds1216.c | 3 --- drivers/rtc/rtc-ds1286.c | 3 --- drivers/rtc/rtc-ds1302.c | 2 -- drivers/rtc/rtc-ds1343.c | 2 -- drivers/rtc/rtc-ds1511.c | 3 --- drivers/rtc/rtc-ds1553.c | 3 --- drivers/rtc/rtc-ds1672.c | 5 ----- drivers/rtc/rtc-ds1685.c | 3 --- drivers/rtc/rtc-ds1742.c | 3 --- drivers/rtc/rtc-ep93xx.c | 3 --- drivers/rtc/rtc-gemini.c | 1 - drivers/rtc/rtc-isl12022.c | 5 ----- drivers/rtc/rtc-isl1208.c | 6 ------ drivers/rtc/rtc-m48t35.c | 3 --- drivers/rtc/rtc-m48t86.c | 4 ---- drivers/rtc/rtc-max6900.c | 5 ----- drivers/rtc/rtc-pcf2123.c | 4 ---- drivers/rtc/rtc-pcf8563.c | 5 ----- drivers/rtc/rtc-rs5c313.c | 2 -- drivers/rtc/rtc-rs5c348.c | 4 ---- drivers/rtc/rtc-rs5c372.c | 6 +----- drivers/rtc/rtc-rx8581.c | 5 ----- drivers/rtc/rtc-sh.c | 2 -- drivers/rtc/rtc-stk17ta8.c | 3 --- drivers/rtc/rtc-x1205.c | 5 ----- 25 files changed, 1 insertion(+), 89 deletions(-) (limited to 'drivers/rtc/rtc-ds1302.c') diff --git a/drivers/rtc/rtc-ds1216.c b/drivers/rtc/rtc-ds1216.c index 12dbd70859ae..9c82b1da2d45 100644 --- a/drivers/rtc/rtc-ds1216.c +++ b/drivers/rtc/rtc-ds1216.c @@ -11,8 +11,6 @@ #include #include -#define DRV_VERSION "0.2" - struct ds1216_regs { u8 tsec; u8 sec; @@ -176,5 +174,4 @@ module_platform_driver_probe(ds1216_rtc_platform_driver, ds1216_rtc_probe); MODULE_AUTHOR("Thomas Bogendoerfer "); MODULE_DESCRIPTION("DS1216 RTC driver"); MODULE_LICENSE("GPL"); -MODULE_VERSION(DRV_VERSION); MODULE_ALIAS("platform:rtc-ds1216"); diff --git a/drivers/rtc/rtc-ds1286.c b/drivers/rtc/rtc-ds1286.c index 8247a29a4eb4..756e509f6ed2 100644 --- a/drivers/rtc/rtc-ds1286.c +++ b/drivers/rtc/rtc-ds1286.c @@ -20,8 +20,6 @@ #include #include -#define DRV_VERSION "1.0" - struct ds1286_priv { struct rtc_device *rtc; u32 __iomem *rtcregs; @@ -363,5 +361,4 @@ module_platform_driver(ds1286_platform_driver); MODULE_AUTHOR("Thomas Bogendoerfer "); MODULE_DESCRIPTION("DS1286 RTC driver"); MODULE_LICENSE("GPL"); -MODULE_VERSION(DRV_VERSION); MODULE_ALIAS("platform:rtc-ds1286"); diff --git a/drivers/rtc/rtc-ds1302.c b/drivers/rtc/rtc-ds1302.c index 5cdc0f201b34..7811b357ed70 100644 --- a/drivers/rtc/rtc-ds1302.c +++ b/drivers/rtc/rtc-ds1302.c @@ -19,7 +19,6 @@ #include #define DRV_NAME "rtc-ds1302" -#define DRV_VERSION "1.0.0" #define RTC_CMD_READ 0x81 /* Read command */ #define RTC_CMD_WRITE 0x80 /* Write command */ @@ -216,6 +215,5 @@ static struct spi_driver ds1302_driver = { module_spi_driver(ds1302_driver); MODULE_DESCRIPTION("Dallas DS1302 RTC driver"); -MODULE_VERSION(DRV_VERSION); MODULE_AUTHOR("Paul Mundt, David McCullough"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/rtc/rtc-ds1343.c b/drivers/rtc/rtc-ds1343.c index 3d389bd8a289..23fa9f0cb5e3 100644 --- a/drivers/rtc/rtc-ds1343.c +++ b/drivers/rtc/rtc-ds1343.c @@ -24,7 +24,6 @@ #include #include -#define DS1343_DRV_VERSION "01.00" #define DALLAS_MAXIM_DS1343 0 #define DALLAS_MAXIM_DS1344 1 @@ -747,4 +746,3 @@ MODULE_DESCRIPTION("DS1343 RTC SPI Driver"); MODULE_AUTHOR("Raghavendra Chandra Ganiga ," "Ankur Srivastava "); MODULE_LICENSE("GPL v2"); -MODULE_VERSION(DS1343_DRV_VERSION); diff --git a/drivers/rtc/rtc-ds1511.c b/drivers/rtc/rtc-ds1511.c index da3d04ce83bd..1b2dcb58c0ab 100644 --- a/drivers/rtc/rtc-ds1511.c +++ b/drivers/rtc/rtc-ds1511.c @@ -25,8 +25,6 @@ #include #include -#define DRV_VERSION "0.6" - enum ds1511reg { DS1511_SEC = 0x0, DS1511_MIN = 0x1, @@ -537,4 +535,3 @@ module_platform_driver(ds1511_rtc_driver); MODULE_AUTHOR("Andrew Sharp "); MODULE_DESCRIPTION("Dallas DS1511 RTC driver"); MODULE_LICENSE("GPL"); -MODULE_VERSION(DRV_VERSION); diff --git a/drivers/rtc/rtc-ds1553.c b/drivers/rtc/rtc-ds1553.c index 38422ab4ec5a..9961ec646fd2 100644 --- a/drivers/rtc/rtc-ds1553.c +++ b/drivers/rtc/rtc-ds1553.c @@ -20,8 +20,6 @@ #include #include -#define DRV_VERSION "0.3" - #define RTC_REG_SIZE 0x2000 #define RTC_OFFSET 0x1ff0 @@ -359,4 +357,3 @@ module_platform_driver(ds1553_rtc_driver); MODULE_AUTHOR("Atsushi Nemoto "); MODULE_DESCRIPTION("Dallas DS1553 RTC driver"); MODULE_LICENSE("GPL"); -MODULE_VERSION(DRV_VERSION); diff --git a/drivers/rtc/rtc-ds1672.c b/drivers/rtc/rtc-ds1672.c index 92b1cbf2c4a7..5c18ac7394c4 100644 --- a/drivers/rtc/rtc-ds1672.c +++ b/drivers/rtc/rtc-ds1672.c @@ -13,8 +13,6 @@ #include #include -#define DRV_VERSION "0.4" - /* Registers */ #define DS1672_REG_CNT_BASE 0 @@ -165,8 +163,6 @@ static int ds1672_probe(struct i2c_client *client, if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) return -ENODEV; - dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n"); - rtc = devm_rtc_device_register(&client->dev, ds1672_driver.driver.name, &ds1672_rtc_ops, THIS_MODULE); @@ -213,4 +209,3 @@ module_i2c_driver(ds1672_driver); MODULE_AUTHOR("Alessandro Zummo "); MODULE_DESCRIPTION("Dallas/Maxim DS1672 timekeeper driver"); MODULE_LICENSE("GPL"); -MODULE_VERSION(DRV_VERSION); diff --git a/drivers/rtc/rtc-ds1685.c b/drivers/rtc/rtc-ds1685.c index 1e6cfc84b1f6..2698d8ffe4fd 100644 --- a/drivers/rtc/rtc-ds1685.c +++ b/drivers/rtc/rtc-ds1685.c @@ -32,8 +32,6 @@ #include #endif -#define DRV_VERSION "0.42.0" - /* ----------------------------------------------------------------------- */ /* Standard read/write functions if platform does not provide overrides */ @@ -2224,5 +2222,4 @@ MODULE_AUTHOR("Joshua Kinard "); MODULE_AUTHOR("Matthias Fuchs "); MODULE_DESCRIPTION("Dallas/Maxim DS1685/DS1687-series RTC driver"); MODULE_LICENSE("GPL"); -MODULE_VERSION(DRV_VERSION); MODULE_ALIAS("platform:rtc-ds1685"); diff --git a/drivers/rtc/rtc-ds1742.c b/drivers/rtc/rtc-ds1742.c index c5168b3bcf1a..3abf1cbfb8ce 100644 --- a/drivers/rtc/rtc-ds1742.c +++ b/drivers/rtc/rtc-ds1742.c @@ -24,8 +24,6 @@ #include #include -#define DRV_VERSION "0.4" - #define RTC_SIZE 8 #define RTC_CONTROL 0 @@ -239,5 +237,4 @@ module_platform_driver(ds1742_rtc_driver); MODULE_AUTHOR("Atsushi Nemoto "); MODULE_DESCRIPTION("Dallas DS1742 RTC driver"); MODULE_LICENSE("GPL"); -MODULE_VERSION(DRV_VERSION); MODULE_ALIAS("platform:rtc-ds1742"); diff --git a/drivers/rtc/rtc-ep93xx.c b/drivers/rtc/rtc-ep93xx.c index a1628adf9f52..694038208745 100644 --- a/drivers/rtc/rtc-ep93xx.c +++ b/drivers/rtc/rtc-ep93xx.c @@ -28,8 +28,6 @@ #define EP93XX_RTC_SWCOMP_INT_MASK 0x0000ffff #define EP93XX_RTC_SWCOMP_INT_SHIFT 0 -#define DRV_VERSION "0.3" - /* * struct device dev.platform_data is used to store our private data * because struct rtc_device does not have a variable to hold it. @@ -184,5 +182,4 @@ module_platform_driver(ep93xx_rtc_driver); MODULE_AUTHOR("Alessandro Zummo "); MODULE_DESCRIPTION("EP93XX RTC driver"); MODULE_LICENSE("GPL"); -MODULE_VERSION(DRV_VERSION); MODULE_ALIAS("platform:ep93xx-rtc"); diff --git a/drivers/rtc/rtc-gemini.c b/drivers/rtc/rtc-gemini.c index f46b6d46a51b..b57505efadbc 100644 --- a/drivers/rtc/rtc-gemini.c +++ b/drivers/rtc/rtc-gemini.c @@ -28,7 +28,6 @@ #include #define DRV_NAME "rtc-gemini" -#define DRV_VERSION "0.2" MODULE_AUTHOR("Hans Ulli Kroll "); MODULE_DESCRIPTION("RTC driver for Gemini SoC"); diff --git a/drivers/rtc/rtc-isl12022.c b/drivers/rtc/rtc-isl12022.c index 839d1fd63cd7..38586a024ee8 100644 --- a/drivers/rtc/rtc-isl12022.c +++ b/drivers/rtc/rtc-isl12022.c @@ -20,8 +20,6 @@ #include #include -#define DRV_VERSION "0.1" - /* ISL register offsets */ #define ISL12022_REG_SC 0x00 #define ISL12022_REG_MN 0x01 @@ -258,8 +256,6 @@ static int isl12022_probe(struct i2c_client *client, if (!isl12022) return -ENOMEM; - dev_dbg(&client->dev, "chip found, driver version " DRV_VERSION "\n"); - i2c_set_clientdata(client, isl12022); isl12022->rtc = devm_rtc_device_register(&client->dev, @@ -299,4 +295,3 @@ module_i2c_driver(isl12022_driver); MODULE_AUTHOR("roman.fietze@telemotive.de"); MODULE_DESCRIPTION("ISL 12022 RTC driver"); MODULE_LICENSE("GPL"); -MODULE_VERSION(DRV_VERSION); diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c index b57a304ff62c..2893785f0eba 100644 --- a/drivers/rtc/rtc-isl1208.c +++ b/drivers/rtc/rtc-isl1208.c @@ -15,8 +15,6 @@ #include #include -#define DRV_VERSION "0.3" - /* Register map */ /* rtc section */ #define ISL1208_REG_SC 0x00 @@ -632,9 +630,6 @@ isl1208_probe(struct i2c_client *client, const struct i2c_device_id *id) if (isl1208_i2c_validate_client(client) < 0) return -ENODEV; - dev_info(&client->dev, - "chip found, driver version " DRV_VERSION "\n"); - if (client->irq > 0) { rc = devm_request_threaded_irq(&client->dev, client->irq, NULL, isl1208_rtc_interrupt, @@ -706,4 +701,3 @@ module_i2c_driver(isl1208_driver); MODULE_AUTHOR("Herbert Valerio Riedel "); MODULE_DESCRIPTION("Intersil ISL1208 RTC driver"); MODULE_LICENSE("GPL"); -MODULE_VERSION(DRV_VERSION); diff --git a/drivers/rtc/rtc-m48t35.c b/drivers/rtc/rtc-m48t35.c index c62b51217ecf..810f4ea481e4 100644 --- a/drivers/rtc/rtc-m48t35.c +++ b/drivers/rtc/rtc-m48t35.c @@ -22,8 +22,6 @@ #include #include -#define DRV_VERSION "1.0" - struct m48t35_rtc { u8 pad[0x7ff8]; /* starts at 0x7ff8 */ u8 control; @@ -190,5 +188,4 @@ module_platform_driver(m48t35_platform_driver); MODULE_AUTHOR("Thomas Bogendoerfer "); MODULE_DESCRIPTION("M48T35 RTC driver"); MODULE_LICENSE("GPL"); -MODULE_VERSION(DRV_VERSION); MODULE_ALIAS("platform:rtc-m48t35"); diff --git a/drivers/rtc/rtc-m48t86.c b/drivers/rtc/rtc-m48t86.c index a17b7a3ceece..f72b91f2501f 100644 --- a/drivers/rtc/rtc-m48t86.c +++ b/drivers/rtc/rtc-m48t86.c @@ -39,9 +39,6 @@ #define M48T86_REG_B_SET (1 << 7) #define M48T86_REG_D_VRT (1 << 7) -#define DRV_VERSION "0.1" - - static int m48t86_rtc_read_time(struct device *dev, struct rtc_time *tm) { unsigned char reg; @@ -178,5 +175,4 @@ module_platform_driver(m48t86_rtc_platform_driver); MODULE_AUTHOR("Alessandro Zummo "); MODULE_DESCRIPTION("M48T86 RTC driver"); MODULE_LICENSE("GPL"); -MODULE_VERSION(DRV_VERSION); MODULE_ALIAS("platform:rtc-m48t86"); diff --git a/drivers/rtc/rtc-max6900.c b/drivers/rtc/rtc-max6900.c index b2a76077bbfa..48b6b411f8b2 100644 --- a/drivers/rtc/rtc-max6900.c +++ b/drivers/rtc/rtc-max6900.c @@ -17,8 +17,6 @@ #include #include -#define DRV_VERSION "0.2" - /* * register indices */ @@ -218,8 +216,6 @@ max6900_probe(struct i2c_client *client, const struct i2c_device_id *id) if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) return -ENODEV; - dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n"); - rtc = devm_rtc_device_register(&client->dev, max6900_driver.driver.name, &max6900_rtc_ops, THIS_MODULE); if (IS_ERR(rtc)) @@ -249,4 +245,3 @@ module_i2c_driver(max6900_driver); MODULE_DESCRIPTION("Maxim MAX6900 RTC driver"); MODULE_AUTHOR("Dale Farnsworth "); MODULE_LICENSE("GPL"); -MODULE_VERSION(DRV_VERSION); diff --git a/drivers/rtc/rtc-pcf2123.c b/drivers/rtc/rtc-pcf2123.c index da27738b1242..f22e060709e5 100644 --- a/drivers/rtc/rtc-pcf2123.c +++ b/drivers/rtc/rtc-pcf2123.c @@ -46,8 +46,6 @@ #include #include -#define DRV_VERSION "0.6" - /* REGISTERS */ #define PCF2123_REG_CTRL1 (0x00) /* Control Register 1 */ #define PCF2123_REG_CTRL2 (0x01) /* Control Register 2 */ @@ -395,7 +393,6 @@ static int pcf2123_probe(struct spi_device *spi) } } - dev_info(&spi->dev, "chip found, driver version " DRV_VERSION "\n"); dev_info(&spi->dev, "spiclk %u KHz.\n", (spi->max_speed_hz + 500) / 1000); @@ -474,4 +471,3 @@ module_spi_driver(pcf2123_driver); MODULE_AUTHOR("Chris Verges "); MODULE_DESCRIPTION("NXP PCF2123 RTC driver"); MODULE_LICENSE("GPL"); -MODULE_VERSION(DRV_VERSION); diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c index c8f95b8e463a..d5e6ed96b748 100644 --- a/drivers/rtc/rtc-pcf8563.c +++ b/drivers/rtc/rtc-pcf8563.c @@ -23,8 +23,6 @@ #include #include -#define DRV_VERSION "0.4.4" - #define PCF8563_REG_ST1 0x00 /* status */ #define PCF8563_REG_ST2 0x01 #define PCF8563_BIT_AIE (1 << 1) @@ -580,8 +578,6 @@ static int pcf8563_probe(struct i2c_client *client, if (!pcf8563) return -ENOMEM; - dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n"); - i2c_set_clientdata(client, pcf8563); pcf8563->client = client; device_set_wakeup_capable(&client->dev, 1); @@ -662,4 +658,3 @@ module_i2c_driver(pcf8563_driver); MODULE_AUTHOR("Alessandro Zummo "); MODULE_DESCRIPTION("Philips PCF8563/Epson RTC8564 RTC driver"); MODULE_LICENSE("GPL"); -MODULE_VERSION(DRV_VERSION); diff --git a/drivers/rtc/rtc-rs5c313.c b/drivers/rtc/rtc-rs5c313.c index 5f48167c802a..89f38e3e917d 100644 --- a/drivers/rtc/rtc-rs5c313.c +++ b/drivers/rtc/rtc-rs5c313.c @@ -50,7 +50,6 @@ #include #define DRV_NAME "rs5c313" -#define DRV_VERSION "1.13" #ifdef CONFIG_SH_LANDISK /*****************************************************/ @@ -407,7 +406,6 @@ static void __exit rs5c313_rtc_exit(void) module_init(rs5c313_rtc_init); module_exit(rs5c313_rtc_exit); -MODULE_VERSION(DRV_VERSION); MODULE_AUTHOR("kogiidena , Nobuhiro Iwamatsu "); MODULE_DESCRIPTION("Ricoh RS5C313 RTC device driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/rtc/rtc-rs5c348.c b/drivers/rtc/rtc-rs5c348.c index 1162fecab8cf..9a306983aaba 100644 --- a/drivers/rtc/rtc-rs5c348.c +++ b/drivers/rtc/rtc-rs5c348.c @@ -25,8 +25,6 @@ #include #include -#define DRV_VERSION "0.2" - #define RS5C348_REG_SECS 0 #define RS5C348_REG_MINS 1 #define RS5C348_REG_HOURS 2 @@ -171,7 +169,6 @@ static int rs5c348_probe(struct spi_device *spi) goto kfree_exit; } - dev_info(&spi->dev, "chip found, driver version " DRV_VERSION "\n"); dev_info(&spi->dev, "spiclk %u KHz.\n", (spi->max_speed_hz + 500) / 1000); @@ -230,5 +227,4 @@ module_spi_driver(rs5c348_driver); MODULE_AUTHOR("Atsushi Nemoto "); MODULE_DESCRIPTION("Ricoh RS5C348 RTC driver"); MODULE_LICENSE("GPL"); -MODULE_VERSION(DRV_VERSION); MODULE_ALIAS("spi:rtc-rs5c348"); diff --git a/drivers/rtc/rtc-rs5c372.c b/drivers/rtc/rtc-rs5c372.c index 28871cd7e3b5..12270c789088 100644 --- a/drivers/rtc/rtc-rs5c372.c +++ b/drivers/rtc/rtc-rs5c372.c @@ -16,9 +16,6 @@ #include #include -#define DRV_VERSION "0.6" - - /* * Ricoh has a family of I2C based RTCs, which differ only slightly from * each other. Differences center on pinout (e.g. how many interrupts, @@ -640,7 +637,7 @@ static int rs5c372_probe(struct i2c_client *client, if (rs5c372_get_datetime(client, &tm) < 0) dev_warn(&client->dev, "clock needs to be set\n"); - dev_info(&client->dev, "%s found, %s, driver version " DRV_VERSION "\n", + dev_info(&client->dev, "%s found, %s\n", ({ char *s; switch (rs5c372->type) { case rtc_r2025sd: s = "r2025sd"; break; case rtc_r2221tl: s = "r2221tl"; break; @@ -696,4 +693,3 @@ MODULE_AUTHOR( "Paul Mundt "); MODULE_DESCRIPTION("Ricoh RS5C372 RTC driver"); MODULE_LICENSE("GPL"); -MODULE_VERSION(DRV_VERSION); diff --git a/drivers/rtc/rtc-rx8581.c b/drivers/rtc/rtc-rx8581.c index 161e25d016c3..0c362a3d1f17 100644 --- a/drivers/rtc/rtc-rx8581.c +++ b/drivers/rtc/rtc-rx8581.c @@ -18,8 +18,6 @@ #include #include -#define DRV_VERSION "0.1" - #define RX8581_REG_SC 0x00 /* Second in BCD */ #define RX8581_REG_MN 0x01 /* Minute in BCD */ #define RX8581_REG_HR 0x02 /* Hour in BCD */ @@ -292,8 +290,6 @@ static int rx8581_probe(struct i2c_client *client, rx8581->write_block_data = rx8581_write_block_data; } - dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n"); - rx8581->rtc = devm_rtc_device_register(&client->dev, rx8581_driver.driver.name, &rx8581_rtc_ops, THIS_MODULE); @@ -325,4 +321,3 @@ module_i2c_driver(rx8581_driver); MODULE_AUTHOR("Martyn Welch "); MODULE_DESCRIPTION("Epson RX-8581 RTC driver"); MODULE_LICENSE("GPL"); -MODULE_VERSION(DRV_VERSION); diff --git a/drivers/rtc/rtc-sh.c b/drivers/rtc/rtc-sh.c index 2b81dd4baf17..a45845a571e5 100644 --- a/drivers/rtc/rtc-sh.c +++ b/drivers/rtc/rtc-sh.c @@ -30,7 +30,6 @@ #include #define DRV_NAME "sh-rtc" -#define DRV_VERSION "0.2.3" #define RTC_REG(r) ((r) * rtc_reg_size) @@ -790,7 +789,6 @@ static struct platform_driver sh_rtc_platform_driver = { module_platform_driver_probe(sh_rtc_platform_driver, sh_rtc_probe); MODULE_DESCRIPTION("SuperH on-chip RTC driver"); -MODULE_VERSION(DRV_VERSION); MODULE_AUTHOR("Paul Mundt , " "Jamie Lenehan , " "Angelo Castello "); diff --git a/drivers/rtc/rtc-stk17ta8.c b/drivers/rtc/rtc-stk17ta8.c index ba6a83b5b5c9..a456cb6177ea 100644 --- a/drivers/rtc/rtc-stk17ta8.c +++ b/drivers/rtc/rtc-stk17ta8.c @@ -23,8 +23,6 @@ #include #include -#define DRV_VERSION "0.1" - #define RTC_REG_SIZE 0x20000 #define RTC_OFFSET 0x1fff0 @@ -366,4 +364,3 @@ module_platform_driver(stk17ta8_rtc_driver); MODULE_AUTHOR("Thomas Hommel "); MODULE_DESCRIPTION("Simtek STK17TA8 RTC driver"); MODULE_LICENSE("GPL"); -MODULE_VERSION(DRV_VERSION); diff --git a/drivers/rtc/rtc-x1205.c b/drivers/rtc/rtc-x1205.c index 5638b7ba8b06..f08f18e4fcdf 100644 --- a/drivers/rtc/rtc-x1205.c +++ b/drivers/rtc/rtc-x1205.c @@ -24,8 +24,6 @@ #include #include -#define DRV_VERSION "1.0.8" - /* offsets into CCR area */ #define CCR_SEC 0 @@ -634,8 +632,6 @@ static int x1205_probe(struct i2c_client *client, if (x1205_validate_client(client) < 0) return -ENODEV; - dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n"); - rtc = devm_rtc_device_register(&client->dev, x1205_driver.driver.name, &x1205_rtc_ops, THIS_MODULE); @@ -693,4 +689,3 @@ MODULE_AUTHOR( "Alessandro Zummo "); MODULE_DESCRIPTION("Xicor/Intersil X1205 RTC driver"); MODULE_LICENSE("GPL"); -MODULE_VERSION(DRV_VERSION); -- cgit From bc83a141b8351f6d4458dd13eca5a66f2c0f3323 Mon Sep 17 00:00:00 2001 From: Akinobu Mita Date: Sun, 10 Apr 2016 23:59:23 +0900 Subject: rtc: ds1302: fix error check in set_time The set_time callback for rtc-ds1302 doesn't write clock registers because the error check for the return value from spi_write_then_read() is not correct. spi_write_then_read() which returns zero on success. Signed-off-by: Akinobu Mita Cc: Sergey Yanovich Cc: Alessandro Zummo Cc: Alexandre Belloni Signed-off-by: Alexandre Belloni --- drivers/rtc/rtc-ds1302.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/rtc/rtc-ds1302.c') diff --git a/drivers/rtc/rtc-ds1302.c b/drivers/rtc/rtc-ds1302.c index 7811b357ed70..283e653fa189 100644 --- a/drivers/rtc/rtc-ds1302.c +++ b/drivers/rtc/rtc-ds1302.c @@ -53,7 +53,7 @@ static int ds1302_rtc_set_time(struct device *dev, struct rtc_time *time) status = spi_write_then_read(spi, buf, 2, NULL, 0); - if (!status) + if (status) return status; /* Write registers starting at the first time/date address. */ -- cgit From ef50f86e15f2516658f0badd7890292d7a685106 Mon Sep 17 00:00:00 2001 From: Akinobu Mita Date: Sun, 10 Apr 2016 23:59:24 +0900 Subject: rtc: ds1302: fix write value for day of week register The valid range of day of week register for DS1302 is 1 to 7. But the set_time callback for rtc-ds1302 attempts to write the value of tm->tm_wday which is in the range 0 to 6. While the get_time callback correctly decodes the register. Signed-off-by: Akinobu Mita Cc: Sergey Yanovich Cc: Alessandro Zummo Cc: Alexandre Belloni Signed-off-by: Alexandre Belloni --- drivers/rtc/rtc-ds1302.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/rtc/rtc-ds1302.c') diff --git a/drivers/rtc/rtc-ds1302.c b/drivers/rtc/rtc-ds1302.c index 283e653fa189..f5dd09fe5add 100644 --- a/drivers/rtc/rtc-ds1302.c +++ b/drivers/rtc/rtc-ds1302.c @@ -65,7 +65,7 @@ static int ds1302_rtc_set_time(struct device *dev, struct rtc_time *time) *bp++ = bin2bcd(time->tm_hour); *bp++ = bin2bcd(time->tm_mday); *bp++ = bin2bcd(time->tm_mon + 1); - *bp++ = time->tm_wday; + *bp++ = time->tm_wday + 1; *bp++ = bin2bcd(time->tm_year % 100); *bp++ = RTC_CMD_WRITE_DISABLE; -- cgit