linux-6.5/sound/soc/codecs/rt722-sdca.c:612: some confused logic ?

From: David Binderman
Date: Thu Aug 31 2023 - 07:08:21 EST


Hello there,

I just ran cppcheck over the source code of linux-6.5. It said:

linux-6.5/sound/soc/codecs/rt722-sdca.c:612:8: style: Expression is always true because 'else if' condition is opposite to previous condition at line 609. [multiCondition]

Source code is

if (!adc_vol_flag) /* boost gain */
ctl = regvalue / boost_step;
else { /* ADC gain */
if (adc_vol_flag)
ctl = p->max - (((vol_max - regvalue) & 0xffff) / interval_offset);
else
ctl = p->max - (((0 - regvalue) & 0xffff) / interval_offset);
}

This code might benefit from some rework.

Regards

David Binderman