f93bdfe63e896248666fa9701301a711baa7a7e6
[openwrt/staging/ldir.git] /
1 From 12b887445779c33285dac5279fc02fd80e0800d8 Mon Sep 17 00:00:00 2001
2 From: Viorel Suman <viorel.suman@nxp.com>
3 Date: Fri, 9 Mar 2018 12:41:42 +0200
4 Subject: [PATCH] MLK-17580: ASoC: fsl: sai: check for pinctrl status
5
6 For some cases (like AMIX) pinctrl may be null - this
7 breaks SAI functionality. Enforce pinctrl null pointer
8 checking prior calling any function which involves
9 pins state changes.
10
11 Signed-off-by: Viorel Suman <viorel.suman@nxp.com>
12 ---
13 sound/soc/fsl/fsl_sai.c | 21 ++++++++++++---------
14 1 file changed, 12 insertions(+), 9 deletions(-)
15
16 --- a/sound/soc/fsl/fsl_sai.c
17 +++ b/sound/soc/fsl/fsl_sai.c
18 @@ -530,14 +530,17 @@ static int fsl_sai_hw_params(struct snd_
19
20 pins = DIV_ROUND_UP(channels, slots);
21 sai->is_dsd = fsl_is_dsd(params);
22 - sai->pins_state = fsl_get_pins_state(sai->pinctrl, params);
23
24 - if (!IS_ERR_OR_NULL(sai->pins_state)) {
25 - ret = pinctrl_select_state(sai->pinctrl, sai->pins_state);
26 - if (ret) {
27 - dev_err(cpu_dai->dev,
28 - "failed to set proper pins state: %d\n", ret);
29 - return ret;
30 + if (!IS_ERR_OR_NULL(sai->pinctrl)) {
31 + sai->pins_state = fsl_get_pins_state(sai->pinctrl, params);
32 +
33 + if (!IS_ERR_OR_NULL(sai->pins_state)) {
34 + ret = pinctrl_select_state(sai->pinctrl, sai->pins_state);
35 + if (ret) {
36 + dev_err(cpu_dai->dev,
37 + "failed to set proper pins state: %d\n", ret);
38 + return ret;
39 + }
40 }
41 }
42
43 @@ -920,7 +923,7 @@ static int fsl_sai_dai_resume(struct snd
44 struct fsl_sai *sai = snd_soc_dai_get_drvdata(cpu_dai);
45 int ret;
46
47 - if (!IS_ERR_OR_NULL(sai->pins_state)) {
48 + if (!IS_ERR_OR_NULL(sai->pinctrl) && !IS_ERR_OR_NULL(sai->pins_state)) {
49 ret = pinctrl_select_state(sai->pinctrl, sai->pins_state);
50 if (ret) {
51 dev_err(cpu_dai->dev,
52 @@ -1346,7 +1349,7 @@ static int fsl_sai_probe(struct platform
53 sai->dma_params_rx.maxburst = FSL_SAI_MAXBURST_RX;
54 sai->dma_params_tx.maxburst = FSL_SAI_MAXBURST_TX;
55
56 - sai->pinctrl = devm_pinctrl_get(&pdev->dev);
57 + sai->pinctrl = devm_pinctrl_get(&pdev->dev);
58
59 platform_set_drvdata(pdev, sai);
60