Skip to content

Commit

Permalink
Merge tag 'rtc-5.2' of git://git.kernel.org/pub/scm/linux/kernel/git/…
Browse files Browse the repository at this point in the history
…abelloni/linux

Pull RTC updates from Alexandre Belloni:
 "A huge series from me this cycle. I went through many drivers to set
  the date and time range supported by the RTC which helps solving HW
  limitation when the time comes (as early as next year for some). This
  time, I focused on drivers using .set_mms and .set_mmss64, allowing me
  to remove those callbacks. About a third of the patches got reviews, I
  actually own the RTCs and I tested another third and the remaining one
  are unlikely to cause any issues.

  Other than that, a single new driver and the usual fixes here and there.

  Summary:

  Subsystem:

   - set_mmss and set_mmss64 rtc_ops removal

   - Fix timestamp value for RTC_TIMESTAMP_BEGIN_1900

   - Use SPDX identifier for the core

   - validate upper bound of tm->tm_year

  New driver:

   - Aspeed BMC SoC RTC

  Drivers:

   - abx80x: use rtc_add_group

   - ds3232: nvram support

   - pcf85063: add alarm, nvram, offset correction and microcrystal
     rv8263 support

   - x1205: add of_match_table

   - Use set_time instead of set_mms/set_mmss64 for: ab3100, coh901331,
     digicolor, ds1672, ds2404, ep93xx, imxdi, jz4740, lpc32xx, mc13xxx,
     mxc, pcap, stmp3xxx, test, wm831x, xgene.

   - Set RTC range for: ab3100, at91sam9, coh901331, da9063, digicolor,
     dm355evm, ds1672, ds2404, ep39xx, goldfish, imxdi, jz4740, lpc32xx,
     mc13xxx, mv, mxc, omap, pcap, pcf85063, pcf85363, ps3, sh,
     stmp3xxx, sun4v, tegra, wm831x, xgene.

   - Switch to rtc_time64_to_tm/rtc_tm_to_time64 for the driver that
     properly set the RTC range.

   - Use dev_get_drvdata instead of multiple indirections"

* tag 'rtc-5.2' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: (177 commits)
  rtc: snvs: Use __maybe_unused instead of #if CONFIG_PM_SLEEP
  rtc: imxdi: remove unused variable
  rtc: drop set_mms and set_mmss64
  rtc: pcap: convert to SPDX identifier
  rtc: pcap: use .set_time
  rtc: pcap: switch to rtc_time64_to_tm/rtc_tm_to_time64
  rtc: pcap: set range
  rtc: digicolor: convert to SPDX identifier
  rtc: digicolor: use .set_time
  rtc: digicolor: set range
  rtc: digicolor: fix possible race condition
  rtc: jz4740: convert to SPDX identifier
  rtc: jz4740: rework invalid time detection
  rtc: jz4740: use dev_pm_set_wake_irq() to simplify code
  rtc: jz4740: use .set_time
  rtc: jz4740: remove useless check
  rtc: jz4740: switch to rtc_time64_to_tm/rtc_tm_to_time64
  rtc: jz4740: set range
  rtc: 88pm860x: prevent use-after-free on device remove
  rtc: Use dev_get_drvdata()
  ...
  • Loading branch information
Linus Torvalds committed May 9, 2019
2 parents 45182e4 + dacb6a4 commit 8e4ff71
Show file tree
Hide file tree
Showing 67 changed files with 1,400 additions and 1,510 deletions.
6 changes: 5 additions & 1 deletion Documentation/devicetree/bindings/rtc/nxp,pcf85063.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
* NXP PCF85063 Real Time Clock

Required properties:
- compatible: Should contain "nxp,pcf85063".
- compatible: Should one of contain:
"nxp,pcf85063",
"nxp,pcf85063a",
"nxp,pcf85063tp",
"microcrystal,rv8263"
- reg: I2C address for chip.

Optional property:
Expand Down
22 changes: 22 additions & 0 deletions Documentation/devicetree/bindings/rtc/rtc-aspeed.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
ASPEED BMC RTC
==============

Required properties:
- compatible: should be one of the following
* aspeed,ast2400-rtc for the ast2400
* aspeed,ast2500-rtc for the ast2500
* aspeed,ast2600-rtc for the ast2600

- reg: physical base address of the controller and length of memory mapped
region

- interrupts: The interrupt number

Example:

rtc@1e781000 {
compatible = "aspeed,ast2400-rtc";
reg = <0x1e781000 0x18>;
interrupts = <22>;
status = "disabled";
};
1 change: 1 addition & 0 deletions Documentation/devicetree/bindings/rtc/rtc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,4 @@ ricoh,rv5c386 I2C bus SERIAL INTERFACE REAL-TIME CLOCK IC
ricoh,rv5c387a I2C bus SERIAL INTERFACE REAL-TIME CLOCK IC
sii,s35390a 2-wire CMOS real-time clock
whwave,sd3078 I2C bus SERIAL INTERFACE REAL-TIME CLOCK IC
xircom,x1205 Xircom X1205 I2C RTC
19 changes: 15 additions & 4 deletions drivers/rtc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ config RTC_DRV_PCF8523

