summaryrefslogtreecommitdiff
path: root/drivers/hid
diff options
context:
space:
mode:
authorIan Abbott <abbotti@mev.co.uk>2020-09-04 16:21:43 +0300
committerJiri Kosina <jkosina@suse.cz>2020-09-07 17:03:51 +0300
commit5eae59cc876c8c1043d3eb55a2e965bb36e90bba (patch)
tree1684c1a18253b7581549f283a86f566ca375ede1 /drivers/hid
parentaeeba45a9df34a00113f96f9f52c45e250ff7b7d (diff)
downloadlinux-5eae59cc876c8c1043d3eb55a2e965bb36e90bba.tar.xz
HID: wiimote: narrow spinlock range in wiimote_hid_event()
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>
Diffstat (limited to 'drivers/hid')
-rw-r--r--drivers/hid/hid-wiimote-core.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/drivers/hid/hid-wiimote-core.c b/drivers/hid/hid-wiimote-core.c
index e03a0ba5611a..41012681cafd 100644
--- a/drivers/hid/hid-wiimote-core.c
+++ b/drivers/hid/hid-wiimote-core.c
@@ -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;
}
}
@@ -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;
}