linux-2.6-block.git
5 years agortc: pcap: switch to rtc_time64_to_tm/rtc_tm_to_time64
Alexandre Belloni [Tue, 30 Apr 2019 09:33:00 +0000 (11:33 +0200)]
rtc: pcap: switch to rtc_time64_to_tm/rtc_tm_to_time64

Call the 64bit versions of rtc_tm time conversion now that the range is
enforced by the core.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: pcap: set range
Alexandre Belloni [Tue, 30 Apr 2019 09:32:59 +0000 (11:32 +0200)]
rtc: pcap: set range

While PCAP_RTC_DAY_MASK is set to 0x3ffff, it is very unlikely to be
correct as this ends in june 1992, before the product even existed. It is
more likely to be a 14-bit day counter. The next product in the family (the
mc13xxx) has a 15-bit day counter.

The same issue is seen with PCAP_RTC_TOD_MASK which only has 65535 seconds
and falls short of the necessary 86400 seconds.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: digicolor: convert to SPDX identifier
Alexandre Belloni [Tue, 30 Apr 2019 09:32:12 +0000 (11:32 +0200)]
rtc: digicolor: convert to SPDX identifier

Use SPDX-License-Identifier instead of a verbose license text.

Acked-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: digicolor: use .set_time
Alexandre Belloni [Tue, 30 Apr 2019 09:32:11 +0000 (11:32 +0200)]
rtc: digicolor: use .set_time

Use .set_time instead of the deprecated .set_mmss.

Acked-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: digicolor: set range
Alexandre Belloni [Tue, 30 Apr 2019 09:32:10 +0000 (11:32 +0200)]
rtc: digicolor: set range

While the range of REFERENCE + TIME is actually 33 bits, the counter
itself (TIME) is a 32-bits seconds counter.

Acked-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: digicolor: fix possible race condition
Alexandre Belloni [Tue, 30 Apr 2019 09:32:09 +0000 (11:32 +0200)]
rtc: digicolor: fix possible race condition

The IRQ is requested before the struct rtc is allocated and registered, but
this struct is used in the IRQ handler. This may lead to a NULL pointer
dereference.

Switch to devm_rtc_allocate_device/rtc_register_device to allocate the rtc
struct before requesting the IRQ.

Acked-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: jz4740: convert to SPDX identifier
Alexandre Belloni [Tue, 30 Apr 2019 09:28:21 +0000 (11:28 +0200)]
rtc: jz4740: convert to SPDX identifier

Use SPDX-License-Identifier instead of a verbose license text.

Tested-by: Mathieu Malaterre <malat@debian.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: jz4740: rework invalid time detection
Alexandre Belloni [Tue, 30 Apr 2019 09:28:20 +0000 (11:28 +0200)]
rtc: jz4740: rework invalid time detection

The scratchpad register is used to detect an invalid time when power to the
RTC has been lost. Instead of deleting that precious information and set
the time to the UNIX epoch, forward it to userspace.

Tested-by: Mathieu Malaterre <malat@debian.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: jz4740: use dev_pm_set_wake_irq() to simplify code
Alexandre Belloni [Tue, 30 Apr 2019 09:28:19 +0000 (11:28 +0200)]
rtc: jz4740: use dev_pm_set_wake_irq() to simplify code

Use dev_pm_set_wake_irq() to set the RTC as a wakeup source for suspend.
This allows to remove the whole dev_pm_ops structure.

Tested-by: Mathieu Malaterre <malat@debian.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: jz4740: use .set_time
Alexandre Belloni [Tue, 30 Apr 2019 09:28:18 +0000 (11:28 +0200)]
rtc: jz4740: use .set_time

Use .set_time instead of the deprecated .set_mmss.

Tested-by: Mathieu Malaterre <malat@debian.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: jz4740: remove useless check
Alexandre Belloni [Tue, 30 Apr 2019 09:28:17 +0000 (11:28 +0200)]
rtc: jz4740: remove useless check

rtc_time64_to_tm always returns a valid tm, it is not necessary to validate
it.

Tested-by: Mathieu Malaterre <malat@debian.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: jz4740: switch to rtc_time64_to_tm/rtc_tm_to_time64
Alexandre Belloni [Tue, 30 Apr 2019 09:28:16 +0000 (11:28 +0200)]
rtc: jz4740: switch to rtc_time64_to_tm/rtc_tm_to_time64

Call the 64bit versions of rtc_tm time conversion now that the range is
enforced by the core.

