2019-03-13 22:02:48 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2017-07-06 09:42:02 +00:00
|
|
|
/*
|
|
|
|
* RTC subsystem, nvmem interface
|
|
|
|
*
|
|
|
|
* Copyright (C) 2017 Alexandre Belloni
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/err.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/nvmem-consumer.h>
|
|
|
|
#include <linux/rtc.h>
|
|
|
|
|
2020-11-09 16:34:06 +00:00
|
|
|
int devm_rtc_nvmem_register(struct rtc_device *rtc,
|
2018-02-12 22:47:17 +00:00
|
|
|
struct nvmem_config *nvmem_config)
|
2017-07-06 09:42:02 +00:00
|
|
|
{
|
2020-11-09 16:34:07 +00:00
|
|
|
struct device *dev = rtc->dev.parent;
|
2018-11-10 20:29:03 +00:00
|
|
|
struct nvmem_device *nvmem;
|
2018-02-12 22:47:18 +00:00
|
|
|
|
2018-02-12 22:47:16 +00:00
|
|
|
if (!nvmem_config)
|
2018-02-12 22:47:17 +00:00
|
|
|
return -ENODEV;
|
2017-07-06 09:42:02 +00:00
|
|
|
|
2020-11-09 16:34:07 +00:00
|
|
|
nvmem_config->dev = dev;
|
2018-02-12 22:47:16 +00:00
|
|
|
nvmem_config->owner = rtc->owner;
|
2023-10-20 10:55:41 +00:00
|
|
|
nvmem_config->add_legacy_fixed_of_cells = true;
|
2020-11-09 16:34:07 +00:00
|
|
|
nvmem = devm_nvmem_register(dev, nvmem_config);
|
|
|
|
if (IS_ERR(nvmem))
|
|
|
|
dev_err(dev, "failed to register nvmem device for RTC\n");
|
2018-02-12 22:47:17 +00:00
|
|
|
|
2020-11-09 16:34:05 +00:00
|
|
|
return PTR_ERR_OR_ZERO(nvmem);
|
2017-07-06 09:42:02 +00:00
|
|
|
}
|
2020-11-09 16:34:06 +00:00
|
|
|
EXPORT_SYMBOL_GPL(devm_rtc_nvmem_register);
|