Commit fbf60d97 authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown

ASoC: max9860: 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 = 1	->	.idle_bias_on = 0
	.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
...@@ -261,8 +261,8 @@ static int max9860_hw_params(struct snd_pcm_substream *substream, ...@@ -261,8 +261,8 @@ static int max9860_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 max9860_priv *max9860 = snd_soc_codec_get_drvdata(codec); struct max9860_priv *max9860 = snd_soc_component_get_drvdata(component);
u8 master; u8 master;
u8 ifc1a = 0; u8 ifc1a = 0;
u8 ifc1b = 0; u8 ifc1b = 0;
...@@ -270,7 +270,7 @@ static int max9860_hw_params(struct snd_pcm_substream *substream, ...@@ -270,7 +270,7 @@ static int max9860_hw_params(struct snd_pcm_substream *substream,
unsigned long n; unsigned long n;
int ret; int ret;
dev_dbg(codec->dev, "hw_params %u Hz, %u channels\n", dev_dbg(component->dev, "hw_params %u Hz, %u channels\n",
params_rate(params), params_rate(params),
params_channels(params)); params_channels(params));
...@@ -306,7 +306,7 @@ static int max9860_hw_params(struct snd_pcm_substream *substream, ...@@ -306,7 +306,7 @@ static int max9860_hw_params(struct snd_pcm_substream *substream,
break; break;
case SND_SOC_DAIFMT_DSP_A: case SND_SOC_DAIFMT_DSP_A:
if (params_width(params) != 16) { if (params_width(params) != 16) {
dev_err(codec->dev, dev_err(component->dev,
"DSP_A works for 16 bits per sample only.\n"); "DSP_A works for 16 bits per sample only.\n");
return -EINVAL; return -EINVAL;
} }
...@@ -315,7 +315,7 @@ static int max9860_hw_params(struct snd_pcm_substream *substream, ...@@ -315,7 +315,7 @@ static int max9860_hw_params(struct snd_pcm_substream *substream,
break; break;
case SND_SOC_DAIFMT_DSP_B: case SND_SOC_DAIFMT_DSP_B:
if (params_width(params) != 16) { if (params_width(params) != 16) {
dev_err(codec->dev, dev_err(component->dev,
"DSP_B works for 16 bits per sample only.\n"); "DSP_B works for 16 bits per sample only.\n");
return -EINVAL; return -EINVAL;
} }
...@@ -352,16 +352,16 @@ static int max9860_hw_params(struct snd_pcm_substream *substream, ...@@ -352,16 +352,16 @@ static int max9860_hw_params(struct snd_pcm_substream *substream,
return -EINVAL; return -EINVAL;
} }
dev_dbg(codec->dev, "IFC1A %02x\n", ifc1a); dev_dbg(component->dev, "IFC1A %02x\n", ifc1a);
ret = regmap_write(max9860->regmap, MAX9860_IFC1A, ifc1a); ret = regmap_write(max9860->regmap, MAX9860_IFC1A, ifc1a);
if (ret) { if (ret) {
dev_err(codec->dev, "Failed to set IFC1A: %d\n", ret); dev_err(component->dev, "Failed to set IFC1A: %d\n", ret);
return ret; return ret;
} }
dev_dbg(codec->dev, "IFC1B %02x\n", ifc1b); dev_dbg(component->dev, "IFC1B %02x\n", ifc1b);
ret = regmap_write(max9860->regmap, MAX9860_IFC1B, ifc1b); ret = regmap_write(max9860->regmap, MAX9860_IFC1B, ifc1b);
if (ret) { if (ret) {
dev_err(codec->dev, "Failed to set IFC1B: %d\n", ret); dev_err(component->dev, "Failed to set IFC1B: %d\n", ret);
return ret; return ret;
} }
...@@ -417,33 +417,33 @@ static int max9860_hw_params(struct snd_pcm_substream *substream, ...@@ -417,33 +417,33 @@ static int max9860_hw_params(struct snd_pcm_substream *substream,
} }
sysclk |= max9860->psclk; sysclk |= max9860->psclk;
dev_dbg(codec->dev, "SYSCLK %02x\n", sysclk); dev_dbg(component->dev, "SYSCLK %02x\n", sysclk);
ret = regmap_write(max9860->regmap, ret = regmap_write(max9860->regmap,
MAX9860_SYSCLK, sysclk); MAX9860_SYSCLK, sysclk);
if (ret) { if (ret) {
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;
} }
dev_dbg(codec->dev, "N %lu\n", n); dev_dbg(component->dev, "N %lu\n", n);
ret = regmap_write(max9860->regmap, ret = regmap_write(max9860->regmap,
MAX9860_AUDIOCLKHIGH, n >> 8); MAX9860_AUDIOCLKHIGH, n >> 8);
if (ret) { if (ret) {
dev_err(codec->dev, "Failed to set NHI: %d\n", ret); dev_err(component->dev, "Failed to set NHI: %d\n", ret);
return ret; return ret;
} }
ret = regmap_write(max9860->regmap, ret = regmap_write(max9860->regmap,
MAX9860_AUDIOCLKLOW, n & 0xff); MAX9860_AUDIOCLKLOW, n & 0xff);
if (ret) { if (ret) {
dev_err(codec->dev, "Failed to set NLO: %d\n", ret); dev_err(component->dev, "Failed to set NLO: %d\n", ret);
return ret; return ret;
} }
if (!master) { if (!master) {
dev_dbg(codec->dev, "Enable PLL\n"); dev_dbg(component->dev, "Enable PLL\n");
ret = regmap_update_bits(max9860->regmap, MAX9860_AUDIOCLKHIGH, ret = regmap_update_bits(max9860->regmap, MAX9860_AUDIOCLKHIGH,
MAX9860_PLL, MAX9860_PLL); MAX9860_PLL, MAX9860_PLL);
if (ret) { if (ret) {
dev_err(codec->dev, "Failed to enable PLL: %d\n", ret); dev_err(component->dev, "Failed to enable PLL: %d\n", ret);
return ret; return ret;
} }
} }
...@@ -453,8 +453,8 @@ static int max9860_hw_params(struct snd_pcm_substream *substream, ...@@ -453,8 +453,8 @@ static int max9860_hw_params(struct snd_pcm_substream *substream,
static int max9860_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) static int max9860_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct max9860_priv *max9860 = snd_soc_codec_get_drvdata(codec); struct max9860_priv *max9860 = 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:
...@@ -500,10 +500,10 @@ static struct snd_soc_dai_driver max9860_dai = { ...@@ -500,10 +500,10 @@ static struct snd_soc_dai_driver max9860_dai = {
.symmetric_rates = 1, .symmetric_rates = 1,
}; };
static int max9860_set_bias_level(struct snd_soc_codec *codec, static int max9860_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level) enum snd_soc_bias_level level)
{ {
struct max9860_priv *max9860 = dev_get_drvdata(codec->dev); struct max9860_priv *max9860 = dev_get_drvdata(component->dev);
int ret; int ret;
switch (level) { switch (level) {
...@@ -515,7 +515,7 @@ static int max9860_set_bias_level(struct snd_soc_codec *codec, ...@@ -515,7 +515,7 @@ static int max9860_set_bias_level(struct snd_soc_codec *codec,
ret = regmap_update_bits(max9860->regmap, MAX9860_PWRMAN, ret = regmap_update_bits(max9860->regmap, MAX9860_PWRMAN,
MAX9860_SHDN, MAX9860_SHDN); MAX9860_SHDN, MAX9860_SHDN);
if (ret) { if (ret) {
dev_err(codec->dev, "Failed to remove SHDN: %d\n", ret); dev_err(component->dev, "Failed to remove SHDN: %d\n", ret);
return ret; return ret;
} }
break; break;
...@@ -524,7 +524,7 @@ static int max9860_set_bias_level(struct snd_soc_codec *codec, ...@@ -524,7 +524,7 @@ static int max9860_set_bias_level(struct snd_soc_codec *codec,
ret = regmap_update_bits(max9860->regmap, MAX9860_PWRMAN, ret = regmap_update_bits(max9860->regmap, MAX9860_PWRMAN,
MAX9860_SHDN, 0); MAX9860_SHDN, 0);
if (ret) { if (ret) {
dev_err(codec->dev, "Failed to request SHDN: %d\n", dev_err(component->dev, "Failed to request SHDN: %d\n",
ret); ret);
return ret; return ret;
} }
...@@ -534,18 +534,17 @@ static int max9860_set_bias_level(struct snd_soc_codec *codec, ...@@ -534,18 +534,17 @@ static int max9860_set_bias_level(struct snd_soc_codec *codec,
return 0; return 0;
} }
static const struct snd_soc_codec_driver max9860_codec_driver = { static const struct snd_soc_component_driver max9860_component_driver = {
.set_bias_level = max9860_set_bias_level, .set_bias_level = max9860_set_bias_level,
.idle_bias_off = true,
.component_driver = {
.controls = max9860_controls, .controls = max9860_controls,
.num_controls = ARRAY_SIZE(max9860_controls), .num_controls = ARRAY_SIZE(max9860_controls),
.dapm_widgets = max9860_dapm_widgets, .dapm_widgets = max9860_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(max9860_dapm_widgets), .num_dapm_widgets = ARRAY_SIZE(max9860_dapm_widgets),
.dapm_routes = max9860_dapm_routes, .dapm_routes = max9860_dapm_routes,
.num_dapm_routes = ARRAY_SIZE(max9860_dapm_routes), .num_dapm_routes = ARRAY_SIZE(max9860_dapm_routes),
}, .use_pmdown_time = 1,
.endianness = 1,
.non_legacy_dai_naming = 1,
}; };
#ifdef CONFIG_PM #ifdef CONFIG_PM
...@@ -698,7 +697,7 @@ static int max9860_probe(struct i2c_client *i2c, ...@@ -698,7 +697,7 @@ static int max9860_probe(struct i2c_client *i2c,
pm_runtime_enable(dev); pm_runtime_enable(dev);
pm_runtime_idle(dev); pm_runtime_idle(dev);
ret = snd_soc_register_codec(dev, &max9860_codec_driver, ret = devm_snd_soc_register_component(dev, &max9860_component_driver,
&max9860_dai, 1); &max9860_dai, 1);
if (ret) { if (ret) {
dev_err(dev, "Failed to register CODEC: %d\n", ret); dev_err(dev, "Failed to register CODEC: %d\n", ret);
...@@ -719,7 +718,6 @@ static int max9860_remove(struct i2c_client *i2c) ...@@ -719,7 +718,6 @@ static int max9860_remove(struct i2c_client *i2c)
struct device *dev = &i2c->dev; struct device *dev = &i2c->dev;
struct max9860_priv *max9860 = dev_get_drvdata(dev); struct max9860_priv *max9860 = dev_get_drvdata(dev);
snd_soc_unregister_codec(dev);
pm_runtime_disable(dev); pm_runtime_disable(dev);
regulator_disable(max9860->dvddio); regulator_disable(max9860->dvddio);
return 0; return 0;
......
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