On Fri, Jun 2, 2023 at 8:20 AM Maxime Ripard mripard@kernel.org wrote:
One small suggestion below <snip>
+static void root_device_devm_register_unregister_test(struct kunit *test) +{
struct test_priv *priv;
int ret;
priv = kunit_kzalloc(test, sizeof(*priv), GFP_KERNEL);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv);
init_waitqueue_head(&priv->release_wq);
Note: should we use an init function to handle this setup? We can store it in test->priv instead.
static int my_init(struct kunit *test) { struct test_priv *priv;
priv = kunit_kzalloc(test, sizeof(test_priv), GFP_KERNEL); if (!priv) return -ENOMEM; // N.B. I think you could probably still use assert instead
init_waitqueue_head(&priv->release_wq);
priv->dev = root_device_register(DEVICE_NAME); if (!priv->dev) return -ENOMEM;
test->priv = priv; }
... static struct kunit_suite root_device_devm_test_suite = { .name = "root-device-devm", .init = my_init, .test_cases = root_device_devm_tests, };
Daniel