Tested-by: Mathieu Malaterre <malat@debian.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: jz4740: set range
Alexandre Belloni [Tue, 30 Apr 2019 09:28:15 +0000 (11:28 +0200)]
rtc: jz4740: set range

RTC_SEC is a 32-bit seconds counter.

Tested-by: Mathieu Malaterre <malat@debian.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: 88pm860x: prevent use-after-free on device remove
Sven Van Asbroeck [Fri, 26 Apr 2019 18:36:35 +0000 (14:36 -0400)]
rtc: 88pm860x: prevent use-after-free on device remove

The device's remove() attempts to shut down the delayed_work scheduled
on the kernel-global workqueue by calling flush_scheduled_work().

Unfortunately, flush_scheduled_work() does not prevent the delayed_work
from re-scheduling itself. The delayed_work might run after the device
has been removed, and touch the already de-allocated info structure.
This is a potential use-after-free.

Fix by calling cancel_delayed_work_sync() during remove(): this ensures
that the delayed work is properly cancelled, is no longer running, and
is not able to re-schedule itself.

This issue was detected with the help of Coccinelle.

Signed-off-by: Sven Van Asbroeck <TheSven73@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: Use dev_get_drvdata()
Kefeng Wang [Tue, 23 Apr 2019 07:50:16 +0000 (15:50 +0800)]
rtc: Use dev_get_drvdata()

Using dev_get_drvdata directly.

Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: linux-rtc@vger.kernel.org
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: imxdi: convert to SPDX identifier
Alexandre Belloni [Tue, 16 Apr 2019 08:34:32 +0000 (10:34 +0200)]
rtc: imxdi: convert to SPDX identifier

Use SPDX-License-Identifier instead of a verbose license text.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: imxdi: remove unnecessary check
Alexandre Belloni [Tue, 16 Apr 2019 08:34:31 +0000 (10:34 +0200)]
rtc: imxdi: remove unnecessary check

The RTC core already ensures the alarm is set to a time in the future, it
is not necessary to check again in the driver.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: imxdi: use .set_time
Alexandre Belloni [Tue, 16 Apr 2019 08:34:30 +0000 (10:34 +0200)]
rtc: imxdi: use .set_time

Use .set_time instead of the deprecated .set_mmss.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: imxdi: switch to rtc_time64_to_tm/rtc_tm_to_time64
Alexandre Belloni [Tue, 16 Apr 2019 08:34:29 +0000 (10:34 +0200)]
rtc: imxdi: switch to rtc_time64_to_tm/rtc_tm_to_time64

Call the 64bit versions of rtc_tm time conversion now that the range is
enforced by the core.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: imxdi: set range
Alexandre Belloni [Tue, 16 Apr 2019 08:34:28 +0000 (10:34 +0200)]
rtc: imxdi: set range

The RTC Time Counter MSB Register contains the 32 most significant bits
(47:16) of the 47-bit RTC Time Counter. Clocked by a 32.768 KHz clock, this
register is effectively a 32-bit seconds counter.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: mxc: use .set_time
Alexandre Belloni [Tue, 16 Apr 2019 08:30:45 +0000 (10:30 +0200)]
rtc: mxc: use .set_time

Use .set_time instead of the deprecated .set_mmss64.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: mxc: set range
Alexandre Belloni [Tue, 16 Apr 2019 08:30:44 +0000 (10:30 +0200)]
rtc: mxc: set range

Let the core handle the range, and in particular the imx1 offsetting. This
has the benefit of extending the range of the RTC further than 365 days and
making .read_time useful again on imx1.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: mxc: fix possible race condition
Alexandre Belloni [Tue, 16 Apr 2019 08:30:43 +0000 (10:30 +0200)]
rtc: mxc: fix possible race condition

The IRQ is requested before the struct rtc is allocated and registered, but
this struct is used in the IRQ handler. This may lead to a NULL pointer
dereference.

Switch to devm_rtc_allocate_device/rtc_register_device to allocate the rtc
struct before requesting the IRQ.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: stm32: manage the get_irq probe defer case
Fabien Dessenne [Wed, 24 Apr 2019 12:26:48 +0000 (14:26 +0200)]
rtc: stm32: manage the get_irq probe defer case

Manage the -EPROBE_DEFER error case for the wake IRQ.

