Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2cc82121 authored by Alexandre Belloni's avatar Alexandre Belloni
Browse files

rtc: nvmem: return error values



In case of error, make rtc_nvmem_register() able to return an error value
to its caller.

Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
parent 4cce9d39
Loading
Loading
Loading
Loading
+6 −4
Original line number Original line Diff line number Diff line
@@ -84,21 +84,23 @@ static void rtc_nvram_unregister(struct rtc_device *rtc)
/*
/*
 * New ABI, uses nvmem
 * New ABI, uses nvmem
 */
 */
void rtc_nvmem_register(struct rtc_device *rtc,
int rtc_nvmem_register(struct rtc_device *rtc,
		       struct nvmem_config *nvmem_config)
		       struct nvmem_config *nvmem_config)
{
{
	if (!nvmem_config)
	if (!nvmem_config)
		return;
		return -ENODEV;


	nvmem_config->dev = &rtc->dev;
	nvmem_config->dev = &rtc->dev;
	nvmem_config->owner = rtc->owner;
	nvmem_config->owner = rtc->owner;
	rtc->nvmem = nvmem_register(nvmem_config);
	rtc->nvmem = nvmem_register(nvmem_config);
	if (IS_ERR_OR_NULL(rtc->nvmem))
	if (IS_ERR_OR_NULL(rtc->nvmem))
		return;
		return PTR_ERR(rtc->nvmem);


	/* Register the old ABI */
	/* Register the old ABI */
	if (rtc->nvram_old_abi)
	if (rtc->nvram_old_abi)
		rtc_nvram_register(rtc, nvmem_config->size);
		rtc_nvram_register(rtc, nvmem_config->size);

	return 0;
}
}


void rtc_nvmem_unregister(struct rtc_device *rtc)
void rtc_nvmem_unregister(struct rtc_device *rtc)
+7 −4
Original line number Original line Diff line number Diff line
@@ -48,11 +48,14 @@ static inline const struct attribute_group **rtc_get_dev_attribute_groups(void)
#endif
#endif


#ifdef CONFIG_RTC_NVMEM
#ifdef CONFIG_RTC_NVMEM
void rtc_nvmem_register(struct rtc_device *rtc,
int rtc_nvmem_register(struct rtc_device *rtc,
		       struct nvmem_config *nvmem_config);
		       struct nvmem_config *nvmem_config);
void rtc_nvmem_unregister(struct rtc_device *rtc);
void rtc_nvmem_unregister(struct rtc_device *rtc);
#else
#else
static inline void rtc_nvmem_register(struct rtc_device *rtc,
static inline int rtc_nvmem_register(struct rtc_device *rtc,
				      struct nvmem_config *nvmem_config) {}
				     struct nvmem_config *nvmem_config)
{
	return -ENODEV;
}
static inline void rtc_nvmem_unregister(struct rtc_device *rtc) {}
static inline void rtc_nvmem_unregister(struct rtc_device *rtc) {}
#endif
#endif