Skip to content

Commit 146f9d9

Browse files
author
Jiri Kosina
committed
Merge branch 'for-5.10/wiimote' into for-linus
- code cleanups for hid-wiimote
2 parents df97550 + 5eae59c commit 146f9d9

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

drivers/hid/hid-wiimote-core.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1586,7 +1586,7 @@ struct wiiproto_handler {
15861586
void (*func)(struct wiimote_data *wdata, const __u8 *payload);
15871587
};
15881588

1589-
static struct wiiproto_handler handlers[] = {
1589+
static const struct wiiproto_handler handlers[] = {
15901590
{ .id = WIIPROTO_REQ_STATUS, .size = 6, .func = handler_status },
15911591
{ .id = WIIPROTO_REQ_STATUS, .size = 2, .func = handler_status_K },
15921592
{ .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,
16181618
u8 *raw_data, int size)
16191619
{
16201620
struct wiimote_data *wdata = hid_get_drvdata(hdev);
1621-
struct wiiproto_handler *h;
1621+
const struct wiiproto_handler *h;
16221622
int i;
16231623
unsigned long flags;
16241624

16251625
if (size < 1)
16261626
return -EINVAL;
16271627

1628-
spin_lock_irqsave(&wdata->state.lock, flags);
1629-
16301628
for (i = 0; handlers[i].id; ++i) {
16311629
h = &handlers[i];
16321630
if (h->id == raw_data[0] && h->size < size) {
1631+
spin_lock_irqsave(&wdata->state.lock, flags);
16331632
h->func(wdata, &raw_data[1]);
1633+
spin_unlock_irqrestore(&wdata->state.lock, flags);
16341634
break;
16351635
}
16361636
}
@@ -1639,8 +1639,6 @@ static int wiimote_hid_event(struct hid_device *hdev, struct hid_report *report,
16391639
hid_warn(hdev, "Unhandled report %hhu size %d\n", raw_data[0],
16401640
size);
16411641

1642-
spin_unlock_irqrestore(&wdata->state.lock, flags);
1643-
16441642
return 0;
16451643
}
16461644

0 commit comments

Comments
 (0)