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.
Unified · Split
| @@ -226,6 +226,12 @@ static int fsl_esai_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, · 225 unmodified lines | |||
| 226 | unsigned long clk_rate; | 226 | unsigned long clk_rate; |
| 227 | int ret; | 227 | int ret; |
| 228 | 228 | ||
| 229 | if (freq == 0) { | ||
| 230 | dev_err(dai->dev, "%sput freq of HCK%c should not be 0Hz\n", | ||
| 231 | in ? "in" : "out", tx ? 'T' : 'R'); | ||
| 232 | return -EINVAL; | ||
| 233 | } | ||
| 234 | |||
| 229 | /* Bypass divider settings if the requirement doesn't change */ | 235 | /* Bypass divider settings if the requirement doesn't change */ |
| 230 | if (freq == esai_priv->hck_rate[tx] && dir == esai_priv->hck_dir[tx]) | 236 | if (freq == esai_priv->hck_rate[tx] && dir == esai_priv->hck_dir[tx]) |
| 231 | return 0; | 237 | return 0; |