3
0
mirror of https://github.com/Qortal/Brooklyn.git synced 2025-01-31 07:12:18 +00:00
Brooklyn/drivers/rtc/nvmem.c

31 lines
703 B
C
Raw Normal View History

2021-05-26 19:09:36 +00:00
// SPDX-License-Identifier: GPL-2.0
/*
* 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>
2021-10-02 16:09:28 +00:00
int devm_rtc_nvmem_register(struct rtc_device *rtc,
2021-05-26 19:09:36 +00:00
struct nvmem_config *nvmem_config)
{
2021-10-02 16:09:28 +00:00
struct device *dev = rtc->dev.parent;
2021-05-26 19:09:36 +00:00
struct nvmem_device *nvmem;
if (!nvmem_config)
return -ENODEV;
2021-10-02 16:09:28 +00:00
nvmem_config->dev = dev;
2021-05-26 19:09:36 +00:00
nvmem_config->owner = rtc->owner;
2021-10-02 16:09:28 +00:00
nvmem = devm_nvmem_register(dev, nvmem_config);
2021-05-26 19:09:36 +00:00
if (IS_ERR(nvmem))
2021-10-02 16:09:28 +00:00
dev_err(dev, "failed to register nvmem device for RTC\n");
2021-05-26 19:09:36 +00:00
2021-10-02 16:09:28 +00:00
return PTR_ERR_OR_ZERO(nvmem);
2021-05-26 19:09:36 +00:00
}
2021-10-02 16:09:28 +00:00
EXPORT_SYMBOL_GPL(devm_rtc_nvmem_register);