1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * RTC subsystem, nvmem interface 4 * 5 * Copyright (C) 2017 Alexandre Belloni 6 */ 7 8 #include <linux/err.h> 9 #include <linux/types.h> 10 #include <linux/nvmem-consumer.h> 11 #include <linux/rtc.h> 12 devm_rtc_nvmem_register(struct rtc_device * rtc,struct nvmem_config * nvmem_config)13int devm_rtc_nvmem_register(struct rtc_device *rtc, 14 struct nvmem_config *nvmem_config) 15 { 16 struct device *dev = rtc->dev.parent; 17 struct nvmem_device *nvmem; 18 19 if (!nvmem_config) 20 return -ENODEV; 21 22 nvmem_config->dev = dev; 23 nvmem_config->owner = rtc->owner; 24 nvmem = devm_nvmem_register(dev, nvmem_config); 25 if (IS_ERR(nvmem)) 26 dev_err(dev, "failed to register nvmem device for RTC\n"); 27 28 return PTR_ERR_OR_ZERO(nvmem); 29 } 30 EXPORT_SYMBOL_GPL(devm_rtc_nvmem_register); 31