lkml.org 
[lkml]   [2009]   [Dec]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] staging: s5k3e2fx.c: simplify complexity by factoring
On Tue, Dec 15, 2009 at 12:52:10PM -0800, Justin Madru wrote:
> the code was looping, seting 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 redues 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;

Care to resend this with a Signed-off-by: line, and add the reviewed-by
line that was requested by Ray?

thanks,

greg k-h


\
 
 \ /
  Last update: 2009-12-18 20:37    [W:0.174 / U:0.476 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site