Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / drivers / rtc / nvmem.c
blob37df7e80525b4a40758d8c291da3f5b4d300eb30
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * RTC subsystem, nvmem interface
5 * Copyright (C) 2017 Alexandre Belloni
6 */
8 #include <linux/err.h>
9 #include <linux/types.h>
10 #include <linux/nvmem-consumer.h>
11 #include <linux/rtc.h>
13 int devm_rtc_nvmem_register(struct rtc_device *rtc,
14 struct nvmem_config *nvmem_config)
16 struct device *dev = rtc->dev.parent;
17 struct nvmem_device *nvmem;
19 if (!nvmem_config)
20 return -ENODEV;
22 nvmem_config->dev = dev;
23 nvmem_config->owner = rtc->owner;
24 nvmem_config->add_legacy_fixed_of_cells = true;
25 nvmem = devm_nvmem_register(dev, nvmem_config);
26 if (IS_ERR(nvmem))
27 dev_err(dev, "failed to register nvmem device for RTC\n");
29 return PTR_ERR_OR_ZERO(nvmem);
31 EXPORT_SYMBOL_GPL(devm_rtc_nvmem_register);