* [PATCH] ASoC: hdmi-codec: Fix hdmi_of_xlate_dai_name when #sound-dai-cells = <0>
@ 2016-10-27 11:42 Jon Medhurst (Tixy)
2016-10-27 14:19 ` Mark Brown
0 siblings, 1 reply; 3+ messages in thread
From: Jon Medhurst (Tixy) @ 2016-10-27 11:42 UTC (permalink / raw)
To: Mark Brown, Kuninori Morimoto
Cc: Jyri Sarha, Liam Girdwood, linux-kernel, alsa-devel, linux-arm-kernel
If a DAI specifies "#sound-dai-cells = <0>" in device-tree then
hdmi_of_xlate_dai_name() will be called with zero args, which it isn't
implemented to cope with. The resulting use of an uninitialised variable
for the id will usually result in an error like:
asoc-simple-card sound: parse error -11
asoc-simple-card: probe of sound failed with error -11
Fix this by using and id of zero if no arg is provided.
Fixes: 9731f82d6016 ("ASoC: hdmi-codec: enable multi probe for same device")
Signed-off-by: Jon Medhurst <tixy@linaro.org>
---
Jyri, FYI, I believe this issue broke your commit df0bd1e8f3c508 ("ARM: dts:
am335x-boneblack: Add HDMI audio support")
sound/soc/codecs/hdmi-codec.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c
index b904492..6661ace 100644
--- a/sound/soc/codecs/hdmi-codec.c
+++ b/sound/soc/codecs/hdmi-codec.c
@@ -364,7 +364,7 @@ static int hdmi_of_xlate_dai_name(struct snd_soc_component *component,
struct of_phandle_args *args,
const char **dai_name)
{
- int id = args->args[0];
+ int id = args->args_count ? args->args[0] : 0;
if (id < ARRAY_SIZE(hdmi_dai_name)) {
*dai_name = hdmi_dai_name[id];
--
2.1.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ASoC: hdmi-codec: Fix hdmi_of_xlate_dai_name when #sound-dai-cells = <0>
2016-10-27 11:42 [PATCH] ASoC: hdmi-codec: Fix hdmi_of_xlate_dai_name when #sound-dai-cells = <0> Jon Medhurst (Tixy)
@ 2016-10-27 14:19 ` Mark Brown
2016-10-28 8:18 ` [PATCH v2] " Jon Medhurst (Tixy)
0 siblings, 1 reply; 3+ messages in thread
From: Mark Brown @ 2016-10-27 14:19 UTC (permalink / raw)
To: Jon Medhurst (Tixy)
Cc: Kuninori Morimoto, Jyri Sarha, Liam Girdwood, linux-kernel,
alsa-devel, linux-arm-kernel
[-- Attachment #1: Type: text/plain, Size: 200 bytes --]
On Thu, Oct 27, 2016 at 12:42:48PM +0100, Jon Medhurst (Tixy) wrote:
> - int id = args->args[0];
> + int id = args->args_count ? args->args[0] : 0;
Please write normal if statements for legibility.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2] ASoC: hdmi-codec: Fix hdmi_of_xlate_dai_name when #sound-dai-cells = <0>
2016-10-27 14:19 ` Mark Brown
@ 2016-10-28 8:18 ` Jon Medhurst (Tixy)
0 siblings, 0 replies; 3+ messages in thread
From: Jon Medhurst (Tixy) @ 2016-10-28 8:18 UTC (permalink / raw)
To: Mark Brown
Cc: Kuninori Morimoto, Jyri Sarha, Liam Girdwood, linux-kernel,
alsa-devel, linux-arm-kernel
If a DAI specifies "#sound-dai-cells = <0>" in device-tree then
hdmi_of_xlate_dai_name() will be called with zero args, which it isn't
implemented to cope with. The resulting use of an uninitialised variable
for the id will usually result in an error like:
asoc-simple-card sound: parse error -11
asoc-simple-card: probe of sound failed with error -11
Fix this by using and id of zero if no arg is provided.
Fixes: 9731f82d6016 ("ASoC: hdmi-codec: enable multi probe for same device")
Signed-off-by: Jon Medhurst <tixy@linaro.org>
---
Changes since v1
- Replace ternary ?: operator with if/else
sound/soc/codecs/hdmi-codec.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c
index b904492..90b5948 100644
--- a/sound/soc/codecs/hdmi-codec.c
+++ b/sound/soc/codecs/hdmi-codec.c
@@ -364,7 +364,12 @@ static int hdmi_of_xlate_dai_name(struct snd_soc_component *component,
struct of_phandle_args *args,
const char **dai_name)
{
- int id = args->args[0];
+ int id;
+
+ if (args->args_count)
+ id = args->args[0];
+ else
+ id = 0;
if (id < ARRAY_SIZE(hdmi_dai_name)) {
*dai_name = hdmi_dai_name[id];
--
2.1.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-10-28 8:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-27 11:42 [PATCH] ASoC: hdmi-codec: Fix hdmi_of_xlate_dai_name when #sound-dai-cells = <0> Jon Medhurst (Tixy)
2016-10-27 14:19 ` Mark Brown
2016-10-28 8:18 ` [PATCH v2] " Jon Medhurst (Tixy)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).