config RTC_DRV_PCF85063
tristate "NXP PCF85063"
select REGMAP_I2C
help
If you say yes here you get support for the PCF85063 RTC chip

Expand All @@ -447,7 +448,6 @@ config RTC_DRV_PCF85063

config RTC_DRV_PCF85363
tristate "NXP PCF85363"
depends on I2C
select REGMAP_I2C
help
If you say yes here you get support for the PCF85363 RTC chip.
Expand Down Expand Up @@ -602,7 +602,6 @@ config RTC_DRV_FM3130

config RTC_DRV_RX8010
tristate "Epson RX8010SJ"
depends on I2C
help
If you say yes here you get support for the Epson RX8010SJ RTC
chip.
Expand Down Expand Up @@ -1432,7 +1431,7 @@ config RTC_DRV_AT91RM9200
config RTC_DRV_AT91SAM9
tristate "AT91SAM9 RTT as RTC"
depends on ARCH_AT91 || COMPILE_TEST
depends on HAS_IOMEM
depends on OF && HAS_IOMEM
select MFD_SYSCON
help
Some AT91SAM9 SoCs provide an RTT (Real Time Timer) block which
Expand Down Expand Up @@ -1841,6 +1840,17 @@ config RTC_DRV_RTD119X
If you say yes here, you get support for the RTD1295 SoC
Real Time Clock.

config RTC_DRV_ASPEED
tristate "ASPEED RTC"
depends on OF
depends on ARCH_ASPEED || COMPILE_TEST
help
If you say yes here you get support for the ASPEED BMC SoC real time
clocks.

This driver can also be built as a module, if so, the module
will be called "rtc-aspeed".

comment "HID Sensor RTC drivers"

config RTC_DRV_HID_SENSOR_TIME
Expand All @@ -1857,7 +1867,8 @@ config RTC_DRV_HID_SENSOR_TIME

config RTC_DRV_GOLDFISH
tristate "Goldfish Real Time Clock"
depends on MIPS && (GOLDFISH || COMPILE_TEST)
depends on OF && HAS_IOMEM
depends on GOLDFISH || COMPILE_TEST
help
Say yes to enable RTC driver for the Goldfish based virtual platform.

Expand Down
1 change: 1 addition & 0 deletions drivers/rtc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ obj-$(CONFIG_RTC_DRV_AC100) += rtc-ac100.o
obj-$(CONFIG_RTC_DRV_ARMADA38X) += rtc-armada38x.o
obj-$(CONFIG_RTC_DRV_AS3722) += rtc-as3722.o
obj-$(CONFIG_RTC_DRV_ASM9260) += rtc-asm9260.o
obj-$(CONFIG_RTC_DRV_ASPEED) += rtc-aspeed.o
obj-$(CONFIG_RTC_DRV_AT91RM9200)+= rtc-at91rm9200.o
obj-$(CONFIG_RTC_DRV_AT91SAM9) += rtc-at91sam9.o
obj-$(CONFIG_RTC_DRV_AU1XXX) += rtc-au1xxx.o
Expand Down
21 changes: 8 additions & 13 deletions drivers/rtc/class.c
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
// SPDX-License-Identifier: GPL-2.0
/*
* RTC subsystem, base class
*
* Copyright (C) 2005 Tower Technologies
* Author: Alessandro Zummo <a.zummo@towertech.it>
*
* class skeleton from drivers/hwmon/hwmon.c
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
*/

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

Expand All @@ -23,13 +20,13 @@

#include "rtc-core.h"


static DEFINE_IDA(rtc_ida);
struct class *rtc_class;

static void rtc_device_release(struct device *dev)
{
struct rtc_device *rtc = to_rtc_device(dev);

ida_simple_remove(&rtc_ida, rtc->id);
kfree(rtc);
}
Expand All @@ -47,7 +44,6 @@ int rtc_hctosys_ret = -ENODEV;

static struct timespec64 old_rtc, old_system, old_delta;


static int rtc_suspend(struct device *dev)
{
struct rtc_device *rtc = to_rtc_device(dev);
Expand All @@ -71,7 +67,6 @@ static int rtc_suspend(struct device *dev)
ktime_get_real_ts64(&old_system);
old_rtc.tv_sec = rtc_tm_to_time64(&tm);


/*
* To avoid drift caused by repeated suspend/resumes,
* which each can add ~1 second drift error,
Expand All @@ -83,7 +78,7 @@ static int rtc_suspend(struct device *dev)
if (delta_delta.tv_sec < -2 || delta_delta.tv_sec >= 2) {
/*
* if delta_delta is too large, assume time correction
* has occured and set old_delta to the current delta.
* has occurred and set old_delta to the current delta.
*/
old_delta = delta;
} else {
Expand Down Expand Up @@ -136,7 +131,7 @@ static int rtc_resume(struct device *dev)
* to keep things accurate.
*/
sleep_time = timespec64_sub(sleep_time,
timespec64_sub(new_system, old_system));
timespec64_sub(new_system, old_system));

