diff --git a/Documentation/ABI/testing/sysfs-class-rtc b/Documentation/ABI/testing/sysfs-class-rtc index 65270d95873cee98d2af19113f85c45d15557a02..792a38300336a2765477bedd5fa0076142ad90d0 100644 --- a/Documentation/ABI/testing/sysfs-class-rtc +++ b/Documentation/ABI/testing/sysfs-class-rtc @@ -57,14 +57,6 @@ Contact: linux-rtc@vger.kernel.org Description: (RO) RTC-provided time in 24-hour notation (hh:mm:ss) -What: /sys/class/rtc/rtcX/*/nvmem -Date: July 2017 -KernelVersion: 4.13 -Contact: linux-rtc@vger.kernel.org -Description: - (RW) The non volatile storage exported as a raw file, as - described in Documentation/nvmem/nvmem.txt - What: /sys/class/rtc/rtcX/offset Date: February 2016 KernelVersion: 4.6 diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c index 47c4aeed5106d63e432809513e8737775d897014..0cab397f6e378a45127b1d7d4d0351ba0fe6422f 100644 --- a/drivers/rtc/class.c +++ b/drivers/rtc/class.c @@ -293,8 +293,6 @@ EXPORT_SYMBOL_GPL(rtc_device_register); */ void rtc_device_unregister(struct rtc_device *rtc) { - rtc_nvmem_unregister(rtc); - mutex_lock(&rtc->ops_lock); /* * Remove innards of this RTC, then disable it, before @@ -312,6 +310,7 @@ static void devm_rtc_device_release(struct device *dev, void *res) { struct rtc_device *rtc = *(struct rtc_device **)res; + rtc_nvmem_unregister(rtc); rtc_device_unregister(rtc); } @@ -382,6 +381,8 @@ static void devm_rtc_release_device(struct device *dev, void *res) { struct rtc_device *rtc = *(struct rtc_device **)res; + rtc_nvmem_unregister(rtc); + if (rtc->registered) rtc_device_unregister(rtc); else diff --git a/drivers/rtc/nvmem.c b/drivers/rtc/nvmem.c index fd1c39a5ade5cd861240d5b5818fdebf6ddd069f..eb8c622cfcf49fd1423d760b3a2d4a35260a3519 100644 --- a/drivers/rtc/nvmem.c +++ b/drivers/rtc/nvmem.c @@ -93,7 +93,7 @@ int rtc_nvmem_register(struct rtc_device *rtc, if (!nvmem_config) return -ENODEV; - nvmem_config->dev = &rtc->dev; + nvmem_config->dev = rtc->dev.parent; nvmem_config->owner = rtc->owner; rtc->nvmem = nvmem_register(nvmem_config); if (IS_ERR_OR_NULL(rtc->nvmem))