OSDN Git Service

ASoC: sgtl5000: avoid division by zero if lo_vag is zero
[sagit-ice-cold/kernel_xiaomi_msm8998.git] / sound / soc / codecs / sgtl5000.c
index 4808b70..a3dd703 100644 (file)
@@ -1415,7 +1415,7 @@ static int sgtl5000_set_power_regs(struct snd_soc_codec *codec)
         * Searching for a suitable index solving this formula:
         * idx = 40 * log10(vag_val / lo_cagcntrl) + 15
         */
-       vol_quot = (vag * 100) / lo_vag;
+       vol_quot = lo_vag ? (vag * 100) / lo_vag : 0;
        lo_vol = 0;
        for (i = 0; i < ARRAY_SIZE(vol_quot_table); i++) {
                if (vol_quot >= vol_quot_table[i])