Commit 91f842ff authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'linux_kselftest-kunit-fixes-6.8-rc5' of...

Merge tag 'linux_kselftest-kunit-fixes-6.8-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest

Pull KUnit fix from Shuah Khan:
 "One important fix to unregister kunit_bus when KUnit module is
  unloaded.

  Not doing so causes an error when KUnit module tries to re-register
  the bus when it gets reloaded"

* tag 'linux_kselftest-kunit-fixes-6.8-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest:
  kunit: device: Unregister the kunit_bus on shutdown
parents 7e90b5c2 829388b7
...@@ -13,5 +13,7 @@ ...@@ -13,5 +13,7 @@
// For internal use only -- registers the kunit_bus. // For internal use only -- registers the kunit_bus.
int kunit_bus_init(void); int kunit_bus_init(void);
// For internal use only -- unregisters the kunit_bus.
void kunit_bus_shutdown(void);
#endif //_KUNIT_DEVICE_IMPL_H #endif //_KUNIT_DEVICE_IMPL_H
...@@ -54,6 +54,20 @@ int kunit_bus_init(void) ...@@ -54,6 +54,20 @@ int kunit_bus_init(void)
return error; return error;
} }
/* Unregister the 'kunit_bus' in case the KUnit module is unloaded. */
void kunit_bus_shutdown(void)
{
/* Make sure the bus exists before we unregister it. */
if (IS_ERR_OR_NULL(kunit_bus_device))
return;
bus_unregister(&kunit_bus_type);
root_device_unregister(kunit_bus_device);
kunit_bus_device = NULL;
}
/* Release a 'fake' KUnit device. */ /* Release a 'fake' KUnit device. */
static void kunit_device_release(struct device *d) static void kunit_device_release(struct device *d)
{ {
......
...@@ -928,6 +928,9 @@ static void __exit kunit_exit(void) ...@@ -928,6 +928,9 @@ static void __exit kunit_exit(void)
#ifdef CONFIG_MODULES #ifdef CONFIG_MODULES
unregister_module_notifier(&kunit_mod_nb); unregister_module_notifier(&kunit_mod_nb);
#endif #endif
kunit_bus_shutdown();
kunit_debugfs_cleanup(); kunit_debugfs_cleanup();
} }
module_exit(kunit_exit); module_exit(kunit_exit);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment