Commit Graph

3244 Commits

Author SHA1 Message Date
Anson Huang
dacb6a4035 rtc: snvs: Use __maybe_unused instead of #if CONFIG_PM_SLEEP
Use __maybe_unused for power management related functions
instead of #if CONFIG_PM_SLEEP to simply the code.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Reviewed-by: Dong Aisheng <aisheng.dong@nxp.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-05-08 22:14:36 +02:00
Anders Roxell
557fbf4f38 rtc: imxdi: remove unused variable
This variable is no longer used and the compiler rightly complains that
it should be removed.

../drivers/rtc/rtc-imxdi.c: In function ‘dryice_rtc_set_alarm’:
../drivers/rtc/rtc-imxdi.c:633:16: warning: unused variable ‘now’ [-Wunused-variable]
  unsigned long now;
                ^~~

Rework to remove the unused variable.

Fixes: 629d488a3e ("rtc: imxdi: remove unnecessary check")
Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-05-08 22:14:36 +02:00
Alexandre Belloni
a01ab0669d rtc: drop set_mms and set_mmss64
There are no users of set_mms and set_mmss64 as they have all been
converted to set_time and are handling the tm to time conversion on their
own.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-05-08 22:14:36 +02:00
Alexandre Belloni
f5fae39566 rtc: pcap: convert to SPDX identifier
Use SPDX-License-Identifier instead of a verbose license text.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-05-08 22:14:36 +02:00
Alexandre Belloni
c8b599ed37 rtc: pcap: use .set_time
Use .set_time instead of the deprecated .set_mmss.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-05-08 22:14:36 +02:00
Alexandre Belloni
03745d1ff4 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>
2019-05-08 22:14:36 +02:00
Alexandre Belloni
d1403c4822 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>
2019-05-08 22:14:36 +02:00
Alexandre Belloni
77c13d992b 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>
2019-05-08 22:14:31 +02:00
Alexandre Belloni
72ef256e3a 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>
2019-05-08 22:14:25 +02:00
Alexandre Belloni
e5fe3c3e4c 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>
2019-05-08 22:14:23 +02:00
Alexandre Belloni
060711f527 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>
2019-05-08 22:13:37 +02:00
Alexandre Belloni
86836d641d 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>
2019-04-30 11:50:24 +02:00
Alexandre Belloni
7fe8fcee0c 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>
2019-04-30 11:50:22 +02:00
Alexandre Belloni
3b2dc19ff9 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>
2019-04-30 11:50:20 +02:00
Alexandre Belloni
e72746e791 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>
2019-04-30 11:50:18 +02:00
Alexandre Belloni
d10dcc95fa 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>
2019-04-30 11:50:17 +02:00
Alexandre Belloni
be8dce96f3 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>
2019-04-30 11:50:13 +02:00
Alexandre Belloni
a7ab6bed28 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>
2019-04-30 11:50:11 +02:00
Sven Van Asbroeck
f22b1ba15e 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>
2019-04-29 15:53:43 +02:00
Kefeng Wang
527bd754d1 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>
2019-04-29 15:53:43 +02:00
Alexandre Belloni
c8889bb6e6 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>
2019-04-29 15:53:43 +02:00
Alexandre Belloni
629d488a3e 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>
2019-04-29 15:53:43 +02:00
Alexandre Belloni
d231d32caa rtc: imxdi: use .set_time
Use .set_time instead of the deprecated .set_mmss.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-04-29 15:53:43 +02:00
Alexandre Belloni
93059793ad 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>
2019-04-29 15:53:43 +02:00
Alexandre Belloni
21c9dfda4b 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>
2019-04-29 15:53:43 +02:00
Alexandre Belloni
02bc723579 rtc: mxc: use .set_time
Use .set_time instead of the deprecated .set_mmss64.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-04-29 15:53:43 +02:00
Alexandre Belloni
83888df4b8 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>
2019-04-29 15:53:42 +02:00
Alexandre Belloni
ebc2ec4ecf 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>
2019-04-29 15:53:42 +02:00
Fabien Dessenne
cf612c5949 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>
2019-04-29 15:53:42 +02:00
Daniel Gomez
f9bf089a70 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>
2019-04-29 15:53:42 +02:00
Alexandre Belloni
498ce4e76b 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>
2019-04-29 15:53:01 +02:00
Alexandre Belloni
d9aa5ca429 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>
2019-04-19 22:37:17 +02:00
Alexandre Belloni
c7ac260fe7 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>
2019-04-19 22:37:17 +02:00
Alexandre Belloni
14556f04e5 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>
2019-04-19 22:37:17 +02:00
Alexandre Belloni
be2b04371a rtc: ds2404: use .set_time
Use .set_time instead of the deprecated .set_mmss.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-04-19 22:37:17 +02:00
Alexandre Belloni
53523216ba 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>
2019-04-19 22:37:16 +02:00
Alexandre Belloni
13bfa94225 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>
2019-04-19 22:37:16 +02:00
Alexandre Belloni
d71c771532 rtc: ep93xx: fix checkpatch issues
Fix sysfs attribute declaration as suggested by checkpatch.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-04-19 22:37:16 +02:00
Alexandre Belloni
4fdf4d237f 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>
2019-04-19 22:37:16 +02:00
Alexandre Belloni
ef9440a2e3 rtc: ep93xx: use .set_time
Use .set_time instead of the deprecated .set_mmss.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-04-19 22:37:16 +02:00
Alexandre Belloni
886a77e73e 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>
2019-04-19 22:37:16 +02:00
Alexandre Belloni
2d4fc6df77 rtc: ep93xx: set range
The ep93xx RTC is a 32-bit seconds counter.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-04-19 22:37:16 +02:00
Alexandre Belloni
09cd030b54 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>
2019-04-19 22:37:16 +02:00
Alexandre Belloni
bac68b30d5 rtc: ep93xx: convert to devm_rtc_allocate_device
This allows further improvement of the driver.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-04-19 22:37:16 +02:00
Alexandre Belloni
b809d192eb rtc: ep93xx: stop setting platform_data
Since commit 28dc5f8038 ("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>
2019-04-19 22:37:16 +02:00
Han Nandor
9eec31f310 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>
2019-04-19 22:36:55 +02:00
Alexandre Belloni
9fc0fd5077 rtc: mc13xxx: fix style issue
Use unsigned int instead of unsigned.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-04-16 18:06:54 +02:00
Alexandre Belloni
edd6d79ece 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>
2019-04-16 18:06:53 +02:00
Alexandre Belloni
eee86deafe rtc: mc13xxx: use .set_time
Use .set_time instead of the deprecated .set_mmss64.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-04-16 18:06:51 +02:00
Alexandre Belloni
e4ae7023e1 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>
2019-04-16 18:06:49 +02:00