Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ASoC: rt1320: fix 32-bit link failure

A plain 64-bit division causes a link failure in some configurations:

ERROR: modpost: "__aeabi_uldivmod" [sound/soc/codecs/snd-soc-rt1320-sdw.ko] undefined!

Since this divides by a constant, using the div_u64() macro ends up
turning this into an efficient multiply/shift operation where possible.

In rt1320_calc_r0(), the open-coded shift seems a litle simpler.

Fixes: da1682d5e8b5 ("ASoC: rt1320: support calibration and temperature/r0 loading")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://patch.msgid.link/20251223215259.677762-1-arnd@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Arnd Bergmann and committed by
Mark Brown
836ecc74 45e9066f

+8 -8
+8 -8
sound/soc/codecs/rt1320-sdw.c
··· 1067 1067 r_rsratio = rt1320_rsgain_to_rsratio(rt1320, r_rsgain); 1068 1068 dev_dbg(dev, "%s, LR rsratio=%lld, %lld\n", __func__, l_rsratio, r_rsratio); 1069 1069 1070 - l_invrs = (l_rsratio * factor) / 1000000000U; 1071 - r_invrs = (r_rsratio * factor) / 1000000000U; 1070 + l_invrs = div_u64(l_rsratio * factor, 1000000000U); 1071 + r_invrs = div_u64(r_rsratio * factor, 1000000000U); 1072 1072 1073 1073 rt1320_fw_param_protocol(rt1320, RT1320_GET_PARAM, 6, &r0_data[0], sizeof(struct rt1320_datafixpoint)); 1074 1074 rt1320_fw_param_protocol(rt1320, RT1320_GET_PARAM, 7, &r0_data[1], sizeof(struct rt1320_datafixpoint)); ··· 1089 1089 static void rt1320_calc_r0(struct rt1320_sdw_priv *rt1320) 1090 1090 { 1091 1091 struct device *dev = &rt1320->sdw_slave->dev; 1092 - unsigned long long l_calir0, r_calir0; 1093 - const unsigned int factor = (1 << 27); 1092 + unsigned long long l_calir0, r_calir0, l_calir0_lo, r_calir0_lo; 1094 1093 1095 - l_calir0 = (rt1320->r0_l_reg * 1000) / factor; 1096 - r_calir0 = (rt1320->r0_r_reg * 1000) / factor; 1094 + l_calir0 = rt1320->r0_l_reg >> 27; 1095 + r_calir0 = rt1320->r0_r_reg >> 27; 1096 + l_calir0_lo = (rt1320->r0_l_reg & ((1ull << 27) - 1) * 1000) >> 27; 1097 + r_calir0_lo = (rt1320->r0_r_reg & ((1ull << 27) - 1) * 1000) >> 27; 1097 1098 1098 1099 dev_dbg(dev, "%s, l_calir0=%lld.%03lld ohm, r_calir0=%lld.%03lld ohm\n", __func__, 1099 - l_calir0 / 1000, l_calir0 % 1000, 1100 - r_calir0 / 1000, r_calir0 % 1000); 1100 + l_calir0, l_calir0_lo, r_calir0, r_calir0_lo); 1101 1101 } 1102 1102 1103 1103 static void rt1320_calibrate(struct rt1320_sdw_priv *rt1320)