Skip to content

Commit

Permalink
HID: wiimote: narrow spinlock range in wiimote_hid_event()
Browse files Browse the repository at this point in the history
In `wiimote_hid_event()`, the `wdata->state.lock` spinlock does not need
to be held while searching `handlers[]` for a suitable handler function.
Change it so the spinlock is only held during the call to the handler
function itself.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: David Rheinsberg <david.rheinsberg@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
  • Loading branch information
Ian Abbott authored and Jiri Kosina committed Sep 7, 2020
1 parent aeeba45 commit 5eae59c
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions drivers/hid/hid-wiimote-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1625,12 +1625,12 @@ static int wiimote_hid_event(struct hid_device *hdev, struct hid_report *report,
if (size < 1)
return -EINVAL;

spin_lock_irqsave(&wdata->state.lock, flags);

for (i = 0; handlers[i].id; ++i) {
h = &handlers[i];
if (h->id == raw_data[0] && h->size < size) {
spin_lock_irqsave(&wdata->state.lock, flags);
h->func(wdata, &raw_data[1]);
spin_unlock_irqrestore(&wdata->state.lock, flags);
break;
}
}
Expand All @@ -1639,8 +1639,6 @@ static int wiimote_hid_event(struct hid_device *hdev, struct hid_report *report,
hid_warn(hdev, "Unhandled report %hhu size %d\n", raw_data[0],
size);

spin_unlock_irqrestore(&wdata->state.lock, flags);

return 0;
}

Expand Down

0 comments on commit 5eae59c

Please sign in to comment.