Commit 672c29b9 authored by Geert Uytterhoeven's avatar Geert Uytterhoeven Committed by Mauro Carvalho Chehab
Browse files

media: i2c: Use div64_ul() for u64-by-unsigned-long divide



div_u64() does a 64-by-32 division, while the divisor max2175.xtal_freq
is unsigned long, thus 64-bit on 64-bit platforms.  Hence the proper
function to call is div64_ul().

Note that this change does not have any functional impact, as the
crystal frequency must be much lower than the 32-bit limit anyway.
On 32-bit platforms, the generated code is the same.  But at least on
arm64, this saves an AND-instruction to truncate xtal_freq to 32-bit.

Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: default avatarSimon Horman <horms+renesas@verge.net.au>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent 31218df7
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -591,7 +591,7 @@ static int max2175_set_lo_freq(struct max2175 *ctx, u32 lo_freq)
		lo_freq *= lo_mult;

	int_desired = lo_freq / ctx->xtal_freq;
	frac_desired = div_u64((u64)(lo_freq % ctx->xtal_freq) << 20,
	frac_desired = div64_ul((u64)(lo_freq % ctx->xtal_freq) << 20,
				ctx->xtal_freq);

	/* Check CSM is not busy */