mirror of
https://github.com/torvalds/linux.git
synced 2026-09-12 20:53:03 +02:00
ASoC: soc-topology-test: use snd_soc_register_component()
It is calling snd_soc_component_initialize() / snd_soc_add_component(). We can now use snd_soc_register_component() instead. It is using container_of() to get kunit_soc_component from component, but will not be able to use it when capsuling has done. We can use snd_soc_component_to_priv() instead. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com> Link: https://patch.msgid.link/87jyqmrz76.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
695cc675f0
commit
10c062304d
|
|
@ -45,15 +45,13 @@ static void snd_soc_tplg_test_exit(struct kunit *test)
|
|||
struct kunit_soc_component {
|
||||
struct kunit *kunit;
|
||||
int expect; /* what result we expect when loading topology */
|
||||
struct snd_soc_component comp;
|
||||
struct snd_soc_card card;
|
||||
struct firmware fw;
|
||||
};
|
||||
|
||||
static int d_probe(struct snd_soc_component *component)
|
||||
{
|
||||
struct kunit_soc_component *kunit_comp =
|
||||
container_of(component, struct kunit_soc_component, comp);
|
||||
struct kunit_soc_component *kunit_comp = snd_soc_component_to_priv(component);
|
||||
int ret;
|
||||
|
||||
ret = snd_soc_tplg_component_load(component, NULL, &kunit_comp->fw);
|
||||
|
|
@ -65,8 +63,7 @@ static int d_probe(struct snd_soc_component *component)
|
|||
|
||||
static void d_remove(struct snd_soc_component *component)
|
||||
{
|
||||
struct kunit_soc_component *kunit_comp =
|
||||
container_of(component, struct kunit_soc_component, comp);
|
||||
struct kunit_soc_component *kunit_comp = snd_soc_component_to_priv(component);
|
||||
int ret;
|
||||
|
||||
ret = snd_soc_tplg_component_remove(component);
|
||||
|
|
@ -214,8 +211,7 @@ static struct tplg_tmpl_002 tplg_tmpl_with_pcm = {
|
|||
*/
|
||||
static int d_probe_null_comp(struct snd_soc_component *component)
|
||||
{
|
||||
struct kunit_soc_component *kunit_comp =
|
||||
container_of(component, struct kunit_soc_component, comp);
|
||||
struct kunit_soc_component *kunit_comp = snd_soc_component_to_priv(component);
|
||||
int ret;
|
||||
|
||||
/* instead of passing component pointer as first argument, pass NULL here */
|
||||
|
|
@ -234,6 +230,7 @@ static const struct snd_soc_component_driver test_component_null_comp = {
|
|||
static void snd_soc_tplg_test_load_with_null_comp(struct kunit *test)
|
||||
{
|
||||
struct kunit_soc_component *kunit_comp;
|
||||
struct snd_soc_component *component;
|
||||
int ret;
|
||||
|
||||
/* prepare */
|
||||
|
|
@ -249,15 +246,17 @@ static void snd_soc_tplg_test_load_with_null_comp(struct kunit *test)
|
|||
kunit_comp->card.num_links = ARRAY_SIZE(kunit_dai_links);
|
||||
kunit_comp->card.fully_routed = true;
|
||||
|
||||
component = snd_soc_component_alloc(test_dev);
|
||||
KUNIT_ASSERT_NOT_NULL(test, component);
|
||||
|
||||
snd_soc_component_set_priv(component, kunit_comp);
|
||||
|
||||
/* run test */
|
||||
ret = snd_soc_register_card(&kunit_comp->card);
|
||||
if (ret != 0 && ret != -EPROBE_DEFER)
|
||||
KUNIT_FAIL(test, "Failed to register card");
|
||||
|
||||
ret = snd_soc_component_initialize(&kunit_comp->comp, &test_component_null_comp, test_dev);
|
||||
KUNIT_EXPECT_EQ(test, 0, ret);
|
||||
|
||||
ret = snd_soc_add_component(&kunit_comp->comp, NULL, 0);
|
||||
ret = snd_soc_register_component(component, &test_component_null_comp, NULL, 0);
|
||||
KUNIT_EXPECT_EQ(test, 0, ret);
|
||||
|
||||
/* cleanup */
|
||||
|
|
@ -276,6 +275,7 @@ static void snd_soc_tplg_test_load_with_null_comp(struct kunit *test)
|
|||
static void snd_soc_tplg_test_load_with_null_ops(struct kunit *test)
|
||||
{
|
||||
struct kunit_soc_component *kunit_comp;
|
||||
struct snd_soc_component *component;
|
||||
int ret;
|
||||
|
||||
/* prepare */
|
||||
|
|
@ -291,15 +291,17 @@ static void snd_soc_tplg_test_load_with_null_ops(struct kunit *test)
|
|||
kunit_comp->card.num_links = ARRAY_SIZE(kunit_dai_links);
|
||||
kunit_comp->card.fully_routed = true;
|
||||
|
||||
component = snd_soc_component_alloc(test_dev);
|
||||
KUNIT_ASSERT_NOT_NULL(test, component);
|
||||
|
||||
snd_soc_component_set_priv(component, kunit_comp);
|
||||
|
||||
/* run test */
|
||||
ret = snd_soc_register_card(&kunit_comp->card);
|
||||
if (ret != 0 && ret != -EPROBE_DEFER)
|
||||
KUNIT_FAIL(test, "Failed to register card");
|
||||
|
||||
ret = snd_soc_component_initialize(&kunit_comp->comp, &test_component, test_dev);
|
||||
KUNIT_EXPECT_EQ(test, 0, ret);
|
||||
|
||||
ret = snd_soc_add_component(&kunit_comp->comp, NULL, 0);
|
||||
ret = snd_soc_register_component(component, &test_component, NULL, 0);
|
||||
KUNIT_EXPECT_EQ(test, 0, ret);
|
||||
|
||||
/* cleanup */
|
||||
|
|
@ -318,8 +320,7 @@ static void snd_soc_tplg_test_load_with_null_ops(struct kunit *test)
|
|||
*/
|
||||
static int d_probe_null_fw(struct snd_soc_component *component)
|
||||
{
|
||||
struct kunit_soc_component *kunit_comp =
|
||||
container_of(component, struct kunit_soc_component, comp);
|
||||
struct kunit_soc_component *kunit_comp = snd_soc_component_to_priv(component);
|
||||
int ret;
|
||||
|
||||
/* instead of passing fw pointer as third argument, pass NULL here */
|
||||
|
|
@ -338,6 +339,7 @@ static const struct snd_soc_component_driver test_component_null_fw = {
|
|||
static void snd_soc_tplg_test_load_with_null_fw(struct kunit *test)
|
||||
{
|
||||
struct kunit_soc_component *kunit_comp;
|
||||
struct snd_soc_component *component;
|
||||
int ret;
|
||||
|
||||
/* prepare */
|
||||
|
|
@ -353,15 +355,17 @@ static void snd_soc_tplg_test_load_with_null_fw(struct kunit *test)
|
|||
kunit_comp->card.num_links = ARRAY_SIZE(kunit_dai_links);
|
||||
kunit_comp->card.fully_routed = true;
|
||||
|
||||
component = snd_soc_component_alloc(test_dev);
|
||||
KUNIT_ASSERT_NOT_NULL(test, component);
|
||||
|
||||
snd_soc_component_set_priv(component, kunit_comp);
|
||||
|
||||
/* run test */
|
||||
ret = snd_soc_register_card(&kunit_comp->card);
|
||||
if (ret != 0 && ret != -EPROBE_DEFER)
|
||||
KUNIT_FAIL(test, "Failed to register card");
|
||||
|
||||
ret = snd_soc_component_initialize(&kunit_comp->comp, &test_component_null_fw, test_dev);
|
||||
KUNIT_EXPECT_EQ(test, 0, ret);
|
||||
|
||||
ret = snd_soc_add_component(&kunit_comp->comp, NULL, 0);
|
||||
ret = snd_soc_register_component(component, &test_component_null_fw, NULL, 0);
|
||||
KUNIT_EXPECT_EQ(test, 0, ret);
|
||||
|
||||
/* cleanup */
|
||||
|
|
@ -375,6 +379,7 @@ static void snd_soc_tplg_test_load_with_null_fw(struct kunit *test)
|
|||
static void snd_soc_tplg_test_load_empty_tplg(struct kunit *test)
|
||||
{
|
||||
struct kunit_soc_component *kunit_comp;
|
||||
struct snd_soc_component *component;
|
||||
struct tplg_tmpl_001 *data;
|
||||
int size;
|
||||
int ret;
|
||||
|
|
@ -401,15 +406,17 @@ static void snd_soc_tplg_test_load_empty_tplg(struct kunit *test)
|
|||
kunit_comp->card.num_links = ARRAY_SIZE(kunit_dai_links);
|
||||
kunit_comp->card.fully_routed = true;
|
||||
|
||||
component = snd_soc_component_alloc(test_dev);
|
||||
KUNIT_ASSERT_NOT_NULL(test, component);
|
||||
|
||||
snd_soc_component_set_priv(component, kunit_comp);
|
||||
|
||||
/* run test */
|
||||
ret = snd_soc_register_card(&kunit_comp->card);
|
||||
if (ret != 0 && ret != -EPROBE_DEFER)
|
||||
KUNIT_FAIL(test, "Failed to register card");
|
||||
|
||||
ret = snd_soc_component_initialize(&kunit_comp->comp, &test_component, test_dev);
|
||||
KUNIT_EXPECT_EQ(test, 0, ret);
|
||||
|
||||
ret = snd_soc_add_component(&kunit_comp->comp, NULL, 0);
|
||||
ret = snd_soc_register_component(component, &test_component, NULL, 0);
|
||||
KUNIT_EXPECT_EQ(test, 0, ret);
|
||||
|
||||
/* cleanup */
|
||||
|
|
@ -425,6 +432,7 @@ static void snd_soc_tplg_test_load_empty_tplg(struct kunit *test)
|
|||
static void snd_soc_tplg_test_load_empty_tplg_bad_magic(struct kunit *test)
|
||||
{
|
||||
struct kunit_soc_component *kunit_comp;
|
||||
struct snd_soc_component *component;
|
||||
struct tplg_tmpl_001 *data;
|
||||
int size;
|
||||
int ret;
|
||||
|
|
@ -456,15 +464,17 @@ static void snd_soc_tplg_test_load_empty_tplg_bad_magic(struct kunit *test)
|
|||
kunit_comp->card.num_links = ARRAY_SIZE(kunit_dai_links);
|
||||
kunit_comp->card.fully_routed = true;
|
||||
|
||||
component = snd_soc_component_alloc(test_dev);
|
||||
KUNIT_ASSERT_NOT_NULL(test, component);
|
||||
|
||||
snd_soc_component_set_priv(component, kunit_comp);
|
||||
|
||||
/* run test */
|
||||
ret = snd_soc_register_card(&kunit_comp->card);
|
||||
if (ret != 0 && ret != -EPROBE_DEFER)
|
||||
KUNIT_FAIL(test, "Failed to register card");
|
||||
|
||||
ret = snd_soc_component_initialize(&kunit_comp->comp, &test_component, test_dev);
|
||||
KUNIT_EXPECT_EQ(test, 0, ret);
|
||||
|
||||
ret = snd_soc_add_component(&kunit_comp->comp, NULL, 0);
|
||||
ret = snd_soc_register_component(component, &test_component, NULL, 0);
|
||||
KUNIT_EXPECT_EQ(test, 0, ret);
|
||||
|
||||
/* cleanup */
|
||||
|
|
@ -480,6 +490,7 @@ static void snd_soc_tplg_test_load_empty_tplg_bad_magic(struct kunit *test)
|
|||
static void snd_soc_tplg_test_load_empty_tplg_bad_abi(struct kunit *test)
|
||||
{
|
||||
struct kunit_soc_component *kunit_comp;
|
||||
struct snd_soc_component *component;
|
||||
struct tplg_tmpl_001 *data;
|
||||
int size;
|
||||
int ret;
|
||||
|
|
@ -511,15 +522,17 @@ static void snd_soc_tplg_test_load_empty_tplg_bad_abi(struct kunit *test)
|
|||
kunit_comp->card.num_links = ARRAY_SIZE(kunit_dai_links);
|
||||
kunit_comp->card.fully_routed = true;
|
||||
|
||||
component = snd_soc_component_alloc(test_dev);
|
||||
KUNIT_ASSERT_NOT_NULL(test, component);
|
||||
|
||||
snd_soc_component_set_priv(component, kunit_comp);
|
||||
|
||||
/* run test */
|
||||
ret = snd_soc_register_card(&kunit_comp->card);
|
||||
if (ret != 0 && ret != -EPROBE_DEFER)
|
||||
KUNIT_FAIL(test, "Failed to register card");
|
||||
|
||||
ret = snd_soc_component_initialize(&kunit_comp->comp, &test_component, test_dev);
|
||||
KUNIT_EXPECT_EQ(test, 0, ret);
|
||||
|
||||
ret = snd_soc_add_component(&kunit_comp->comp, NULL, 0);
|
||||
ret = snd_soc_register_component(component, &test_component, NULL, 0);
|
||||
KUNIT_EXPECT_EQ(test, 0, ret);
|
||||
|
||||
/* cleanup */
|
||||
|
|
@ -535,6 +548,7 @@ static void snd_soc_tplg_test_load_empty_tplg_bad_abi(struct kunit *test)
|
|||
static void snd_soc_tplg_test_load_empty_tplg_bad_size(struct kunit *test)
|
||||
{
|
||||
struct kunit_soc_component *kunit_comp;
|
||||
struct snd_soc_component *component;
|
||||
struct tplg_tmpl_001 *data;
|
||||
int size;
|
||||
int ret;
|
||||
|
|
@ -566,15 +580,17 @@ static void snd_soc_tplg_test_load_empty_tplg_bad_size(struct kunit *test)
|
|||
kunit_comp->card.num_links = ARRAY_SIZE(kunit_dai_links);
|
||||
kunit_comp->card.fully_routed = true;
|
||||
|
||||
component = snd_soc_component_alloc(test_dev);
|
||||
KUNIT_ASSERT_NOT_NULL(test, component);
|
||||
|
||||
snd_soc_component_set_priv(component, kunit_comp);
|
||||
|
||||
/* run test */
|
||||
ret = snd_soc_register_card(&kunit_comp->card);
|
||||
if (ret != 0 && ret != -EPROBE_DEFER)
|
||||
KUNIT_FAIL(test, "Failed to register card");
|
||||
|
||||
ret = snd_soc_component_initialize(&kunit_comp->comp, &test_component, test_dev);
|
||||
KUNIT_EXPECT_EQ(test, 0, ret);
|
||||
|
||||
ret = snd_soc_add_component(&kunit_comp->comp, NULL, 0);
|
||||
ret = snd_soc_register_component(component, &test_component, NULL, 0);
|
||||
KUNIT_EXPECT_EQ(test, 0, ret);
|
||||
|
||||
/* cleanup */
|
||||
|
|
@ -590,6 +606,7 @@ static void snd_soc_tplg_test_load_empty_tplg_bad_size(struct kunit *test)
|
|||
static void snd_soc_tplg_test_load_empty_tplg_bad_payload_size(struct kunit *test)
|
||||
{
|
||||
struct kunit_soc_component *kunit_comp;
|
||||
struct snd_soc_component *component;
|
||||
struct tplg_tmpl_001 *data;
|
||||
int size;
|
||||
int ret;
|
||||
|
|
@ -622,15 +639,17 @@ static void snd_soc_tplg_test_load_empty_tplg_bad_payload_size(struct kunit *tes
|
|||
kunit_comp->card.num_links = ARRAY_SIZE(kunit_dai_links);
|
||||
kunit_comp->card.fully_routed = true;
|
||||
|
||||
component = snd_soc_component_alloc(test_dev);
|
||||
KUNIT_ASSERT_NOT_NULL(test, component);
|
||||
|
||||
snd_soc_component_set_priv(component, kunit_comp);
|
||||
|
||||
/* run test */
|
||||
ret = snd_soc_register_card(&kunit_comp->card);
|
||||
if (ret != 0 && ret != -EPROBE_DEFER)
|
||||
KUNIT_FAIL(test, "Failed to register card");
|
||||
|
||||
ret = snd_soc_component_initialize(&kunit_comp->comp, &test_component, test_dev);
|
||||
KUNIT_EXPECT_EQ(test, 0, ret);
|
||||
|
||||
ret = snd_soc_add_component(&kunit_comp->comp, NULL, 0);
|
||||
ret = snd_soc_register_component(component, &test_component, NULL, 0);
|
||||
KUNIT_EXPECT_EQ(test, 0, ret);
|
||||
|
||||
/* cleanup */
|
||||
|
|
@ -644,6 +663,7 @@ static void snd_soc_tplg_test_load_empty_tplg_bad_payload_size(struct kunit *tes
|
|||
static void snd_soc_tplg_test_load_pcm_tplg(struct kunit *test)
|
||||
{
|
||||
struct kunit_soc_component *kunit_comp;
|
||||
struct snd_soc_component *component;
|
||||
u8 *data;
|
||||
int size;
|
||||
int ret;
|
||||
|
|
@ -670,15 +690,17 @@ static void snd_soc_tplg_test_load_pcm_tplg(struct kunit *test)
|
|||
kunit_comp->card.num_links = ARRAY_SIZE(kunit_dai_links);
|
||||
kunit_comp->card.fully_routed = true;
|
||||
|
||||
component = snd_soc_component_alloc(test_dev);
|
||||
KUNIT_ASSERT_NOT_NULL(test, component);
|
||||
|
||||
snd_soc_component_set_priv(component, kunit_comp);
|
||||
|
||||
/* run test */
|
||||
ret = snd_soc_register_card(&kunit_comp->card);
|
||||
if (ret != 0 && ret != -EPROBE_DEFER)
|
||||
KUNIT_FAIL(test, "Failed to register card");
|
||||
|
||||
ret = snd_soc_component_initialize(&kunit_comp->comp, &test_component, test_dev);
|
||||
KUNIT_EXPECT_EQ(test, 0, ret);
|
||||
|
||||
ret = snd_soc_add_component(&kunit_comp->comp, NULL, 0);
|
||||
ret = snd_soc_register_component(component, &test_component, NULL, 0);
|
||||
KUNIT_EXPECT_EQ(test, 0, ret);
|
||||
|
||||
snd_soc_unregister_component(test_dev);
|
||||
|
|
@ -693,6 +715,7 @@ static void snd_soc_tplg_test_load_pcm_tplg(struct kunit *test)
|
|||
static void snd_soc_tplg_test_load_pcm_tplg_reload_comp(struct kunit *test)
|
||||
{
|
||||
struct kunit_soc_component *kunit_comp;
|
||||
struct snd_soc_component *component;
|
||||
u8 *data;
|
||||
int size;
|
||||
int ret;
|
||||
|
|
@ -720,16 +743,19 @@ static void snd_soc_tplg_test_load_pcm_tplg_reload_comp(struct kunit *test)
|
|||
kunit_comp->card.num_links = ARRAY_SIZE(kunit_dai_links);
|
||||
kunit_comp->card.fully_routed = true;
|
||||
|
||||
component = snd_soc_component_alloc(test_dev);
|
||||
KUNIT_ASSERT_NOT_NULL(test, component);
|
||||
|
||||
snd_soc_component_set_priv(component, kunit_comp);
|
||||
|
||||
/* run test */
|
||||
ret = snd_soc_register_card(&kunit_comp->card);
|
||||
if (ret != 0 && ret != -EPROBE_DEFER)
|
||||
KUNIT_FAIL(test, "Failed to register card");
|
||||
|
||||
for (i = 0; i < 100; i++) {
|
||||
ret = snd_soc_component_initialize(&kunit_comp->comp, &test_component, test_dev);
|
||||
KUNIT_EXPECT_EQ(test, 0, ret);
|
||||
|
||||
ret = snd_soc_add_component(&kunit_comp->comp, NULL, 0);
|
||||
ret = snd_soc_register_component(component, &test_component, NULL, 0);
|
||||
KUNIT_EXPECT_EQ(test, 0, ret);
|
||||
|
||||
snd_soc_unregister_component(test_dev);
|
||||
|
|
@ -745,6 +771,7 @@ static void snd_soc_tplg_test_load_pcm_tplg_reload_comp(struct kunit *test)
|
|||
static void snd_soc_tplg_test_load_pcm_tplg_reload_card(struct kunit *test)
|
||||
{
|
||||
struct kunit_soc_component *kunit_comp;
|
||||
struct snd_soc_component *component;
|
||||
u8 *data;
|
||||
int size;
|
||||
int ret;
|
||||
|
|
@ -772,11 +799,13 @@ static void snd_soc_tplg_test_load_pcm_tplg_reload_card(struct kunit *test)
|
|||
kunit_comp->card.num_links = ARRAY_SIZE(kunit_dai_links);
|
||||
kunit_comp->card.fully_routed = true;
|
||||
|
||||
/* run test */
|
||||
ret = snd_soc_component_initialize(&kunit_comp->comp, &test_component, test_dev);
|
||||
KUNIT_EXPECT_EQ(test, 0, ret);
|
||||
component = snd_soc_component_alloc(test_dev);
|
||||
KUNIT_ASSERT_NOT_NULL(test, component);
|
||||
|
||||
ret = snd_soc_add_component(&kunit_comp->comp, NULL, 0);
|
||||
snd_soc_component_set_priv(component, kunit_comp);
|
||||
|
||||
/* run test */
|
||||
ret = snd_soc_register_component(component, &test_component, NULL, 0);
|
||||
KUNIT_EXPECT_EQ(test, 0, ret);
|
||||
|
||||
for (i = 0; i < 100; i++) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user