diff options
author | Stephen Rothwell <sfr@canb.auug.org.au> | 2018-09-12 12:48:01 +1000 |
---|---|---|
committer | Stephen Rothwell <sfr@canb.auug.org.au> | 2018-09-12 12:48:01 +1000 |
commit | 65efff2139f1a5398a6b2e8887078c54fcc51a8f (patch) | |
tree | e6b4bf6fa5e57a3eaa8eef0dd9c35dacedf24e66 /drivers | |
parent | 3a375b45855e88d28d17ec7db4a3062b6167af32 (diff) | |
parent | b7aff107f34f007f32f45136c9a935912a481d32 (diff) | |
download | linux-next-65efff2139f1a5398a6b2e8887078c54fcc51a8f.tar.gz |
Merge remote-tracking branch 'rtc/rtc-next'
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/char/Kconfig | 2 | ||||
-rw-r--r-- | drivers/rtc/Kconfig | 2 | ||||
-rw-r--r-- | drivers/rtc/rtc-mrst.c | 5 | ||||
-rw-r--r-- | drivers/rtc/rtc-mt6397.c | 13 | ||||
-rw-r--r-- | drivers/rtc/rtc-omap.c | 28 | ||||
-rw-r--r-- | drivers/rtc/rtc-pl030.c | 15 | ||||
-rw-r--r-- | drivers/rtc/rtc-pl031.c | 18 | ||||
-rw-r--r-- | drivers/rtc/rtc-rv8803.c | 7 | ||||
-rw-r--r-- | drivers/rtc/rtc-sun6i.c | 3 | ||||
-rw-r--r-- | drivers/rtc/rtc-sysfs.c | 4 |
10 files changed, 55 insertions, 42 deletions
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index 40728491f37b..9d03b2ff5df6 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig @@ -268,7 +268,7 @@ if RTC_LIB=n config RTC tristate "Enhanced Real Time Clock Support (legacy PC RTC driver)" - depends on ALPHA || (MIPS && MACH_LOONGSON64) + depends on ALPHA ---help--- If you say Y here and create a character special file /dev/rtc with major number 10 and minor number 135 using mknod ("man mknod"), you diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index 7d7be60a2413..a0f291c052bc 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig @@ -1587,7 +1587,7 @@ config RTC_DRV_MPC5121 config RTC_DRV_JZ4740 tristate "Ingenic JZ4740 SoC" - depends on MACH_INGENIC || COMPILE_TEST + depends on MIPS || COMPILE_TEST help If you say yes here you get support for the Ingenic JZ47xx SoCs RTC controllers. diff --git a/drivers/rtc/rtc-mrst.c b/drivers/rtc/rtc-mrst.c index 1925aaf09093..daf354a6a853 100644 --- a/drivers/rtc/rtc-mrst.c +++ b/drivers/rtc/rtc-mrst.c @@ -90,7 +90,7 @@ static int mrst_read_time(struct device *dev, struct rtc_time *time) unsigned long flags; if (vrtc_is_updating()) - mdelay(20); + msleep(20); spin_lock_irqsave(&rtc_lock, flags); time->tm_sec = vrtc_cmos_read(RTC_SECONDS); @@ -261,11 +261,10 @@ static int mrst_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) static int mrst_procfs(struct device *dev, struct seq_file *seq) { - unsigned char rtc_control, valid; + unsigned char rtc_control; spin_lock_irq(&rtc_lock); rtc_control = vrtc_cmos_read(RTC_CONTROL); - valid = vrtc_cmos_read(RTC_VALID); spin_unlock_irq(&rtc_lock); seq_printf(seq, diff --git a/drivers/rtc/rtc-mt6397.c b/drivers/rtc/rtc-mt6397.c index 385f8303bb41..e9a25ec4d434 100644 --- a/drivers/rtc/rtc-mt6397.c +++ b/drivers/rtc/rtc-mt6397.c @@ -332,6 +332,10 @@ static int mtk_rtc_probe(struct platform_device *pdev) platform_set_drvdata(pdev, rtc); + rtc->rtc_dev = devm_rtc_allocate_device(rtc->dev); + if (IS_ERR(rtc->rtc_dev)) + return PTR_ERR(rtc->rtc_dev); + ret = request_threaded_irq(rtc->irq, NULL, mtk_rtc_irq_handler_thread, IRQF_ONESHOT | IRQF_TRIGGER_HIGH, @@ -344,11 +348,11 @@ static int mtk_rtc_probe(struct platform_device *pdev) device_init_wakeup(&pdev->dev, 1); - rtc->rtc_dev = rtc_device_register("mt6397-rtc", &pdev->dev, - &mtk_rtc_ops, THIS_MODULE); - if (IS_ERR(rtc->rtc_dev)) { + rtc->rtc_dev->ops = &mtk_rtc_ops; + + ret = rtc_register_device(rtc->rtc_dev); + if (ret) { dev_err(&pdev->dev, "register rtc device failed\n"); - ret = PTR_ERR(rtc->rtc_dev); goto out_free_irq; } @@ -365,7 +369,6 @@ static int mtk_rtc_remove(struct platform_device *pdev) { struct mt6397_rtc *rtc = platform_get_drvdata(pdev); - rtc_device_unregister(rtc->rtc_dev); free_irq(rtc->irq, rtc->rtc_dev); irq_dispose_mapping(rtc->irq); diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c index 323ff55cc165..320b4a520eb3 100644 --- a/drivers/rtc/rtc-omap.c +++ b/drivers/rtc/rtc-omap.c @@ -421,12 +421,6 @@ static struct omap_rtc *omap_rtc_power_off_rtc; * The RTC can be used to control an external PMIC via the pmic_power_en pin, * which can be configured to transition to OFF on ALARM2 events. * - * Notes: - * The two-second alarm offset is the shortest offset possible as the alarm - * registers must be set before the next timer update and the offset - * calculation is too heavy for everything to be done within a single access - * period (~15 us). - * * Called with local interrupts disabled. */ static void omap_rtc_power_off(void) @@ -434,6 +428,7 @@ static void omap_rtc_power_off(void) struct omap_rtc *rtc = omap_rtc_power_off_rtc; struct rtc_time tm; unsigned long now; + int seconds; u32 val; rtc->type->unlock(rtc); @@ -441,11 +436,13 @@ static void omap_rtc_power_off(void) val = rtc_readl(rtc, OMAP_RTC_PMIC_REG); rtc_writel(rtc, OMAP_RTC_PMIC_REG, val | OMAP_RTC_PMIC_POWER_EN_EN); - /* set alarm two seconds from now */ +again: + /* set alarm one second from now */ omap_rtc_read_time_raw(rtc, &tm); + seconds = tm.tm_sec; bcd2tm(&tm); rtc_tm_to_time(&tm, &now); - rtc_time_to_tm(now + 2, &tm); + rtc_time_to_tm(now + 1, &tm); if (tm2bcd(&tm) < 0) { dev_err(&rtc->rtc->dev, "power off failed\n"); @@ -470,14 +467,22 @@ static void omap_rtc_power_off(void) val = rtc_read(rtc, OMAP_RTC_INTERRUPTS_REG); rtc_writel(rtc, OMAP_RTC_INTERRUPTS_REG, val | OMAP_RTC_INTERRUPTS_IT_ALARM2); + + /* Retry in case roll over happened before alarm was armed. */ + if (rtc_read(rtc, OMAP_RTC_SECONDS_REG) != seconds) { + val = rtc_read(rtc, OMAP_RTC_STATUS_REG); + if (!(val & OMAP_RTC_STATUS_ALARM2)) + goto again; + } + rtc->type->lock(rtc); /* - * Wait for alarm to trigger (within two seconds) and external PMIC to + * Wait for alarm to trigger (within one second) and external PMIC to * power off the system. Add a 500 ms margin for external latencies * (e.g. debounce circuits). */ - mdelay(2500); + mdelay(1500); } static const struct rtc_class_ops omap_rtc_ops = { @@ -721,8 +726,7 @@ static int omap_rtc_probe(struct platform_device *pdev) if (of_id) { rtc->type = of_id->data; rtc->is_pmic_controller = rtc->type->has_pmic_mode && - of_property_read_bool(pdev->dev.of_node, - "system-power-controller"); + of_device_is_system_power_controller(pdev->dev.of_node); } else { id_entry = platform_get_device_id(pdev); rtc->type = (void *)id_entry->driver_data; diff --git a/drivers/rtc/rtc-pl030.c b/drivers/rtc/rtc-pl030.c index f85a1a93e669..343bb6ed1783 100644 --- a/drivers/rtc/rtc-pl030.c +++ b/drivers/rtc/rtc-pl030.c @@ -112,6 +112,13 @@ static int pl030_probe(struct amba_device *dev, const struct amba_id *id) goto err_rtc; } + rtc->rtc = devm_rtc_allocate_device(&dev->dev); + if (IS_ERR(rtc->rtc)) { + ret = PTR_ERR(rtc->rtc); + goto err_rtc; + } + + rtc->rtc->ops = &pl030_ops; rtc->base = ioremap(dev->res.start, resource_size(&dev->res)); if (!rtc->base) { ret = -ENOMEM; @@ -128,12 +135,9 @@ static int pl030_probe(struct amba_device *dev, const struct amba_id *id) if (ret) goto err_irq; - rtc->rtc = rtc_device_register("pl030", &dev->dev, &pl030_ops, - THIS_MODULE); - if (IS_ERR(rtc->rtc)) { - ret = PTR_ERR(rtc->rtc); + ret = rtc_register_device(rtc->rtc); + if (ret) goto err_reg; - } return 0; @@ -154,7 +158,6 @@ static int pl030_remove(struct amba_device *dev) writel(0, rtc->base + RTC_CR); free_irq(dev->irq[0], rtc); - rtc_device_unregister(rtc->rtc); iounmap(rtc->base); amba_release_regions(dev); diff --git a/drivers/rtc/rtc-pl031.c b/drivers/rtc/rtc-pl031.c index 82eb7da2c478..30943d200c5e 100644 --- a/drivers/rtc/rtc-pl031.c +++ b/drivers/rtc/rtc-pl031.c @@ -310,7 +310,6 @@ static int pl031_remove(struct amba_device *adev) device_init_wakeup(&adev->dev, false); if (adev->irq[0]) free_irq(adev->irq[0], ldata); - rtc_device_unregister(ldata->rtc); amba_release_regions(adev); return 0; @@ -383,24 +382,25 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id) } device_init_wakeup(&adev->dev, true); - ldata->rtc = rtc_device_register("pl031", &adev->dev, ops, - THIS_MODULE); - if (IS_ERR(ldata->rtc)) { - ret = PTR_ERR(ldata->rtc); + ldata->rtc = devm_rtc_allocate_device(&adev->dev); + if (IS_ERR(ldata->rtc)) + return PTR_ERR(ldata->rtc); + + ldata->rtc->ops = ops; + + ret = rtc_register_device(ldata->rtc); + if (ret) goto out; - } if (adev->irq[0]) { ret = request_irq(adev->irq[0], pl031_interrupt, vendor->irqflags, "rtc-pl031", ldata); if (ret) - goto out_no_irq; + goto out; dev_pm_set_wake_irq(&adev->dev, adev->irq[0]); } return 0; -out_no_irq: - rtc_device_unregister(ldata->rtc); out: amba_release_regions(adev); err_req: diff --git a/drivers/rtc/rtc-rv8803.c b/drivers/rtc/rtc-rv8803.c index 29fc3d210392..450a0b831a2d 100644 --- a/drivers/rtc/rtc-rv8803.c +++ b/drivers/rtc/rtc-rv8803.c @@ -615,6 +615,7 @@ static int rv8803_probe(struct i2c_client *client, static const struct i2c_device_id rv8803_id[] = { { "rv8803", rv_8803 }, + { "rx8803", rv_8803 }, { "rx8900", rx_8900 }, { } }; @@ -623,7 +624,11 @@ MODULE_DEVICE_TABLE(i2c, rv8803_id); static const struct of_device_id rv8803_of_match[] = { { .compatible = "microcrystal,rv8803", - .data = (void *)rx_8900 + .data = (void *)rv_8803 + }, + { + .compatible = "epson,rx8803", + .data = (void *)rv_8803 }, { .compatible = "epson,rx8900", diff --git a/drivers/rtc/rtc-sun6i.c b/drivers/rtc/rtc-sun6i.c index 2cd5a7b1a2e3..fe07310952df 100644 --- a/drivers/rtc/rtc-sun6i.c +++ b/drivers/rtc/rtc-sun6i.c @@ -199,8 +199,7 @@ static void __init sun6i_rtc_clk_init(struct device_node *node) if (!rtc) return; - clk_data = kzalloc(sizeof(*clk_data) + (sizeof(*clk_data->hws) * 2), - GFP_KERNEL); + clk_data = kzalloc(struct_size(clk_data, hws, 2), GFP_KERNEL); if (!clk_data) { kfree(rtc); return; diff --git a/drivers/rtc/rtc-sysfs.c b/drivers/rtc/rtc-sysfs.c index f1ff30ade534..9746c32eee2e 100644 --- a/drivers/rtc/rtc-sysfs.c +++ b/drivers/rtc/rtc-sysfs.c @@ -338,8 +338,8 @@ int rtc_add_groups(struct rtc_device *rtc, const struct attribute_group **grps) new_cnt = old_cnt + add_cnt + 1; groups = devm_kcalloc(&rtc->dev, new_cnt, sizeof(*groups), GFP_KERNEL); - if (IS_ERR_OR_NULL(groups)) - return PTR_ERR(groups); + if (!groups) + return -ENOMEM; memcpy(groups, rtc->dev.groups, old_cnt * sizeof(*groups)); memcpy(groups + old_cnt, grps, add_cnt * sizeof(*groups)); groups[old_cnt + add_cnt] = NULL; |