summaryrefslogtreecommitdiff
path: root/sound/soc
diff options
context:
space:
mode:
authorDaniel Baluta <daniel.baluta@nxp.com>2017-06-20 13:46:53 +0300
committerDaniel Baluta <daniel.baluta@nxp.com>2017-06-21 11:49:44 +0300
commitbe3df8a8e94e77acb00e84bd6d7747373c54d1f5 (patch)
treef63f15565a351d2da351aa3005ea27c135a76f51 /sound/soc
parent9e722cd5f7cc95f84819f36cbdad0dc64e2088cb (diff)
MLK-15067: ASoC: fsl: imx-wm8958: Refactor GPR parsing
This is similar with commit c79a82aec8ccf ("ASoC: fsl: imx-wm8960: Refactor GPR parsing") and it is needed for easier adding support for non-gpr boards. Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
Diffstat (limited to 'sound/soc')
-rw-r--r--sound/soc/fsl/imx-wm8958.c43
1 files changed, 29 insertions, 14 deletions
diff --git a/sound/soc/fsl/imx-wm8958.c b/sound/soc/fsl/imx-wm8958.c
index 73e57557f5fc..63c83afb5f48 100644
--- a/sound/soc/fsl/imx-wm8958.c
+++ b/sound/soc/fsl/imx-wm8958.c
@@ -401,6 +401,32 @@ static int imx_wm8958_set_bias_level_post(struct snd_soc_card *card,
return 0;
}
+static int of_parse_gpr(struct platform_device *pdev,
+ struct imx_wm8958_data *data)
+{
+ int ret;
+ struct of_phandle_args args;
+
+ ret = of_parse_phandle_with_fixed_args(pdev->dev.of_node,
+ "gpr", 3, 0, &args);
+ if (ret) {
+ dev_warn(&pdev->dev, "failed to get gpr property\n");
+ return ret;
+ }
+
+ data->gpr = syscon_node_to_regmap(args.np);
+ if (IS_ERR(data->gpr)) {
+ ret = PTR_ERR(data->gpr);
+ dev_err(&pdev->dev, "failed to get gpr regmap\n");
+ return ret;
+ }
+
+ regmap_update_bits(data->gpr, args.args[0], args.args[1],
+ args.args[2]);
+
+ return 0;
+}
+
static int imx_wm8958_probe(struct platform_device *pdev)
{
struct device_node *cpu_np, *codec_np = NULL;
@@ -409,7 +435,6 @@ static int imx_wm8958_probe(struct platform_device *pdev)
struct imx_priv *priv = &card_priv;
struct i2c_client *codec_dev;
struct imx_wm8958_data *data;
- struct of_phandle_args args;
int ret;
priv->pdev = pdev;
@@ -448,19 +473,9 @@ static int imx_wm8958_probe(struct platform_device *pdev)
goto fail;
}
- ret = of_parse_phandle_with_fixed_args(pdev->dev.of_node, "gpr", 3,
- 0, &args);
- if (ret) {
- dev_warn(&pdev->dev, "failed to get gpr property\n");
- } else {
- data->gpr = syscon_node_to_regmap(args.np);
- if (IS_ERR(data->gpr)) {
- ret = PTR_ERR(data->gpr);
- dev_err(&pdev->dev, "failed to get gpr regmap\n");
- goto fail;
- }
- regmap_update_bits(data->gpr, args.args[0], args.args[1], args.args[2]);
- }
+ ret = of_parse_gpr(pdev, data);
+ if (ret)
+ goto fail;
if (of_property_read_bool(np, "codec-master")) {
data->dai.dai_fmt = SND_SOC_DAIFMT_CBM_CFM;