Commit e57cdff0 authored by davidgow@google.com's avatar davidgow@google.com Committed by Shuah Khan

ASoC: topology: Replace fake root_device with kunit_device in tests

Using struct root_device to create fake devices for tests is something
of a hack. The new struct kunit_device is meant for this purpose, so use
it instead.
Acked-by: default avatarMark Brown <broonie@kernel.org>
Signed-off-by: default avatarDavid Gow <davidgow@google.com>
Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
parent 83701838
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <sound/core.h> #include <sound/core.h>
#include <sound/soc.h> #include <sound/soc.h>
#include <sound/soc-topology.h> #include <sound/soc-topology.h>
#include <kunit/device.h>
#include <kunit/test.h> #include <kunit/test.h>
/* ===== HELPER FUNCTIONS =================================================== */ /* ===== HELPER FUNCTIONS =================================================== */
...@@ -21,26 +22,19 @@ ...@@ -21,26 +22,19 @@
*/ */
static struct device *test_dev; static struct device *test_dev;
static struct device_driver test_drv = {
.name = "sound-soc-topology-test-driver",
};
static int snd_soc_tplg_test_init(struct kunit *test) static int snd_soc_tplg_test_init(struct kunit *test)
{ {
test_dev = root_device_register("sound-soc-topology-test"); test_dev = kunit_device_register(test, "sound-soc-topology-test");
test_dev = get_device(test_dev); test_dev = get_device(test_dev);
if (!test_dev) if (!test_dev)
return -ENODEV; return -ENODEV;
test_dev->driver = &test_drv;
return 0; return 0;
} }
static void snd_soc_tplg_test_exit(struct kunit *test) static void snd_soc_tplg_test_exit(struct kunit *test)
{ {
put_device(test_dev); put_device(test_dev);
root_device_unregister(test_dev);
} }
/* /*
......
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