ASoC: soc-core: tidyup with soc_find_component()
cover ASoC: soc-core: tidyup with soc_find_component()
Hi Mark
These are cleanup for soc_find_component().
I want to post soc-core cleanup patches,
and these are 1st step for it.
Kuninori Morimoto (4):
ASoC: soc-core: move soc_find_component()
ASoC: soc-core: soc_find_component() uses snd_soc_is_matching_component()
ASoC: soc-core: soc_find_component() uses snd_soc_dai_link_component
ASoC: soc-core: use soc_find_component() at snd_soc_find_dai()
sound/soc/soc-core.c | 76 +++++++++++++++++++++++----------------------------- 1 file changed, 33 insertions(+), 43 deletions(-)
Signature · 1 line
2.7.4
PATCH 1/4 ASoC: soc-core: move soc_find_component()
From: Kuninori Morimoto <[email protected]>
move soc_find_component() next to snd_soc_is_matching_component(). This is prepare for soc_find_component() cleanup
--- sound/soc/soc-core.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-)
sound/soc/soc-core.c +19 -19
@@ -760,6 +760,25 @@ static struct device_nodereturn of_node; } +static int snd_soc_is_matching_component ( +const struct snd_soc_dai_link_component *dlc, +struct snd_soc_component *component) +{ +struct device_node *component_of_node; + +if (!dlc) +return 0 ; + + component_of_node =soc_component_to_node (component); + +if (dlc->of_node && component_of_node != dlc->of_node) +return 0 ; +if (dlc->name &&strcmp (component->name, dlc->name)) +return 0 ; + +return 1 ; +} +static struct snd_soc_component *soc_find_component (const struct device_node *of_node,const char *name) {
@@ -782,25 +801,6 @@ static struct snd_soc_component *soc_find_component(return NULL ; } -static int snd_soc_is_matching_component ( -const struct snd_soc_dai_link_component *dlc, -struct snd_soc_component *component) -{ -struct device_node *component_of_node; - -if (!dlc) -return 0 ; - - component_of_node =soc_component_to_node (component); - -if (dlc->of_node && component_of_node != dlc->of_node) -return 0 ; -if (dlc->name &&strcmp (component->name, dlc->name)) -return 0 ; - -return 1 ; -} -/** * snd_soc_find_dai - Find a registered DAI *
Signature · 1 line
2.7.4
Mark Brown
maintainerApplied "ASoC: soc-core: move soc_find_component()" to the asoc tree
The patch
ASoC: soc-core: move soc_find_component()
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.3
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
7d7db5d3c3d849c2f877be3b4c9afa7f5b5257c2Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto <[email protected]>
Date: Thu, 20 Jun 2019 09:49:17 +0900
Subject: [PATCH] ASoC: soc-core: move soc_find_component()
move soc_find_component() next to snd_soc_is_matching_component(). This is prepare for soc_find_component() cleanup
--- sound/soc/soc-core.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-)
sound/soc/soc-core.c +19 -19
@@ -760,6 +760,25 @@ static struct device_nodereturn of_node; } +static int snd_soc_is_matching_component ( +const struct snd_soc_dai_link_component *dlc, +struct snd_soc_component *component) +{ +struct device_node *component_of_node; + +if (!dlc) +return 0 ; + + component_of_node =soc_component_to_node (component); + +if (dlc->of_node && component_of_node != dlc->of_node) +return 0 ; +if (dlc->name &&strcmp (component->name, dlc->name)) +return 0 ; + +return 1 ; +} +static struct snd_soc_component *soc_find_component (const struct device_node *of_node,const char *name) {
@@ -782,25 +801,6 @@ static struct snd_soc_component *soc_find_component(return NULL ; } -static int snd_soc_is_matching_component ( -const struct snd_soc_dai_link_component *dlc, -struct snd_soc_component *component) -{ -struct device_node *component_of_node; - -if (!dlc) -return 0 ; - - component_of_node =soc_component_to_node (component); - -if (dlc->of_node && component_of_node != dlc->of_node) -return 0 ; -if (dlc->name &&strcmp (component->name, dlc->name)) -return 0 ; - -return 1 ; -} -/** * snd_soc_find_dai - Find a registered DAI *
Signature · 1 line
2.20.1
PATCH 2/4 ASoC: soc-core: soc_find_component() uses snd_soc_is_matching_component()
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
ALSA SoC already has snd_soc_is_matching_component() to confirming matching component, but, soc_find_component() has original implementation to confirm component.
We shouldn't have duplicate implementation to do same things. This patch uses snd_soc_is_matching_component() at soc_find_component()
--- sound/soc/soc-core.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-)
sound/soc/soc-core.c +5 -9
@@ -780,22 +780,18 @@ static int snd_soc_is_matching_component( }static struct snd_soc_component *soc_find_component ( -const struct device_node *of_node,const char *name) +struct device_node *of_node,const char *name) {struct snd_soc_component *component; -struct device_node *component_of_node; +struct snd_soc_dai_link_component dlc;lockdep_assert_held (&client_mutex);for_each_component (component) { -if (of_node) { - component_of_node =soc_component_to_node (component); - -if (component_of_node == of_node) -return component; - }else if (name &&strcmp (component->name, name) ==0 ) { + dlc.name = name; + dlc.of_node = of_node; +if (snd_soc_is_matching_component (&dlc, component))return component; - } }return NULL ;
Signature · 1 line
2.7.4
Mark Brown
maintainerApplied "ASoC: soc-core: soc_find_component() uses snd_soc_is_matching_component()" to the asoc tree
The patch
ASoC: soc-core: soc_find_component() uses snd_soc_is_matching_component()
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.3
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
a9ec84966f6d887b9066029596eb361b5d2af214Mon Sep 17 00:00:00 2001
From: Kuninori Morimoto <[email protected]>
Date: Thu, 20 Jun 2019 09:49:23 +0900
Subject: [PATCH] ASoC: soc-core: soc_find_component() uses
snd_soc_is_matching_component()
ALSA SoC already has snd_soc_is_matching_component() to confirming matching component, but, soc_find_component() has original implementation to confirm component.
We shouldn't have duplicate implementation to do same things. This patch uses snd_soc_is_matching_component() at soc_find_component()
--- sound/soc/soc-core.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-)
sound/soc/soc-core.c +5 -9
@@ -780,22 +780,18 @@ static int snd_soc_is_matching_component( }static struct snd_soc_component *soc_find_component ( -const struct device_node *of_node,const char *name) +struct device_node *of_node,const char *name) {struct snd_soc_component *component; -struct device_node *component_of_node; +struct snd_soc_dai_link_component dlc;lockdep_assert_held (&client_mutex);for_each_component (component) { -if (of_node) { - component_of_node =soc_component_to_node (component); - -if (component_of_node == of_node) -return component; - }else if (name &&strcmp (component->name, name) ==0 ) { + dlc.name = name; + dlc.of_node = of_node; +if (snd_soc_is_matching_component (&dlc, component))return component; - } }return NULL ;
Signature · 1 line
2.20.1
PATCH 3/4 ASoC: soc-core: soc_find_component() uses snd_soc_dai_link_component
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
soc_find_component() is using "of_node" and "name" to finding component, but we should use snd_soc_dai_link_component now, because it is created to such purpose.
This patch uses snd_soc_dai_link_component for soc_find_component().
--- sound/soc/soc-core.c | 45 ++++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 25 deletions(-)
sound/soc/soc-core.c +20 -25
@@ -780,19 +780,15 @@ static int snd_soc_is_matching_component( }static struct snd_soc_component *soc_find_component ( -struct device_node *of_node,const char *name) +const struct snd_soc_dai_link_component *dlc) {struct snd_soc_component *component; -struct snd_soc_dai_link_component dlc;lockdep_assert_held (&client_mutex); -for_each_component (component) { - dlc.name = name; - dlc.of_node = of_node; -if (snd_soc_is_matching_component (&dlc, component)) +for_each_component (component) +if (snd_soc_is_matching_component (dlc, component))return component; - }return NULL ; }
@@ -1106,8 +1102,7 @@ static int soc_init_dai_link(struct snd_soc_card *card,* added to component list. */ if ((link->platforms->of_node || link->platforms->name) && - !soc_find_component (link->platforms->of_node, - link->platforms->name)) + !soc_find_component (link->platforms))return -EPROBE_DEFER ; }
@@ -1136,7 +1131,7 @@ static int soc_init_dai_link(struct snd_soc_card *card,* component list. */ if ((link->cpus->of_node || link->cpus->name) && - !soc_find_component (link->cpus->of_node, link->cpus->name)) + !soc_find_component (link->cpus))return -EPROBE_DEFER ;/*
@@ -1580,23 +1575,23 @@ static int soc_bind_aux_dev(struct snd_soc_card *card, int num) {struct snd_soc_aux_dev *aux_dev = &card->aux_dev[num];struct snd_soc_component *component; -const char *name; -struct device_node *codec_of_node; +struct snd_soc_dai_link_component dlc;if (aux_dev->codec_of_node || aux_dev->codec_name) {/* codecs, usually analog devices */ - name = aux_dev->codec_name; - codec_of_node = aux_dev->codec_of_node; - component =soc_find_component (codec_of_node, name); + dlc.name = aux_dev->codec_name; + dlc.of_node = aux_dev->codec_of_node; + component =soc_find_component (&dlc);if (!component) { -if (codec_of_node) - name =of_node_full_name (codec_of_node); +if (dlc.of_node) + dlc.name =of_node_full_name (dlc.of_node); goto err_defer; } }else if (aux_dev->name) {/* generic components */ - name = aux_dev->name; - component =soc_find_component (NULL , name); + dlc.name = aux_dev->name; + dlc.of_node =NULL ; + component =soc_find_component (&dlc);if (!component) goto err_defer; }else {
@@ -1610,7 +1605,7 @@ static int soc_bind_aux_dev(struct snd_soc_card *card, int num)return 0 ; err_defer: -dev_err (card->dev,"ASoC: %s not registered\n" , name); +dev_err (card->dev,"ASoC: %s not registered\n" , dlc.name);return -EPROBE_DEFER ; }
@@ -3661,11 +3656,11 @@ EXPORT_SYMBOL_GPL(snd_soc_of_parse_daifmt);int snd_soc_get_dai_id (struct device_node *ep) {struct snd_soc_component *component; -struct device_node *node; +struct snd_soc_dai_link_component dlc;int ret; - node =of_graph_get_port_parent (ep); - + dlc.of_node =of_graph_get_port_parent (ep); + dlc.name =NULL ;/* * For example HDMI case, HDMI has video/sound port, * but ALSA SoC needs sound port number only.
@@ -3674,13 +3669,13 @@ int snd_soc_get_dai_id(struct device_node *ep)*/ ret = -ENOTSUPP ;mutex_lock (&client_mutex); - component =soc_find_component (node,NULL ); + component =soc_find_component (&dlc);if (component && component->driver->of_xlate_dai_id) ret = component->driver->of_xlate_dai_id (component, ep);mutex_unlock (&client_mutex); -of_node_put (node); +of_node_put (dlc.of_node);return ret; }
Signature · 1 line
2.7.4
Mark Brown
maintainerApplied "ASoC: soc-core: soc_find_component() uses snd_soc_dai_link_component" to the asoc tree
The patch
ASoC: soc-core: soc_find_component() uses snd_soc_dai_link_component
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.3
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
c1e230f0f7a3cc640317aa78389258a2fa54bcdeMon Sep 17 00:00:00 2001
From: Kuninori Morimoto <[email protected]>
Date: Thu, 20 Jun 2019 09:49:27 +0900
Subject: [PATCH] ASoC: soc-core: soc_find_component() uses
snd_soc_dai_link_component
soc_find_component() is using "of_node" and "name" to finding component, but we should use snd_soc_dai_link_component now, because it is created to such purpose.
This patch uses snd_soc_dai_link_component for soc_find_component().
--- sound/soc/soc-core.c | 45 ++++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 25 deletions(-)
sound/soc/soc-core.c +20 -25
@@ -780,19 +780,15 @@ static int snd_soc_is_matching_component( }static struct snd_soc_component *soc_find_component ( -struct device_node *of_node,const char *name) +const struct snd_soc_dai_link_component *dlc) {struct snd_soc_component *component; -struct snd_soc_dai_link_component dlc;lockdep_assert_held (&client_mutex); -for_each_component (component) { - dlc.name = name; - dlc.of_node = of_node; -if (snd_soc_is_matching_component (&dlc, component)) +for_each_component (component) +if (snd_soc_is_matching_component (dlc, component))return component; - }return NULL ; }
@@ -1106,8 +1102,7 @@ static int soc_init_dai_link(struct snd_soc_card *card,* added to component list. */ if ((link->platforms->of_node || link->platforms->name) && - !soc_find_component (link->platforms->of_node, - link->platforms->name)) + !soc_find_component (link->platforms))return -EPROBE_DEFER ; }
@@ -1136,7 +1131,7 @@ static int soc_init_dai_link(struct snd_soc_card *card,* component list. */ if ((link->cpus->of_node || link->cpus->name) && - !soc_find_component (link->cpus->of_node, link->cpus->name)) + !soc_find_component (link->cpus))return -EPROBE_DEFER ;/*
@@ -1580,23 +1575,23 @@ static int soc_bind_aux_dev(struct snd_soc_card *card, int num) {struct snd_soc_aux_dev *aux_dev = &card->aux_dev[num];struct snd_soc_component *component; -const char *name; -struct device_node *codec_of_node; +struct snd_soc_dai_link_component dlc;if (aux_dev->codec_of_node || aux_dev->codec_name) {/* codecs, usually analog devices */ - name = aux_dev->codec_name; - codec_of_node = aux_dev->codec_of_node; - component =soc_find_component (codec_of_node, name); + dlc.name = aux_dev->codec_name; + dlc.of_node = aux_dev->codec_of_node; + component =soc_find_component (&dlc);if (!component) { -if (codec_of_node) - name =of_node_full_name (codec_of_node); +if (dlc.of_node) + dlc.name =of_node_full_name (dlc.of_node); goto err_defer; } }else if (aux_dev->name) {/* generic components */ - name = aux_dev->name; - component =soc_find_component (NULL , name); + dlc.name = aux_dev->name; + dlc.of_node =NULL ; + component =soc_find_component (&dlc);if (!component) goto err_defer; }else {
@@ -1610,7 +1605,7 @@ static int soc_bind_aux_dev(struct snd_soc_card *card, int num)return 0 ; err_defer: -dev_err (card->dev,"ASoC: %s not registered\n" , name); +dev_err (card->dev,"ASoC: %s not registered\n" , dlc.name);return -EPROBE_DEFER ; }
@@ -3661,11 +3656,11 @@ EXPORT_SYMBOL_GPL(snd_soc_of_parse_daifmt);int snd_soc_get_dai_id (struct device_node *ep) {struct snd_soc_component *component; -struct device_node *node; +struct snd_soc_dai_link_component dlc;int ret; - node =of_graph_get_port_parent (ep); - + dlc.of_node =of_graph_get_port_parent (ep); + dlc.name =NULL ;/* * For example HDMI case, HDMI has video/sound port, * but ALSA SoC needs sound port number only.
@@ -3674,13 +3669,13 @@ int snd_soc_get_dai_id(struct device_node *ep)*/ ret = -ENOTSUPP ;mutex_lock (&client_mutex); - component =soc_find_component (node,NULL ); + component =soc_find_component (&dlc);if (component && component->driver->of_xlate_dai_id) ret = component->driver->of_xlate_dai_id (component, ep);mutex_unlock (&client_mutex); -of_node_put (node); +of_node_put (dlc.of_node);return ret; }
Signature · 1 line
2.20.1
PATCH 4/4 ASoC: soc-core: use soc_find_component() at snd_soc_find_dai()
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
snd_soc_find_dai() finds component first via specified snd_soc_dai_link_component, and find DAI from it.
We already have soc_find_component() to find component, but soc_find_dai() has original implementation to find component.
We shouldn't have duplicate implementation to do same things. This patch uses soc_find_component() at soc_find_dai()
--- sound/soc/soc-core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
sound/soc/soc-core.c +2 -3
@@ -813,9 +813,8 @@ struct snd_soc_dai *snd_soc_find_dai(lockdep_assert_held (&client_mutex);/* Find CPU DAI from registered DAIs */ -for_each_component (component) { -if (!snd_soc_is_matching_component (dlc, component)) -continue ; + component =soc_find_component (dlc); +if (component) {for_each_component_dais (component, dai) { if (dlc->dai_name && strcmp(dai->name, dlc->dai_name) && (!dai->driver->name
Signature · 1 line
2.7.4
Mark Brown
maintainerApplied "ASoC: soc-core: use soc_find_component() at snd_soc_find_dai()" to the asoc tree
The patch
ASoC: soc-core: use soc_find_component() at snd_soc_find_dai()
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.3
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
b9f2e25c599bbbf0646957e07ebb72b942c286ccMon Sep 17 00:00:00 2001
From: Kuninori Morimoto <[email protected]>
Date: Thu, 20 Jun 2019 09:49:33 +0900
Subject: [PATCH] ASoC: soc-core: use soc_find_component() at
snd_soc_find_dai()
snd_soc_find_dai() finds component first via specified snd_soc_dai_link_component, and find DAI from it.
We already have soc_find_component() to find component, but soc_find_dai() has original implementation to find component.
We shouldn't have duplicate implementation to do same things. This patch uses soc_find_component() at soc_find_dai()
--- sound/soc/soc-core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
sound/soc/soc-core.c +2 -3
@@ -813,9 +813,8 @@ struct snd_soc_dai *snd_soc_find_dai(lockdep_assert_held (&client_mutex);/* Find CPU DAI from registered DAIs */ -for_each_component (component) { -if (!snd_soc_is_matching_component (dlc, component)) -continue ; + component =soc_find_component (dlc); +if (component) {for_each_component_dais (component, dai) { if (dlc->dai_name && strcmp(dai->name, dlc->dai_name) && (!dai->driver->name
Signature · 1 line
2.20.1