Commit 86c2eddf authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown

ASoC: cs35l35: replace codec to component

Now we can replace Codec to Component. Let's do it.

Note:
	xxx_codec_xxx()		->	xxx_component_xxx()
	.idle_bias_off = 0	->	.idle_bias_on = 1
	.ignore_pmdown_time = 0	->	.use_pmdown_time = 1
	-			->	.endianness = 1
	-			->	.non_legacy_dai_naming = 1
Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 7928b2cb
...@@ -194,8 +194,8 @@ static int cs35l35_wait_for_pdn(struct cs35l35_private *cs35l35) ...@@ -194,8 +194,8 @@ static int cs35l35_wait_for_pdn(struct cs35l35_private *cs35l35)
static int cs35l35_sdin_event(struct snd_soc_dapm_widget *w, static int cs35l35_sdin_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event) struct snd_kcontrol *kcontrol, int event)
{ {
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
struct cs35l35_private *cs35l35 = snd_soc_codec_get_drvdata(codec); struct cs35l35_private *cs35l35 = snd_soc_component_get_drvdata(component);
int ret = 0; int ret = 0;
switch (event) { switch (event) {
...@@ -231,7 +231,7 @@ static int cs35l35_sdin_event(struct snd_soc_dapm_widget *w, ...@@ -231,7 +231,7 @@ static int cs35l35_sdin_event(struct snd_soc_dapm_widget *w,
1 << CS35L35_AMP_DIGSFT_SHIFT); 1 << CS35L35_AMP_DIGSFT_SHIFT);
break; break;
default: default:
dev_err(codec->dev, "Invalid event = 0x%x\n", event); dev_err(component->dev, "Invalid event = 0x%x\n", event);
ret = -EINVAL; ret = -EINVAL;
} }
return ret; return ret;
...@@ -240,8 +240,8 @@ static int cs35l35_sdin_event(struct snd_soc_dapm_widget *w, ...@@ -240,8 +240,8 @@ static int cs35l35_sdin_event(struct snd_soc_dapm_widget *w,
static int cs35l35_main_amp_event(struct snd_soc_dapm_widget *w, static int cs35l35_main_amp_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event) struct snd_kcontrol *kcontrol, int event)
{ {
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
struct cs35l35_private *cs35l35 = snd_soc_codec_get_drvdata(codec); struct cs35l35_private *cs35l35 = snd_soc_component_get_drvdata(component);
unsigned int reg[4]; unsigned int reg[4];
int i; int i;
...@@ -301,7 +301,7 @@ static int cs35l35_main_amp_event(struct snd_soc_dapm_widget *w, ...@@ -301,7 +301,7 @@ static int cs35l35_main_amp_event(struct snd_soc_dapm_widget *w,
break; break;
default: default:
dev_err(codec->dev, "Invalid event = 0x%x\n", event); dev_err(component->dev, "Invalid event = 0x%x\n", event);
} }
return 0; return 0;
} }
...@@ -369,8 +369,8 @@ static const struct snd_soc_dapm_route cs35l35_audio_map[] = { ...@@ -369,8 +369,8 @@ static const struct snd_soc_dapm_route cs35l35_audio_map[] = {
static int cs35l35_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) static int cs35l35_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
{ {
struct snd_soc_codec *codec = codec_dai->codec; struct snd_soc_component *component = codec_dai->component;
struct cs35l35_private *cs35l35 = snd_soc_codec_get_drvdata(codec); struct cs35l35_private *cs35l35 = snd_soc_component_get_drvdata(component);
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
case SND_SOC_DAIFMT_CBM_CFM: case SND_SOC_DAIFMT_CBM_CFM:
...@@ -470,8 +470,8 @@ static int cs35l35_hw_params(struct snd_pcm_substream *substream, ...@@ -470,8 +470,8 @@ static int cs35l35_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params, struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct cs35l35_private *cs35l35 = snd_soc_codec_get_drvdata(codec); struct cs35l35_private *cs35l35 = snd_soc_component_get_drvdata(component);
struct classh_cfg *classh = &cs35l35->pdata.classh_algo; struct classh_cfg *classh = &cs35l35->pdata.classh_algo;
int srate = params_rate(params); int srate = params_rate(params);
int ret = 0; int ret = 0;
...@@ -482,7 +482,7 @@ static int cs35l35_hw_params(struct snd_pcm_substream *substream, ...@@ -482,7 +482,7 @@ static int cs35l35_hw_params(struct snd_pcm_substream *substream,
int clk_ctl = cs35l35_get_clk_config(cs35l35->sysclk, srate); int clk_ctl = cs35l35_get_clk_config(cs35l35->sysclk, srate);
if (clk_ctl < 0) { if (clk_ctl < 0) {
dev_err(codec->dev, "Invalid CLK:Rate %d:%d\n", dev_err(component->dev, "Invalid CLK:Rate %d:%d\n",
cs35l35->sysclk, srate); cs35l35->sysclk, srate);
return -EINVAL; return -EINVAL;
} }
...@@ -490,7 +490,7 @@ static int cs35l35_hw_params(struct snd_pcm_substream *substream, ...@@ -490,7 +490,7 @@ static int cs35l35_hw_params(struct snd_pcm_substream *substream,
ret = regmap_update_bits(cs35l35->regmap, CS35L35_CLK_CTL2, ret = regmap_update_bits(cs35l35->regmap, CS35L35_CLK_CTL2,
CS35L35_CLK_CTL2_MASK, clk_ctl); CS35L35_CLK_CTL2_MASK, clk_ctl);
if (ret != 0) { if (ret != 0) {
dev_err(codec->dev, "Failed to set port config %d\n", ret); dev_err(component->dev, "Failed to set port config %d\n", ret);
return ret; return ret;
} }
...@@ -509,7 +509,7 @@ static int cs35l35_hw_params(struct snd_pcm_substream *substream, ...@@ -509,7 +509,7 @@ static int cs35l35_hw_params(struct snd_pcm_substream *substream,
CS35L35_CH_WKFET_DEL_MASK, CS35L35_CH_WKFET_DEL_MASK,
0 << CS35L35_CH_WKFET_DEL_SHIFT); 0 << CS35L35_CH_WKFET_DEL_SHIFT);
if (ret != 0) { if (ret != 0) {
dev_err(codec->dev, "Failed to set fet config %d\n", dev_err(component->dev, "Failed to set fet config %d\n",
ret); ret);
return ret; return ret;
} }
...@@ -531,7 +531,7 @@ static int cs35l35_hw_params(struct snd_pcm_substream *substream, ...@@ -531,7 +531,7 @@ static int cs35l35_hw_params(struct snd_pcm_substream *substream,
audin_format = CS35L35_SDIN_DEPTH_24; audin_format = CS35L35_SDIN_DEPTH_24;
break; break;
default: default:
dev_err(codec->dev, "Unsupported Width %d\n", dev_err(component->dev, "Unsupported Width %d\n",
params_width(params)); params_width(params));
return -EINVAL; return -EINVAL;
} }
...@@ -554,7 +554,7 @@ static int cs35l35_hw_params(struct snd_pcm_substream *substream, ...@@ -554,7 +554,7 @@ static int cs35l35_hw_params(struct snd_pcm_substream *substream,
* to configure the CLOCK_CTL3 register correctly * to configure the CLOCK_CTL3 register correctly
*/ */
if ((cs35l35->sclk / srate) % 4) { if ((cs35l35->sclk / srate) % 4) {
dev_err(codec->dev, "Unsupported sclk/fs ratio %d:%d\n", dev_err(component->dev, "Unsupported sclk/fs ratio %d:%d\n",
cs35l35->sclk, srate); cs35l35->sclk, srate);
return -EINVAL; return -EINVAL;
} }
...@@ -568,7 +568,7 @@ static int cs35l35_hw_params(struct snd_pcm_substream *substream, ...@@ -568,7 +568,7 @@ static int cs35l35_hw_params(struct snd_pcm_substream *substream,
case CS35L35_SP_SCLKS_64FS: case CS35L35_SP_SCLKS_64FS:
break; break;
default: default:
dev_err(codec->dev, "ratio not supported\n"); dev_err(component->dev, "ratio not supported\n");
return -EINVAL; return -EINVAL;
} }
} else { } else {
...@@ -578,7 +578,7 @@ static int cs35l35_hw_params(struct snd_pcm_substream *substream, ...@@ -578,7 +578,7 @@ static int cs35l35_hw_params(struct snd_pcm_substream *substream,
case CS35L35_SP_SCLKS_64FS: case CS35L35_SP_SCLKS_64FS:
break; break;
default: default:
dev_err(codec->dev, "ratio not supported\n"); dev_err(component->dev, "ratio not supported\n");
return -EINVAL; return -EINVAL;
} }
} }
...@@ -587,7 +587,7 @@ static int cs35l35_hw_params(struct snd_pcm_substream *substream, ...@@ -587,7 +587,7 @@ static int cs35l35_hw_params(struct snd_pcm_substream *substream,
CS35L35_SP_SCLKS_MASK, sp_sclks << CS35L35_SP_SCLKS_MASK, sp_sclks <<
CS35L35_SP_SCLKS_SHIFT); CS35L35_SP_SCLKS_SHIFT);
if (ret != 0) { if (ret != 0) {
dev_err(codec->dev, "Failed to set fsclk %d\n", ret); dev_err(component->dev, "Failed to set fsclk %d\n", ret);
return ret; return ret;
} }
} }
...@@ -607,8 +607,8 @@ static const struct snd_pcm_hw_constraint_list cs35l35_constraints = { ...@@ -607,8 +607,8 @@ static const struct snd_pcm_hw_constraint_list cs35l35_constraints = {
static int cs35l35_pcm_startup(struct snd_pcm_substream *substream, static int cs35l35_pcm_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct cs35l35_private *cs35l35 = snd_soc_codec_get_drvdata(codec); struct cs35l35_private *cs35l35 = snd_soc_component_get_drvdata(component);
if (!substream->runtime) if (!substream->runtime)
return 0; return 0;
...@@ -635,8 +635,8 @@ static const struct snd_pcm_hw_constraint_list cs35l35_pdm_constraints = { ...@@ -635,8 +635,8 @@ static const struct snd_pcm_hw_constraint_list cs35l35_pdm_constraints = {
static int cs35l35_pdm_startup(struct snd_pcm_substream *substream, static int cs35l35_pdm_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct cs35l35_private *cs35l35 = snd_soc_codec_get_drvdata(codec); struct cs35l35_private *cs35l35 = snd_soc_component_get_drvdata(component);
if (!substream->runtime) if (!substream->runtime)
return 0; return 0;
...@@ -655,8 +655,8 @@ static int cs35l35_pdm_startup(struct snd_pcm_substream *substream, ...@@ -655,8 +655,8 @@ static int cs35l35_pdm_startup(struct snd_pcm_substream *substream,
static int cs35l35_dai_set_sysclk(struct snd_soc_dai *dai, static int cs35l35_dai_set_sysclk(struct snd_soc_dai *dai,
int clk_id, unsigned int freq, int dir) int clk_id, unsigned int freq, int dir)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct cs35l35_private *cs35l35 = snd_soc_codec_get_drvdata(codec); struct cs35l35_private *cs35l35 = snd_soc_component_get_drvdata(component);
/* Need the SCLK Frequency regardless of sysclk source for I2S */ /* Need the SCLK Frequency regardless of sysclk source for I2S */
cs35l35->sclk = freq; cs35l35->sclk = freq;
...@@ -712,11 +712,11 @@ static struct snd_soc_dai_driver cs35l35_dai[] = { ...@@ -712,11 +712,11 @@ static struct snd_soc_dai_driver cs35l35_dai[] = {
}, },
}; };
static int cs35l35_codec_set_sysclk(struct snd_soc_codec *codec, static int cs35l35_component_set_sysclk(struct snd_soc_component *component,
int clk_id, int source, unsigned int freq, int clk_id, int source, unsigned int freq,
int dir) int dir)
{ {
struct cs35l35_private *cs35l35 = snd_soc_codec_get_drvdata(codec); struct cs35l35_private *cs35l35 = snd_soc_component_get_drvdata(component);
int clksrc; int clksrc;
int ret = 0; int ret = 0;
...@@ -731,7 +731,7 @@ static int cs35l35_codec_set_sysclk(struct snd_soc_codec *codec, ...@@ -731,7 +731,7 @@ static int cs35l35_codec_set_sysclk(struct snd_soc_codec *codec,
clksrc = CS35L35_CLK_SOURCE_PDM; clksrc = CS35L35_CLK_SOURCE_PDM;
break; break;
default: default:
dev_err(codec->dev, "Invalid CLK Source\n"); dev_err(component->dev, "Invalid CLK Source\n");
return -EINVAL; return -EINVAL;
} }
...@@ -749,7 +749,7 @@ static int cs35l35_codec_set_sysclk(struct snd_soc_codec *codec, ...@@ -749,7 +749,7 @@ static int cs35l35_codec_set_sysclk(struct snd_soc_codec *codec,
cs35l35->sysclk = freq; cs35l35->sysclk = freq;
break; break;
default: default:
dev_err(codec->dev, "Invalid CLK Frequency Input : %d\n", freq); dev_err(component->dev, "Invalid CLK Frequency Input : %d\n", freq);
return -EINVAL; return -EINVAL;
} }
...@@ -757,7 +757,7 @@ static int cs35l35_codec_set_sysclk(struct snd_soc_codec *codec, ...@@ -757,7 +757,7 @@ static int cs35l35_codec_set_sysclk(struct snd_soc_codec *codec,
CS35L35_CLK_SOURCE_MASK, CS35L35_CLK_SOURCE_MASK,
clksrc << CS35L35_CLK_SOURCE_SHIFT); clksrc << CS35L35_CLK_SOURCE_SHIFT);
if (ret != 0) { if (ret != 0) {
dev_err(codec->dev, "Failed to set sysclk %d\n", ret); dev_err(component->dev, "Failed to set sysclk %d\n", ret);
return ret; return ret;
} }
...@@ -834,9 +834,9 @@ static int cs35l35_boost_inductor(struct cs35l35_private *cs35l35, ...@@ -834,9 +834,9 @@ static int cs35l35_boost_inductor(struct cs35l35_private *cs35l35,
return 0; return 0;
} }
static int cs35l35_codec_probe(struct snd_soc_codec *codec) static int cs35l35_component_probe(struct snd_soc_component *component)
{ {
struct cs35l35_private *cs35l35 = snd_soc_codec_get_drvdata(codec); struct cs35l35_private *cs35l35 = snd_soc_component_get_drvdata(component);
struct classh_cfg *classh = &cs35l35->pdata.classh_algo; struct classh_cfg *classh = &cs35l35->pdata.classh_algo;
struct monitor_cfg *monitor_config = &cs35l35->pdata.mon_cfg; struct monitor_cfg *monitor_config = &cs35l35->pdata.mon_cfg;
int ret; int ret;
...@@ -880,7 +880,7 @@ static int cs35l35_codec_probe(struct snd_soc_codec *codec) ...@@ -880,7 +880,7 @@ static int cs35l35_codec_probe(struct snd_soc_codec *codec)
regmap_update_bits(cs35l35->regmap, CS35L35_CLASS_H_CTL, regmap_update_bits(cs35l35->regmap, CS35L35_CLASS_H_CTL,
CS35L35_CH_STEREO_MASK, CS35L35_CH_STEREO_MASK,
1 << CS35L35_CH_STEREO_SHIFT); 1 << CS35L35_CH_STEREO_SHIFT);
ret = snd_soc_add_codec_controls(codec, cs35l35_adv_controls, ret = snd_soc_add_component_controls(component, cs35l35_adv_controls,
ARRAY_SIZE(cs35l35_adv_controls)); ARRAY_SIZE(cs35l35_adv_controls));
if (ret) if (ret)
return ret; return ret;
...@@ -1079,20 +1079,19 @@ static int cs35l35_codec_probe(struct snd_soc_codec *codec) ...@@ -1079,20 +1079,19 @@ static int cs35l35_codec_probe(struct snd_soc_codec *codec)
return 0; return 0;
} }
static const struct snd_soc_codec_driver soc_codec_dev_cs35l35 = { static const struct snd_soc_component_driver soc_component_dev_cs35l35 = {
.probe = cs35l35_codec_probe, .probe = cs35l35_component_probe,
.set_sysclk = cs35l35_codec_set_sysclk, .set_sysclk = cs35l35_component_set_sysclk,
.component_driver = { .dapm_widgets = cs35l35_dapm_widgets,
.dapm_widgets = cs35l35_dapm_widgets, .num_dapm_widgets = ARRAY_SIZE(cs35l35_dapm_widgets),
.num_dapm_widgets = ARRAY_SIZE(cs35l35_dapm_widgets), .dapm_routes = cs35l35_audio_map,
.num_dapm_routes = ARRAY_SIZE(cs35l35_audio_map),
.dapm_routes = cs35l35_audio_map, .controls = cs35l35_aud_controls,
.num_dapm_routes = ARRAY_SIZE(cs35l35_audio_map), .num_controls = ARRAY_SIZE(cs35l35_aud_controls),
.idle_bias_on = 1,
.controls = cs35l35_aud_controls, .use_pmdown_time = 1,
.num_controls = ARRAY_SIZE(cs35l35_aud_controls), .endianness = 1,
}, .non_legacy_dai_naming = 1,
}; };
static struct regmap_config cs35l35_regmap = { static struct regmap_config cs35l35_regmap = {
...@@ -1617,10 +1616,10 @@ static int cs35l35_i2c_probe(struct i2c_client *i2c_client, ...@@ -1617,10 +1616,10 @@ static int cs35l35_i2c_probe(struct i2c_client *i2c_client,
regmap_update_bits(cs35l35->regmap, CS35L35_PROTECT_CTL, regmap_update_bits(cs35l35->regmap, CS35L35_PROTECT_CTL,
CS35L35_AMP_MUTE_MASK, 1 << CS35L35_AMP_MUTE_SHIFT); CS35L35_AMP_MUTE_MASK, 1 << CS35L35_AMP_MUTE_SHIFT);
ret = snd_soc_register_codec(dev, &soc_codec_dev_cs35l35, cs35l35_dai, ret = devm_snd_soc_register_component(dev, &soc_component_dev_cs35l35,
ARRAY_SIZE(cs35l35_dai)); cs35l35_dai, ARRAY_SIZE(cs35l35_dai));
if (ret < 0) { if (ret < 0) {
dev_err(dev, "Failed to register codec: %d\n", ret); dev_err(dev, "Failed to register component: %d\n", ret);
goto err; goto err;
} }
...@@ -1634,12 +1633,6 @@ static int cs35l35_i2c_probe(struct i2c_client *i2c_client, ...@@ -1634,12 +1633,6 @@ static int cs35l35_i2c_probe(struct i2c_client *i2c_client,
return ret; return ret;
} }
static int cs35l35_i2c_remove(struct i2c_client *client)
{
snd_soc_unregister_codec(&client->dev);
return 0;
}
static const struct of_device_id cs35l35_of_match[] = { static const struct of_device_id cs35l35_of_match[] = {
{.compatible = "cirrus,cs35l35"}, {.compatible = "cirrus,cs35l35"},
{}, {},
...@@ -1660,7 +1653,6 @@ static struct i2c_driver cs35l35_i2c_driver = { ...@@ -1660,7 +1653,6 @@ static struct i2c_driver cs35l35_i2c_driver = {
}, },
.id_table = cs35l35_id, .id_table = cs35l35_id,
.probe = cs35l35_i2c_probe, .probe = cs35l35_i2c_probe,
.remove = cs35l35_i2c_remove,
}; };
module_i2c_driver(cs35l35_i2c_driver); module_i2c_driver(cs35l35_i2c_driver);
......
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