.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * HID driver for Nintendo Wii / Wii U peripherals |
---|
3 | 4 | * Copyright (c) 2011-2013 David Herrmann <dh.herrmann@gmail.com> |
---|
4 | 5 | */ |
---|
5 | 6 | |
---|
6 | 7 | /* |
---|
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. |
---|
11 | 8 | */ |
---|
12 | 9 | |
---|
13 | 10 | #include <linux/completion.h> |
---|
.. | .. |
---|
1589 | 1586 | void (*func)(struct wiimote_data *wdata, const __u8 *payload); |
---|
1590 | 1587 | }; |
---|
1591 | 1588 | |
---|
1592 | | -static struct wiiproto_handler handlers[] = { |
---|
| 1589 | +static const struct wiiproto_handler handlers[] = { |
---|
1593 | 1590 | { .id = WIIPROTO_REQ_STATUS, .size = 6, .func = handler_status }, |
---|
1594 | 1591 | { .id = WIIPROTO_REQ_STATUS, .size = 2, .func = handler_status_K }, |
---|
1595 | 1592 | { .id = WIIPROTO_REQ_DATA, .size = 21, .func = handler_data }, |
---|
.. | .. |
---|
1621 | 1618 | u8 *raw_data, int size) |
---|
1622 | 1619 | { |
---|
1623 | 1620 | struct wiimote_data *wdata = hid_get_drvdata(hdev); |
---|
1624 | | - struct wiiproto_handler *h; |
---|
| 1621 | + const struct wiiproto_handler *h; |
---|
1625 | 1622 | int i; |
---|
1626 | 1623 | unsigned long flags; |
---|
1627 | 1624 | |
---|
1628 | 1625 | if (size < 1) |
---|
1629 | 1626 | return -EINVAL; |
---|
1630 | 1627 | |
---|
1631 | | - spin_lock_irqsave(&wdata->state.lock, flags); |
---|
1632 | | - |
---|
1633 | 1628 | for (i = 0; handlers[i].id; ++i) { |
---|
1634 | 1629 | h = &handlers[i]; |
---|
1635 | 1630 | if (h->id == raw_data[0] && h->size < size) { |
---|
| 1631 | + spin_lock_irqsave(&wdata->state.lock, flags); |
---|
1636 | 1632 | h->func(wdata, &raw_data[1]); |
---|
| 1633 | + spin_unlock_irqrestore(&wdata->state.lock, flags); |
---|
1637 | 1634 | break; |
---|
1638 | 1635 | } |
---|
1639 | 1636 | } |
---|
.. | .. |
---|
1641 | 1638 | if (!handlers[i].id) |
---|
1642 | 1639 | hid_warn(hdev, "Unhandled report %hhu size %d\n", raw_data[0], |
---|
1643 | 1640 | size); |
---|
1644 | | - |
---|
1645 | | - spin_unlock_irqrestore(&wdata->state.lock, flags); |
---|
1646 | 1641 | |
---|
1647 | 1642 | return 0; |
---|
1648 | 1643 | } |
---|
.. | .. |
---|
1675 | 1670 | case WIIMOTE_EXT_GUITAR: |
---|
1676 | 1671 | return sprintf(buf, "guitar\n"); |
---|
1677 | 1672 | case WIIMOTE_EXT_UNKNOWN: |
---|
1678 | | - /* fallthrough */ |
---|
1679 | 1673 | default: |
---|
1680 | 1674 | return sprintf(buf, "unknown\n"); |
---|
1681 | 1675 | } |
---|
.. | .. |
---|
1725 | 1719 | case WIIMOTE_DEV_PENDING: |
---|
1726 | 1720 | return sprintf(buf, "pending\n"); |
---|
1727 | 1721 | case WIIMOTE_DEV_UNKNOWN: |
---|
1728 | | - /* fallthrough */ |
---|
1729 | 1722 | default: |
---|
1730 | 1723 | return sprintf(buf, "unknown\n"); |
---|
1731 | 1724 | } |
---|
.. | .. |
---|
1873 | 1866 | USB_DEVICE_ID_NINTENDO_WIIMOTE2) }, |
---|
1874 | 1867 | { } |
---|
1875 | 1868 | }; |
---|
| 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 | + |
---|
1876 | 1874 | MODULE_DEVICE_TABLE(hid, wiimote_hid_devices); |
---|
1877 | 1875 | |
---|
1878 | 1876 | static struct hid_driver wiimote_hid_driver = { |
---|