diff options
author | Nicolin Chen <nicoleotsuka@gmail.com> | 2018-04-08 17:33:54 -0700 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2018-04-16 13:04:40 +0100 |
commit | 8a2278b7fb3df67cd415c679ba1a0e5e4a1761a7 (patch) | |
tree | d53889272ca23930fc49af307484cb228df55e13 /sound/soc/fsl | |
parent | 728815e3feec751769b3a9fe406fbc529de7cdc0 (diff) | |
download | linux-8a2278b7fb3df67cd415c679ba1a0e5e4a1761a7.tar.gz linux-8a2278b7fb3df67cd415c679ba1a0e5e4a1761a7.tar.bz2 linux-8a2278b7fb3df67cd415c679ba1a0e5e4a1761a7.zip |
ASoC: fsl_esai: Add freq check in set_dai_sysclk()
The freq parameter indicates the physical frequency of an actual
input clock or a desired frequency of an output clock for HCKT/R.
It should never be passed 0. This might cause Division-by-zero.
So this patch adds a check to fix it.
Signed-off-by: Nicolin Chen <nicoleotsuka@gmail.com>
Reviewed-by: Fabio Estevam <fabio.estevam@nxp.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/fsl')
-rw-r--r-- | sound/soc/fsl/fsl_esai.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/sound/soc/fsl/fsl_esai.c b/sound/soc/fsl/fsl_esai.c index da8fd98c7f51..d79e99ef31ad 100644 --- a/sound/soc/fsl/fsl_esai.c +++ b/sound/soc/fsl/fsl_esai.c @@ -226,6 +226,12 @@ static int fsl_esai_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned long clk_rate; int ret; + if (freq == 0) { + dev_err(dai->dev, "%sput freq of HCK%c should not be 0Hz\n", + in ? "in" : "out", tx ? 'T' : 'R'); + return -EINVAL; + } + /* Bypass divider settings if the requirement doesn't change */ if (freq == esai_priv->hck_rate[tx] && dir == esai_priv->hck_dir[tx]) return 0; |