Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rtc: class: remove unnecessary device_get() in rtc_device_unregister

Technically the address of rtc->dev can never be NULL, so get_device()
can never fail. Also caller of rtc_device_unregister() supposed to be
the owner of the device and thus have a valid reference. Therefore
call to get_device() is not needed here.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>

authored by

Dmitry Torokhov and committed by
Alexandre Belloni
c3b399a4 6706664d

+12 -13
+12 -13
drivers/rtc/class.c
··· 266 266 */ 267 267 void rtc_device_unregister(struct rtc_device *rtc) 268 268 { 269 - if (get_device(&rtc->dev) != NULL) { 270 - mutex_lock(&rtc->ops_lock); 271 - /* remove innards of this RTC, then disable it, before 272 - * letting any rtc_class_open() users access it again 273 - */ 274 - rtc_sysfs_del_device(rtc); 275 - rtc_dev_del_device(rtc); 276 - rtc_proc_del_device(rtc); 277 - device_unregister(&rtc->dev); 278 - rtc->ops = NULL; 279 - mutex_unlock(&rtc->ops_lock); 280 - put_device(&rtc->dev); 281 - } 269 + mutex_lock(&rtc->ops_lock); 270 + /* 271 + * Remove innards of this RTC, then disable it, before 272 + * letting any rtc_class_open() users access it again 273 + */ 274 + rtc_sysfs_del_device(rtc); 275 + rtc_dev_del_device(rtc); 276 + rtc_proc_del_device(rtc); 277 + device_del(&rtc->dev); 278 + rtc->ops = NULL; 279 + mutex_unlock(&rtc->ops_lock); 280 + put_device(&rtc->dev); 282 281 } 283 282 EXPORT_SYMBOL_GPL(rtc_device_unregister); 284 283