Skip to content

Commit

Permalink
HID: pidff - fix unnecessary loop iterations on reset
Browse files Browse the repository at this point in the history
When encountering a strange value in the pool report, pidff_reset
will always refetch the report 20 times, even if one of the retries
results in a sane value. This is because a temporary variable being
used to store the value is not being updated inside the loop.

Fix it by using the value directly in the loop.

Reported-by: Roel Kluin <roel.kluin@gmail.com>
Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
  • Loading branch information
Anssi Hannula authored and Jiri Kosina committed Nov 4, 2009
1 parent 80f5069 commit 1168df7
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions drivers/hid/usbhid/hid-pidff.c
Original file line number Diff line number Diff line change
Expand Up @@ -1181,12 +1181,11 @@ static void pidff_reset(struct pidff_device *pidff)
usbhid_wait_io(hid);

if (pidff->pool[PID_SIMULTANEOUS_MAX].value) {
int sim_effects = pidff->pool[PID_SIMULTANEOUS_MAX].value[0];
while (sim_effects < 2) {
while (pidff->pool[PID_SIMULTANEOUS_MAX].value[0] < 2) {
if (i++ > 20) {
printk(KERN_WARNING "hid-pidff: device reports "
"%d simultaneous effects\n",
sim_effects);
pidff->pool[PID_SIMULTANEOUS_MAX].value[0]);
break;
}
debug("pid_pool requested again");
Expand Down

0 comments on commit 1168df7

Please sign in to comment.