diff options
author | David Gow <davidgow@google.com> | 2024-02-01 14:04:36 +0800 |
---|---|---|
committer | Shuah Khan <skhan@linuxfoundation.org> | 2024-02-06 17:07:37 -0700 |
commit | 829388b725f8d266ccec32a2f446717d8693eaba (patch) | |
tree | e78cc7504880a13c161d8e7b6d50706277499470 /lib/kunit/device-impl.h | |
parent | 1a9f2c776d1416c4ea6cb0d0b9917778c41a1a7d (diff) |
kunit: device: Unregister the kunit_bus on shutdown
If KUnit is built as a module, and it's unloaded, the kunit_bus is not
unregistered. This causes an error if it's then re-loaded later, as we
try to re-register the bus.
Unregister the bus and root_device on shutdown, if it looks valid.
In addition, be more specific about the value of kunit_bus_device. It
is:
- a valid struct device* if the kunit_bus initialised correctly.
- an ERR_PTR if it failed to initialise.
- NULL before initialisation and after shutdown.
Fixes: d03c720e03bd ("kunit: Add APIs for managing devices")
Signed-off-by: David Gow <davidgow@google.com>
Reviewed-by: Rae Moar <rmoar@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Diffstat (limited to 'lib/kunit/device-impl.h')
-rw-r--r-- | lib/kunit/device-impl.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/kunit/device-impl.h b/lib/kunit/device-impl.h index 54bd55836405..5fcd48ff0f36 100644 --- a/lib/kunit/device-impl.h +++ b/lib/kunit/device-impl.h @@ -13,5 +13,7 @@ // For internal use only -- registers the kunit_bus. int kunit_bus_init(void); +// For internal use only -- unregisters the kunit_bus. +void kunit_bus_shutdown(void); #endif //_KUNIT_DEVICE_IMPL_H |