Commit 4ca8701e authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown

ASoC: soc-component: add soc_component_pin() and share code

soc-component has too many snd_soc_component_xxx_pin_xxx() functions.
The difference between these functions are used function name and
enable/disable.
This patch adds common soc_component_pin() and share code.
Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: default avatarRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/87tuzrw8zw.wl-kuninori.morimoto.gx@renesas.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 17212e71
......@@ -77,8 +77,10 @@ int snd_soc_component_set_bias_level(struct snd_soc_component *component,
return 0;
}
int snd_soc_component_enable_pin(struct snd_soc_component *component,
const char *pin)
static int soc_component_pin(struct snd_soc_component *component,
const char *pin,
int (*pin_func)(struct snd_soc_dapm_context *dapm,
const char *pin))
{
struct snd_soc_dapm_context *dapm =
snd_soc_component_get_dapm(component);
......@@ -86,170 +88,71 @@ int snd_soc_component_enable_pin(struct snd_soc_component *component,
int ret;
if (!component->name_prefix)
return snd_soc_dapm_enable_pin(dapm, pin);
return pin_func(dapm, pin);
full_name = kasprintf(GFP_KERNEL, "%s %s", component->name_prefix, pin);
if (!full_name)
return -ENOMEM;
ret = snd_soc_dapm_enable_pin(dapm, full_name);
ret = pin_func(dapm, full_name);
kfree(full_name);
return ret;
}
int snd_soc_component_enable_pin(struct snd_soc_component *component,
const char *pin)
{
return soc_component_pin(component, pin, snd_soc_dapm_enable_pin);
}
EXPORT_SYMBOL_GPL(snd_soc_component_enable_pin);
int snd_soc_component_enable_pin_unlocked(struct snd_soc_component *component,
const char *pin)
{
struct snd_soc_dapm_context *dapm =
snd_soc_component_get_dapm(component);
char *full_name;
int ret;
if (!component->name_prefix)
return snd_soc_dapm_enable_pin_unlocked(dapm, pin);
full_name = kasprintf(GFP_KERNEL, "%s %s", component->name_prefix, pin);
if (!full_name)
return -ENOMEM;
ret = snd_soc_dapm_enable_pin_unlocked(dapm, full_name);
kfree(full_name);
return ret;
return soc_component_pin(component, pin, snd_soc_dapm_enable_pin_unlocked);
}
EXPORT_SYMBOL_GPL(snd_soc_component_enable_pin_unlocked);
int snd_soc_component_disable_pin(struct snd_soc_component *component,
const char *pin)
{
struct snd_soc_dapm_context *dapm =
snd_soc_component_get_dapm(component);
char *full_name;
int ret;
if (!component->name_prefix)
return snd_soc_dapm_disable_pin(dapm, pin);
full_name = kasprintf(GFP_KERNEL, "%s %s", component->name_prefix, pin);
if (!full_name)
return -ENOMEM;
ret = snd_soc_dapm_disable_pin(dapm, full_name);
kfree(full_name);
return ret;
return soc_component_pin(component, pin, snd_soc_dapm_disable_pin);
}
EXPORT_SYMBOL_GPL(snd_soc_component_disable_pin);
int snd_soc_component_disable_pin_unlocked(struct snd_soc_component *component,
const char *pin)
{
struct snd_soc_dapm_context *dapm =
snd_soc_component_get_dapm(component);
char *full_name;
int ret;
if (!component->name_prefix)
return snd_soc_dapm_disable_pin_unlocked(dapm, pin);
full_name = kasprintf(GFP_KERNEL, "%s %s", component->name_prefix, pin);
if (!full_name)
return -ENOMEM;
ret = snd_soc_dapm_disable_pin_unlocked(dapm, full_name);
kfree(full_name);
return ret;
return soc_component_pin(component, pin, snd_soc_dapm_disable_pin_unlocked);
}
EXPORT_SYMBOL_GPL(snd_soc_component_disable_pin_unlocked);
int snd_soc_component_nc_pin(struct snd_soc_component *component,
const char *pin)
{
struct snd_soc_dapm_context *dapm =
snd_soc_component_get_dapm(component);
char *full_name;
int ret;
if (!component->name_prefix)
return snd_soc_dapm_nc_pin(dapm, pin);
full_name = kasprintf(GFP_KERNEL, "%s %s", component->name_prefix, pin);
if (!full_name)
return -ENOMEM;
ret = snd_soc_dapm_nc_pin(dapm, full_name);
kfree(full_name);
return ret;
return soc_component_pin(component, pin, snd_soc_dapm_nc_pin);
}
EXPORT_SYMBOL_GPL(snd_soc_component_nc_pin);
int snd_soc_component_nc_pin_unlocked(struct snd_soc_component *component,
const char *pin)
{
struct snd_soc_dapm_context *dapm =
snd_soc_component_get_dapm(component);
char *full_name;
int ret;
if (!component->name_prefix)
return snd_soc_dapm_nc_pin_unlocked(dapm, pin);
full_name = kasprintf(GFP_KERNEL, "%s %s", component->name_prefix, pin);
if (!full_name)
return -ENOMEM;
ret = snd_soc_dapm_nc_pin_unlocked(dapm, full_name);
kfree(full_name);
return ret;
return soc_component_pin(component, pin, snd_soc_dapm_nc_pin_unlocked);
}
EXPORT_SYMBOL_GPL(snd_soc_component_nc_pin_unlocked);
int snd_soc_component_get_pin_status(struct snd_soc_component *component,
const char *pin)
{
struct snd_soc_dapm_context *dapm =
snd_soc_component_get_dapm(component);
char *full_name;
int ret;
if (!component->name_prefix)
return snd_soc_dapm_get_pin_status(dapm, pin);
full_name = kasprintf(GFP_KERNEL, "%s %s", component->name_prefix, pin);
if (!full_name)
return -ENOMEM;
ret = snd_soc_dapm_get_pin_status(dapm, full_name);
kfree(full_name);
return ret;
return soc_component_pin(component, pin, snd_soc_dapm_get_pin_status);
}
EXPORT_SYMBOL_GPL(snd_soc_component_get_pin_status);
int snd_soc_component_force_enable_pin(struct snd_soc_component *component,
const char *pin)
{
struct snd_soc_dapm_context *dapm =
snd_soc_component_get_dapm(component);
char *full_name;
int ret;
if (!component->name_prefix)
return snd_soc_dapm_force_enable_pin(dapm, pin);
full_name = kasprintf(GFP_KERNEL, "%s %s", component->name_prefix, pin);
if (!full_name)
return -ENOMEM;
ret = snd_soc_dapm_force_enable_pin(dapm, full_name);
kfree(full_name);
return ret;
return soc_component_pin(component, pin, snd_soc_dapm_force_enable_pin);
}
EXPORT_SYMBOL_GPL(snd_soc_component_force_enable_pin);
......@@ -257,22 +160,7 @@ int snd_soc_component_force_enable_pin_unlocked(
struct snd_soc_component *component,
const char *pin)
{
struct snd_soc_dapm_context *dapm =
snd_soc_component_get_dapm(component);
char *full_name;
int ret;
if (!component->name_prefix)
return snd_soc_dapm_force_enable_pin_unlocked(dapm, pin);
full_name = kasprintf(GFP_KERNEL, "%s %s", component->name_prefix, pin);
if (!full_name)
return -ENOMEM;
ret = snd_soc_dapm_force_enable_pin_unlocked(dapm, full_name);
kfree(full_name);
return ret;
return soc_component_pin(component, pin, snd_soc_dapm_force_enable_pin_unlocked);
}
EXPORT_SYMBOL_GPL(snd_soc_component_force_enable_pin_unlocked);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment