diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2009-12-25 00:44:19 -0500 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2009-12-25 00:54:09 -0500 |
commit | 1b11c88d3e8f55dc9d193d19de11e3f7abc1b7d7 (patch) | |
tree | 51adca3f94ca3a1a31d249faa9da8b6b0d3f8e6b /drivers | |
parent | 25ae08317647c68ed9276f7bdc07d0d5fd042628 (diff) |
Input: ff-memless - another fix for signed to unsigned overflow
The commit 9e68177ef93b2f34eee5a1e1707bceef4b9ba69c changed 'gain' from
signed to unsigned to fix an issue with rumble effect calculation, however
it introduced problems when calculating constant effects. Having 'gain'
being unsigned int was an unfortunate choice since it dominates all
implicit type conversions causing everything to be treated as unsigned
int.
Let's change it back to signed int and simply add proper casts to rumble
effect calculations.
Reported-by: Gary Stein <lordcnidarian@gmail.com>
Acked-by: Anssi Hannula <anssi.hannula@iki.fi>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/input/ff-memless.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/input/ff-memless.c b/drivers/input/ff-memless.c index decc51f45bfd..9667a5fd6bd7 100644 --- a/drivers/input/ff-memless.c +++ b/drivers/input/ff-memless.c | |||
@@ -225,7 +225,7 @@ static int get_compatible_type(struct ff_device *ff, int effect_type) | |||
225 | */ | 225 | */ |
226 | static void ml_combine_effects(struct ff_effect *effect, | 226 | static void ml_combine_effects(struct ff_effect *effect, |
227 | struct ml_effect_state *state, | 227 | struct ml_effect_state *state, |
228 | unsigned int gain) | 228 | int gain) |
229 | { | 229 | { |
230 | struct ff_effect *new = state->effect; | 230 | struct ff_effect *new = state->effect; |
231 | unsigned int strong, weak, i; | 231 | unsigned int strong, weak, i; |
@@ -252,8 +252,8 @@ static void ml_combine_effects(struct ff_effect *effect, | |||
252 | break; | 252 | break; |
253 | 253 | ||
254 | case FF_RUMBLE: | 254 | case FF_RUMBLE: |
255 | strong = new->u.rumble.strong_magnitude * gain / 0xffff; | 255 | strong = (u32)new->u.rumble.strong_magnitude * gain / 0xffff; |
256 | weak = new->u.rumble.weak_magnitude * gain / 0xffff; | 256 | weak = (u32)new->u.rumble.weak_magnitude * gain / 0xffff; |
257 | effect->u.rumble.strong_magnitude = | 257 | effect->u.rumble.strong_magnitude = |
258 | min(strong + effect->u.rumble.strong_magnitude, | 258 | min(strong + effect->u.rumble.strong_magnitude, |
259 | 0xffffU); | 259 | 0xffffU); |