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