ASoC: rsnd: remove NULL check from rsnd_mod_name()/rsnd_mod_id()
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Wed, 1 Nov 2017 07:17:34 +0000 (07:17 +0000)
committerMark Brown <broonie@kernel.org>
Wed, 1 Nov 2017 09:53:19 +0000 (09:53 +0000)
commit9b6ea25066b05c4b8bc4ea69037741bd67649cd1
treef6a0ef3529915964e3b33c6fc0dd4b2105a2339c
parent21781e87881f9c420871b1d1f3f29d4cd7bffb10
ASoC: rsnd: remove NULL check from rsnd_mod_name()/rsnd_mod_id()

Current rsnd driver has rsnd_mod_id() which returns mod ID,
and it returns -1 if mod was NULL.
In the same time, this driver has rsnd_mod_name() which returns mod
name, and it returns "unknown" if mod or mod->ops was NULL.

Basically these "mod" never be NULL, but the reason why rsnd driver
has such behavior is that DMA path finder is assuming memory as
"mod == NULL".
Thus, current DMA path debug code prints like below.
Here "unknown[-1]" means it was memory.

...
rcar_sound ec500000.sound:   unknown[-1] from
rcar_sound ec500000.sound:   src[0] to
rcar_sound ec500000.sound:   ctu[2]
rcar_sound ec500000.sound:   mix[0]
rcar_sound ec500000.sound:   dvc[0]
rcar_sound ec500000.sound:   ssi[0]
rcar_sound ec500000.sound: audmac[0] unknown[-1] -> src[0]
...

1st issue is that it is confusable for user.
2nd issue is rsnd driver has something like below code.

mask |= 1 << rsnd_mod_id(mod);

Because of this kind of code, some statically code checker will
reports "Shifting by a negative value is undefined behaviour".

But this "mod" never be NULL, thus negative shift never happen.
To avoid these issues, this patch adds new dummy "mem" to
indicate memory, and use it to indicate debug information,
and, remove unneeded "NULL mod" behavior from rsnd_mod_id() and
rsnd_mod_name().

The debug information will be like below by this patch
...
rcar_sound ec500000.sound:   mem[0] from
rcar_sound ec500000.sound:   src[0] to
rcar_sound ec500000.sound:   ctu[2]
rcar_sound ec500000.sound:   mix[0]
rcar_sound ec500000.sound:   dvc[0]
rcar_sound ec500000.sound:   ssi[0]
rcar_sound ec500000.sound: audmac[0] mem[0] -> src[0]
...

Reported-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sh/rcar/core.c
sound/soc/sh/rcar/dma.c
sound/soc/sh/rcar/rsnd.h