Commit 86909c8f authored by Hans de Goede's avatar Hans de Goede Committed by Mark Brown

ASoC: Intel: bytcht_es8316: Minor refactoring

Some minor refactoring:
1) Group the code setting the card dev and prive pointers together with
   registering the card
2) Properly put the comment about registering the card at the place where
   we actually register the card and add a new comment for getting the clk
3) Add a struct device *dev helper variable (this will be used more in
   follow up commits)
4) Reword error message to have the same "foo failed: %d" wording as others
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Acked-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 6ca382c4
...@@ -237,17 +237,18 @@ static char codec_name[SND_ACPI_I2C_ID_LEN]; ...@@ -237,17 +237,18 @@ static char codec_name[SND_ACPI_I2C_ID_LEN];
static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev) static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev)
{ {
struct byt_cht_es8316_private *priv; struct byt_cht_es8316_private *priv;
struct device *dev = &pdev->dev;
struct snd_soc_acpi_mach *mach; struct snd_soc_acpi_mach *mach;
const char *i2c_name = NULL; const char *i2c_name = NULL;
int dai_index = 0; int dai_index = 0;
int i; int i;
int ret = 0; int ret = 0;
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv) if (!priv)
return -ENOMEM; return -ENOMEM;
mach = (&pdev->dev)->platform_data; mach = dev->platform_data;
/* fix index of codec dai */ /* fix index of codec dai */
for (i = 0; i < ARRAY_SIZE(byt_cht_es8316_dais); i++) { for (i = 0; i < ARRAY_SIZE(byt_cht_es8316_dais); i++) {
if (!strcmp(byt_cht_es8316_dais[i].codec_name, if (!strcmp(byt_cht_es8316_dais[i].codec_name,
...@@ -265,26 +266,25 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev) ...@@ -265,26 +266,25 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev)
byt_cht_es8316_dais[dai_index].codec_name = codec_name; byt_cht_es8316_dais[dai_index].codec_name = codec_name;
} }
/* register the soc card */ /* get the clock */
byt_cht_es8316_card.dev = &pdev->dev; priv->mclk = devm_clk_get(dev, "pmc_plt_clk_3");
snd_soc_card_set_drvdata(&byt_cht_es8316_card, priv);
priv->mclk = devm_clk_get(&pdev->dev, "pmc_plt_clk_3");
if (IS_ERR(priv->mclk)) { if (IS_ERR(priv->mclk)) {
ret = PTR_ERR(priv->mclk); ret = PTR_ERR(priv->mclk);
dev_err(&pdev->dev, dev_err(dev, "clk_get pmc_plt_clk_3 failed: %d\n", ret);
"Failed to get MCLK from pmc_plt_clk_3: %d\n",
ret);
return ret; return ret;
} }
ret = devm_snd_soc_register_card(&pdev->dev, &byt_cht_es8316_card); /* register the soc card */
byt_cht_es8316_card.dev = dev;
snd_soc_card_set_drvdata(&byt_cht_es8316_card, priv);
ret = devm_snd_soc_register_card(dev, &byt_cht_es8316_card);
if (ret) { if (ret) {
dev_err(&pdev->dev, "snd_soc_register_card failed %d\n", ret); dev_err(dev, "snd_soc_register_card failed: %d\n", ret);
return ret; return ret;
} }
platform_set_drvdata(pdev, &byt_cht_es8316_card); platform_set_drvdata(pdev, &byt_cht_es8316_card);
return ret; return 0;
} }
static struct platform_driver snd_byt_cht_es8316_mc_driver = { static struct platform_driver snd_byt_cht_es8316_mc_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