Re: [PATCH RESEND 1/2] drivers: base: Add basic devm tests for root devices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jun 2, 2023 at 8:20 AM Maxime Ripard <mripard@xxxxxxxxxx> 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




[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux