mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-31 07:03:28 -04:00
ASoC: soc-component: add snd_soc_register_component_{c/d}()
We have snd_soc_register_component() (A), but we can't setup component
specific setting, like name, etc from driver, because component
itself is allocated in that function (x).
(A) int snd_soc_register_component(...)
{
...
(x) component = devm_kzalloc(...);
if (!component)
return -ENOMEM;
(B) ret = snd_soc_component_initialize(...);
if (ret < 0)
return ret;
(C) return snd_soc_add_component(...);
}
So each driver needs to use snd_soc_component_{initialize/add}() (= B/C)
instead of using snd_soc_register_component() (A), but it looks
unbalanced with its paired unregiser function.
Let's merge (B) and (C) into new register function, and allows component
as parameter. We can use both
snd_soc_register_component(dev, ...); // already exists
snd_soc_register_component(component, ...); // new function
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://patch.msgid.link/87tspqrz7w.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
committed by
Mark Brown
parent
de182d84b3
commit
3e53dc96a0
@@ -453,9 +453,16 @@ int snd_soc_component_initialize(struct snd_soc_component *component,
|
||||
int snd_soc_add_component(struct snd_soc_component *component,
|
||||
struct snd_soc_dai_driver *dai_drv,
|
||||
int num_dai);
|
||||
int snd_soc_register_component(struct device *dev,
|
||||
int snd_soc_register_component_c(struct snd_soc_component *component,
|
||||
const struct snd_soc_component_driver *component_driver,
|
||||
struct snd_soc_dai_driver *dai_drv, int num_dai);
|
||||
int snd_soc_register_component_d(struct device *dev,
|
||||
const struct snd_soc_component_driver *component_driver,
|
||||
struct snd_soc_dai_driver *dai_drv, int num_dai);
|
||||
#define snd_soc_register_component(x, ...) _Generic((x), \
|
||||
struct device * : snd_soc_register_component_d, \
|
||||
struct snd_soc_component * : snd_soc_register_component_c)(x, __VA_ARGS__)
|
||||
|
||||
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);
|
||||
|
||||
@@ -2780,25 +2780,35 @@ int snd_soc_add_component(struct snd_soc_component *component,
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(snd_soc_add_component);
|
||||
|
||||
int snd_soc_register_component(struct device *dev,
|
||||
int snd_soc_register_component_c(struct snd_soc_component *component,
|
||||
const struct snd_soc_component_driver *component_driver,
|
||||
struct snd_soc_dai_driver *dai_drv,
|
||||
int num_dai)
|
||||
{
|
||||
struct snd_soc_component *component;
|
||||
int ret;
|
||||
|
||||
component = devm_kzalloc(dev, sizeof(*component), GFP_KERNEL);
|
||||
if (!component)
|
||||
return -ENOMEM;
|
||||
|
||||
ret = snd_soc_component_initialize(component, component_driver, dev);
|
||||
ret = snd_soc_component_initialize(component, component_driver, component->dev);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
return snd_soc_add_component(component, dai_drv, num_dai);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(snd_soc_register_component);
|
||||
EXPORT_SYMBOL_GPL(snd_soc_register_component_c);
|
||||
|
||||
int snd_soc_register_component_d(struct device *dev,
|
||||
const struct snd_soc_component_driver *component_driver,
|
||||
struct snd_soc_dai_driver *dai_drv,
|
||||
int num_dai)
|
||||
{
|
||||
struct snd_soc_component *component;
|
||||
|
||||
component = snd_soc_component_alloc(dev);
|
||||
if (!component)
|
||||
return -ENOMEM;
|
||||
|
||||
return snd_soc_register_component_c(component, component_driver, dai_drv, num_dai);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(snd_soc_register_component_d);
|
||||
|
||||
/**
|
||||
* snd_soc_unregister_component_by_driver - Unregister component using a given driver
|
||||
|
||||
Reference in New Issue
Block a user