diff options
author | Jiri Kosina | 2020-10-15 20:41:00 +0200 |
---|---|---|
committer | Jiri Kosina | 2020-10-15 20:41:00 +0200 |
commit | 146f9d9189b153c3132429578554f3a7896081fc (patch) | |
tree | 86edbe98ce5159c98ff2f00547149971d94c8cd5 /drivers/hid | |
parent | df975502e5b793d40e094df8c8b1252f6b28a554 (diff) | |
parent | 5eae59cc876c8c1043d3eb55a2e965bb36e90bba (diff) |
Merge branch 'for-5.10/wiimote' into for-linus
- code cleanups for hid-wiimote
Diffstat (limited to 'drivers/hid')
-rw-r--r-- | drivers/hid/hid-wiimote-core.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/drivers/hid/hid-wiimote-core.c b/drivers/hid/hid-wiimote-core.c index e484c3618dec..41012681cafd 100644 --- a/drivers/hid/hid-wiimote-core.c +++ b/drivers/hid/hid-wiimote-core.c @@ -1586,7 +1586,7 @@ struct wiiproto_handler { void (*func)(struct wiimote_data *wdata, const __u8 *payload); }; -static struct wiiproto_handler handlers[] = { +static const struct wiiproto_handler handlers[] = { { .id = WIIPROTO_REQ_STATUS, .size = 6, .func = handler_status }, { .id = WIIPROTO_REQ_STATUS, .size = 2, .func = handler_status_K }, { .id = WIIPROTO_REQ_DATA, .size = 21, .func = handler_data }, @@ -1618,19 +1618,19 @@ static int wiimote_hid_event(struct hid_device *hdev, struct hid_report *report, u8 *raw_data, int size) { struct wiimote_data *wdata = hid_get_drvdata(hdev); - struct wiiproto_handler *h; + const struct wiiproto_handler *h; int i; unsigned long flags; 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; } |