if (sleep_time.tv_sec >= 0)
timekeeping_inject_sleeptime64(&sleep_time);
Expand Down Expand Up @@ -397,9 +392,9 @@ EXPORT_SYMBOL_GPL(__rtc_register_device);
* rtc_register_device instead
*/
struct rtc_device *devm_rtc_device_register(struct device *dev,
const char *name,
const struct rtc_class_ops *ops,
struct module *owner)
const char *name,
const struct rtc_class_ops *ops,
struct module *owner)
{
struct rtc_device *rtc;
int err;
Expand Down
20 changes: 10 additions & 10 deletions drivers/rtc/dev.c
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
// SPDX-License-Identifier: GPL-2.0
/*
* RTC subsystem, dev interface
*
* Copyright (C) 2005 Tower Technologies
* Author: Alessandro Zummo <a.zummo@towertech.it>
*
* based on arch/arm/common/rtctime.c
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
*/

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

Expand Down Expand Up @@ -60,7 +57,7 @@ static void rtc_uie_task(struct work_struct *work)
} else if (rtc->oldsecs != tm.tm_sec) {
num = (tm.tm_sec + 60 - rtc->oldsecs) % 60;
rtc->oldsecs = tm.tm_sec;
rtc->uie_timer.expires = jiffies + HZ - (HZ/10);
rtc->uie_timer.expires = jiffies + HZ - (HZ / 10);
rtc->uie_timer_active = 1;
rtc->uie_task_active = 0;
add_timer(&rtc->uie_timer);
Expand All @@ -71,6 +68,7 @@ static void rtc_uie_task(struct work_struct *work)
if (num)
rtc_handle_legacy_irq(rtc, num, RTC_UF);
}

static void rtc_uie_timer(struct timer_list *t)
{
struct rtc_device *rtc = from_timer(rtc, t, uie_timer);
Expand Down Expand Up @@ -202,14 +200,14 @@ static __poll_t rtc_dev_poll(struct file *file, poll_table *wait)
}

static long rtc_dev_ioctl(struct file *file,
unsigned int cmd, unsigned long arg)
unsigned int cmd, unsigned long arg)
{
int err = 0;
struct rtc_device *rtc = file->private_data;
const struct rtc_class_ops *ops = rtc->ops;
struct rtc_time tm;
struct rtc_wkalrm alarm;
void __user *uarg = (void __user *) arg;
void __user *uarg = (void __user *)arg;

err = mutex_lock_interruptible(&rtc->ops_lock);
if (err)
Expand All @@ -233,7 +231,7 @@ static long rtc_dev_ioctl(struct file *file,

case RTC_PIE_ON:
if (rtc->irq_freq > rtc->max_user_freq &&
!capable(CAP_SYS_RESOURCE))
!capable(CAP_SYS_RESOURCE))
err = -EACCES;
break;
}
Expand Down Expand Up @@ -390,8 +388,9 @@ static long rtc_dev_ioctl(struct file *file,
err = ops->ioctl(rtc->dev.parent, cmd, arg);
if (err == -ENOIOCTLCMD)
err = -ENOTTY;
} else
} else {
err = -ENOTTY;
}
break;
}

Expand All @@ -403,6 +402,7 @@ static long rtc_dev_ioctl(struct file *file,
static int rtc_dev_fasync(int fd, struct file *file, int on)
{
struct rtc_device *rtc = file->private_data;

return fasync_helper(fd, file, on, &rtc->async_queue);
}

Expand Down
10 changes: 3 additions & 7 deletions drivers/rtc/hctosys.c
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
// SPDX-License-Identifier: GPL-2.0
/*
* RTC subsystem, initialize system time on startup
*
* Copyright (C) 2005 Tower Technologies
* Author: Alessandro Zummo <a.zummo@towertech.it>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
*/

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

Expand All @@ -33,7 +30,7 @@ static int __init rtc_hctosys(void)
};
struct rtc_device *rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE);

if (rtc == NULL) {
if (!rtc) {
pr_info("unable to open rtc device (%s)\n",
CONFIG_RTC_HCTOSYS_DEVICE);
goto err_open;
Expand All @@ -44,7 +41,6 @@ static int __init rtc_hctosys(void)
dev_err(rtc->dev.parent,
"hctosys: unable to read the hardware clock\n");
goto err_read;

}

tv64.tv_sec = rtc_tm_to_time64(&tm);
Expand Down
Loading

0 comments on commit 8e4ff71

Please sign in to comment.