ASoC: add new Component functions
Subsystems (3)
v2 cover ASoC: add new Component functions
Hi Mark
This is v2 patch-set
I'm now posting ASoC Capsuling patches.
Current status, and this patch-set postion is below. This patch-set moves Card related functions to soc-card.c
x: done
o: This patch-set
[x] move DAI functions
[x] add new DAI functions
[x] move Component functions
[x] move Card functions
[o] add new Component functions
[ ] rename DAI/Component list
[ ] move Card functions v2
[ ] add new Card functions
[ ] adjust Test
[ ] use new Card register
[ ] use new functions on all drivers
[ ] Capsule DAI/Component/Card
v1 -> v2
- Care CONFIG_REGMAP
- Add new snd_soc_component_unregister() and fixup soc-generic-dmaengine-pcm.c issue
- keep snd_soc_component_regmap_xxx() in soc-component.c
- tidyup function doc
- tidyup git-log
- add Reviewed-by from Alvin
Kuninori Morimoto (27):
ASoC: soc-generic-dmaengine-pcm: move devm_snd_dmaengine_pcm_register()
ASoC: soc-component: rename snd_soc_component_{init/exit}_regmap() to snd_soc_component_regmap_{init/exit}()
ASoC: soc-component: rename snd_soc_component_regmap_val_bytes()
ASoC: soc-component: rename snd_soc_component_regmap_cache_sync()
ASoC: soc-component: align snd_soc_component_{regmap/regcache}_xxx() functions
ASoC: soc-core: move snd_soc_del_component_unlocked()
ASoC: soc-core: add missing snd_soc_component_unregister()
ASoC: soc-generic-dmaengine-pcm: use snd_soc_component_unregister()
ASoC: soc-devres: use snd_soc_component_unregister() for devm_snd_soc_register_component()
ASoC: soc-core: remove snd_soc_unregister_component_by_driver()
ASoC: soc-component: move snd_soc_register_[un]component() to soc-component.c
ASoC: soc-component: move devm_snd_soc_component_register()
ASoC: soc-component: move snd_soc_of_xlate_dai_name() to soc-component.c
ASoC: soc-component: add snd_soc_component_name_prefix()
ASoC: soc-component: add snd_soc_component_to_dev()
ASoC: soc-component: add snd_soc_component_to_driver()
ASoC: soc-component: add snd_soc_component_to_card()
ASoC: soc-component: add snd_soc_component_to_debugfs_root()
ASoC: soc-component: add snd_soc_component_to_regmap()
ASoC: soc-component: add snd_soc_component_regcache_mark_dirty()
ASoC: soc-component: add snd_soc_component_regcache_cache_only()
ASoC: soc-component: add snd_soc_component_regcache_cache_bypass()
ASoC: soc-component: add snd_soc_component_regmap_multi_reg_write_bypassed()
ASoC: soc-component: add snd_soc_component_num_dai()
ASoC: soc-component: add snd_soc_component_connect_dai()
ASoC: soc-component: add snd_soc_component_active_update()
ASoC: soc-component: add snd_soc_component_device_link_{add/del}()
include/sound/soc-component.h | 42 ++- include/sound/soc.h | 14 - sound/soc/soc-card.c | 22 +- sound/soc/soc-component.c | 515 +++++++++++++++++++++++--- sound/soc/soc-core.c | 245 ------------ sound/soc/soc-dai.c | 5 +- sound/soc/soc-devres.c | 80 ---- sound/soc/soc-generic-dmaengine-pcm.c | 38 +- sound/soc/soc-internal.h | 4 + sound/soc/soc-pcm.c | 2 +- 10 files changed, 552 insertions(+), 415 deletions(-)
Signature · 1 line
2.53.0
PATCH v2 1/27 ASoC: soc-generic-dmaengine-pcm: move devm_snd_dmaengine_pcm_register()
We don't need to have dmaengine related function in soc-devres.c. Let's move it.
--- sound/soc/soc-devres.c | 40 --------------------------- sound/soc/soc-generic-dmaengine-pcm.c | 36 ++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 40 deletions(-)
sound/soc/soc-devres.c +0 -40
@@ -63,43 +63,3 @@ int devm_snd_soc_register_card(struct device *dev, struct snd_soc_card *card)return snd_soc_register_card (card); }EXPORT_SYMBOL_GPL (devm_snd_soc_register_card); - -#ifdef CONFIG_SND_SOC_GENERIC_DMAENGINE_PCM - -static void devm_dmaengine_pcm_release (struct device *dev,void *res) -{ -snd_dmaengine_pcm_unregister (*(struct device **)res); -} - -/** -* devm_snd_dmaengine_pcm_register - resource managed dmaengine PCM registration -* @dev: The parent device for the PCM device -* @config: Platform specific PCM configuration -* @flags: Platform specific quirks -* -* Register a dmaengine based PCM device with automatic unregistration when the -* device is unregistered. -*/ -int devm_snd_dmaengine_pcm_register (struct device *dev, -const struct snd_dmaengine_pcm_config *config,unsigned int flags) -{ -struct device **ptr; -int ret; - - ptr =devres_alloc (devm_dmaengine_pcm_release,sizeof (*ptr),GFP_KERNEL ); -if (!ptr) -return -ENOMEM ; - - ret =snd_dmaengine_pcm_register (dev, config, flags); -if (ret ==0 ) { - *ptr = dev; -devres_add (dev, ptr); - }else { -devres_free (ptr); - } - -return ret; -} -EXPORT_SYMBOL_GPL (devm_snd_dmaengine_pcm_register); - -#endif
sound/soc/soc-generic-dmaengine-pcm.c +36 -0
@@ -520,5 +520,41 @@ void snd_dmaengine_pcm_unregister(struct device *dev) }EXPORT_SYMBOL_GPL (snd_dmaengine_pcm_unregister); +static void devm_dmaengine_pcm_release (struct device *dev,void *res) +{ +snd_dmaengine_pcm_unregister (*(struct device **)res); +} + +/** +* devm_snd_dmaengine_pcm_register - resource managed dmaengine PCM registration +* @dev: The parent device for the PCM device +* @config: Platform specific PCM configuration +* @flags: Platform specific quirks +* +* Register a dmaengine based PCM device with automatic unregistration when the +* device is unregistered. +*/ +int devm_snd_dmaengine_pcm_register (struct device *dev, +const struct snd_dmaengine_pcm_config *config,unsigned int flags) +{ +struct device **ptr; +int ret; + + ptr =devres_alloc (devm_dmaengine_pcm_release,sizeof (*ptr),GFP_KERNEL ); +if (!ptr) +return -ENOMEM ; + + ret =snd_dmaengine_pcm_register (dev, config, flags); +if (ret ==0 ) { + *ptr = dev; +devres_add (dev, ptr); + }else { +devres_free (ptr); + } + +return ret; +} +EXPORT_SYMBOL_GPL (devm_snd_dmaengine_pcm_register); +MODULE_DESCRIPTION ("ASoC helpers for generic PCM dmaengine API" );MODULE_LICENSE ("GPL" );
Signature · 1 line
2.53.0
PATCH v2 2/27 ASoC: soc-component: rename snd_soc_component_{init/exit}_regmap() to snd_soc_component_regmap_{init/exit}()
In reply to Kuninori Morimotostruct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.
We already have snd_soc_component_regmap_xxx() functions. Let's standardize the function names.
- snd_soc_component_{init/exit}_regmap()
+ snd_soc_component_regmap_{init/exit}()
--- include/sound/soc-component.h | 6 ++++-- sound/soc/soc-component.c | 14 +++++++------- 2 files changed, 11 insertions(+), 9 deletions(-)
include/sound/soc-component.h +4 -2
@@ -337,9 +337,9 @@ int snd_soc_component_regmap_val_bytes(struct snd_soc_component *component);int snd_soc_component_regmap_cache_sync (struct snd_soc_component *component);void snd_soc_component_regmap_async_complete (struct snd_soc_component *component);#ifdef CONFIG_REGMAP -void snd_soc_component_init_regmap (struct snd_soc_component *component, +void snd_soc_component_regmap_init (struct snd_soc_component *component,struct regmap *regmap); -void snd_soc_component_exit_regmap (struct snd_soc_component *component); +void snd_soc_component_regmap_exit (struct snd_soc_component *component);#endif int snd_soc_component_fixup_controls (struct snd_soc_component *component);
@@ -445,6 +445,8 @@ void snd_soc_pcm_component_delay(struct snd_pcm_substream *substream, snd_pcm_sframes_t *cpu_delay, snd_pcm_sframes_t *codec_delay);/* REMOVE ME */ +#define snd_soc_component_init_regmap snd_soc_component_regmap_init +#define snd_soc_component_exit_regmap snd_soc_component_regmap_exit#define snd_soc_component_cache_sync snd_soc_component_regmap_cache_sync#define snd_soc_component_async_complete snd_soc_component_regmap_async_complete#define snd_soc_lookup_component_nolocked snd_soc_component_lookup_nolock
sound/soc/soc-component.c +7 -7
@@ -435,7 +435,7 @@ EXPORT_SYMBOL_GPL(snd_soc_component_regmap_async_complete);#ifdef CONFIG_REGMAP /** -* snd_soc_component_init_regmap() - Initialize regmap instance for the +* snd_soc_component_regmap_init() - Initialize regmap instance for the * component * @component: The component for which to initialize the regmap instance * @regmap: The regmap instance that should be used by the component
@@ -445,30 +445,30 @@ EXPORT_SYMBOL_GPL(snd_soc_component_regmap_async_complete);* yet ready when the component is registered. The function must also be called * before the first IO attempt of the component. */ -void snd_soc_component_init_regmap (struct snd_soc_component *component, +void snd_soc_component_regmap_init (struct snd_soc_component *component,struct regmap *regmap) { component->regmap = regmap; } -EXPORT_SYMBOL_GPL (snd_soc_component_init_regmap); +EXPORT_SYMBOL_GPL (snd_soc_component_regmap_init);/** -* snd_soc_component_exit_regmap() - De-initialize regmap instance for the +* snd_soc_component_regmap_exit() - De-initialize regmap instance for the * component * @component: The component for which to de-initialize the regmap instance * * Calls regmap_exit() on the regmap instance associated to the component and * removes the regmap instance from the component. * -* This function should only be used if snd_soc_component_init_regmap() was used +* This function should only be used if snd_soc_component_regmap_init() was used * to initialize the regmap instance. */ -void snd_soc_component_exit_regmap (struct snd_soc_component *component) +void snd_soc_component_regmap_exit (struct snd_soc_component *component) {regmap_exit (component->regmap); component->regmap =NULL ; } -EXPORT_SYMBOL_GPL (snd_soc_component_exit_regmap); +EXPORT_SYMBOL_GPL (snd_soc_component_regmap_exit);#endif
Signature · 1 line
2.53.0
Re: [PATCH v2 02/27] ASoC: soc-component: rename snd_soc_component_{init/exit}_regmap() to snd_soc_component_regmap_{init/exit}()
Quoted 9 lines · Kuninori Morimoto
struct
snd_soc_componentwill be capsuled soon, its member will not be able to access from nonsoc-component.c.We already have
snd_soc_component_regmap_xxx()functions. Let's standardize the function names.
- snd_soc_component_{init/exit}_regmap()
+ snd_soc_component_regmap_{init/exit}()Signed-off-by Kuninori Morimoto <[email protected]>
Quoted 4 lines
--- include/sound/soc-component.h | 6 ++++-- sound/soc/soc-component.c | 14 +++++++------- 2 files changed, 11 insertions(+), 9 deletions(-)
PATCH v2 3/27 ASoC: soc-component: rename snd_soc_component_regmap_val_bytes()
In reply to Kuninori Morimotosnd_soc_component_regmap_val_bytes() (A) calls regmap_get_val_bytes() (B)
(A) snd_soc_component_regmap_ val_bytes()
(B) regmap_get_val_bytes()
^^^^
Let's align the function name to original function.
--- include/sound/soc-component.h | 3 ++- sound/soc/soc-component.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-)
include/sound/soc-component.h +2 -1
@@ -333,7 +333,7 @@ int snd_soc_component_stream_event(struct snd_soc_component *component,int snd_soc_component_set_bias_level (struct snd_soc_component *component,enum snd_soc_bias_level level); -int snd_soc_component_regmap_val_bytes (struct snd_soc_component *component); +int snd_soc_component_regmap_get_val_bytes (struct snd_soc_component *component);int snd_soc_component_regmap_cache_sync (struct snd_soc_component *component);void snd_soc_component_regmap_async_complete (struct snd_soc_component *component);#ifdef CONFIG_REGMAP
@@ -448,6 +448,7 @@ void snd_soc_pcm_component_delay(struct snd_pcm_substream *substream,#define snd_soc_component_init_regmap snd_soc_component_regmap_init#define snd_soc_component_exit_regmap snd_soc_component_regmap_exit#define snd_soc_component_cache_sync snd_soc_component_regmap_cache_sync +#define snd_soc_component_regmap_val_bytes snd_soc_component_regmap_get_val_bytes#define snd_soc_component_async_complete snd_soc_component_regmap_async_complete#define snd_soc_lookup_component_nolocked snd_soc_component_lookup_nolock#define snd_soc_lookup_component snd_soc_component_lookup
sound/soc/soc-component.c +2 -2
@@ -386,7 +386,7 @@ int snd_soc_component_of_xlate_dai_name(struct snd_soc_component *component,return -ENOTSUPP ; } -int snd_soc_component_regmap_val_bytes (struct snd_soc_component *component) +int snd_soc_component_regmap_get_val_bytes (struct snd_soc_component *component) {int val_bytes;
@@ -401,7 +401,7 @@ int snd_soc_component_regmap_val_bytes(struct snd_soc_component *component)return val_bytes; } -EXPORT_SYMBOL_GPL (snd_soc_component_regmap_val_bytes); +EXPORT_SYMBOL_GPL (snd_soc_component_regmap_get_val_bytes);/** * snd_soc_component_regmap_cache_sync() - Sync the register cache with the hardware
Signature · 1 line
2.53.0
Re: [PATCH v2 03/27] ASoC: soc-component: rename snd_soc_component_regmap_val_bytes()
Quoted 9 lines · Kuninori Morimoto
snd_soc_component_regmap_val_bytes()(A) callsregmap_get_val_bytes()(B)(A)
snd_soc_component_regmap_val_bytes()
(B)regmap_get_val_bytes()^^^^Let's align the function name to original function.
Signed-off-by Kuninori Morimoto <[email protected]>
Quoted 4 lines
--- include/sound/soc-component.h | 3 ++- sound/soc/soc-component.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-)
PATCH v2 4/27 ASoC: soc-component: rename snd_soc_component_regmap_cache_sync()
In reply to Kuninori Morimotosnd_soc_component_regmap_cache_sync() (A) calls regcache_sync() (B)
(A) snd_soc_component_regmap_cache_sync()
(B) reg cache_sync()
Let's align the function name to original function.
There is no snd_soc_component_regmap_cache_sync() user yet (function name change will be happen later when all new functions were ready to use). Don't need to care re-rename the function name in macro.
--- include/sound/soc-component.h | 4 ++-- sound/soc/soc-component.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-)
include/sound/soc-component.h +2 -2
@@ -334,8 +334,8 @@ int snd_soc_component_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level);int snd_soc_component_regmap_get_val_bytes (struct snd_soc_component *component); -int snd_soc_component_regmap_cache_sync (struct snd_soc_component *component);void snd_soc_component_regmap_async_complete (struct snd_soc_component *component); +int snd_soc_component_regcache_sync (struct snd_soc_component *component);#ifdef CONFIG_REGMAP void snd_soc_component_regmap_init (struct snd_soc_component *component,struct regmap *regmap);
@@ -447,7 +447,7 @@ void snd_soc_pcm_component_delay(struct snd_pcm_substream *substream,/* REMOVE ME */ #define snd_soc_component_init_regmap snd_soc_component_regmap_init#define snd_soc_component_exit_regmap snd_soc_component_regmap_exit -#define snd_soc_component_cache_sync snd_soc_component_regmap_cache_sync +#define snd_soc_component_cache_sync snd_soc_component_regcache_sync#define snd_soc_component_regmap_val_bytes snd_soc_component_regmap_get_val_bytes#define snd_soc_component_async_complete snd_soc_component_regmap_async_complete#define snd_soc_lookup_component_nolocked snd_soc_component_lookup_nolock
sound/soc/soc-component.c +3 -3
@@ -404,19 +404,19 @@ int snd_soc_component_regmap_get_val_bytes(struct snd_soc_component *component)EXPORT_SYMBOL_GPL (snd_soc_component_regmap_get_val_bytes);/** -* snd_soc_component_regmap_cache_sync() - Sync the register cache with the hardware +* snd_soc_component_regcache_sync() - Sync the register cache with the hardware * @component: COMPONENT to sync * * Note: This function will call regcache_sync() */ -int snd_soc_component_regmap_cache_sync (struct snd_soc_component *component) +int snd_soc_component_regcache_sync (struct snd_soc_component *component) {if (!component->regmap)return 0 ;return regcache_sync (component->regmap); } -EXPORT_SYMBOL_GPL (snd_soc_component_regmap_cache_sync); +EXPORT_SYMBOL_GPL (snd_soc_component_regcache_sync);/** * snd_soc_component_regmap_async_complete() - Ensure asynchronous I/O has completed
Signature · 1 line
2.53.0
Re: [PATCH v2 04/27] ASoC: soc-component: rename snd_soc_component_regmap_cache_sync()
Quoted 5 lines · Kuninori Morimoto
snd_soc_component_regmap_cache_sync()(A) callsregcache_sync()(B)(A)
snd_soc_component_regmap_cache_sync()
(B) regcache_sync()
Quoted 7 lines
Let's align the function name to original function.
There is no
snd_soc_component_regmap_cache_sync()user yet (function name change will be happen later when all new functions were ready to use). Don't need to care re-rename the function name in macro.Signed-off-by Kuninori Morimoto <[email protected]>
Quoted 4 lines
--- include/sound/soc-component.h | 4 ++-- sound/soc/soc-component.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-)
PATCH v2 5/27 ASoC: soc-component: align snd_soc_component_{regmap/regcache}_xxx() functions
In reply to Kuninori MorimotoCurrent soc-component.c has snd_soc_component_{regmap/regcache}_xxx(), but are located randumly. Let's align them.
No functional changes.
--- include/sound/soc-component.h | 6 +-- sound/soc/soc-component.c | 92 +++++++++++++++++------------------ 2 files changed, 49 insertions(+), 49 deletions(-)
include/sound/soc-component.h +3 -3
@@ -333,14 +333,14 @@ int snd_soc_component_stream_event(struct snd_soc_component *component,int snd_soc_component_set_bias_level (struct snd_soc_component *component,enum snd_soc_bias_level level); -int snd_soc_component_regmap_get_val_bytes (struct snd_soc_component *component); -void snd_soc_component_regmap_async_complete (struct snd_soc_component *component); -int snd_soc_component_regcache_sync (struct snd_soc_component *component);#ifdef CONFIG_REGMAP void snd_soc_component_regmap_init (struct snd_soc_component *component,struct regmap *regmap);void snd_soc_component_regmap_exit (struct snd_soc_component *component);#endif +int snd_soc_component_regmap_get_val_bytes (struct snd_soc_component *component); +void snd_soc_component_regmap_async_complete (struct snd_soc_component *component); +int snd_soc_component_regcache_sync (struct snd_soc_component *component);int snd_soc_component_fixup_controls (struct snd_soc_component *component); int snd_soc_component_add_controls(struct snd_soc_component *component,
sound/soc/soc-component.c +46 -46
104 lines not on this page · raw message
Signature · 1 line
2.53.0
Re: [PATCH v2 05/27] ASoC: soc-component: align snd_soc_component_{regmap/regcache}_xxx() functions
Quoted 5 lines · Kuninori Morimoto
Current
soc-component.chas snd_soc_component_{regmap/regcache}_xxx(), but are located randumly. Let's align them.
No functional changes.Signed-off-by Kuninori Morimoto <[email protected]>
Quoted 4 lines
--- include/sound/soc-component.h | 6 +-- sound/soc/soc-component.c | 92 +++++++++++++++++------------------ 2 files changed, 49 insertions(+), 49 deletions(-)
PATCH v2 6/27 ASoC: soc-core: move snd_soc_del_component_unlocked()
In reply to Kuninori MorimotoNo functional change, just for preparation for cleanup.
--- sound/soc/soc-core.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
sound/soc/soc-core.c +12 -12
@@ -1456,18 +1456,6 @@ static void convert_endianness_formats(struct snd_soc_pcm_stream *stream) stream->formats |= endianness_format_map[i]; } -static void snd_soc_del_component_unlocked (struct snd_soc_component *component) -{ -struct snd_soc_card *card = component->card; - -snd_soc_unregister_dais (component); - -if (card) -snd_soc_card_unbind (card, true); - -list_del (&component->list); -} -struct snd_soc_component *snd_soc_component_new (struct device *dev,const char *name,const struct snd_soc_component_driver *driver) {
@@ -1504,6 +1492,18 @@ struct snd_soc_component *snd_soc_component_new(struct device *dev, const char * }EXPORT_SYMBOL_GPL (snd_soc_component_new); +static void snd_soc_del_component_unlocked (struct snd_soc_component *component) +{ +struct snd_soc_card *card = component->card; + +snd_soc_unregister_dais (component); + +if (card) +snd_soc_card_unbind (card, true); + +list_del (&component->list); +} +int snd_soc_component_register (struct snd_soc_component *component,struct snd_soc_dai_driver *dai_drv,int num_dai)
Signature · 1 line
2.53.0
Re: [PATCH v2 06/27] ASoC: soc-core: move snd_soc_del_component_unlocked()
Quoted 3 lines · Kuninori Morimoto
No functional change, just for preparation for cleanup.
Signed-off-by Kuninori Morimoto <[email protected]>
Quoted 3 lines
--- sound/soc/soc-core.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
PATCH v2 7/27 ASoC: soc-core: add missing snd_soc_component_unregister()
In reply to Kuninori MorimotoCurrent soc-component has snd_soc_component_register() (A), but not have snd_soc_component_unregister() (B)
(A) snd_soc_component_register()
(B) snd_soc_component_unregister()
We can use snd_soc_del_component_unlocked() for (B). Let's add snd_soc_component_unregister().
--- include/sound/soc-component.h | 1 + sound/soc/soc-core.c | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-)
include/sound/soc-component.h +1 -0
@@ -275,6 +275,7 @@ struct snd_soc_component {struct snd_soc_dapm_context *snd_soc_component_to_dapm (struct snd_soc_component *component);struct snd_soc_component *snd_soc_component_new (struct device *dev,const char *name,const struct snd_soc_component_driver *driver); +void snd_soc_component_unregister (struct snd_soc_component *component);int snd_soc_component_register (struct snd_soc_component *component,struct snd_soc_dai_driver *dai_drv,int num_dai);
sound/soc/soc-core.c +11 -3
@@ -1492,7 +1492,7 @@ struct snd_soc_component *snd_soc_component_new(struct device *dev, const char * }EXPORT_SYMBOL_GPL (snd_soc_component_new); -static void snd_soc_del_component_unlocked (struct snd_soc_component *component) +static void snd_soc_component_unregister_unlocked (struct snd_soc_component *component) {struct snd_soc_card *card = component->card;
@@ -1504,6 +1504,14 @@ static void snd_soc_del_component_unlocked(struct snd_soc_component *component)list_del (&component->list); } +void snd_soc_component_unregister (struct snd_soc_component *component) +{ +guard (mutex)(&client_mutex); + +snd_soc_component_unregister_unlocked (component); +} +EXPORT_SYMBOL_GPL (snd_soc_component_unregister); +int snd_soc_component_register (struct snd_soc_component *component,struct snd_soc_dai_driver *dai_drv,int num_dai)
@@ -1539,7 +1547,7 @@ int snd_soc_component_register(struct snd_soc_component *component, err_cleanup:if (ret <0 ) -snd_soc_del_component_unlocked (component); +snd_soc_component_unregister_unlocked (component);return ret; }
@@ -1583,7 +1591,7 @@ void snd_soc_unregister_component_by_driver(struct device *dev,if (!component)break ; -snd_soc_del_component_unlocked (component); +snd_soc_component_unregister_unlocked (component); } }EXPORT_SYMBOL_GPL (snd_soc_unregister_component_by_driver);
Signature · 1 line
2.53.0
Re: [PATCH v2 07/27] ASoC: soc-core: add missing snd_soc_component_unregister()
Quoted 10 lines · Kuninori Morimoto
Current soc-component has
snd_soc_component_register()(A), but not havesnd_soc_component_unregister()(B)(A)
snd_soc_component_register()
(B)snd_soc_component_unregister()We can use
snd_soc_del_component_unlocked()for (B). Let's addsnd_soc_component_unregister().Signed-off-by Kuninori Morimoto <[email protected]>
Quoted 4 lines
--- include/sound/soc-component.h | 1 + sound/soc/soc-core.c | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-)
PATCH v2 8/27 ASoC: soc-generic-dmaengine-pcm: use snd_soc_component_unregister()
In reply to Kuninori MorimotoCurrent snd_dmaengine_pcm_unregister() (X) is using snd_soc_unregister_component_by_driver() (Y) to unregister component.
(X) void snd_dmaengine_pcm_unregister(...)
{
(Z) component = snd_soc_lookup_component(...);
...(p) pcm = snd_soc_component_to_priv(component);
(Y) snd_soc_unregister_component_by_driver(...);
(p) dmaengine_pcm_release_chan(pcm);
(p) kfree(pcm); }
But it try to unregister all components from dev (a).
(Y) void snd_soc_unregister_component(...)
{
...
while (1) {
(Z) component = snd_soc_lookup_component_nolocked(...);
...
(a) snd_soc_component_unregister(component);
}
}snd_dmaengine_pcm_unregister() (X) need to care/free pcm which is connected to component (= p). Both (X) and (Y) are using lookup_component (Z). So (X) can handle first component/pcm (p), but can't handle 2nd or more component/pcm eventhough (X) was called multiple times, because (Y) unregister all components. Let's call snd_soc_component_unregister() (a) instead of snd_soc_unregister_component_by_driver() (Y) in (X), and unregister target component only, not all.
--- sound/soc/soc-generic-dmaengine-pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/soc-generic-dmaengine-pcm.c +1 -1
@@ -514,7 +514,7 @@ void snd_dmaengine_pcm_unregister(struct device *dev) pcm =snd_soc_component_to_priv (component); -snd_soc_unregister_component_by_driver (dev, component->driver); +snd_soc_component_unregister (component);dmaengine_pcm_release_chan (pcm);kfree (pcm); }
Signature · 1 line
2.53.0
Re: [PATCH v2 08/27] ASoC: soc-generic-dmaengine-pcm: use snd_soc_component_unregister()
Quoted 34 lines · Kuninori Morimoto
Current
snd_dmaengine_pcm_unregister()(X) is usingsnd_soc_unregister_component_by_driver()(Y) to unregister component.(X) void
snd_dmaengine_pcm_unregister(...){ (Z) component = snd_soc_lookup_component(...); ...(p) pcm =
snd_soc_component_to_priv(component);(Y)
snd_soc_unregister_component_by_driver(...);
(p)dmaengine_pcm_release_chan(pcm);(p) kfree(pcm); }But it try to unregister all components from dev (a).
(Y) void
snd_soc_unregister_component(...){ ... while (1) { (Z) component = snd_soc_lookup_component_nolocked(...); ... (a) snd_soc_component_unregister(component); } }
snd_dmaengine_pcm_unregister()(X) need to care/free pcm which is connected to component (= p). Both (X) and (Y) are usinglookup_component(Z). So (X) can handle first component/pcm (p), but can't handle 2nd or more component/pcm eventhough (X) was called multiple times, because (Y) unregister all components. Let's callsnd_soc_component_unregister()(a) instead ofsnd_soc_unregister_component_by_driver()(Y) in (X), and unregister target component only, not all.
Quoted 3 lines
Signed-off-by Kuninori Morimoto <[email protected]>Reported-by Sashiko <[email protected]>
Quoted 3 lines
--- sound/soc/soc-generic-dmaengine-pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Re: [PATCH v2 08/27] ASoC: soc-generic-dmaengine-pcm: use snd_soc_component_unregister()
In reply to Kuninori MorimotoHi Kuninori,
Quoted 7 lines · Kuninori Morimoto
Current
snd_dmaengine_pcm_unregister()(X) is usingsnd_soc_unregister_component_by_driver()(Y) to unregister component.(X) void
snd_dmaengine_pcm_unregister(...){ (Z) component = snd_soc_lookup_component(...); ...
Sorry - I was a bit too quick to review this. I think there is another issue.
(Z) expanded is:
component = snd_soc_lookup_component(dev, SND_DMAENGINE_PCM_DRV_NAME);
which will walk the global component_list until it finds a component matching the dev and SND_DMAENGINE_PCM_DRV_NAME.
If there's more than one snd_dmaengine_pcm component registered on the same dev, how do we know that this lookup will pick the correct one?
It looks like the code was written with the assumption that there can only be one snd_dmaengine_pcm component per dev. But I didn't look at the history.
Does such a case exist? If not, maybe the easier solution (for now) is to check if one has already been registered before registering another one:
int snd_dmaengine_pcm_register(dev, config, flags)
{
component = snd_soc_lookup_component(dev, SND_DMAENGINE_PCM_DRV_NAME);
if (component)
return -EBUSY;
...
}Then you don't have to worry about the 2x unregister problem sashiko pointed out.
In general there are not many users of this lookup feature. Besides snd_dmaengine_pcm there's just mtk-soundcard-driver.c and fsl_asrc_dma.c. Both look a bit weird too. So maybe there's a way to get rid of it altogether...
Kind regards,
Alvin
Quoted 50 lines
(p) pcm =
snd_soc_component_to_priv(component);(Y)
snd_soc_unregister_component_by_driver(...);
(p)dmaengine_pcm_release_chan(pcm);(p) kfree(pcm); }But it try to unregister all components from dev (a).
(Y) void
snd_soc_unregister_component(...){ ... while (1) { (Z) component = snd_soc_lookup_component_nolocked(...); ... (a) snd_soc_component_unregister(component); } }
snd_dmaengine_pcm_unregister()(X) need to care/free pcm which is connected to component (= p). Both (X) and (Y) are usinglookup_component(Z). So (X) can handle first component/pcm (p), but can't handle 2nd or more component/pcm eventhough (X) was called multiple times, because (Y) unregister all components. Let's callsnd_soc_component_unregister()(a) instead ofsnd_soc_unregister_component_by_driver()(Y) in (X), and unregister target component only, not all.Signed-off-by Kuninori Morimoto <[email protected]>Reported-by Sashiko <[email protected]>--- sound/soc/soc-generic-dmaengine-pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)sound/soc/soc-generic-dmaengine-pcm.c +1
-1@@ -514,7 +514,7 @@ void snd_dmaengine_pcm_unregister(struct device *dev) pcm =snd_soc_component_to_priv (component); -snd_soc_unregister_component_by_driver (dev, component->driver); +snd_soc_component_unregister (component);dmaengine_pcm_release_chan (pcm);kfree (pcm); }Signature · 1 line
2.53.0
Re: [PATCH v2 08/27] ASoC: soc-generic-dmaengine-pcm: use snd_soc_component_unregister()
Hi Alvin
Thank you for your review
# Office365 is back !
Quoted 27 lines
(Z) expanded is:
component = snd_soc_lookup_component(dev, SND_DMAENGINE_PCM_DRV_NAME);which will walk the global
component_listuntil it finds a component matching the dev andSND_DMAENGINE_PCM_DRV_NAME.If there's more than one
snd_dmaengine_pcmcomponent registered on the same dev, how do we know that this lookup will pick the correct one?It looks like the code was written with the assumption that there can only be one
snd_dmaengine_pcmcomponent per dev. But I didn't look at the history.Does such a case exist? If not, maybe the easier solution (for now) is to check if one has already been registered before registering another one:
int
snd_dmaengine_pcm_register(dev, config, flags){ component = snd_soc_lookup_component(dev, SND_DMAENGINE_PCM_DRV_NAME); if (component) return -EBUSY; ... }
Quoted 7 lines
Then you don't have to worry about the 2x unregister problem sashiko pointed out.
In general there are not many users of this lookup feature. Besides
snd_dmaengine_pcmthere's justmtk-soundcard-driver.candfsl_asrc_dma.c. Both look a bit weird too. So maybe there's a way to get rid of it altogether...
Yes, sashiko has pointed that 2nd unregister() will be issue, but after careful consideration, the issue is not new unregister side, but driver side which is calling mulipul unregister().
The driver which is using devm_ register() shouldn't call unregister, IMO. I have posted that driver side fixup patch.
Thank you for your help !!
Best regards
---
Kuninori Morimoto
PATCH v2 9/27 ASoC: soc-devres: use snd_soc_component_unregister() for devm_snd_soc_register_component()
In reply to Kuninori MorimotoCurrent devm_snd_soc_register_component() (X) is using snd_soc_unregister_component() (Y) to unregiser component.
(X) static void devm_component_release(...)
{
...
(Y) snd_soc_unregister_component(...);
}
int devm_snd_soc_register_component(...)
{
...
ptr = devres_alloc(devm_component_release, ...);
...
}But now, (Y) will removes all components if multiple component were connected to dev.
We can use snd_soc_component_unregister() (Z) which unregiser only target component, not all. Let's use
(Y) snd_soc_unregister_component() // unregister all components
(Z) snd_soc_component_unregister() // unregister only target component
--- sound/soc/soc-devres.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-)
sound/soc/soc-devres.c +23 -12
@@ -11,9 +11,9 @@static void devm_component_release (struct device *dev,void *res) { -const struct snd_soc_component_driver **cmpnt_drv = res; +struct snd_soc_component **component = res; -snd_soc_unregister_component_by_driver (dev, *cmpnt_drv); +snd_soc_component_unregister (*component); }/**
@@ -30,21 +30,32 @@ int devm_snd_soc_register_component(struct device *dev,const struct snd_soc_component_driver *cmpnt_drv, struct snd_soc_dai_driver *dai_drv, int num_dai) { - const struct snd_soc_component_driver **ptr; -int ret; + const struct snd_soc_component **ptr; +struct snd_soc_component *component; +int ret = -ENOMEM ; + + component =snd_soc_component_new (dev,NULL , cmpnt_drv); +if (IS_ERR (component)) + goto err; ptr =devres_alloc (devm_component_release,sizeof (*ptr),GFP_KERNEL );if (!ptr) -return -ENOMEM ; + goto free_component; + + ret =snd_soc_component_register (component, dai_drv, num_dai); +if (ret <0 ) + goto free_devres; - ret =snd_soc_register_component (dev, cmpnt_drv, dai_drv, num_dai); -if (ret ==0 ) { - *ptr = cmpnt_drv; -devres_add (dev, ptr); - }else { -devres_free (ptr); - } + *ptr = component; +devres_add (dev, ptr); + +return ret; +free_devres: +devres_free (ptr); +free_component: +devm_kfree (dev, component); +err:return ret; }EXPORT_SYMBOL_GPL (devm_snd_soc_register_component);
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH v2 09/27] ASoC: soc-devres: use snd_soc_component_unregister() for devm_snd_soc_register_component()
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] ASoC: soc-devres: double list_del() in devm_component_release() on teardown --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [High] ASoC: soc-devres: double list_del() in devm_component_release() on teardown
--
commit 38a63673c76cb0aea6b0a6701713c1de6335cb5e
Author: Kuninori Morimoto <[email protected]>
ASoC: soc-devres: use snd_soc_component_unregister() for devm_snd_soc_register_component()
This commit changes devm_snd_soc_register_component() to store the registered struct snd_soc_component pointer in devres and pass it directly to snd_soc_component_unregister() on release.
Quoted 5 lines
sound/soc/soc-devres.c +0
-0
sound/soc/soc-devres.c line 17
Quoted 9 lines
sound/soc/soc-devres.c +2
-2@@ -11,9 +11,9 @@static void devm_component_release (struct device *dev,void *res) { -const struct snd_soc_component_driver **cmpnt_drv = res; +struct snd_soc_component **component = res; -snd_soc_unregister_component_by_driver (dev, *cmpnt_drv); +snd_soc_component_unregister (*component); }
[Severity: High]
Can devm_component_release() call list_del(&component->list) a second time if the driver already called snd_soc_unregister_component(dev)?
Previously, snd_soc_unregister_component_by_driver() looked up the component on component_list first, making devm_component_release() a no-op if it had already been removed. Now, calling snd_soc_component_unregister(*component) directly invokes snd_soc_component_unregister_unlocked(), which unconditionally runs list_del(&component->list) without checking whether the component is still linked.
Drivers that mix devm_snd_soc_register_component() with snd_soc_unregister_component(dev) will hit a double list_del() on a poisoned list head during teardown:
sound/soc/mediatek/mt8173/mt8173-afe-pcm.c:mt8173_afe_pcm_dev_probe() {
...
ret = devm_snd_soc_register_component(dev, &mtk_afe_pcm_platform,
NULL, 0);
if (ret)
goto err_pm;
ret = snd_soc_register_component(dev,
&mt8173_afe_pcm_dai_component,
mt8173_afe_pcm_dais,
ARRAY_SIZE(mt8173_afe_pcm_dais));
...
err_cleanup_components:
snd_soc_unregister_component(dev);
...
}mt8173_afe_pcm_dev_remove(), stm32_adfsdm_remove(), and tas_remove() in sound/soc/codecs/tas2783-sdw.c also call snd_soc_unregister_component() before devres_release_all() runs devm_component_release().
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=9
Re: [PATCH v2 09/27] ASoC: soc-devres: use snd_soc_component_unregister() for devm_snd_soc_register_component()
Hi ALSA ML
Quoted 11 lines
[Severity: High]
Candevm_component_release()calllist_del(&component->list)a second time if the driver already calledsnd_soc_unregister_component(dev)?Previously,
snd_soc_unregister_component_by_driver()looked up the component oncomponent_listfirst, makingdevm_component_release()a no-op if it had already been removed. Now, callingsnd_soc_component_unregister(*component)directly invokessnd_soc_component_unregister_unlocked(), which unconditionally runslist_del(&component->list)without checking whether the component is still linked.
Ah, good cache.
I will fixup it in v3
Thank you for your help !!
Best regards
---
Kuninori Morimoto
PATCH v2 10/27 ASoC: soc-core: remove snd_soc_unregister_component_by_driver()
In reply to Kuninori MorimotoNo one is using snd_soc_unregister_component_by_driver(). Let's remove it.
--- include/sound/soc.h | 4 +--- sound/soc/soc-core.c | 15 ++++----------- 2 files changed, 5 insertions(+), 14 deletions(-)
include/sound/soc.h +1 -3
@@ -454,9 +454,7 @@ int snd_soc_register_component(struct device *dev,int devm_snd_soc_register_component (struct device *dev,const struct snd_soc_component_driver *component_driver,struct snd_soc_dai_driver *dai_drv,int num_dai); -#define snd_soc_unregister_component (dev) snd_soc_unregister_component_by_driver(dev, NULL) -void snd_soc_unregister_component_by_driver (struct device *dev, -const struct snd_soc_component_driver *component_driver); +void snd_soc_unregister_component (struct device *dev);int soc_new_pcm (struct snd_soc_pcm_runtime *rtd);#ifdef CONFIG_SND_SOC_COMPRESS
sound/soc/soc-core.c +4 -11
@@ -1569,24 +1569,17 @@ int snd_soc_register_component(struct device *dev,EXPORT_SYMBOL_GPL (snd_soc_register_component);/** -* snd_soc_unregister_component_by_driver - Unregister component using a given driver +* snd_soc_unregister_component - Unregister component using a given driver * from the ASoC core * * @dev: The device to unregister -* @component_driver: The component driver to unregister */ -void snd_soc_unregister_component_by_driver (struct device *dev, -const struct snd_soc_component_driver *component_driver) +void snd_soc_unregister_component (struct device *dev) { -const char *driver_name =NULL ; - -if (component_driver) - driver_name = component_driver->name; -guard (mutex)(&client_mutex);while (1 ) { -struct snd_soc_component *component =snd_soc_lookup_component_nolocked (dev, driver_name); +struct snd_soc_component *component =snd_soc_lookup_component_nolocked (dev,NULL );if (!component)break ;
@@ -1594,7 +1587,7 @@ void snd_soc_unregister_component_by_driver(struct device *dev,snd_soc_component_unregister_unlocked (component); } } -EXPORT_SYMBOL_GPL (snd_soc_unregister_component_by_driver); +EXPORT_SYMBOL_GPL (snd_soc_unregister_component);/* Retrieve a card's name from device tree */ int snd_soc_of_parse_card_name(struct snd_soc_card *card,
Signature · 1 line
2.53.0
PATCH v2 11/27 ASoC: soc-component: move snd_soc_register_[un]component() to soc-component.c
In reply to Kuninori Morimotostruct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.
move snd_soc_register_[un]component() to soc-component.c
--- include/sound/soc-component.h | 8 ++ include/sound/soc.h | 9 -- sound/soc/soc-component.c | 214 ++++++++++++++++++++++++++++++++++ sound/soc/soc-core.c | 213 --------------------------------- 4 files changed, 222 insertions(+), 222 deletions(-)
include/sound/soc-component.h +8 -0
@@ -279,6 +279,14 @@ void snd_soc_component_unregister(struct snd_soc_component *component);int snd_soc_component_register (struct snd_soc_component *component,struct snd_soc_dai_driver *dai_drv,int num_dai); +int snd_soc_register_component (struct device *dev, +const struct snd_soc_component_driver *component_driver, +struct snd_soc_dai_driver *dai_drv,int num_dai); + +int devm_snd_soc_register_component (struct device *dev, +const struct snd_soc_component_driver *component_driver, +struct snd_soc_dai_driver *dai_drv,int num_dai); +void snd_soc_unregister_component (struct device *dev);const char *snd_soc_component_name (struct snd_soc_component *component);
include/sound/soc.h +0 -9
@@ -447,15 +447,6 @@ static inline int snd_soc_resume(struct device *dev) }#endif int snd_soc_poweroff (struct device *dev); -int snd_soc_register_component (struct device *dev, -const struct snd_soc_component_driver *component_driver, -struct snd_soc_dai_driver *dai_drv,int num_dai); - -int devm_snd_soc_register_component (struct device *dev, -const struct snd_soc_component_driver *component_driver, -struct snd_soc_dai_driver *dai_drv,int num_dai); -void snd_soc_unregister_component (struct device *dev); -int soc_new_pcm (struct snd_soc_pcm_runtime *rtd);#ifdef CONFIG_SND_SOC_COMPRESS int snd_soc_new_compress (struct snd_soc_pcm_runtime *rtd);
sound/soc/soc-component.c +214 -0
217 lines not on this page · raw message
sound/soc/soc-core.c +0 -213
219 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH v2 12/27 ASoC: soc-component: move devm_snd_soc_component_register()
In reply to Kuninori MorimotoWe don't need to have component related function in soc-devres.c. Let's move it.
--- sound/soc/soc-component.c | 51 +++++++++++++++++++++++++++++++++++++++ sound/soc/soc-devres.c | 51 --------------------------------------- 2 files changed, 51 insertions(+), 51 deletions(-)
sound/soc/soc-component.c +51 -0
@@ -1767,3 +1767,54 @@ void snd_soc_unregister_component(struct device *dev) } }EXPORT_SYMBOL_GPL (snd_soc_unregister_component); + +static void devm_component_release (struct device *dev,void *res) +{ +struct snd_soc_component **component = res; + +snd_soc_component_unregister (*component); +} + +/** +* devm_snd_soc_register_component - resource managed component registration +* @dev: Device used to manage component +* @cmpnt_drv: Component driver +* @dai_drv: DAI driver +* @num_dai: Number of DAIs to register +* +* Register a component with automatic unregistration when the device is +* unregistered. +*/ +int devm_snd_soc_register_component (struct device *dev, +const struct snd_soc_component_driver *cmpnt_drv, +struct snd_soc_dai_driver *dai_drv,int num_dai) +{ +const struct snd_soc_component **ptr; +struct snd_soc_component *component; +int ret = -ENOMEM ; + + component =snd_soc_component_new (dev,NULL , cmpnt_drv); +if (IS_ERR (component)) + goto err; + + ptr =devres_alloc (devm_component_release,sizeof (*ptr),GFP_KERNEL ); +if (!ptr) + goto free_component; + + ret =snd_soc_component_register (component, dai_drv, num_dai); +if (ret <0 ) + goto free_devres; + + *ptr = component; +devres_add (dev, ptr); + +return ret; + +free_devres: +devres_free (ptr); +free_component: +devm_kfree (dev, component); +err: +return ret; +} +EXPORT_SYMBOL_GPL (devm_snd_soc_register_component);
sound/soc/soc-devres.c +0 -51
57 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH v2 13/27 ASoC: soc-component: move snd_soc_of_xlate_dai_name() to soc-component.c
In reply to Kuninori Morimotostruct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.
move snd_soc_of_xlate_dai_name() to soc-component.c
This renames function name
- snd_soc_of_xlate_dai_name()
+ snd_soc_component_of_simple_xlate_dai_name().
--- include/sound/soc-component.h | 4 ++++ include/sound/soc.h | 3 --- sound/soc/soc-component.c | 33 +++++++++++++++++++++++++++++++++ sound/soc/soc-core.c | 33 --------------------------------- 4 files changed, 37 insertions(+), 36 deletions(-)
include/sound/soc-component.h +4 -0
@@ -401,6 +401,9 @@ int snd_soc_component_of_xlate_dai_id(struct snd_soc_component *component,int snd_soc_component_of_xlate_dai_name (struct snd_soc_component *component,const struct of_phandle_args *args,const char **dai_name); +int snd_soc_component_of_simple_xlate_dai_name (struct snd_soc_component *component, +const struct of_phandle_args *args, +const char **dai_name);int snd_soc_component_compr_open (struct snd_soc_component *component,struct snd_compr_stream *cstream); void snd_soc_component_compr_free(struct snd_soc_component *component,
@@ -462,5 +465,6 @@ void snd_soc_pcm_component_delay(struct snd_pcm_substream *substream,#define snd_soc_lookup_component_nolocked snd_soc_component_lookup_nolock#define snd_soc_lookup_component snd_soc_component_lookup#define snd_soc_lookup_component_by_name snd_soc_component_lookup_by_name +#define snd_soc_of_xlate_dai_name snd_soc_component_of_simple_xlate_dai_name#endif /* __SOC_COMPONENT_H */
include/sound/soc.h +0 -3
@@ -1303,9 +1303,6 @@ int snd_soc_of_parse_tdm_slot(struct device_node *np,unsigned int *rx_mask, unsigned int *slots, unsigned int *slot_width); -int snd_soc_of_xlate_dai_name (struct snd_soc_component *component, -const struct of_phandle_args *args, -const char **dai_name); void snd_soc_of_parse_node_prefix(struct device_node *np, struct snd_soc_codec_conf *codec_conf, struct device_node *of_node,
sound/soc/soc-component.c +33 -0
@@ -1818,3 +1818,36 @@ int devm_snd_soc_register_component(struct device *dev,return ret; }EXPORT_SYMBOL_GPL (devm_snd_soc_register_component); + +/** +* snd_soc_component_of_simple_xlate_dai_name - Resolve a sound-dai phandle argument to a +* DAI name by searching the component DAI list. +* @component: ASoC component to search. +* @args: Phandle arguments from the sound-dai property; args[0] is the +* DAI ID. +* @dai_name: Output pointer set to the matched DAI name on success. +* +* Return: 0 on success, -EINVAL if args_count != 1 or no match is found. +*/ +int snd_soc_component_of_simple_xlate_dai_name (struct snd_soc_component *component, +const struct of_phandle_args *args, +const char **dai_name) +{ +struct snd_soc_dai *dai; +int id; + +if (args->args_count !=1 ) +return -EINVAL ; + + id = args->args[0 ]; + +for_each_component_dais (component, dai) { +if (dai->driver->id == id) { + *dai_name =snd_soc_dai_name (dai); +return 0 ; + } + } + +return -EINVAL ; +} +EXPORT_SYMBOL_GPL (snd_soc_component_of_simple_xlate_dai_name);
sound/soc/soc-core.c +0 -33
@@ -1593,39 +1593,6 @@ int snd_soc_of_parse_tdm_slot(struct device_node *np, }EXPORT_SYMBOL_GPL (snd_soc_of_parse_tdm_slot); -/** -* snd_soc_of_xlate_dai_name - Resolve a sound-dai phandle argument to a -* DAI name by searching the component DAI list. -* @component: ASoC component to search. -* @args: Phandle arguments from the sound-dai property; args[0] is the -* DAI ID. -* @dai_name: Output pointer set to the matched DAI name on success. -* -* Return: 0 on success, -EINVAL if args_count != 1 or no match is found. -*/ -int snd_soc_of_xlate_dai_name (struct snd_soc_component *component, -const struct of_phandle_args *args, -const char **dai_name) -{ -struct snd_soc_dai *dai; -int id; - -if (args->args_count !=1 ) -return -EINVAL ; - - id = args->args[0 ]; - -for_each_component_dais (component, dai) { -if (dai->driver->id == id) { - *dai_name =snd_soc_dai_name (dai); -return 0 ; - } - } - -return -EINVAL ; -} -EXPORT_SYMBOL_GPL (snd_soc_of_xlate_dai_name); -void snd_soc_dlc_use_cpu_as_platform (struct snd_soc_dai_link_component *platforms,struct snd_soc_dai_link_component *cpus) {
Signature · 1 line
2.53.0
PATCH v2 14/27 ASoC: soc-component: add snd_soc_component_name_prefix()
In reply to Kuninori Morimotostruct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.
Add snd_soc_component_name_prefix() to soc-component.c
--- include/sound/soc-component.h | 1 + sound/soc/soc-component.c | 6 ++++++ 2 files changed, 7 insertions(+)
include/sound/soc-component.h +1 -0
@@ -289,6 +289,7 @@ int devm_snd_soc_register_component(struct device *dev,void snd_soc_unregister_component (struct device *dev);const char *snd_soc_component_name (struct snd_soc_component *component); +const char *snd_soc_component_name_prefix (struct snd_soc_component *component);void snd_soc_component_set_priv (struct snd_soc_component *component,void *priv);void *snd_soc_component_to_priv (struct snd_soc_component *component);
sound/soc/soc-component.c +6 -0
@@ -43,6 +43,12 @@ const char *snd_soc_component_name(struct snd_soc_component *component) }EXPORT_SYMBOL_GPL (snd_soc_component_name); +const char *snd_soc_component_name_prefix (struct snd_soc_component *component) +{ +return component->name_prefix; +} +EXPORT_SYMBOL_GPL (snd_soc_component_name_prefix); +void snd_soc_component_set_priv (struct snd_soc_component *component,void *priv) { component->priv = priv;
Signature · 1 line
2.53.0
PATCH v2 15/27 ASoC: soc-component: add snd_soc_component_to_dev()
In reply to Kuninori Morimotostruct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.
Add snd_soc_component_to_dev() to soc-component.c
--- include/sound/soc-component.h | 1 + sound/soc/soc-component.c | 6 ++++++ 2 files changed, 7 insertions(+)
include/sound/soc-component.h +1 -0
@@ -272,6 +272,7 @@ struct snd_soc_component {snd_soc_dai_to_list (dai) != &(component)->dai_list; \ dai = _dai, _dai = snd_soc_dai_from_list(snd_soc_dai_to_list(_dai)->next)) +struct device *snd_soc_component_to_dev (struct snd_soc_component *component);struct snd_soc_dapm_context *snd_soc_component_to_dapm (struct snd_soc_component *component);struct snd_soc_component *snd_soc_component_new (struct device *dev,const char *name,const struct snd_soc_component_driver *driver);
sound/soc/soc-component.c +6 -0
@@ -61,6 +61,12 @@ void *snd_soc_component_to_priv(struct snd_soc_component *component) }EXPORT_SYMBOL_GPL (snd_soc_component_to_priv); +struct device *snd_soc_component_to_dev (struct snd_soc_component *component) +{ +return component->dev; +} +EXPORT_SYMBOL_GPL (snd_soc_component_to_dev); +struct snd_soc_dapm_context *snd_soc_component_to_dapm (struct snd_soc_component *component) {return component->dapm;
Signature · 1 line
2.53.0
PATCH v2 16/27 ASoC: soc-component: add snd_soc_component_to_driver()
In reply to Kuninori Morimotostruct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.
Add snd_soc_component_to_driver() to soc-component.c
--- include/sound/soc-component.h | 2 ++ sound/soc/soc-component.c | 7 +++++++ 2 files changed, 9 insertions(+)
include/sound/soc-component.h +2 -0
@@ -274,6 +274,8 @@ struct snd_soc_component {struct device *snd_soc_component_to_dev (struct snd_soc_component *component);struct snd_soc_dapm_context *snd_soc_component_to_dapm (struct snd_soc_component *component); +const struct snd_soc_component_driver +*snd_soc_component_to_driver (struct snd_soc_component *component);struct snd_soc_component *snd_soc_component_new (struct device *dev,const char *name,const struct snd_soc_component_driver *driver);void snd_soc_component_unregister (struct snd_soc_component *component);
sound/soc/soc-component.c +7 -0
@@ -73,6 +73,13 @@ struct snd_soc_dapm_context *snd_soc_component_to_dapm(struct snd_soc_component }EXPORT_SYMBOL_GPL (snd_soc_component_to_dapm); +const struct snd_soc_component_driver * +snd_soc_component_to_driver (struct snd_soc_component *component) +{ +return component->driver; +} +EXPORT_SYMBOL_GPL (snd_soc_component_to_driver); +unsigned int snd_soc_component_active (struct snd_soc_component *component) {return component->active;
Signature · 1 line
2.53.0
PATCH v2 17/27 ASoC: soc-component: add snd_soc_component_to_card()
In reply to Kuninori Morimotostruct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.
Add snd_soc_component_to_card() to soc-component.c
--- include/sound/soc-component.h | 1 + sound/soc/soc-component.c | 6 ++++++ 2 files changed, 7 insertions(+)
include/sound/soc-component.h +1 -0
@@ -276,6 +276,7 @@ struct device *snd_soc_component_to_dev(struct snd_soc_component *component);struct snd_soc_dapm_context *snd_soc_component_to_dapm (struct snd_soc_component *component);const struct snd_soc_component_driver *snd_soc_component_to_driver (struct snd_soc_component *component); +struct snd_soc_card *snd_soc_component_to_card (struct snd_soc_component *component);struct snd_soc_component *snd_soc_component_new (struct device *dev,const char *name,const struct snd_soc_component_driver *driver);void snd_soc_component_unregister (struct snd_soc_component *component);
sound/soc/soc-component.c +6 -0
@@ -80,6 +80,12 @@ snd_soc_component_to_driver(struct snd_soc_component *component) }EXPORT_SYMBOL_GPL (snd_soc_component_to_driver); +struct snd_soc_card *snd_soc_component_to_card (struct snd_soc_component *component) +{ +return component->card; +} +EXPORT_SYMBOL_GPL (snd_soc_component_to_card); +unsigned int snd_soc_component_active (struct snd_soc_component *component) {return component->active;
Signature · 1 line
2.53.0
PATCH v2 18/27 ASoC: soc-component: add snd_soc_component_to_debugfs_root()
In reply to Kuninori Morimotostruct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.
This patch adds snd_soc_component_debugfs_root() to get component->debugfs_root.
--- include/sound/soc-component.h | 1 + sound/soc/soc-component.c | 6 ++++++ 2 files changed, 7 insertions(+)
include/sound/soc-component.h +1 -0
@@ -277,6 +277,7 @@ struct snd_soc_dapm_context *snd_soc_component_to_dapm(struct snd_soc_componentconst struct snd_soc_component_driver *snd_soc_component_to_driver (struct snd_soc_component *component);struct snd_soc_card *snd_soc_component_to_card (struct snd_soc_component *component); +struct dentry *snd_soc_component_to_debugfs_root (struct snd_soc_component *component);struct snd_soc_component *snd_soc_component_new (struct device *dev,const char *name,const struct snd_soc_component_driver *driver);void snd_soc_component_unregister (struct snd_soc_component *component);
sound/soc/soc-component.c +6 -0
@@ -86,6 +86,12 @@ struct snd_soc_card *snd_soc_component_to_card(struct snd_soc_component *compone }EXPORT_SYMBOL_GPL (snd_soc_component_to_card); +struct dentry *snd_soc_component_to_debugfs_root (struct snd_soc_component *component) +{ +return component->debugfs_root; +} +EXPORT_SYMBOL_GPL (snd_soc_component_to_debugfs_root); +unsigned int snd_soc_component_active (struct snd_soc_component *component) {return component->active;
Signature · 1 line
2.53.0
PATCH v2 19/27 ASoC: soc-component: add snd_soc_component_to_regmap()
In reply to Kuninori Morimotostruct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.
Add snd_soc_component_to_regmap() to soc-component.c
--- include/sound/soc-component.h | 1 + sound/soc/soc-component.c | 6 ++++++ 2 files changed, 7 insertions(+)
include/sound/soc-component.h +1 -0
@@ -278,6 +278,7 @@ const struct snd_soc_component_driver *snd_soc_component_to_driver(struct snd_soc_component *component);struct snd_soc_card *snd_soc_component_to_card (struct snd_soc_component *component);struct dentry *snd_soc_component_to_debugfs_root (struct snd_soc_component *component); +struct regmap *snd_soc_component_to_regmap (struct snd_soc_component *component);struct snd_soc_component *snd_soc_component_new (struct device *dev,const char *name,const struct snd_soc_component_driver *driver);void snd_soc_component_unregister (struct snd_soc_component *component);
sound/soc/soc-component.c +6 -0
@@ -92,6 +92,12 @@ struct dentry *snd_soc_component_to_debugfs_root(struct snd_soc_component *compo }EXPORT_SYMBOL_GPL (snd_soc_component_to_debugfs_root); +struct regmap *snd_soc_component_to_regmap (struct snd_soc_component *component) +{ +return component->regmap; +} +EXPORT_SYMBOL_GPL (snd_soc_component_to_regmap); +unsigned int snd_soc_component_active (struct snd_soc_component *component) {return component->active;
Signature · 1 line
2.53.0
PATCH v2 20/27 ASoC: soc-component: add snd_soc_component_regcache_mark_dirty()
In reply to Kuninori Morimotostruct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.
Adds snd_soc_component_regcache_mark_dirty().
--- include/sound/soc-component.h | 1 + sound/soc/soc-component.c | 9 +++++++++ 2 files changed, 10 insertions(+)
include/sound/soc-component.h +1 -0
@@ -357,6 +357,7 @@ void snd_soc_component_regmap_exit(struct snd_soc_component *component);int snd_soc_component_regmap_get_val_bytes (struct snd_soc_component *component);void snd_soc_component_regmap_async_complete (struct snd_soc_component *component);int snd_soc_component_regcache_sync (struct snd_soc_component *component); +void snd_soc_component_regcache_mark_dirty (struct snd_soc_component *component);int snd_soc_component_fixup_controls (struct snd_soc_component *component); int snd_soc_component_add_controls(struct snd_soc_component *component,
sound/soc/soc-component.c +9 -0
@@ -509,6 +509,15 @@ int snd_soc_component_regcache_sync(struct snd_soc_component *component) }EXPORT_SYMBOL_GPL (snd_soc_component_regcache_sync); +void snd_soc_component_regcache_mark_dirty (struct snd_soc_component *component) +{ +struct regmap *regmap = component->regmap; + +if (regmap) +regcache_mark_dirty (regmap); +} +EXPORT_SYMBOL_GPL (snd_soc_component_regcache_mark_dirty); +int snd_soc_component_compr_open (struct snd_soc_component *component,struct snd_compr_stream *cstream) {
Signature · 1 line
2.53.0
PATCH v2 21/27 ASoC: soc-component: add snd_soc_component_regcache_cache_only()
In reply to Kuninori Morimotostruct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.
Adds snd_soc_component_regcache_cache_only().
--- include/sound/soc-component.h | 1 + sound/soc/soc-component.c | 9 +++++++++ 2 files changed, 10 insertions(+)
include/sound/soc-component.h +1 -0
@@ -358,6 +358,7 @@ int snd_soc_component_regmap_get_val_bytes(struct snd_soc_component *component);void snd_soc_component_regmap_async_complete (struct snd_soc_component *component);int snd_soc_component_regcache_sync (struct snd_soc_component *component);void snd_soc_component_regcache_mark_dirty (struct snd_soc_component *component); +void snd_soc_component_regcache_cache_only (struct snd_soc_component *component,bool enable);int snd_soc_component_fixup_controls (struct snd_soc_component *component); int snd_soc_component_add_controls(struct snd_soc_component *component,
sound/soc/soc-component.c +9 -0
@@ -518,6 +518,15 @@ void snd_soc_component_regcache_mark_dirty(struct snd_soc_component *component) }EXPORT_SYMBOL_GPL (snd_soc_component_regcache_mark_dirty); +void snd_soc_component_regcache_cache_only (struct snd_soc_component *component,bool enable) +{ +struct regmap *regmap = component->regmap; + +if (regmap) +regcache_cache_only (regmap, enable); +} +EXPORT_SYMBOL_GPL (snd_soc_component_regcache_cache_only); +int snd_soc_component_compr_open (struct snd_soc_component *component,struct snd_compr_stream *cstream) {
Signature · 1 line
2.53.0
PATCH v2 22/27 ASoC: soc-component: add snd_soc_component_regcache_cache_bypass()
In reply to Kuninori Morimotostruct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.
Adds snd_soc_component_regcache_cache_bypass().
--- include/sound/soc-component.h | 1 + sound/soc/soc-component.c | 9 +++++++++ 2 files changed, 10 insertions(+)
include/sound/soc-component.h +1 -0
@@ -359,6 +359,7 @@ void snd_soc_component_regmap_async_complete(struct snd_soc_component *componentint snd_soc_component_regcache_sync (struct snd_soc_component *component);void snd_soc_component_regcache_mark_dirty (struct snd_soc_component *component);void snd_soc_component_regcache_cache_only (struct snd_soc_component *component,bool enable); +void snd_soc_component_regcache_cache_bypass (struct snd_soc_component *component,bool enable);int snd_soc_component_fixup_controls (struct snd_soc_component *component); int snd_soc_component_add_controls(struct snd_soc_component *component,
sound/soc/soc-component.c +9 -0
@@ -527,6 +527,15 @@ void snd_soc_component_regcache_cache_only(struct snd_soc_component *component, }EXPORT_SYMBOL_GPL (snd_soc_component_regcache_cache_only); +void snd_soc_component_regcache_cache_bypass (struct snd_soc_component *component,bool enable) +{ +struct regmap *regmap = component->regmap; + +if (regmap) +regcache_cache_bypass (regmap, enable); +} +EXPORT_SYMBOL_GPL (snd_soc_component_regcache_cache_bypass); +int snd_soc_component_compr_open (struct snd_soc_component *component,struct snd_compr_stream *cstream) {
Signature · 1 line
2.53.0
PATCH v2 23/27 ASoC: soc-component: add snd_soc_component_regmap_multi_reg_write_bypassed()
In reply to Kuninori Morimotostruct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.
Adds snd_soc_component_regmap_multi_reg_write_bypassed().
--- include/sound/soc-component.h | 3 +++ sound/soc/soc-component.c | 13 +++++++++++++ 2 files changed, 16 insertions(+)
include/sound/soc-component.h +3 -0
@@ -353,6 +353,9 @@ int snd_soc_component_set_bias_level(struct snd_soc_component *component,void snd_soc_component_regmap_init (struct snd_soc_component *component,struct regmap *regmap);void snd_soc_component_regmap_exit (struct snd_soc_component *component); +int snd_soc_component_regmap_multi_reg_write_bypassed (struct snd_soc_component *component, +const struct reg_sequence *regs, +int num_regs);#endif int snd_soc_component_regmap_get_val_bytes (struct snd_soc_component *component);void snd_soc_component_regmap_async_complete (struct snd_soc_component *component);
sound/soc/soc-component.c +13 -0
@@ -461,6 +461,19 @@ void snd_soc_component_regmap_exit(struct snd_soc_component *component) }EXPORT_SYMBOL_GPL (snd_soc_component_regmap_exit); +int snd_soc_component_regmap_multi_reg_write_bypassed (struct snd_soc_component *component, +const struct reg_sequence *regs, +int num_regs) +{ +struct regmap *regmap = component->regmap; + +if (!regmap) +return 0 ; + +return regmap_multi_reg_write_bypassed (regmap, regs, num_regs); +} +EXPORT_SYMBOL_GPL (snd_soc_component_regmap_multi_reg_write_bypassed); +#endif int snd_soc_component_regmap_get_val_bytes (struct snd_soc_component *component)
Signature · 1 line
2.53.0
PATCH v2 24/27 ASoC: soc-component: add snd_soc_component_num_dai()
In reply to Kuninori Morimotostruct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.
This patch adds snd_soc_component_num_dai() to get component->num_dai.
--- include/sound/soc-component.h | 1 + sound/soc/soc-component.c | 6 ++++++ 2 files changed, 7 insertions(+)
include/sound/soc-component.h +1 -0
@@ -393,6 +393,7 @@ static inline void *snd_soc_component_get_drvdata(struct snd_soc_component *c) }unsigned int snd_soc_component_active (struct snd_soc_component *component); +int snd_soc_component_num_dai (struct snd_soc_component *component);/* component controls */ struct snd_kcontrol *snd_soc_component_get_kcontrol(struct snd_soc_component *component,
sound/soc/soc-component.c +6 -0
@@ -104,6 +104,12 @@ unsigned int snd_soc_component_active(struct snd_soc_component *component) }EXPORT_SYMBOL_GPL (snd_soc_component_active); +int snd_soc_component_num_dai (struct snd_soc_component *component) +{ +return component->num_dai; +} +EXPORT_SYMBOL_GPL (snd_soc_component_num_dai); +/* * We might want to check substream by using list. * In such case, we can update these macros.
Signature · 1 line
2.53.0
PATCH v2 25/27 ASoC: soc-component: add snd_soc_component_connect_dai()
In reply to Kuninori Morimotostruct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.
This patch adds snd_soc_component_connect_dai() to connect DAI to Component.
--- sound/soc/soc-component.c | 7 +++++++ sound/soc/soc-dai.c | 3 +-- sound/soc/soc-internal.h | 1 + 3 files changed, 9 insertions(+), 2 deletions(-)
sound/soc/soc-component.c +7 -0
@@ -110,6 +110,13 @@ int snd_soc_component_num_dai(struct snd_soc_component *component) }EXPORT_SYMBOL_GPL (snd_soc_component_num_dai); +void snd_soc_component_connect_dai (struct snd_soc_component *component,struct snd_soc_dai *dai) +{ +/* dai->list <-> component->dai_list */ +list_add_tail (snd_soc_dai_to_list (dai), &component->dai_list); + component->num_dai++; +} +/* * We might want to check substream by using list. * In such case, we can update these macros.
sound/soc/soc-dai.c +1 -2
@@ -1265,8 +1265,7 @@ struct snd_soc_dai *snd_soc_dai_register(struct snd_soc_component *component, dai->driver = dai_drv;/* see for_each_component_dais */ -list_add_tail (&dai->list, &component->dai_list); - component->num_dai++; +snd_soc_component_connect_dai (component, dai);dev_dbg (dev,"ASoC: Registered DAI '%s'\n" , dai->name);return dai;
sound/soc/soc-internal.h +1 -0
@@ -69,6 +69,7 @@ bool snd_soc_component_matches_dlc(struct snd_soc_component *component,void snd_soc_component_remove (struct snd_soc_component *component,int probed);int snd_soc_component_probe (struct snd_soc_component *component,struct snd_soc_card *card);struct list_head *snd_soc_component_get_list_head (void ); +void snd_soc_component_connect_dai (struct snd_soc_component *component,struct snd_soc_dai *dai);#define for_each_component (component) \ list_for_each_entry(component, snd_soc_component_get_list_head(), list)
Signature · 1 line
2.53.0
PATCH v2 26/27 ASoC: soc-component: add snd_soc_component_active_update()
In reply to Kuninori Morimotostruct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.
This patch adds snd_soc_component_active_update() to handle Component acitive count.
--- sound/soc/soc-component.c | 5 +++++ sound/soc/soc-dai.c | 2 +- sound/soc/soc-internal.h | 1 + sound/soc/soc-pcm.c | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-)
sound/soc/soc-component.c +5 -0
@@ -104,6 +104,11 @@ unsigned int snd_soc_component_active(struct snd_soc_component *component) }EXPORT_SYMBOL_GPL (snd_soc_component_active); +void snd_soc_component_active_update (struct snd_soc_component *component,int action) +{ + component->active += action; +} +int snd_soc_component_num_dai (struct snd_soc_component *component) {return component->num_dai;
sound/soc/soc-dai.c +1 -1
@@ -713,7 +713,7 @@ void snd_soc_dai_active_update(struct snd_soc_dai *dai, int stream, int action) dai->stream[stream].active += action;/* see snd_soc_component_active() */ - dai->component->active += action; +snd_soc_component_active_update (dai->component, action); }int snd_soc_dai_active (const struct snd_soc_dai *dai)
sound/soc/soc-internal.h +1 -0
@@ -70,6 +70,7 @@ void snd_soc_component_remove(struct snd_soc_component *component, int probed);int snd_soc_component_probe (struct snd_soc_component *component,struct snd_soc_card *card);struct list_head *snd_soc_component_get_list_head (void );void snd_soc_component_connect_dai (struct snd_soc_component *component,struct snd_soc_dai *dai); +void snd_soc_component_active_update (struct snd_soc_component *component,int action);#define for_each_component (component) \ list_for_each_entry(component, snd_soc_component_get_list_head(), list)
sound/soc/soc-pcm.c +1 -1
@@ -374,7 +374,7 @@ void snd_soc_runtime_action(struct snd_soc_pcm_runtime *rtd,for_each_rtd_components (rtd, i, component) {if (component->num_dai)continue ; - component->active += action; +snd_soc_component_active_update (component, action); } }EXPORT_SYMBOL_GPL (snd_soc_runtime_action);
Signature · 1 line
2.53.0
PATCH v2 27/27 ASoC: soc-component: add snd_soc_component_device_link_{add/del}()
In reply to Kuninori Morimotostruct snd_soc_component will be capsuled soon, its member will not be able to access from non soc-component.c.
This patch adds snd_soc_component_device_link_{add/del}() to handle Component device_link.
--- sound/soc/soc-card.c | 22 ++++------------------ sound/soc/soc-component.c | 28 ++++++++++++++++++++++++++++ sound/soc/soc-internal.h | 2 ++ 3 files changed, 34 insertions(+), 18 deletions(-)
sound/soc/soc-card.c +4 -18
@@ -884,12 +884,8 @@ static void snd_soc_remove_device_links(struct snd_soc_card *card) {struct snd_soc_component *component; -for_each_card_components (card, component) { -if (component->card_device_link) { -device_link_del (component->card_device_link); - component->card_device_link =NULL ; - } - } +for_each_card_components (card, component) +snd_soc_component_device_link_del (component); }void snd_soc_card_unbind (struct snd_soc_card *card,bool reuse)
@@ -1043,18 +1039,8 @@ static int snd_soc_card_bind(struct snd_soc_card *card)* If a driver pair already have a link in the opposite direction * they must manage their own suspend order. */ -for_each_card_components (card, component) { -if (card->dev == component->dev) -continue ; - - component->card_device_link =device_link_add (card->dev, - component->dev, -DL_FLAG_STATELESS ); -if (!component->card_device_link) { -dev_warn (card->dev,"Could not create device link to %s\n" , -dev_name (component->dev)); - } - } +for_each_card_components (card, component) +snd_soc_component_device_link_add (component); ret =snd_soc_card_late_probe (card);if (ret <0 )
sound/soc/soc-component.c +28 -0
@@ -122,6 +122,34 @@ void snd_soc_component_connect_dai(struct snd_soc_component *component, struct s component->num_dai++; } +void snd_soc_component_device_link_del (struct snd_soc_component *component) +{ +if (component->card_device_link) { +device_link_del (component->card_device_link); + component->card_device_link =NULL ; + } +} + +int snd_soc_component_device_link_add (struct snd_soc_component *component) +{ +struct snd_soc_card *card =snd_soc_component_to_card (component); +struct device *card_dev = card->dev; +struct device *component_dev =snd_soc_component_to_dev (component); + +if (card_dev == component_dev) +return 0 ; + + component->card_device_link =device_link_add (card_dev, component_dev, +DL_FLAG_STATELESS ); +if (!component->card_device_link) { +dev_warn (card_dev,"Could not create device link to %s\n" , +dev_name (component_dev)); +return -EINVAL ; + } + +return 0 ; +} +/* * We might want to check substream by using list. * In such case, we can update these macros.
sound/soc/soc-internal.h +2 -0
@@ -71,6 +71,8 @@ int snd_soc_component_probe(struct snd_soc_component *component, struct snd_soc_struct list_head *snd_soc_component_get_list_head (void );void snd_soc_component_connect_dai (struct snd_soc_component *component,struct snd_soc_dai *dai);void snd_soc_component_active_update (struct snd_soc_component *component,int action); +void snd_soc_component_device_link_del (struct snd_soc_component *component); +int snd_soc_component_device_link_add (struct snd_soc_component *component);#define for_each_component (component) \ list_for_each_entry(component, snd_soc_component_get_list_head(), list)
Signature · 1 line
2.53.0
Mark Brown
maintainerQuoted 8 lines · Kuninori Morimoto
Hi Mark
This is v2 patch-set
I'm now posting ASoC Capsuling patches.
Current status, and this patch-set postion is below. This patch-set moves Card related functions tosoc-card.c
This needs a rebase against current code.