Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit 8c172dde authored by Justin Madru's avatar Justin Madru Committed by Greg Kroah-Hartman
Browse files

Staging: s5k3e2fx.c: simplify complexity by factoring



the code was looping, setting s_move[i] to the following calculations

if (actual_step>= 0)
         s_move[i] = ((((i + 1) * gain + 0x200) - (i * gain + 0x200)) / 0x400);
else
         s_move[i] = ((((i + 1) * gain - 0x200) - (i * gain - 0x200)) / 0x400);

but, this code reduces to the expression
	s_move[i] = gain>>  10;

The reason for the complexity was to generate a step function with
integer division and rounding to land on specific values. But these calculations
can be simplified to the following code:

	gain = ((actual_step<<  10) / 5)>>  10;
	for (i = 0; i<= 4; i++)
		s_move[i] = gain;

Signed-off-by: default avatarJustin <Madru&lt;jdm64@gawab.com>
Reviewed-by: default avatarRay <Lee&lt;ray-lk@madrabbit.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 096417e0
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment