From: Justin Madru <jdm64@gawab.com>
To: gregkh@suse.de
Cc: Dan Carpenter <error27@gmail.com>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: s5k3e2fx.c: reduce complexity by factoring
Date: Mon, 14 Dec 2009 16:38:40 -0800 [thread overview]
Message-ID: <4B26DA90.7090702@gawab.com> (raw)
In-Reply-To: <20091209095700.GA19355@bicker>
On 12/09/2009 01:57 AM, Dan Carpenter wrote:
> On Sat, Dec 05, 2009 at 06:03:20PM -0800, Justin Madru wrote:
>
>> I was style fixing some code when I ran into this code.
>> It seems like the code could be reduced, by factoring the expression.
>> But this results in a very simple expression.
>>
>> Am I assuming something wrong? Or is this a bug in the original code?
>> This doesn't look right because the assignment of s_move[i] has no mention
>> of the loop counter.
>>
>> Justin
>>
>> ------
>>
>> 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, by factoring the expression, it can be shown that they both reduce
>> to a very simple expression:
>>
>> s_move[i] = gain / 0x400;
>>
>>
> Heh.
>
> Looks like an improvement to me.
>
> If gain were 16 bits instead of 32 I would think the "* 0x400 / 0x400" was
> designed to mask out the highest 10 bits.
>
> Acked-by: Dan Carpenter<error27@gmail.com>
>
> regards,
> dan carpenter
>
>
>> Signed-off-by: Justin Madru<jdm64@gawab.com>
>> ---
>> drivers/staging/dream/camera/s5k3e2fx.c | 10 +++-------
>> 1 files changed, 3 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/staging/dream/camera/s5k3e2fx.c b/drivers/staging/dream/camera/s5k3e2fx.c
>> index f0e49be..d205a2d 100644
>> --- a/drivers/staging/dream/camera/s5k3e2fx.c
>> +++ b/drivers/staging/dream/camera/s5k3e2fx.c
>> @@ -1092,14 +1092,10 @@ static int32_t s5k3e2fx_move_focus(int direction, int32_t num_steps)
>>
>> actual_step = step_direction * (int16_t)num_steps;
>> pos_offset = init_code + s5k3e2fx_ctrl->curr_lens_pos;
>> - gain = actual_step * 0x400 / 5;
>> + gain = actual_step / 5;
>>
>> - for (i = 0; i<= 4; i++) {
>> - 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);
>> - }
>> + for (i = 0; i<= 4; i++)
>> + s_move[i] = gain;
>>
>> /* Ring Damping Code */
>> for (i = 0; i<= 4; i++) {
>> --
>> 1.6.5.4
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at http://www.tux.org/lkml/
>>
I've yet to see a reply from GregH. Has this patch been misplaced or
dropped?
Or is the patch no longer valid/correct?
Justin Madru
next prev parent reply other threads:[~2009-12-15 0:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-06 2:03 [PATCH] staging: s5k3e2fx.c: reduce complexity by factoring Justin Madru
2009-12-09 9:57 ` Dan Carpenter
2009-12-15 0:38 ` Justin Madru [this message]
2009-12-15 0:47 ` Greg KH
2009-12-15 4:02 ` Ray Lee
2009-12-15 18:37 ` Justin Madru
2009-12-15 19:10 ` Ray Lee
2009-12-15 20:57 ` Justin Madru
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4B26DA90.7090702@gawab.com \
--to=jdm64@gawab.com \
--cc=error27@gmail.com \
--cc=gregkh@suse.de \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox