Skip to content

Commit

Permalink
Merge branch 'for-5.10/wiimote' into for-linus
Browse files Browse the repository at this point in the history
- code cleanups for hid-wiimote
  • Loading branch information
Jiri Kosina committed Oct 15, 2020
2 parents df97550 + 5eae59c commit 146f9d9
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions drivers/hid/hid-wiimote-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down Expand Up @@ -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;
}
}
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 146f9d9

Please sign in to comment.