History log of /linux-master/drivers/rtc/nvmem.c
Revision Date Author Comments
# 2cc3b37f 20-Oct-2023 Rafał Miłecki <rafal@milecki.pl>

nvmem: add explicit config option to read old syntax fixed OF cells

Binding for fixed NVMEM cells defined directly as NVMEM device subnodes
has been deprecated. It has been replaced by the "fixed-layout" NVMEM
layout binding.

New syntax is meant to be clearer and should help avoiding imprecise
bindings.

NVMEM subsystem already supports the new binding. It should be a good
idea to limit support for old syntax to existing drivers that actually
support & use it (we can't break backward compatibility!). That way we
additionally encourage new bindings & drivers to ignore deprecated
binding.

It wasn't clear (to me) if rtc and w1 code actually uses old syntax
fixed cells. I enabled them to don't risk any breakage.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
[for meson-{efuse,mx-efuse}.c]
Acked-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
[for mtk-efuse.c, nvmem/core.c, nvmem-provider.h]
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
[MT8192, MT8195 Chromebooks]
Tested-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
[for microchip-otpc.c]
Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>
[SAMA7G5-EK]
Tested-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20231020105545.216052-3-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 6746bc09 09-Nov-2020 Bartosz Golaszewski <bgolaszewski@baylibre.com>

rtc: nvmem: emit an error message when nvmem registration fails

Some users check the return value of devm_rtc_nvmem_register() only in
order to emit an error message and then continue probing. This is fine
as an rtc can function without exposing nvmem but let's generalize it:
let's make the registration function emit the error message so that
users don't have to.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20201109163409.24301-7-brgl@bgdev.pl


# 3a905c2d 09-Nov-2020 Bartosz Golaszewski <bgolaszewski@baylibre.com>

rtc: add devm_ prefix to rtc_nvmem_register()

rtc_nvmem_register() is a managed interface. It doesn't require any
release function to be called at driver detach. To avoid confusing
driver authors, let's rename it to devm_rtc_nvmem_register() and add it
to the list of managed interfaces in Documentation/.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20201109163409.24301-6-brgl@bgdev.pl


# 25ece305 09-Nov-2020 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: nvmem: remove nvram ABI

The nvram sysfs attributes have been deprecated at least since v4.13, more
than 3 years ago and nobody ever complained about the deprecation warning.

Remove the sysfs attributes now.

[Bartosz: remove the declaration of rtc_nvmem_unregister()]

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Link: https://lore.kernel.org/r/20201109163409.24301-5-brgl@bgdev.pl


# 606cc43c 19-Mar-2019 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: core: correct trivial checkpatch warnings

Correct trivial checkpatch warnings, mostly whitespace issues and
unbalanced braces.

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


# cdf7545a 13-Mar-2019 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: convert core to SPDX identifier

Use SPDX-License-Identifier instead of a verbose license text. Also fix the
block comment alignment.

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


# bba3d2da 30-Dec-2018 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: nvmem: fix possible use after free

In cas of probe failure, devres may free the memory allocated for
rtc->nvram before devm_rtc_release_device() is called. This leads to
rtc_nvram_unregister using it after being freed which may lead to a crash.

This has been shown to happen after commit 461e557b9727 ("rtc: nvmem: use
devm_nvmem_register()")

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>


# 41c9e132 10-Nov-2018 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: nvmem: remove nvmem from struct rtc_device

Using devm_nvmem_register allows to avoid tracking the nvmem pointer in the
rtc_device structure.
This ultimately allows to register multiple nvmem devices from an RTC
driver.

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


# 461e557b 10-Nov-2018 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: nvmem: use devm_nvmem_register()

Use the resource managed variant of nvmem_register().

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


# 046dbb24 20-May-2018 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

rtc: nvmem: don't use IS_ERR_OR_NULL

nvmem_register() never returns NULL, so IS_ERR is good enough here.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>


# fd5cd21d 12-Feb-2018 Alexandre Belloni <alexandre.belloni@bootlin.com>

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>


# ac75779b 28-Feb-2018 Alexandre Belloni <alexandre.belloni@bootlin.com>

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>


# ab3ea36e 12-Feb-2018 Alexandre Belloni <alexandre.belloni@bootlin.com>

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>


# 2cc82121 12-Feb-2018 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: nvmem: return error values

In case of error, make rtc_nvmem_register() able to return an error value
to its caller.

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


# 4cce9d39 12-Feb-2018 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: nvmem: pass nvmem_config to rtc_nvmem_register()

To be able to remove nvmem_config from struct rtc_device, pass it as a
parameter to rtc_nvmem_register.

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


# 697e5a47 06-Jul-2017 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: add generic nvmem support

Many RTCs have an on board non volatile storage. It can be battery backed
RAM or an EEPROM. Use the nvmem subsystem to export it to both userspace
and in-kernel consumers.

This stays compatible with the previous (non documented) ABI that was using
/sys/class/rtc/rtcx/device/nvram to export that memory. But will warn about
the deprecation.

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