Signed-off-by: Fabien Dessenne <fabien.dessenne@st.com>
Acked-by: Amelie Delaunay <amelie.delaunay@st.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: rx6110: declare missing of table
Daniel Gomez [Mon, 22 Apr 2019 19:08:52 +0000 (21:08 +0200)]
rtc: rx6110: declare missing of table

Add missing <of_device_id> table for SPI driver relying on SPI
device match since compatible is in a DT binding or in a DTS.

Before this patch:
modinfo drivers/rtc/rtc-rx6110.ko | grep alias
alias:          spi:rx6110

After this patch:
modinfo drivers/rtc/rtc-rx6110.ko | grep alias
alias:          spi:rx6110
alias:          of:N*T*Cepson,rx6110C*
alias:          of:N*T*Cepson,rx6110

Reported-by: Javier Martinez Canillas <javier@dowhile0.org>
Signed-off-by: Daniel Gomez <dagmcr@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: wm831x: use .set_time
Alexandre Belloni [Sun, 7 Apr 2019 11:54:44 +0000 (13:54 +0200)]
rtc: wm831x: use .set_time

Use .set_time instead of the deprecated .set_mmss.

Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: ds2404: simplify .probe and remove .remove
Alexandre Belloni [Fri, 19 Apr 2019 08:25:01 +0000 (10:25 +0200)]
rtc: ds2404: simplify .probe and remove .remove

Use devm_add_action_or_reset to simplify .probe and remove .remove

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: ds2404: remove ds2404_chip_ops
Alexandre Belloni [Fri, 19 Apr 2019 08:25:00 +0000 (10:25 +0200)]
rtc: ds2404: remove ds2404_chip_ops

There is only one ds2404_chip_ops struct that is implemented, remove the
unnecessary indirection.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: ds2404: convert to SPDX identifier
Alexandre Belloni [Fri, 19 Apr 2019 08:24:59 +0000 (10:24 +0200)]
rtc: ds2404: convert to SPDX identifier

Use SPDX-License-Identifier instead of a verbose license text.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: ds2404: use .set_time
Alexandre Belloni [Fri, 19 Apr 2019 08:24:58 +0000 (10:24 +0200)]
rtc: ds2404: use .set_time

Use .set_time instead of the deprecated .set_mmss.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: ds2404: switch to rtc_time64_to_tm
Alexandre Belloni [Fri, 19 Apr 2019 08:24:57 +0000 (10:24 +0200)]
rtc: ds2404: switch to rtc_time64_to_tm

Call the 64bit version of rtc_time_to_tm now that the range is enforced by
the core.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: ds2404: set range
Alexandre Belloni [Fri, 19 Apr 2019 08:24:56 +0000 (10:24 +0200)]
rtc: ds2404: set range

The real-time clock is a 5-byte binary counter. It is incremented 256 times
per second. The least significant byte is a count of fractional seconds.
The upper four bytes are a count of seconds. The realtime clock can
accumulate 136 years of seconds before rolling over.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: ep93xx: fix checkpatch issues
Alexandre Belloni [Fri, 19 Apr 2019 08:00:05 +0000 (10:00 +0200)]
rtc: ep93xx: fix checkpatch issues

Fix sysfs attribute declaration as suggested by checkpatch.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: ep93xx: convert to SPDX identifier
Alexandre Belloni [Fri, 19 Apr 2019 08:00:04 +0000 (10:00 +0200)]
rtc: ep93xx: convert to SPDX identifier

Use SPDX-License-Identifier instead of a verbose license text.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: ep93xx: use .set_time
Alexandre Belloni [Fri, 19 Apr 2019 08:00:03 +0000 (10:00 +0200)]
rtc: ep93xx: use .set_time

Use .set_time instead of the deprecated .set_mmss.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: ep93xx: switch to rtc_time64_to_tm
Alexandre Belloni [Fri, 19 Apr 2019 08:00:02 +0000 (10:00 +0200)]
rtc: ep93xx: switch to rtc_time64_to_tm

Call the 64bit version of rtc_time_to_tm now that the range is enforced by
the core.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: ep93xx: set range
Alexandre Belloni [Fri, 19 Apr 2019 08:00:01 +0000 (10:00 +0200)]
rtc: ep93xx: set range

The ep93xx RTC is a 32-bit seconds counter.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: ep93xx: use rtc_add_group
Alexandre Belloni [Fri, 19 Apr 2019 08:00:00 +0000 (10:00 +0200)]
rtc: ep93xx: use rtc_add_group

