diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-06-10 16:13:24 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-06-10 16:13:24 -0700 |
commit | 1aaccb5fa0eac996adde53538ca4b87a0b229ab7 (patch) | |
tree | 3d00406e38ca168ef6c23c3e1c8f4809e8983d20 /drivers/rtc/rtc-mrst.c | |
parent | ab0b2e59323cd3972e5f011fbbf3868a4ec360dd (diff) | |
parent | e4302aec8a0646828a701443e303eb5ef48b37f5 (diff) | |
download | linux-1aaccb5fa0eac996adde53538ca4b87a0b229ab7.tar.bz2 |
Merge tag 'rtc-4.18' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux
Pull RTC updates from Alexandre Belloni:
"Setting the supported range from drivers for RTCs failing soon has
started. A few fixes are developed along the way. Some drivers have
been switched to SPDX by their maintainers.
Subsystem:
- rework of the rtc-test driver which allows to test the core more
thoroughly
- rtc_set_alarm() now fails early when alarms are not supported
Drivers:
- mktime() is now replaced by mktime64()
- RTC range added for 88pm80x, ab-b5ze-s3, at91rm9200,
brcmstb-waketimer, ds1685, ftrtc010, ls1x, mxc_v2, rx8581, sprd,
st-lpc, tps6586x, tps65910 and vr41xx
- fixed a possible race condition in probe functions
- pxa: fix the probe function that is broken since v4.3
- stm32: now supports stm32mp1"
* tag 'rtc-4.18' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: (78 commits)
rtc: pxa: fix probe function
rtc: cros-ec: Switch to SPDX identifier.
rtc: cros-ec: Make license text and module license match.
rtc: ensure rtc_set_alarm fails when alarms are not supported
rtc: test: remove alarm support from the first device
rtc: test: convert to devm_rtc_allocate_device
rtc: ftrtc010: let the core handle range
rtc: ftrtc010: handle dates after 2106
rtc: ftrtc010: switch to devm_rtc_allocate_device
rtc: mrst: switch to devm functions
rtc: sunxi: fix possible race condition
rtc: test: remove irq sysfs file
rtc: test: emulate alarms using timers
rtc: test: store time as an offset to system time
rtc: test: allow registering many devices
rtc: test: remove useless proc info
rtc: ds1685: Add range
rtc: ds1685: fix possible race condition
rtc: sprd: Add new RTC power down check method
rtc: sun6i: Fix bit_idx value for clk_register_gate
...
Diffstat (limited to 'drivers/rtc/rtc-mrst.c')
-rw-r--r-- | drivers/rtc/rtc-mrst.c | 45 |
1 files changed, 18 insertions, 27 deletions
diff --git a/drivers/rtc/rtc-mrst.c b/drivers/rtc/rtc-mrst.c index fcb9de5218b2..097a4d4e2aba 100644 --- a/drivers/rtc/rtc-mrst.c +++ b/drivers/rtc/rtc-mrst.c @@ -45,7 +45,6 @@ struct mrst_rtc { struct rtc_device *rtc; struct device *dev; int irq; - struct resource *iomem; u8 enabled_wake; u8 suspend_ctrl; @@ -329,24 +328,22 @@ static int vrtc_mrst_do_probe(struct device *dev, struct resource *iomem, if (!iomem) return -ENODEV; - iomem = request_mem_region(iomem->start, resource_size(iomem), - driver_name); + iomem = devm_request_mem_region(dev, iomem->start, resource_size(iomem), + driver_name); if (!iomem) { dev_dbg(dev, "i/o mem already in use.\n"); return -EBUSY; } mrst_rtc.irq = rtc_irq; - mrst_rtc.iomem = iomem; mrst_rtc.dev = dev; dev_set_drvdata(dev, &mrst_rtc); - mrst_rtc.rtc = rtc_device_register(driver_name, dev, - &mrst_rtc_ops, THIS_MODULE); - if (IS_ERR(mrst_rtc.rtc)) { - retval = PTR_ERR(mrst_rtc.rtc); - goto cleanup0; - } + mrst_rtc.rtc = devm_rtc_allocate_device(dev); + if (IS_ERR(mrst_rtc.rtc)) + return PTR_ERR(mrst_rtc.rtc); + + mrst_rtc.rtc->ops = &mrst_rtc_ops; rename_region(iomem, dev_name(&mrst_rtc.rtc->dev)); @@ -359,23 +356,27 @@ static int vrtc_mrst_do_probe(struct device *dev, struct resource *iomem, dev_dbg(dev, "TODO: support more than 24-hr BCD mode\n"); if (rtc_irq) { - retval = request_irq(rtc_irq, mrst_rtc_irq, - 0, dev_name(&mrst_rtc.rtc->dev), - mrst_rtc.rtc); + retval = devm_request_irq(dev, rtc_irq, mrst_rtc_irq, + 0, dev_name(&mrst_rtc.rtc->dev), + mrst_rtc.rtc); if (retval < 0) { dev_dbg(dev, "IRQ %d is already in use, err %d\n", rtc_irq, retval); - goto cleanup1; + goto cleanup0; } } + + retval = rtc_register_device(mrst_rtc.rtc); + if (retval) { + retval = PTR_ERR(mrst_rtc.rtc); + goto cleanup0; + } + dev_dbg(dev, "initialised\n"); return 0; -cleanup1: - rtc_device_unregister(mrst_rtc.rtc); cleanup0: mrst_rtc.dev = NULL; - release_mem_region(iomem->start, resource_size(iomem)); dev_err(dev, "rtc-mrst: unable to initialise\n"); return retval; } @@ -390,20 +391,10 @@ static void rtc_mrst_do_shutdown(void) static void rtc_mrst_do_remove(struct device *dev) { struct mrst_rtc *mrst = dev_get_drvdata(dev); - struct resource *iomem; rtc_mrst_do_shutdown(); - if (mrst->irq) - free_irq(mrst->irq, mrst->rtc); - - rtc_device_unregister(mrst->rtc); mrst->rtc = NULL; - - iomem = mrst->iomem; - release_mem_region(iomem->start, resource_size(iomem)); - mrst->iomem = NULL; - mrst->dev = NULL; } |