diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-04-10 10:22:27 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-04-10 10:22:27 -0700 |
commit | fbe173e3ffbd897b5a859020d714c0eaf4af2a1a (patch) | |
tree | 602fd9da34454d934fcee56b8a74ebed05ba7d1c /drivers/rtc/rtc-ds1553.c | |
parent | 5e630afdcb82779f5bf03fd4a5e86adc56fe7c8a (diff) | |
parent | 1485991c024603b2fb4ae77beb7a0d741128a48e (diff) |
Merge tag 'rtc-4.17' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux
Pull RTC updates from Alexandre Belloni:
"This contains a few series that have been in preparation for a while
and that will help systems with RTCs that will fail in 2038, 2069 or
2100.
Subsystem:
- Add tracepoints
- Rework of the RTC/nvmem API to allow drivers to discard struct
nvmem_config after registration
- New range API, drivers can now expose the useful range of the RTC
- New offset API the core is now able to add an offset to the RTC
time, modifying the supported range.
- Multiple rtc_time64_to_tm fixes
- Handle time_t overflow on 32 bit platforms in the core instead of
letting drivers do crazy things.
- remove rtc_control API
New driver:
- Intersil ISL12026
Drivers:
- Drivers exposing the RTC non volatile memory have been converted to
use nvmem
- Removed useless time and date validation
- Removed an indirection pattern that was a cargo cult from ancient
drivers
- Removed VLA usage
- Fixed a possible race condition in probe functions
- AB8540 support is dropped from ab8500
- pcf85363 now has alarm support"
* tag 'rtc-4.17' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: (128 commits)
rtc: snvs: Fix usage of snvs_rtc_enable
rtc: mt7622: fix module autoloading for OF platform drivers
rtc: isl12022: use true and false for boolean values
rtc: ab8500: Drop AB8540 support
rtc: remove a warning during scripts/kernel-doc step
rtc: 88pm860x: remove artificial limitation
rtc: 88pm80x: remove artificial limitation
rtc: st-lpc: remove artificial limitation
rtc: mrst: remove artificial limitation
rtc: mv: remove artificial limitation
rtc: hctosys: Ensure system time doesn't overflow time_t
parisc: time: stop validating rtc_time in .read_time
rtc: pcf85063: fix clearing bits in pcf85063_start_clock
rtc: at91sam9: Set name of regmap_config
rtc: s5m: Remove VLA usage
rtc: s5m: Move enum from rtc.h to rtc-s5m.c
rtc: remove VLA usage
rtc: Add useful timestamp definitions
rtc: Add one offset seconds to expand RTC range
rtc: Factor out the RTC range validation into rtc_valid_range()
...
Diffstat (limited to 'drivers/rtc/rtc-ds1553.c')
-rw-r--r-- | drivers/rtc/rtc-ds1553.c | 78 |
1 files changed, 31 insertions, 47 deletions
diff --git a/drivers/rtc/rtc-ds1553.c b/drivers/rtc/rtc-ds1553.c index 9961ec646fd2..2441b9a2b366 100644 --- a/drivers/rtc/rtc-ds1553.c +++ b/drivers/rtc/rtc-ds1553.c @@ -127,10 +127,6 @@ static int ds1553_rtc_read_time(struct device *dev, struct rtc_time *tm) /* year is 1900 + tm->tm_year */ tm->tm_year = bcd2bin(year) + bcd2bin(century) * 100 - 1900; - if (rtc_valid_tm(tm) < 0) { - dev_err(dev, "retrieved date/time is not valid.\n"); - rtc_time_to_tm(0, tm); - } return 0; } @@ -233,46 +229,32 @@ static const struct rtc_class_ops ds1553_rtc_ops = { .alarm_irq_enable = ds1553_rtc_alarm_irq_enable, }; -static ssize_t ds1553_nvram_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, - char *buf, loff_t pos, size_t size) +static int ds1553_nvram_read(void *priv, unsigned int pos, void *val, + size_t bytes) { - struct device *dev = container_of(kobj, struct device, kobj); - struct platform_device *pdev = to_platform_device(dev); + struct platform_device *pdev = priv; struct rtc_plat_data *pdata = platform_get_drvdata(pdev); void __iomem *ioaddr = pdata->ioaddr; - ssize_t count; + u8 *buf = val; - for (count = 0; count < size; count++) + for (; bytes; bytes--) *buf++ = readb(ioaddr + pos++); - return count; + return 0; } -static ssize_t ds1553_nvram_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, - char *buf, loff_t pos, size_t size) +static int ds1553_nvram_write(void *priv, unsigned int pos, void *val, + size_t bytes) { - struct device *dev = container_of(kobj, struct device, kobj); - struct platform_device *pdev = to_platform_device(dev); + struct platform_device *pdev = priv; struct rtc_plat_data *pdata = platform_get_drvdata(pdev); void __iomem *ioaddr = pdata->ioaddr; - ssize_t count; + u8 *buf = val; - for (count = 0; count < size; count++) + for (; bytes; bytes--) writeb(*buf++, ioaddr + pos++); - return count; + return 0; } -static struct bin_attribute ds1553_nvram_attr = { - .attr = { - .name = "nvram", - .mode = S_IRUGO | S_IWUSR, - }, - .size = RTC_OFFSET, - .read = ds1553_nvram_read, - .write = ds1553_nvram_write, -}; - static int ds1553_rtc_probe(struct platform_device *pdev) { struct resource *res; @@ -280,6 +262,15 @@ static int ds1553_rtc_probe(struct platform_device *pdev) struct rtc_plat_data *pdata; void __iomem *ioaddr; int ret = 0; + struct nvmem_config nvmem_cfg = { + .name = "ds1553_nvram", + .word_size = 1, + .stride = 1, + .size = RTC_OFFSET, + .reg_read = ds1553_nvram_read, + .reg_write = ds1553_nvram_write, + .priv = pdev, + }; pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); if (!pdata) @@ -308,11 +299,17 @@ static int ds1553_rtc_probe(struct platform_device *pdev) pdata->last_jiffies = jiffies; platform_set_drvdata(pdev, pdata); - pdata->rtc = devm_rtc_device_register(&pdev->dev, pdev->name, - &ds1553_rtc_ops, THIS_MODULE); + pdata->rtc = devm_rtc_allocate_device(&pdev->dev); if (IS_ERR(pdata->rtc)) return PTR_ERR(pdata->rtc); + pdata->rtc->ops = &ds1553_rtc_ops; + pdata->rtc->nvram_old_abi = true; + + ret = rtc_register_device(pdata->rtc); + if (ret) + return ret; + if (pdata->irq > 0) { writeb(0, ioaddr + RTC_INTERRUPTS); if (devm_request_irq(&pdev->dev, pdata->irq, @@ -323,21 +320,9 @@ static int ds1553_rtc_probe(struct platform_device *pdev) } } - ret = sysfs_create_bin_file(&pdev->dev.kobj, &ds1553_nvram_attr); - if (ret) - dev_err(&pdev->dev, "unable to create sysfs file: %s\n", - ds1553_nvram_attr.attr.name); - - return 0; -} - -static int ds1553_rtc_remove(struct platform_device *pdev) -{ - struct rtc_plat_data *pdata = platform_get_drvdata(pdev); + if (rtc_nvmem_register(pdata->rtc, &nvmem_cfg)) + dev_err(&pdev->dev, "unable to register nvmem\n"); - sysfs_remove_bin_file(&pdev->dev.kobj, &ds1553_nvram_attr); - if (pdata->irq > 0) - writeb(0, pdata->ioaddr + RTC_INTERRUPTS); return 0; } @@ -346,7 +331,6 @@ MODULE_ALIAS("platform:rtc-ds1553"); static struct platform_driver ds1553_rtc_driver = { .probe = ds1553_rtc_probe, - .remove = ds1553_rtc_remove, .driver = { .name = "rtc-ds1553", }, |