platform/kernel/linux-starfive.git
6 years agortc: isl1208: switch to rtc_register_device
Denis Osterland [Mon, 5 Mar 2018 10:43:53 +0000 (10:43 +0000)]
rtc: isl1208: switch to rtc_register_device

Fix possible race condition.
It is not allowed to return with an error code after RTC is registered.

Suggested-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Denis Osterland <Denis.Osterland@diehl.com>
Reviewed-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: isl1208: enable interrupt after context preparation
Michael Grzeschik [Mon, 5 Mar 2018 10:43:53 +0000 (10:43 +0000)]
rtc: isl1208: enable interrupt after context preparation

The interrupt handler got enabled very early. If the interrupt cause is
triggering immediately before the context is fully prepared. This can
lead to undefined behaviour. Therefor we move the interrupt enable code
to the end of the probe function.

Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Signed-off-by: Denis Osterland <Denis.Osterland@diehl.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: cros-ec: return -ETIME when refused to set alarms in the past
Jeffy Chen [Tue, 27 Feb 2018 02:50:03 +0000 (10:50 +0800)]
rtc: cros-ec: return -ETIME when refused to set alarms in the past

Since accessing a Chrome OS EC based rtc is a slow operation, there is a
race window where if the alarm is set for the next second and the second
ticks over right before calculating the alarm offset.

In this case the current driver is setting a 0-second alarm, which would
be considered as disabling alarms by the EC(EC_RTC_ALARM_CLEAR).

This breaks, e.g., hwclock which relies on RTC_UIE_ON ->
rtc_update_irq_enable(), which sets a 1-second alarm and expects it to
fire an interrupt.

So return -ETIME when the alarm is in the past, follow __rtc_set_alarm().

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
Reviewed-by: Brian Norris <briannorris@chromium.org>
Tested-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: pm8xxx: Fix issue in RTC write path
Mohit Aggarwal [Mon, 5 Mar 2018 09:05:58 +0000 (14:35 +0530)]
rtc: pm8xxx: Fix issue in RTC write path

In order to set time in rtc, need to disable
rtc hw before writing into rtc registers.

Also fixes disabling of alarm while setting
rtc time.

Signed-off-by: Mohit Aggarwal <maggarwa@codeaurora.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: at91sam: add 'depends on HAS_IOMEM' to fix unmet dependency
Masahiro Yamada [Tue, 6 Mar 2018 11:08:11 +0000 (20:08 +0900)]
rtc: at91sam: add 'depends on HAS_IOMEM' to fix unmet dependency

This config select's MFD_SYSCON, but does not depend on HAS_IOMEM.

Compile testing on architecture without HAS_IOMEM causes "unmet
direct dependencies" in Kconfig phase.

Detected by "make ARCH=score allyesconfig".

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: isl12026: fixup nvmem registration
Alexandre Belloni [Fri, 2 Mar 2018 23:50:29 +0000 (00:50 +0100)]
rtc: isl12026: fixup nvmem registration

The probe function must not fail after rtc_register_device. Also, rename
the nvmem device so it is easily identifiable in /sys/bus/nvmem.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: isl12026: new driver.
David Daney [Thu, 22 Feb 2018 20:04:32 +0000 (12:04 -0800)]
rtc: isl12026: new driver.

The ISL12026 is a combination RTC and EEPROM device with I2C
interface.  The standard RTC driver interface is provided.  The EEPROM
is accessed via the NVMEM interface.

Reviewed-by: Rob Herring <robh@kernel.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: David Daney <david.daney@cavium.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: brcmstb-waketimer: Set wktmr prescaler
Justin Chen [Mon, 26 Feb 2018 20:09:58 +0000 (12:09 -0800)]
rtc: brcmstb-waketimer: Set wktmr prescaler

The HW default is one tick per second, however instead of assuming this,
lets make sure the waketimer is actually one tick per second before
arming the alarm.

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Justin Chen <justinpopo6@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: fix rtc_time64_to_tm for 3477
Alexandre Belloni [Wed, 28 Feb 2018 21:50:53 +0000 (22:50 +0100)]
rtc: fix rtc_time64_to_tm for 3477

The current correction for leap years will fail in 3477. 3476-12-31 being
3477-01-00 because this is 366 leap years after 1970 and 3477 isn't a leap
year.

Fix that by looping over until days is positive or zero.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: ac100: Fix ac100 determine rate bug
Philipp Rossak [Mon, 26 Feb 2018 21:19:01 +0000 (22:19 +0100)]
rtc: ac100: Fix ac100 determine rate bug

This patch fixes a bug, that prevents the Allwinner A83T and the A80
from a successful boot.

The bug is there since v4.16-rc1 and appeared after the clk branch was
merged.

You can find the shortend trace below:

