2019-03-14 06:02:48 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2017-07-06 17:42:02 +08: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-10 00:34:06 +08:00
|
|
|
int devm_rtc_nvmem_register(struct rtc_device *rtc,
|
2018-02-13 06:47:17 +08:00
|
|
|
struct nvmem_config *nvmem_config)
|
2017-07-06 17:42:02 +08:00
|
|
|
{
|
2020-11-10 00:34:07 +08:00
|
|
|
struct device *dev = rtc->dev.parent;
|
2018-11-11 04:29:03 +08:00
|
|
|
struct nvmem_device *nvmem;
|
2018-02-13 06:47:18 +08:00
|
|
|
|
2018-02-13 06:47:16 +08:00
|
|
|
if (!nvmem_config)
|
2018-02-13 06:47:17 +08:00
|
|
|
return -ENODEV;
|
2017-07-06 17:42:02 +08:00
|
|
|
|
2020-11-10 00:34:07 +08:00
|
|
|
nvmem_config->dev = dev;
|
2018-02-13 06:47:16 +08:00
|
|
|
nvmem_config->owner = rtc->owner;
|
2020-11-10 00:34:07 +08: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-13 06:47:17 +08:00
|
|
|
|
2020-11-10 00:34:05 +08:00
|
|
|
return PTR_ERR_OR_ZERO(nvmem);
|
2017-07-06 17:42:02 +08:00
|
|
|
}
|
2020-11-10 00:34:06 +08:00
|
|
|
EXPORT_SYMBOL_GPL(devm_rtc_nvmem_register);
|