hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/hid/hid-wiimote-core.c
....@@ -1,13 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * HID driver for Nintendo Wii / Wii U peripherals
34 * Copyright (c) 2011-2013 David Herrmann <dh.herrmann@gmail.com>
45 */
56
67 /*
7
- * This program is free software; you can redistribute it and/or modify it
8
- * under the terms of the GNU General Public License as published by the Free
9
- * Software Foundation; either version 2 of the License, or (at your option)
10
- * any later version.
118 */
129
1310 #include <linux/completion.h>
....@@ -1589,7 +1586,7 @@
15891586 void (*func)(struct wiimote_data *wdata, const __u8 *payload);
15901587 };
15911588
1592
-static struct wiiproto_handler handlers[] = {
1589
+static const struct wiiproto_handler handlers[] = {
15931590 { .id = WIIPROTO_REQ_STATUS, .size = 6, .func = handler_status },
15941591 { .id = WIIPROTO_REQ_STATUS, .size = 2, .func = handler_status_K },
15951592 { .id = WIIPROTO_REQ_DATA, .size = 21, .func = handler_data },
....@@ -1621,19 +1618,19 @@
16211618 u8 *raw_data, int size)
16221619 {
16231620 struct wiimote_data *wdata = hid_get_drvdata(hdev);
1624
- struct wiiproto_handler *h;
1621
+ const struct wiiproto_handler *h;
16251622 int i;
16261623 unsigned long flags;
16271624
16281625 if (size < 1)
16291626 return -EINVAL;
16301627
1631
- spin_lock_irqsave(&wdata->state.lock, flags);
1632
-
16331628 for (i = 0; handlers[i].id; ++i) {
16341629 h = &handlers[i];
16351630 if (h->id == raw_data[0] && h->size < size) {
1631
+ spin_lock_irqsave(&wdata->state.lock, flags);
16361632 h->func(wdata, &raw_data[1]);
1633
+ spin_unlock_irqrestore(&wdata->state.lock, flags);
16371634 break;
16381635 }
16391636 }
....@@ -1641,8 +1638,6 @@
16411638 if (!handlers[i].id)
16421639 hid_warn(hdev, "Unhandled report %hhu size %d\n", raw_data[0],
16431640 size);
1644
-
1645
- spin_unlock_irqrestore(&wdata->state.lock, flags);
16461641
16471642 return 0;
16481643 }
....@@ -1675,7 +1670,6 @@
16751670 case WIIMOTE_EXT_GUITAR:
16761671 return sprintf(buf, "guitar\n");
16771672 case WIIMOTE_EXT_UNKNOWN:
1678
- /* fallthrough */
16791673 default:
16801674 return sprintf(buf, "unknown\n");
16811675 }
....@@ -1725,7 +1719,6 @@
17251719 case WIIMOTE_DEV_PENDING:
17261720 return sprintf(buf, "pending\n");
17271721 case WIIMOTE_DEV_UNKNOWN:
1728
- /* fallthrough */
17291722 default:
17301723 return sprintf(buf, "unknown\n");
17311724 }
....@@ -1873,6 +1866,11 @@
18731866 USB_DEVICE_ID_NINTENDO_WIIMOTE2) },
18741867 { }
18751868 };
1869
+
1870
+bool wiimote_dpad_as_analog = false;
1871
+module_param_named(dpad_as_analog, wiimote_dpad_as_analog, bool, 0644);
1872
+MODULE_PARM_DESC(dpad_as_analog, "Use D-Pad as main analog input");
1873
+
18761874 MODULE_DEVICE_TABLE(hid, wiimote_hid_devices);
18771875
18781876 static struct hid_driver wiimote_hid_driver = {