Use rtc_add_group to add the sysfs group in a race free manner.
This has the side effect of moving the files to their proper location.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: ep93xx: convert to devm_rtc_allocate_device
Alexandre Belloni [Fri, 19 Apr 2019 07:59:59 +0000 (09:59 +0200)]
rtc: ep93xx: convert to devm_rtc_allocate_device

This allows further improvement of the driver.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: ep93xx: stop setting platform_data
Alexandre Belloni [Fri, 19 Apr 2019 07:59:58 +0000 (09:59 +0200)]
rtc: ep93xx: stop setting platform_data

Since commit 28dc5f803899 ("drivers/rtc/rtc-ep93xx.c: use
dev_get_platdata()"), platform_data is not used directly, it is not
necessary to set it anymore.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: ds3232: get SRAM access using NVMEM Framework
Han Nandor [Tue, 16 Apr 2019 10:57:54 +0000 (10:57 +0000)]
rtc: ds3232: get SRAM access using NVMEM Framework

DS3232 RTC has 236 bytes of persistent memory.

Add RTC SRAM read and write access using
the NVMEM Framework.

Signed-off-by: Han Nandor <nandor.han@vaisala.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: mc13xxx: fix style issue
Alexandre Belloni [Tue, 16 Apr 2019 08:33:08 +0000 (10:33 +0200)]
rtc: mc13xxx: fix style issue

Use unsigned int instead of unsigned.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: mc13xxx: convert to SPDX identifier
Alexandre Belloni [Tue, 16 Apr 2019 08:33:07 +0000 (10:33 +0200)]
rtc: mc13xxx: convert to SPDX identifier

Use SPDX-License-Identifier instead of a verbose license text.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: mc13xxx: use .set_time
Alexandre Belloni [Tue, 16 Apr 2019 08:33:06 +0000 (10:33 +0200)]
rtc: mc13xxx: use .set_time

Use .set_time instead of the deprecated .set_mmss64.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: mc13xxx: set range
Alexandre Belloni [Tue, 16 Apr 2019 08:33:05 +0000 (10:33 +0200)]
rtc: mc13xxx: set range

All supported PMICs have a 15 bits days counter and hours, minutes, seconds

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: ds1685: use threaded interrupt
Thomas Bogendoerfer [Tue, 16 Apr 2019 09:34:04 +0000 (11:34 +0200)]
rtc: ds1685: use threaded interrupt

Handling of extended interrupts (kickstart, wake-up, ram-clear) was
moved off to a work queue, but the interrupts aren't acknowledged
in the interrupt handler. This leads to a deadlock, if driver
is used with interrupts. To fix this we use a threaded interrupt, get rid
of the work queue and do locking with just the rtc mutex lock.

Fixes: aaaf5fbf56f1 ("rtc: add driver for DS1685 family of real time clocks")
Signed-off-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: ds1685: remove dead code
Thomas Bogendoerfer [Tue, 16 Apr 2019 09:34:03 +0000 (11:34 +0200)]
rtc: ds1685: remove dead code

ds1685_rtc_begin_ctrl_access/ds1685_rtc_end_ctrl_access aren't used,
so get rid of it.

Signed-off-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: ds1685: fix crash caused by referencing wrong device struct
Thomas Bogendoerfer [Thu, 11 Apr 2019 14:33:21 +0000 (16:33 +0200)]
rtc: ds1685: fix crash caused by referencing wrong device struct

sysfs entries added by rtc_add_group are called with the rtc device
as argument and not the underlying device. Fixed by using the dev->parent

Fixes: cfb74916e2ec ("rtc: ds1685: use rtc_add_group")
Signed-off-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: lpc32xx: convert to SPDX identifier
Alexandre Belloni [Tue, 9 Apr 2019 10:16:31 +0000 (12:16 +0200)]
rtc: lpc32xx: convert to SPDX identifier

Use SPDX-License-Identifier instead of a verbose license text.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: lpc32xx: use .set_time
Alexandre Belloni [Tue, 9 Apr 2019 10:16:30 +0000 (12:16 +0200)]
rtc: lpc32xx: use .set_time

Use .set_time instead of the deprecated .set_mmss.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: lpc32xx: switch to rtc_time64_to_tm/rtc_tm_to_time64
Alexandre Belloni [Tue, 9 Apr 2019 10:16:29 +0000 (12:16 +0200)]
rtc: lpc32xx: switch to rtc_time64_to_tm/rtc_tm_to_time64

Call the 64bit versions of rtc_tm time conversion now that the range is
enforced by the core.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: lpc32xx: simplify IRQ setup
Alexandre Belloni [Tue, 9 Apr 2019 10:16:28 +0000 (12:16 +0200)]
rtc: lpc32xx: simplify IRQ setup

Move the optional IRQ setup to a single location.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: lpc32xx: set range
Alexandre Belloni [Tue, 9 Apr 2019 10:16:27 +0000 (12:16 +0200)]
rtc: lpc32xx: set range

The LPC32xx RTC is a 32bit second counter.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: lpc32xx: convert to devm_rtc_allocate_device
Alexandre Belloni [Tue, 9 Apr 2019 10:16:26 +0000 (12:16 +0200)]
rtc: lpc32xx: convert to devm_rtc_allocate_device

This allows further improvement of the driver.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: mxc_v2: use dev_pm_set_wake_irq() to simplify code
Anson Huang [Thu, 11 Apr 2019 02:19:48 +0000 (02:19 +0000)]
rtc: mxc_v2: use dev_pm_set_wake_irq() to simplify code

With calling dev_pm_set_wake_irq() to set MXC_V2 RTC as wakeup source
for suspend, generic wake irq mechanism will automatically enable
it as wakeup source when suspend, then the suspend/resume callback
which are ONLY for enabling/disabling irq wake can be removed, it
simplifies the code.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: mxc: use dev_pm_set_wake_irq() to simplify code
Anson Huang [Thu, 11 Apr 2019 02:06:04 +0000 (02:06 +0000)]
rtc: mxc: use dev_pm_set_wake_irq() to simplify code

With calling dev_pm_set_wake_irq() to set MXC RTC as wakeup source
for suspend, generic wake irq mechanism will automatically enable
it as wakeup source when suspend, then the suspend/resume callback
which are ONLY for enabling/disabling irq wake can be removed, it
simplifies the code.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: rx8025: Fix a parameter to %ptR in rx8025_read_alarm()
Andy Shevchenko [Wed, 10 Apr 2019 14:05:59 +0000 (17:05 +0300)]
rtc: rx8025: Fix a parameter to %ptR in rx8025_read_alarm()

The commit 1921cab11723 ("rtc: rx8025: Switch to use %ptR") converted
the driver to use new %p extension, but actually used wrong type of
the parameter in one case.

Fix a parameter to %ptR in rx8025_read_alarm().

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: sirfsoc: Make sysrtc_regmap_config static
YueHaibing [Wed, 10 Apr 2019 13:43:36 +0000 (21:43 +0800)]
rtc: sirfsoc: Make sysrtc_regmap_config static

Fix sparse warning:

drivers/rtc/rtc-sirfsoc.c:282:28: warning:
 symbol 'sysrtc_regmap_config' was not declared. Should it be static?

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: ab3100: convert to SPDX identifier
Alexandre Belloni [Tue, 9 Apr 2019 19:59:45 +0000 (21:59 +0200)]
rtc: ab3100: convert to SPDX identifier

Use SPDX-License-Identifier instead of the custom license line.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: ab3100: use .set_time
Alexandre Belloni [Tue, 9 Apr 2019 19:59:44 +0000 (21:59 +0200)]
rtc: ab3100: use .set_time

Use .set_time instead of the deprecated .set_mmss64.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: ab3100: set range
Alexandre Belloni [Tue, 9 Apr 2019 19:59:43 +0000 (21:59 +0200)]
rtc: ab3100: set range

The ab3100 has a 48bit counter running at 65536 Hz (despite one of the
comment). The max value is then (2^48 - 1)/2^16 == 2^32 - 1.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: pcf85363: convert to SPDX identifier
Alexandre Belloni [Wed, 10 Apr 2019 20:56:04 +0000 (22:56 +0200)]
rtc: pcf85363: convert to SPDX identifier

Use SPDX-License-Identifier instead of a verbose license text.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: pcf85363: remove useless forward declaration
Alexandre Belloni [Wed, 10 Apr 2019 20:56:03 +0000 (22:56 +0200)]
rtc: pcf85363: remove useless forward declaration

It is not necessary to forward declare pcf85363_driver as it is not used
before being declared.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: pcf85363: remove bogus i2c functionality check
Alexandre Belloni [Wed, 10 Apr 2019 20:56:02 +0000 (22:56 +0200)]
rtc: pcf85363: remove bogus i2c functionality check

regmap is abstracting the i2c functionalities the best it can, there is no
need to check.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: pcf85363: set range
Alexandre Belloni [Wed, 10 Apr 2019 20:56:01 +0000 (22:56 +0200)]
rtc: pcf85363: set range

This is a standard BCD RTC that will fail in 2100.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: pcf85363: remove unused struct pcf85363 member
Alexandre Belloni [Wed, 10 Apr 2019 20:56:00 +0000 (22:56 +0200)]
rtc: pcf85363: remove unused struct pcf85363 member

pcf85363->dev is unused, remove it.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: stmp3xxx: convert to SPDX identifier
Alexandre Belloni [Sun, 7 Apr 2019 21:12:23 +0000 (23:12 +0200)]
rtc: stmp3xxx: convert to SPDX identifier

Use SPDX-License-Identifier instead of a verbose license text.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: stmp3xxx: use .set_time
Alexandre Belloni [Sun, 7 Apr 2019 21:12:22 +0000 (23:12 +0200)]
rtc: stmp3xxx: use .set_time

Use .set_time instead of the deprecated .set_mmss.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: stmp3xxx: switch to rtc_time64_to_tm/rtc_tm_to_time64
Alexandre Belloni [Sun, 7 Apr 2019 21:12:21 +0000 (23:12 +0200)]
rtc: stmp3xxx: switch to rtc_time64_to_tm/rtc_tm_to_time64

Call the 64bit versions of rtc_tm time conversion now that the range is
enforced by the core.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: stmp3xxx: set range
Alexandre Belloni [Sun, 7 Apr 2019 21:12:20 +0000 (23:12 +0200)]
rtc: stmp3xxx: set range

From the datasheet: "HW_RTC_SECONDS provides access to the 32-bit real-time
seconds counter."

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: tegra: convert to SPDX identifier
Alexandre Belloni [Sun, 7 Apr 2019 21:16:46 +0000 (23:16 +0200)]
rtc: tegra: convert to SPDX identifier

Use SPDX-License-Identifier instead of a verbose license text.

Acked-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: tegra: switch to rtc_time64_to_tm/rtc_tm_to_time64
Alexandre Belloni [Sun, 7 Apr 2019 21:16:45 +0000 (23:16 +0200)]
rtc: tegra: switch to rtc_time64_to_tm/rtc_tm_to_time64

Call the 64bit versions of rtc_tm time conversion now that the range is
enforced by the core.

Acked-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: tegra: set range
Alexandre Belloni [Sun, 7 Apr 2019 21:16:44 +0000 (23:16 +0200)]
rtc: tegra: set range

The Tegra 20 RTC is a 32bit seconds counter (with an unused millisecond
counter).

Acked-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: coh901331: convert to SPDX identifier
Alexandre Belloni [Sun, 7 Apr 2019 21:10:27 +0000 (23:10 +0200)]
rtc: coh901331: convert to SPDX identifier

Use SPDX-License-Identifier instead of the custom license line.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: coh901331: use .set_time
Alexandre Belloni [Sun, 7 Apr 2019 21:10:26 +0000 (23:10 +0200)]
rtc: coh901331: use .set_time

Use .set_time instead of the deprecated .set_mmss.

Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: coh901331: switch to rtc_time64_to_tm/rtc_tm_to_time64
Alexandre Belloni [Sun, 7 Apr 2019 21:10:25 +0000 (23:10 +0200)]
rtc: coh901331: switch to rtc_time64_to_tm/rtc_tm_to_time64

Call the 64bit versions of rtc_tm time conversion now that the range is
enforced by the core.

Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: coh901331: set range
Alexandre Belloni [Sun, 7 Apr 2019 21:10:24 +0000 (23:10 +0200)]
rtc: coh901331: set range

The COH 901 331 is a 32bit seconds counter.

Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: ds1672: switch debug message to %ptR
Alexandre Belloni [Sun, 7 Apr 2019 21:05:41 +0000 (23:05 +0200)]
rtc: ds1672: switch debug message to %ptR

Use %ptR to simplify debug message.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: ds1672: convert to SPDX identifier
Alexandre Belloni [Sun, 7 Apr 2019 21:05:40 +0000 (23:05 +0200)]
rtc: ds1672: convert to SPDX identifier

Use SPDX-License-Identifier instead of a verbose license text.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: ds1672: use .set_time
Alexandre Belloni [Sun, 7 Apr 2019 21:05:39 +0000 (23:05 +0200)]
rtc: ds1672: use .set_time

Use .set_time instead of the deprecated .set_mmss.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: ds1672: use rtc_time64_to_tm
Alexandre Belloni [Sun, 7 Apr 2019 21:05:38 +0000 (23:05 +0200)]
rtc: ds1672: use rtc_time64_to_tm

Use the 64bit version of rtc_time_to_tm.rtc_time_to_tm.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: ds1672: remove useless indirection
Alexandre Belloni [Sun, 7 Apr 2019 21:05:37 +0000 (23:05 +0200)]
rtc: ds1672: remove useless indirection

ds1672_get_datetime and ds1672_set_mmss are only used after casting dev
to an i2c_client. Remove that useless indirection.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: ds1672: remove sysfs debug interface
Alexandre Belloni [Sun, 7 Apr 2019 21:05:36 +0000 (23:05 +0200)]
rtc: ds1672: remove sysfs debug interface

Remove the control sysfs file as it is not documented, read only and was
only used to provide the oscillator state.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: ds1672: move oscillator handling to .read_time
Alexandre Belloni [Sun, 7 Apr 2019 21:05:35 +0000 (23:05 +0200)]
rtc: ds1672: move oscillator handling to .read_time

Return -EINVAL when trying to read an invalid time instead of just probe
because this is a useful information for userspace.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: ds1672: set range
Alexandre Belloni [Sun, 7 Apr 2019 21:05:34 +0000 (23:05 +0200)]
rtc: ds1672: set range

The ds1672 is a 32bit seconds counter.

Also remove erroneous comment claiming that epoch is set to 2000, it was
not.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: test: use .set_time
Alexandre Belloni [Sun, 7 Apr 2019 21:30:12 +0000 (23:30 +0200)]
rtc: test: use .set_time

Use .set_time instead of the deprecated .set_mmss64.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: lib: check whether tm->tm_year in int32 range
Xuefeng Wang [Fri, 15 Feb 2019 03:13:59 +0000 (11:13 +0800)]
rtc: lib: check whether tm->tm_year in int32 range

When setting rtc alarm (RTC_WKALM_SET), the tm_year is not checked if it
is in suiteable range. Use INT_MAX - 1900 to check it.

UBSAN: Undefined behaviour in drivers/rtc/rtc-lib.c:119:30
signed integer overflow:
2147483647 + 1900 cannot be represented in type 'int'
CPU: 1 PID: 20994 Comm: syz-executor0 Not tainted 4.19.18-514.55.6.9.x86_64
+ #1
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1
04/01/2014
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0xca/0x13e lib/dump_stack.c:113
 ubsan_epilogue+0xe/0x81 lib/ubsan.c:159
 handle_overflow+0x193/0x1e2 lib/ubsan.c:190
 rtc_tm_to_time64+0x267/0x280 drivers/rtc/rtc-lib.c:119
 rtc_tm_to_ktime+0x16/0x70 drivers/rtc/rtc-lib.c:129
 rtc_set_alarm+0x1a9/0x2d0 drivers/rtc/interface.c:466
 rtc_dev_ioctl+0x6db/0x810 drivers/rtc/rtc-dev.c:380
 vfs_ioctl fs/ioctl.c:46 [inline]
 do_vfs_ioctl+0x1a5/0x10b0 fs/ioctl.c:690
 ksys_ioctl+0x89/0xa0 fs/ioctl.c:705
 __do_sys_ioctl fs/ioctl.c:712 [inline]
 __se_sys_ioctl fs/ioctl.c:710 [inline]
 __x64_sys_ioctl+0x74/0xb0 fs/ioctl.c:710
 do_syscall_64+0xc8/0x580 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x462589
Code: f7 d8 64 89 02 b8 ff ff ff ff c3 66 0f 1f 44 00 00 48 89
f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08
0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 bc ff ff ff f7 d8
64 89 01 48
RSP: 002b:00007f5348896c58 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 000000000072bf00 RCX: 0000000000462589
RDX: 0000000020000000 RSI: 000000004028700f RDI: 0000000000000003
RBP: 0000000000000003 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f53488976bc
R13: 00000000004bf67e R14: 00000000006f96e0 R15: 00000000ffffffff

==========================================================================

Signed-off-by: Xuefeng Wang <wxf.wang@hisilicon.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: don't reference bogus function pointer in kdoc
Wolfram Sang [Wed, 3 Apr 2019 15:19:52 +0000 (17:19 +0200)]
rtc: don't reference bogus function pointer in kdoc

The mentioned function pointer is long gone since early 2011. Remove the
reference in the comment and reword it slightly.

Fixes: 51ba60c5bb3b ("RTC: Cleanup rtc_class_ops->update_irq_enable()")
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: remove unnecessary Kconfig dependencies
Alexandre Belloni [Tue, 2 Apr 2019 21:54:47 +0000 (23:54 +0200)]
rtc: remove unnecessary Kconfig dependencies

Remove the unused "depends on I2C" as the config options are already
guarded by if I2C.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: pcf85063: add RTC_VL_READ/RTC_VL_CLR support
Alexandre Belloni [Mon, 1 Apr 2019 16:08:16 +0000 (18:08 +0200)]
rtc: pcf85063: add RTC_VL_READ/RTC_VL_CLR support

Allow reading the oscillator status bit. Also allow clearing it even if
that makes little sense and can't be done in a race free way.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: pcf85063: add offset correction support
Alexandre Belloni [Mon, 1 Apr 2019 16:08:15 +0000 (18:08 +0200)]
rtc: pcf85063: add offset correction support

The PCF850363 has an offset correction with two modes:

With mode 0, the correction is triggered once every two hours and then
correction pulses are applied once per minute until the programmed
correction values have been implemented. This gives a step of 4.34 ppm.

With mode 1, the correction is triggered once every four minutes and then
correction pulses are applied once per second up to a maximum of 60 pulses.
When correction values greater than 60 pulses are used, additional
correction pulses are made in the 59 th second. This gives a step of 4.069
ppm.

Use the correction closest to the requested value.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: pcf85063: add nvram support
Alexandre Belloni [Mon, 1 Apr 2019 16:08:14 +0000 (18:08 +0200)]
rtc: pcf85063: add nvram support

The pcf85063 has one byte of nvram.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: pcf85063: add Micro Crystal RV8263 support
Alexandre Belloni [Mon, 1 Apr 2019 16:08:13 +0000 (18:08 +0200)]
rtc: pcf85063: add Micro Crystal RV8263 support

The Micro Crystal RV8263 has the same IC as the pcf85063 but has an on
board crystal. This means that the CAP_SEL bit has to be cleared so the
correct capacitance is selected for the crystal.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: pcf85063: add alarm support
Alexandre Belloni [Mon, 1 Apr 2019 16:08:12 +0000 (18:08 +0200)]
rtc: pcf85063: add alarm support

Add support for the alarms. The match on the weekday is not used as it it
not necessarily properly set.

The tested RTC shows a behaviour where setting an alarm on the second right
after an alarm that fired is not working, probably because of the circuit
that ensures an alarm only fires once. This is why uie_unsupported is set.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: pcf85063: differentiate pcf85063a and pcf85063tp
Alexandre Belloni [Mon, 1 Apr 2019 16:08:11 +0000 (18:08 +0200)]
rtc: pcf85063: differentiate pcf85063a and pcf85063tp

As stated in a comment pcf85063a and pcf85063tp don't have the same number
of registers. Especially, pcf85063tp doesn't have alarm support.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: pcf85063: switch to regmap
Alexandre Belloni [Mon, 1 Apr 2019 16:08:10 +0000 (18:08 +0200)]
rtc: pcf85063: switch to regmap

Switch to regmap to simplify register accesses and remove the need for
pcf85063_stop_clock/pcf85063_start_clock.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: pcf85063: set range
Alexandre Belloni [Mon, 1 Apr 2019 16:08:09 +0000 (18:08 +0200)]
rtc: pcf85063: set range

This is a standard BCD RTC that will fail in 2100.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: pcf85063: convert to devm_rtc_allocate_device
Alexandre Belloni [Mon, 1 Apr 2019 16:08:08 +0000 (18:08 +0200)]
rtc: pcf85063: convert to devm_rtc_allocate_device

This allows further improvement of the driver.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: pcf85063: remove bogus i2c functionality check
Alexandre Belloni [Mon, 1 Apr 2019 16:08:07 +0000 (18:08 +0200)]
rtc: pcf85063: remove bogus i2c functionality check

Only smbus reads and write are done in the driver, plain i2c functionality
is not required.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
5 years agortc: pcf85063: convert to SPDX identifier
Alexandre Belloni [Mon, 1 Apr 2019 16:33:49 +0000 (18:33 +0200)]
rtc: pcf85063: convert to SPDX identifier

Use SPDX-License-Identifier instead of a verbose license text.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>