Unable to handle kernel NULL pointer dereference at virtual address
00000000
pgd = (ptrval)
[00000000] *pgd=00000000
Internal error: Oops: 5 [#1] SMP ARM
Modules linked in:
CPU: 0 PID: 49 Comm: kworker/0:1 Not tainted 4.15.0-10190-gb89e32ccd1be #2
Hardware name: Allwinner sun8i Family
Workqueue: events deferred_probe_work_func
PC is at clk_hw_get_rate+0x0/0x34
LR is at ac100_clkout_determine_rate+0x48/0x19c

[ ... ]

(clk_hw_get_rate) from (ac100_clkout_determine_rate+0x48/0x19c)
(ac100_clkout_determine_rate) from  (clk_core_set_rate_nolock+0x3c/0x1a0)
(clk_core_set_rate_nolock) from (clk_set_rate+0x30/0x88)
(clk_set_rate) from (of_clk_set_defaults+0x200/0x364)
(of_clk_set_defaults) from (platform_drv_probe+0x18/0xb0)

To fix that bug, we first check if the return of the
clk_hw_get_parent_by_index is non zero. If it is zero we skip that
clock parent.

The BUG report could be found here: https://lkml.org/lkml/2018/2/10/198

Fixes: 04940631b8d2 ("rtc: ac100: Add clk output support")

Signed-off-by: Philipp Rossak <embed3d@gmail.com>
Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: pcf85363: set time accurately
Alexandre Belloni [Sat, 24 Feb 2018 00:08:53 +0000 (01:08 +0100)]
rtc: pcf85363: set time accurately

As per 8.2.6 Setting and reading the time in RTC mode, first stop the clok,
then reset it before setting the date and time registers. Finally, start
the clock.

This uses register address wrap around from 0x2f to 0x00 for efficiency.

This allows to set the clock with a millisecond accuracy (drift is not
corrected in this example):

RTC        System
1325388767 1325388767.000029180
1325388768 1325388768.000018362
1325388769 1325388769.000006544
1325388770 1325388769.999992725
1325388771 1325388770.999974544

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: pcf85363: add alarm support
Alexandre Belloni [Thu, 1 Mar 2018 00:42:19 +0000 (01:42 +0100)]
rtc: pcf85363: add alarm support

Handle alarms, currently only on INTA

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: pcf85363: add .max_register in regmap_config
Alexandre Belloni [Sat, 24 Feb 2018 00:08:50 +0000 (01:08 +0100)]
rtc: pcf85363: add .max_register in regmap_config

This helps debugging as it allows reading registers from debugfs.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: m41t80: remove useless indirection
Alexandre Belloni [Sun, 25 Feb 2018 22:15:00 +0000 (23:15 +0100)]
rtc: m41t80: remove useless indirection

m41t80_get_datetime and m41t80_set_datetime are only used after casting dev
to an i2c_client. Remove that useless indirection.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: m41t80: fix race conditions
Alexandre Belloni [Sun, 25 Feb 2018 20:14:31 +0000 (21:14 +0100)]
rtc: m41t80: fix race conditions

The IRQ is requested before the struct rtc is allocated and registered, but
this struct is used in the IRQ handler, leading to:

Unable to handle kernel NULL pointer dereference at virtual address 0000017c
pgd = a38a2f9b
[0000017c] *pgd=00000000
Internal error: Oops: 5 [#1] ARM
Modules linked in:
CPU: 0 PID: 613 Comm: irq/48-m41t80 Not tainted 4.16.0-rc1+ #42
Hardware name: Atmel SAMA5
PC is at mutex_lock+0x14/0x38
LR is at m41t80_handle_irq+0x1c/0x9c
pc : [<c06e864c>]    lr : [<c04b70f0>]    psr: 20000013
sp : dec73f30  ip : 00000000  fp : dec56d98
r10: df437cf0  r9 : c0a03008  r8 : c0145ffc
r7 : df5c4300  r6 : dec568d0  r5 : df593000  r4 : 0000017c
r3 : df592800  r2 : 60000013  r1 : df593000  r0 : 0000017c
Flags: nzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
Control: 10c53c7d  Table: 20004059  DAC: 00000051
Process irq/48-m41t80 (pid: 613, stack limit = 0xb52d091e)
Stack: (0xdec73f30 to 0xdec74000)
3f20:                                     dec56840 df5c4300 00000001 df5c4300
3f40: c0145ffc c0146018 dec56840 ffffe000 00000001 c0146290 dec567c0 00000000
3f60: c0146084 ed7c9a62 c014615c dec56d80 dec567c0 00000000 dec72000 dec56840
3f80: c014615c c012ffc0 dec72000 dec567c0 c012fe80 00000000 00000000 00000000
3fa0: 00000000 00000000 00000000 c01010e8 00000000 00000000 00000000 00000000
3fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
3fe0: 00000000 00000000 00000000 00000000 00000013 00000000 29282726 2d2c2b2a
[<c06e864c>] (mutex_lock) from [<c04b70f0>] (m41t80_handle_irq+0x1c/0x9c)
[<c04b70f0>] (m41t80_handle_irq) from [<c0146018>] (irq_thread_fn+0x1c/0x54)
[<c0146018>] (irq_thread_fn) from [<c0146290>] (irq_thread+0x134/0x1c0)
[<c0146290>] (irq_thread) from [<c012ffc0>] (kthread+0x140/0x148)
[<c012ffc0>] (kthread) from [<c01010e8>] (ret_from_fork+0x14/0x2c)
Exception stack(0xdec73fb0 to 0xdec73ff8)
3fa0:                                     00000000 00000000 00000000 00000000
3fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
3fe0: 00000000 00000000 00000000 00000000 00000013 00000000
Code: e3c33d7f e3c3303f f5d0f000 e593300c (e1901f9f)
---[ end trace 22b027302eb7c604 ]---
genirq: exiting task "irq/48-m41t80" (613) is an active IRQ thread (irq 48)

Also, there is another possible race condition. The probe function is not
allowed to fail after the RTC is registered because the following may
happen:

CPU0:                                CPU1:
sys_load_module()
 do_init_module()
  do_one_initcall()
   cmos_do_probe()
    rtc_device_register()
     __register_chrdev()
     cdev->owner = struct module*
                                     open("/dev/rtc0")
    rtc_device_unregister()
  module_put()
  free_module()
   module_free(mod->module_core)
   /* struct module *module is now
      freed */
                                      chrdev_open()
                                       spin_lock(cdev_lock)
                                       cdev_get()
                                        try_module_get()
                                         module_is_live()
                                         /* dereferences already
                                            freed struct module* */

Switch to devm_rtc_allocate_device/rtc_register_device to allocate the rtc
before requesting the IRQ and register it as late as possible.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: m41t80: move m41t80_rtc_mutex to the block where it is used
Sebastian Andrzej Siewior [Fri, 9 Feb 2018 18:05:34 +0000 (19:05 +0100)]
rtc: m41t80: move m41t80_rtc_mutex to the block where it is used

Without CONFIG_RTC_DRV_M41T80_WDT the compiler complains:

|drivers/rtc/rtc-m41t80.c:76 ‘m41t80_rtc_mutex’ defined but not used [-Wunused-variable]

Move the variable to the block where it is used.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: pcf85063: remove useless indirection
Alexandre Belloni [Wed, 21 Feb 2018 15:09:27 +0000 (16:09 +0100)]
rtc: pcf85063: remove useless indirection

pcf85063_get_datetime and pcf85063_set_datetime are only used after casting
dev to an i2c_client. Remove that useless indirection.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: pcf85063: stop validating rtc_time in .read_time
Alexandre Belloni [Wed, 21 Feb 2018 15:07:34 +0000 (16:07 +0100)]
rtc: pcf85063: stop validating rtc_time in .read_time

The RTC core is always calling rtc_valid_tm after the read_time callback.
It is not necessary to call it before returning from the callback.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: max6900: remove useless indirection
Alexandre Belloni [Wed, 21 Feb 2018 15:04:27 +0000 (16:04 +0100)]
rtc: max6900: remove useless indirection

max6900_i2c_read_time and max6900_i2c_set_time are only used after casting
dev to an i2c_client. Remove that useless indirection.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: max6900: stop validating rtc_time in .read_time
Alexandre Belloni [Wed, 21 Feb 2018 15:01:52 +0000 (16:01 +0100)]
rtc: max6900: stop validating rtc_time in .read_time

The RTC core is always calling rtc_valid_tm after the read_time callback.
It is not necessary to call it before returning from the callback.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: rs5c372: remove useless indirection
Alexandre Belloni [Wed, 21 Feb 2018 14:47:14 +0000 (15:47 +0100)]
rtc: rs5c372: remove useless indirection

rs5c372_get_datetime and rs5c372_set_datetime are only used after casting
dev to an i2c_client. Remove that useless indirection.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: rs5c372: stop validating rtc_time in .read_time
Alexandre Belloni [Wed, 21 Feb 2018 14:43:53 +0000 (15:43 +0100)]
rtc: rs5c372: stop validating rtc_time in .read_time

The RTC core is always calling rtc_valid_tm after the read_time callback.
It is not necessary to call it before returning from the callback.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: rs5c372: remove useless message
Alexandre Belloni [Wed, 21 Feb 2018 14:42:32 +0000 (15:42 +0100)]
rtc: rs5c372: remove useless message

It is not necessary to print a message when the time is invalid as
userspace will already get an error (and an optional dev_dbg message).

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: s35390a: remove useless indirection
Alexandre Belloni [Wed, 21 Feb 2018 13:00:18 +0000 (14:00 +0100)]
rtc: s35390a: remove useless indirection

s35390a_set_datetime, s35390a_get_datetime, s35390a_set_alarm and
s35390a_read_alarm are only used after casting dev to an i2c_client. Remove
that useless indirection.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: s35390a: stop validating rtc_time in .read_time
Alexandre Belloni [Wed, 21 Feb 2018 12:54:46 +0000 (13:54 +0100)]
rtc: s35390a: stop validating rtc_time in .read_time

The RTC core is always calling rtc_valid_tm after the read_time callback.
It is not necessary to call it before returning from the callback.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: s35390a: remove useless message
Alexandre Belloni [Wed, 21 Feb 2018 12:52:35 +0000 (13:52 +0100)]
rtc: s35390a: remove useless message

It is not necessary to print a message when the time is invalid as
userspace will already get an error (and an optional dev_dbg message).

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: rk808: fix possible race condition
Alexandre Belloni [Wed, 21 Feb 2018 10:57:05 +0000 (11:57 +0100)]
rtc: rk808: fix possible race condition

The probe function is not allowed to fail after registering the RTC because
the following may happen:

CPU0:                                CPU1:
sys_load_module()
 do_init_module()
  do_one_initcall()
   cmos_do_probe()
    rtc_device_register()
     __register_chrdev()
     cdev->owner = struct module*
                                     open("/dev/rtc0")
    rtc_device_unregister()
  module_put()
  free_module()
   module_free(mod->module_core)
   /* struct module *module is now
      freed */
                                      chrdev_open()
                                       spin_lock(cdev_lock)
                                       cdev_get()
                                        try_module_get()
                                         module_is_live()
                                         /* dereferences already
                                            freed struct module* */

Switch to devm_rtc_allocate_device/rtc_register_device to register the rtc
as late as possible.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: rk808: remove useless debug message
Alexandre Belloni [Wed, 21 Feb 2018 10:48:46 +0000 (11:48 +0100)]
rtc: rk808: remove useless debug message

At probe time, printing a message when the time is invalid doesn't have
much value. Also, as the comment suggest, this is a leftover from
development wherhe this was used to set the RTc to a default time.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: rx8581: remove useless message
Alexandre Belloni [Tue, 20 Feb 2018 23:25:18 +0000 (00:25 +0100)]
rtc: rx8581: remove useless message

It is not necessary to print a message when the time is invalid as
userspace will already get an error (and an optional dev_dbg message).

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: rx4581: remove useless message
Alexandre Belloni [Tue, 20 Feb 2018 23:23:31 +0000 (00:23 +0100)]
rtc: rx4581: remove useless message

It is not necessary to print a message when the time is invalid as
userspace will already get an error (and an optional dev_dbg message).

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: pm8xxx: remove useless message
Alexandre Belloni [Tue, 20 Feb 2018 23:10:41 +0000 (00:10 +0100)]
rtc: pm8xxx: remove useless message

It is not necessary to print a message when the time is invalid as
userspace will already get an error (and an optional dev_dbg message).

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: abx80x: remove useless message
Alexandre Belloni [Tue, 20 Feb 2018 22:42:27 +0000 (23:42 +0100)]
rtc: abx80x: remove useless message

It is not necessary to print a message when the time is invalid as
userspace will already get an error (and an optional dev_dbg message).

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: tegra: stop validating rtc_time in .set_time
Alexandre Belloni [Wed, 21 Feb 2018 10:03:49 +0000 (11:03 +0100)]
rtc: tegra: stop validating rtc_time in .set_time

The RTC core is always validating the rtc_time struct before calling
.set_time. It is not necessary to do it again in .set_time.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: spear: stop validating rtc_time in .set_time and .set_alarm
Alexandre Belloni [Wed, 21 Feb 2018 10:23:19 +0000 (11:23 +0100)]
rtc: spear: stop validating rtc_time in .set_time and .set_alarm

The RTC core is always validating the rtc_time struct before calling
.set_time or .set_alarm. It is not necessary to do it again.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: omap: stop validating rtc_time in .set_time and .set_alarm
Alexandre Belloni [Wed, 21 Feb 2018 10:33:37 +0000 (11:33 +0100)]
rtc: omap: stop validating rtc_time in .set_time and .set_alarm

The RTC core is always validating the rtc_time struct before calling
.set_time or .set_alarm. It is not necessary to do it again.
Also, rtc_time_to_tm never generates an invalid rtc_tm (it can be out of
range though).

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: max77686: stop validating rtc_time in .read_time
Alexandre Belloni [Tue, 20 Feb 2018 23:05:20 +0000 (00:05 +0100)]
rtc: max77686: stop validating rtc_time in .read_time

The RTC core is always calling rtc_valid_tm after the read_time callback.
It is not necessary to call it just before returning from the callback.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: m41t93: stop validating rtc_time in .read_time
Alexandre Belloni [Tue, 20 Feb 2018 23:02:08 +0000 (00:02 +0100)]
rtc: m41t93: stop validating rtc_time in .read_time

The RTC core is always calling rtc_valid_tm after the read_time callback.
It is not necessary to call it just before returning from the callback.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: isl12022: remove useless indirection
Alexandre Belloni [Tue, 20 Feb 2018 22:55:40 +0000 (23:55 +0100)]
rtc: isl12022: remove useless indirection

isl12022_get_datetime and isl12022_set_datetime are only used after casting
dev to an i2c_client. Remove that useless indirection.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: sc27xx: stop validating rtc_time in .read_time
Alexandre Belloni [Mon, 19 Feb 2018 15:24:19 +0000 (16:24 +0100)]
rtc: sc27xx: stop validating rtc_time in .read_time

rtc_time64_to_tm never generates an invalid tm. It is not necessary to
validate it. Also, the RTC core is always calling rtc_valid_tm after the
read_time callback.

Reviewed-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: r7301: stop validating rtc_time in .read_time
Alexandre Belloni [Tue, 20 Feb 2018 23:18:23 +0000 (00:18 +0100)]
rtc: r7301: stop validating rtc_time in .read_time

The RTC core is always calling rtc_valid_tm after the read_time callback.
It is not necessary to call it just before returning from the callback.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: nuc900: stop validating rtc_time in .read_time
Alexandre Belloni [Wed, 21 Feb 2018 10:27:10 +0000 (11:27 +0100)]
rtc: nuc900: stop validating rtc_time in .read_time

The RTC core is always calling rtc_valid_tm after the read_time callback.
It is not necessary to call it before returning from the callback.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: diasemi: stop validating rtc_time in .read_time
Alexandre Belloni [Fri, 2 Mar 2018 09:08:47 +0000 (10:08 +0100)]
rtc: diasemi: stop validating rtc_time in .read_time

The RTC core is always calling rtc_valid_tm after the read_time callback.
It is not necessary to call it before returning from the callback.

Acked-by: Steve Twiss <stwiss.opensource@diasemi.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: cpcap: stop validating rtc_time in .read_time
Alexandre Belloni [Mon, 19 Feb 2018 15:23:57 +0000 (16:23 +0100)]
rtc: cpcap: stop validating rtc_time in .read_time

The RTC core is always calling rtc_valid_tm after the read_time callback.
It is not necessary to call it just before returning from the callback.

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: ab-b5ze-s3: stop validating rtc_time in .read_time
Alexandre Belloni [Mon, 19 Feb 2018 15:23:54 +0000 (16:23 +0100)]
rtc: ab-b5ze-s3: stop validating rtc_time in .read_time

The RTC core is always calling rtc_valid_tm after the read_time callback.
It is not necessary to call it just before returning from the callback.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: stop validating rtc_time in .read_time
Alexandre Belloni [Mon, 19 Feb 2018 15:23:56 +0000 (16:23 +0100)]
rtc: stop validating rtc_time in .read_time

The RTC core is always calling rtc_valid_tm after the read_time callback.
It is not necessary to call it just before returning from the callback.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: stop validating rtc_time after rtc_time_to_tm
Alexandre Belloni [Mon, 19 Feb 2018 15:23:55 +0000 (16:23 +0100)]
rtc: stop validating rtc_time after rtc_time_to_tm

rtc_time_to_tm never generates an invalid tm. It is not necessary to
validate it.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: stop validating rtc_time after rtc_time64_to_tm
Alexandre Belloni [Mon, 19 Feb 2018 15:23:55 +0000 (16:23 +0100)]
rtc: stop validating rtc_time after rtc_time64_to_tm

rtc_time64_to_tm never generates an invalid tm. It is not necessary to
validate it.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: stk17ta8: let the core handle invalid time
Alexandre Belloni [Sun, 18 Feb 2018 22:36:18 +0000 (23:36 +0100)]
rtc: stk17ta8: let the core handle invalid time

Returning a valid time when the time is invalid is a bad practice, because
then userspace is not able to react on the information. Also, it doesn't
make sense to return epoch because it is already the default time.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: rs5c348: let the core handle invalid time
Alexandre Belloni [Tue, 20 Feb 2018 23:20:43 +0000 (00:20 +0100)]
rtc: rs5c348: let the core handle invalid time

Returning a valid time when the time is invalid is a bad practice, because
then userspace is not able to react on the information. Also, it doesn't
make sense to return epoch because it is already the default time.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: cmos: let the core handle invalid time
Alexandre Belloni [Wed, 21 Feb 2018 10:44:26 +0000 (11:44 +0100)]
rtc: cmos: let the core handle invalid time

Setting the rtc to a valid time when the time is invalid is a bad practice,
because then userspace doesn't know it shouldn't trust the RTC.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: ds1553: let the core handle invalid time
Alexandre Belloni [Tue, 20 Feb 2018 22:43:09 +0000 (23:43 +0100)]
rtc: ds1553: let the core handle invalid time

Returning a valid time when the time is invalid is a bad practice, because
then userspace is not able to react on the information. Also, it doesn't
make sense to return epoch because it is already the default time.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: ds1511: let the core handle invalid time
Alexandre Belloni [Tue, 20 Feb 2018 21:05:29 +0000 (22:05 +0100)]
rtc: ds1511: let the core handle invalid time

Returning a valid time when the time is invalid is a bad practice, because
then userspace is not able to react on the information. Also, it doesn't
make sense to return epoch because it is already the default time.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: tx4939: avoid unintended sign extension on a 24 bit shift
Colin Ian King [Thu, 15 Feb 2018 19:36:14 +0000 (19:36 +0000)]
rtc: tx4939: avoid unintended sign extension on a 24 bit shift

The shifting of buf[5] by 24 bits to the left will be promoted to
a 32 bit signed int and then sign-extended to an unsigned long. If
the top bit of buf[5] is set then all then all the upper bits sec
end up as also being set because of the sign-extension. Fix this by
casting buf[5] to an unsigned long before the shift.

Detected by CoverityScan, CID#1465292 ("Unintended sign extension")

Fixes: 0e1492330cd2 ("rtc: add rtc-tx4939 driver")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agoMAINTAINERS: rtc: update my email address
Alexandre Belloni [Fri, 16 Feb 2018 10:06:00 +0000 (11:06 +0100)]
MAINTAINERS: rtc: update my email address

Free Electrons is now Bootlin.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agochar: rtc: remove unused rtc_control() API
Alexandre Belloni [Tue, 6 Feb 2018 22:12:26 +0000 (23:12 +0100)]
char: rtc: remove unused rtc_control() API

Since commit 34ce71a96dcb ("ALSA: timer: remove legacy rtctimer"), the
rtc_register/rtc_control/rtc_unregister API is unused. As it is highly
unlikely to be needed again, remove it.

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: mxc_v2: Fix _iomem pointer notation
Fabio Estevam [Mon, 12 Feb 2018 02:38:46 +0000 (00:38 -0200)]
rtc: mxc_v2: Fix _iomem pointer notation

Fix the iomem pointer notation in order to fix the following sparse
warnings:

drivers/rtc/rtc-mxc_v2.c:280:18: warning: incorrect type in argument 1 (different address spaces)
drivers/rtc/rtc-mxc_v2.c:280:18:    expected void const volatile [noderef] <asn:2>*addr
drivers/rtc/rtc-mxc_v2.c:280:18:    got void *[noderef] <asn:2>ioaddr
drivers/rtc/rtc-mxc_v2.c:329:44: warning: incorrect type in argument 1 (different address spaces)
drivers/rtc/rtc-mxc_v2.c:329:44:    expected void *[noderef] <asn:2>ioaddr
drivers/rtc/rtc-mxc_v2.c:329:44:    got void [noderef] <asn:2>*
drivers/rtc/rtc-mxc_v2.c:339:44: warning: incorrect type in argument 1 (different address spaces)
drivers/rtc/rtc-mxc_v2.c:339:44:    expected void *[noderef] <asn:2>ioaddr
drivers/rtc/rtc-mxc_v2.c:339:44:    got void [noderef] <asn:2>*

Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: isl1208: Fix unintended clear of SR bits
Denis Osterland [Tue, 23 Jan 2018 12:17:58 +0000 (13:17 +0100)]
rtc: isl1208: Fix unintended clear of SR bits

After successful
sr = isl1208_i2c_set_regs(client, 0, regs, ISL1208_RTC_SECTION_LEN);
sr will be 0.
As a result
sr = i2c_smbus_write_byte_data(client, ISL1208_REG_SR,
sr & ~ISL1208_REG_SR_WRTC);
is equal to
sr = i2c_smbus_write_byte_data(client, ISL1208_REG_SR, 0);
which clears all flags in SR.

Add an additional read of SR, to have value of SR in sr again.

Signed-off-by: Denis Osterland <Denis.Osterland@diehl.com>
Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: tx4939: use generic nvmem
Alexandre Belloni [Mon, 12 Feb 2018 22:47:59 +0000 (23:47 +0100)]
rtc: tx4939: use generic nvmem

Instead of adding a binary sysfs attribute from the driver, use the core to
register an nvmem device.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: tx4939: fix possible race condition
Alexandre Belloni [Mon, 12 Feb 2018 22:47:58 +0000 (23:47 +0100)]
rtc: tx4939: fix possible race condition

The probe function is not allowed to fail after registering the RTC. Call
rtc_register_device() at the end.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: tx4939: switch to rtc_register_device
Alexandre Belloni [Mon, 12 Feb 2018 22:47:57 +0000 (23:47 +0100)]
rtc: tx4939: switch to rtc_register_device

This allows for future improvement of the driver.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: tx4939: extend test coverage
Alexandre Belloni [Mon, 12 Feb 2018 22:47:56 +0000 (23:47 +0100)]
rtc: tx4939: extend test coverage

The rtc-tx4939 driver now compiles correctly on other architectures, add
COMPILE_TEST to improve code coverage.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: tx4939: remove arch/mips dependency
Alexandre Belloni [Mon, 12 Feb 2018 22:47:55 +0000 (23:47 +0100)]
rtc: tx4939: remove arch/mips dependency

Copy RTC definitions from arch/mips/include/asm/txx9/tx4939.h to the RTC
driver so it doesn't depend on arch/mips anymore.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: stk17ta8: use generic nvmem
Alexandre Belloni [Mon, 12 Feb 2018 22:47:54 +0000 (23:47 +0100)]
rtc: stk17ta8: use generic nvmem

Instead of adding a binary sysfs attribute from the driver, use the core to
register an nvmem device.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: stk17ta8: fix possible race condition
Alexandre Belloni [Mon, 12 Feb 2018 22:47:53 +0000 (23:47 +0100)]
rtc: stk17ta8: fix possible race condition

The probe function is not allowed to fail after registering the RTC. Call
rtc_register_device() at the end.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: stk17ta8: switch to rtc_register_device
Alexandre Belloni [Mon, 12 Feb 2018 22:47:52 +0000 (23:47 +0100)]
rtc: stk17ta8: switch to rtc_register_device

This allows for future improvement of the driver.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: stk17ta8: make alarms useful
Alexandre Belloni [Mon, 12 Feb 2018 22:47:51 +0000 (23:47 +0100)]
rtc: stk17ta8: make alarms useful

Currently, the IRQs are disabled when the rtc driver is removed (e.g. when
shutting down the platform).
This means that the RTC will be unable to wakeup the platform.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: rp5c01: use generic nvmem
Alexandre Belloni [Mon, 12 Feb 2018 22:47:50 +0000 (23:47 +0100)]
rtc: rp5c01: use generic nvmem

Instead of adding a binary sysfs attribute from the driver, use the core to
register an nvmem device.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: rp5c01: fix possible race condition
Alexandre Belloni [Mon, 12 Feb 2018 22:47:49 +0000 (23:47 +0100)]
rtc: rp5c01: fix possible race condition

The probe function is not allowed to fail after registering the RTC because
the following may happen:

CPU0:                                CPU1:
sys_load_module()
 do_init_module()
  do_one_initcall()
   cmos_do_probe()
    rtc_device_register()
     __register_chrdev()
     cdev->owner = struct module*
                                     open("/dev/rtc0")
    rtc_device_unregister()
  module_put()
  free_module()
   module_free(mod->module_core)
   /* struct module *module is now
      freed */
                                      chrdev_open()
                                       spin_lock(cdev_lock)
                                       cdev_get()
                                        try_module_get()
                                         module_is_live()
                                         /* dereferences already
                                            freed struct module* */

Switch to devm_rtc_allocate_device/rtc_register_device to register the rtc
as late as possible.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: ds1742: use generic nvmem
Alexandre Belloni [Mon, 12 Feb 2018 22:47:48 +0000 (23:47 +0100)]
rtc: ds1742: use generic nvmem

Instead of adding a binary sysfs attribute from the driver (which suffers
from a race condition as the attribute appears after the device), use the
core to register an nvmem device.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: ds1742: switch to rtc_register_device
Alexandre Belloni [Mon, 12 Feb 2018 22:47:47 +0000 (23:47 +0100)]
rtc: ds1742: switch to rtc_register_device

This allows for future improvement of the driver.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: cmos: use generic nvmem
Alexandre Belloni [Mon, 12 Feb 2018 22:47:46 +0000 (23:47 +0100)]
rtc: cmos: use generic nvmem

Instead of adding a binary sysfs attribute from the driver, use the
core to register an nvmem device. This allows to use the in-kernel
interface to access the nvram.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: cmos: fix possible race condition
Alexandre Belloni [Mon, 12 Feb 2018 22:47:45 +0000 (23:47 +0100)]
rtc: cmos: fix possible race condition

The probe function is not allowed to fail after registering the RTC because
the following may happen:

CPU0:                                CPU1:
sys_load_module()
 do_init_module()
  do_one_initcall()
   cmos_do_probe()
    rtc_device_register()
     __register_chrdev()
     cdev->owner = struct module*
                                     open("/dev/rtc0")
    rtc_device_unregister()
  module_put()
  free_module()
   module_free(mod->module_core)
   /* struct module *module is now
      freed */
                                      chrdev_open()
                                       spin_lock(cdev_lock)
                                       cdev_get()
                                        try_module_get()
                                         module_is_live()
                                         /* dereferences already
                                            freed struct module* */

Switch to devm_rtc_allocate_device/rtc_register_device to register the rtc
as late as possible.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: ds1553: make alarms useful
Alexandre Belloni [Mon, 12 Feb 2018 22:47:44 +0000 (23:47 +0100)]
rtc: ds1553: make alarms useful

Currently, the IRQs are disabled when the rtc driver is removed (e.g. when
shutting down the platform).
This means that the RTC will be unable to wakeup the platform.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: ds1553: use generic nvmem
Alexandre Belloni [Mon, 12 Feb 2018 22:47:43 +0000 (23:47 +0100)]
rtc: ds1553: use generic nvmem

Instead of adding a binary sysfs attribute from the driver (which suffers
from a race condition as the attribute appears after the device), use the
core to register an nvmem device.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: ds1553: switch to rtc_register_device
Alexandre Belloni [Mon, 12 Feb 2018 22:47:42 +0000 (23:47 +0100)]
rtc: ds1553: switch to rtc_register_device

This allows for future improvement of the driver.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: sirfsoc: remove useless sirfsoc_rtc_ioctl
Alexandre Belloni [Mon, 12 Feb 2018 22:47:41 +0000 (23:47 +0100)]
rtc: sirfsoc: remove useless sirfsoc_rtc_ioctl

sirfsoc_rtc_ioctl() doesn't implement any actual ioctl, remove it.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: m48t59: use generic nvmem
Alexandre Belloni [Mon, 12 Feb 2018 22:47:40 +0000 (23:47 +0100)]
rtc: m48t59: use generic nvmem

Instead of adding a binary sysfs attribute from the driver (which suffers
from a race condition as the attribute appears after the device), use the
core to register an nvmem device.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: m48t59: switch to rtc_register_device
Alexandre Belloni [Mon, 12 Feb 2018 22:47:39 +0000 (23:47 +0100)]
rtc: m48t59: switch to rtc_register_device

This allows for future improvement of the driver.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: ds1343: use generic nvmem
Alexandre Belloni [Mon, 12 Feb 2018 22:47:38 +0000 (23:47 +0100)]
rtc: ds1343: use generic nvmem

Instead of adding a binary sysfs attribute from the driver (which suffers
from a race condition as the attribute appears after the device), use the
core to register an nvmem device.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: ds1343: remove undocumented and useless sysfs files
Alexandre Belloni [Mon, 12 Feb 2018 22:47:37 +0000 (23:47 +0100)]
rtc: ds1343: remove undocumented and useless sysfs files

A documented ABI already exists to get information about the alarm. It is
the only one that is used.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: ds1343: switch to rtc_register_device
Alexandre Belloni [Mon, 12 Feb 2018 22:47:36 +0000 (23:47 +0100)]
rtc: ds1343: switch to rtc_register_device

This allows for future improvement of the driver.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: ds1343: simplify regmap initialization
Alexandre Belloni [Mon, 12 Feb 2018 22:47:35 +0000 (23:47 +0100)]
rtc: ds1343: simplify regmap initialization

Avoid using memset as gcc can properly initialize structures.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: remove nvmem_config
Alexandre Belloni [Mon, 12 Feb 2018 22:47:34 +0000 (23:47 +0100)]
rtc: remove nvmem_config

Because nvmem_config is only used and copied at nvmem registration, remove
it from struct rtc_device.

All the rtc drivers using nvmem are now calling rtc_nvmem_register
directly.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: rv8803: fix possible race condition
Alexandre Belloni [Mon, 12 Feb 2018 22:47:33 +0000 (23:47 +0100)]
rtc: rv8803: fix possible race condition

The probe function is not allowed to fail after registering the RTC. Call
rtc_register_device() at the end.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: rv8803: put struct nvmem_config on the stack
Alexandre Belloni [Mon, 12 Feb 2018 22:47:32 +0000 (23:47 +0100)]
rtc: rv8803: put struct nvmem_config on the stack

Avoid allocating memory for struct nvmem_config.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: rv8803: call rtc_nvmem_register()
Alexandre Belloni [Mon, 12 Feb 2018 22:47:31 +0000 (23:47 +0100)]
rtc: rv8803: call rtc_nvmem_register()

Call rtc_nvmem_register instead of letting the core do it and stop using
the nvmem_config member of struct rtc_device.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: pcf85363: put struct nvmem_config on the stack
Alexandre Belloni [Mon, 12 Feb 2018 22:47:30 +0000 (23:47 +0100)]
rtc: pcf85363: put struct nvmem_config on the stack

Avoid allocating memory for struct nvmem_config.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: pcf85363: call rtc_nvmem_register()
Alexandre Belloni [Mon, 12 Feb 2018 22:47:29 +0000 (23:47 +0100)]
rtc: pcf85363: call rtc_nvmem_register()

Call rtc_nvmem_register instead of letting the core do it and stop using
the nvmem_config member of struct rtc_device.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: omap: call rtc_nvmem_register()
Alexandre Belloni [Mon, 12 Feb 2018 22:47:28 +0000 (23:47 +0100)]
rtc: omap: call rtc_nvmem_register()

Call rtc_nvmem_register instead of letting the core do it and stop using
the nvmem_config member of struct rtc_device.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: m48t86: put m48t86_nvmem_cfg on the stack
Alexandre Belloni [Mon, 12 Feb 2018 22:47:27 +0000 (23:47 +0100)]
rtc: m48t86: put m48t86_nvmem_cfg on the stack

Move m48t86_nvmem_cfg to the stack of m48t86_rtc_probe. This results in a
very small code size reduction and make it safer on systems with two
similar RTCs:

   text    data     bss     dec     hex filename
   1733     164       0    1897     769 drivers/rtc/rtc-m48t86.o.before
   1793     100       0    1893     765 drivers/rtc/rtc-m48t86.o.after

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: m48t86: call rtc_nvmem_register()
Alexandre Belloni [Mon, 12 Feb 2018 22:47:26 +0000 (23:47 +0100)]
rtc: m48t86: call rtc_nvmem_register()

Call rtc_nvmem_register instead of letting the core do it and stop using
the nvmem_config member of struct rtc_device.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: ds1511: put ds1511_nvmem_cfg on the stack
Alexandre Belloni [Mon, 12 Feb 2018 22:47:25 +0000 (23:47 +0100)]
rtc: ds1511: put ds1511_nvmem_cfg on the stack

Move ds1511_nvmem_cfg to the stack of ds1511_rtc_probe. This results in a
very small code size reduction and make it safer on systems with two
similar RTCs:

   text    data     bss     dec     hex filename
   2128     164       4    2296     8f8 drivers/rtc/rtc-ds1511.o.before
   2175     100       4    2279     8e7 drivers/rtc/rtc-ds1511.o.after

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: ds1511: call rtc_nvmem_register()
Alexandre Belloni [Mon, 12 Feb 2018 22:47:24 +0000 (23:47 +0100)]
rtc: ds1511: call rtc_nvmem_register()

Call rtc_nvmem_register instead of letting the core do it and stop using
the nvmem_config member of struct rtc_device.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: ds1307: put struct nvmem_config on the stack
Alexandre Belloni [Mon, 12 Feb 2018 22:47:23 +0000 (23:47 +0100)]
rtc: ds1307: put struct nvmem_config on the stack

Avoid allocating memory for struct nvmem_config as it is only necessary at
the nvmem registration.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: ds1307: call rtc_nvmem_register()
Alexandre Belloni [Mon, 12 Feb 2018 22:47:22 +0000 (23:47 +0100)]
rtc: ds1307: call rtc_nvmem_register()

Call rtc_nvmem_register instead of letting the core do it and stop using
the nvmem_config member of struct rtc_device.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: ds1305: put ds1305_nvmem_cfg on the stack
Alexandre Belloni [Mon, 12 Feb 2018 22:47:21 +0000 (23:47 +0100)]
rtc: ds1305: put ds1305_nvmem_cfg on the stack

This makes to code safer on system using two similar RTCs.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: ds1305: call rtc_nvmem_register()
Alexandre Belloni [Mon, 12 Feb 2018 22:47:20 +0000 (23:47 +0100)]
rtc: ds1305: call rtc_nvmem_register()

Call rtc_nvmem_register instead of letting the core do it and stop using
the nvmem_config member of struct rtc_device.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: export rtc_nvmem_register() to drivers
Alexandre Belloni [Mon, 12 Feb 2018 22:47:19 +0000 (23:47 +0100)]
rtc: export rtc_nvmem_register() to drivers

Export rtc_nvmem_register() so it can be called from drivers instead of
only the core.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: nvmem: allow registering the nvmem device before the rtc
Alexandre Belloni [Wed, 28 Feb 2018 20:58:02 +0000 (21:58 +0100)]
rtc: nvmem: allow registering the nvmem device before the rtc

Switch the parent of the nvmem device to the parent of the rtc device so it
can be registered before the RTC.

This is a small change in the ABI as the nvmem moves out of the
/sys/class/rtc/rtcX folder to be under the parent device folder (that is
where the previous nvram files where registered).

However, it is still available under its correct location,
/sys/bus/nvmem/devices which is the one that should be used by userspace
applications.

The other benefit is that the nvmem device can stay registered even if the
rtc registration fails. Or it is possible to not register the rtc if the
nvmem registration failed.

Finally, it makes a lot of sense for devices that actually have different
i2c or spi addresses for the RTC and the EEPROM. That is basically how it
would end up when using MFD or even completely separate devices.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
6 years agortc: nvmem: disallow registering nvmem more than once
Alexandre Belloni [Mon, 12 Feb 2018 22:47:18 +0000 (23:47 +0100)]
rtc: nvmem: disallow registering nvmem more than once

Make rtc_nvmem_register return -EBUSY when an nvmem is already registered
for that RTC.

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