summaryrefslogtreecommitdiff
path: root/drivers/rtc/nvmem.c
blob: 37df7e80525b4a40758d8c291da3f5b4d300eb30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// 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>

int devm_rtc_nvmem_register(struct rtc_device *rtc,
		       struct nvmem_config *nvmem_config)
{
	struct device *dev = rtc->dev.parent;
	struct nvmem_device *nvmem;

	if (!nvmem_config)
		return -ENODEV;

	nvmem_config->dev = dev;
	nvmem_config->owner = rtc->owner;
	nvmem_config->add_legacy_fixed_of_cells = true;
	nvmem = devm_nvmem_register(dev, nvmem_config);
	if (IS_ERR(nvmem))
		dev_err(dev, "failed to register nvmem device for RTC\n");

	return PTR_ERR_OR_ZERO(nvmem);
}
EXPORT_SYMBOL_GPL(devm_rtc_nvmem_register);