diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-01-14 19:20:42 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-01-14 19:20:42 -0500 |
| commit | c2848f2eef4dd08b0fd2a8eba1694fd8e77ddb67 (patch) | |
| tree | 8e84e3cc86074aabd3d2ea9c48e33221bc01d4fe | |
| parent | 75f26df6ae6f8787fc6198609c8be17400a69e25 (diff) | |
| parent | 83f1bfd6f57c422da70d1e296df1becc35c868be (diff) | |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid
Pull HID updates from Jiri Kosina:
- appoint Benjamin Tissoires as co-maintainer / designated reviewer
- sysfs report_descriptor visibility fix for unclaimed devices, from
Andy Lutomirski
- suspend/resume fixes for Sony driver from Frank Praznik
- IRQ deadlock fix from Ioan-Adrian Ratiu
- hid-i2c fixes affecting (at least) Yoga 900 from Mika Westerberg and
Srinivas Pandruvada
- a lot of new device support (especially, but not limited to, Wacom)
and assorted small misc fixes
- almost complete G920 support; the only bit that is missing is
switching the device to HID mode automatically; Simon Wood and Michal
Maly are working on it.
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid: (46 commits)
Revert "INPUT: xpad: switch Logitech G920 Wheel into HID mode"
HID: sensor-hub: Add quirk for Lenovo Yoga 900 with ITE Chips
HID: Add new PID for Microchip Pick16F1454
HID: wacom: Use correct report to query pen ID from INTUOSHT2 devices
HID: i2c-hid: Prevent sending reports from racing with device reset
HID: use kobj_to_dev()
HID: wiimote: use dev_to_wii()
HID: add a new helper to_hid_driver()
HID: use to_hid_device()
HID: move to_hid_device() to hid.h
HID: usbhid: use to_usb_device
HID: corsair: Convert to use module_hid_driver
HID: input: ignore the battery in OKLICK Laser BTmouse
HID: wacom: Fix pad button range for CINTIQ_COMPANION_2
HID: wacom: Fix touchring value reporting
HID: wacom: Report 'strip2' values in ABS_RY
HID: wacom: Limit touchstrip data to 13 bits
HID: wacom: bitwise vs logical ORs
HID: wacom: Apply lowres quirk to BAMBOO_TOUCH devices
HID: enable hid device to suspend/resume asynchronously
...
35 files changed, 819 insertions, 574 deletions
diff --git a/MAINTAINERS b/MAINTAINERS index ab68d0597542..5696e08918f2 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
| @@ -4984,6 +4984,7 @@ F: arch/*/include/asm/suspend*.h | |||
| 4984 | 4984 | ||
| 4985 | HID CORE LAYER | 4985 | HID CORE LAYER |
| 4986 | M: Jiri Kosina <jikos@kernel.org> | 4986 | M: Jiri Kosina <jikos@kernel.org> |
| 4987 | R: Benjamin Tissoires <benjamin.tissoires@redhat.com> | ||
| 4987 | L: linux-input@vger.kernel.org | 4988 | L: linux-input@vger.kernel.org |
| 4988 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid.git | 4989 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid.git |
| 4989 | S: Maintained | 4990 | S: Maintained |
| @@ -11162,6 +11163,7 @@ F: include/linux/usb/gadget* | |||
| 11162 | 11163 | ||
| 11163 | USB HID/HIDBP DRIVERS (USB KEYBOARDS, MICE, REMOTE CONTROLS, ...) | 11164 | USB HID/HIDBP DRIVERS (USB KEYBOARDS, MICE, REMOTE CONTROLS, ...) |
| 11164 | M: Jiri Kosina <jikos@kernel.org> | 11165 | M: Jiri Kosina <jikos@kernel.org> |
| 11166 | R: Benjamin Tissoires <benjamin.tissoires@redhat.com> | ||
| 11165 | L: linux-usb@vger.kernel.org | 11167 | L: linux-usb@vger.kernel.org |
| 11166 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid.git | 11168 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid.git |
| 11167 | S: Maintained | 11169 | S: Maintained |
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index c6f7a694f67a..7e89288b1537 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c | |||
| @@ -625,7 +625,7 @@ static void hid_close_report(struct hid_device *device) | |||
| 625 | 625 | ||
| 626 | static void hid_device_release(struct device *dev) | 626 | static void hid_device_release(struct device *dev) |
| 627 | { | 627 | { |
| 628 | struct hid_device *hid = container_of(dev, struct hid_device, dev); | 628 | struct hid_device *hid = to_hid_device(dev); |
| 629 | 629 | ||
| 630 | hid_close_report(hid); | 630 | hid_close_report(hid); |
| 631 | kfree(hid->dev_rdesc); | 631 | kfree(hid->dev_rdesc); |
| @@ -1571,8 +1571,8 @@ read_report_descriptor(struct file *filp, struct kobject *kobj, | |||
| 1571 | struct bin_attribute *attr, | 1571 | struct bin_attribute *attr, |
| 1572 | char *buf, loff_t off, size_t count) | 1572 | char *buf, loff_t off, size_t count) |
| 1573 | { | 1573 | { |
| 1574 | struct device *dev = container_of(kobj, struct device, kobj); | 1574 | struct device *dev = kobj_to_dev(kobj); |
| 1575 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 1575 | struct hid_device *hdev = to_hid_device(dev); |
| 1576 | 1576 | ||
| 1577 | if (off >= hdev->rsize) | 1577 | if (off >= hdev->rsize) |
| 1578 | return 0; | 1578 | return 0; |
| @@ -1589,7 +1589,7 @@ static ssize_t | |||
| 1589 | show_country(struct device *dev, struct device_attribute *attr, | 1589 | show_country(struct device *dev, struct device_attribute *attr, |
| 1590 | char *buf) | 1590 | char *buf) |
| 1591 | { | 1591 | { |
| 1592 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 1592 | struct hid_device *hdev = to_hid_device(dev); |
| 1593 | 1593 | ||
| 1594 | return sprintf(buf, "%02x\n", hdev->country & 0xff); | 1594 | return sprintf(buf, "%02x\n", hdev->country & 0xff); |
| 1595 | } | 1595 | } |
| @@ -1691,11 +1691,6 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask) | |||
| 1691 | hid_warn(hdev, | 1691 | hid_warn(hdev, |
| 1692 | "can't create sysfs country code attribute err: %d\n", ret); | 1692 | "can't create sysfs country code attribute err: %d\n", ret); |
| 1693 | 1693 | ||
| 1694 | ret = device_create_bin_file(&hdev->dev, &dev_bin_attr_report_desc); | ||
| 1695 | if (ret) | ||
| 1696 | hid_warn(hdev, | ||
| 1697 | "can't create sysfs report descriptor attribute err: %d\n", ret); | ||
| 1698 | |||
| 1699 | hid_info(hdev, "%s: %s HID v%x.%02x %s [%s] on %s\n", | 1694 | hid_info(hdev, "%s: %s HID v%x.%02x %s [%s] on %s\n", |
| 1700 | buf, bus, hdev->version >> 8, hdev->version & 0xff, | 1695 | buf, bus, hdev->version >> 8, hdev->version & 0xff, |
| 1701 | type, hdev->name, hdev->phys); | 1696 | type, hdev->name, hdev->phys); |
| @@ -1707,7 +1702,6 @@ EXPORT_SYMBOL_GPL(hid_connect); | |||
| 1707 | void hid_disconnect(struct hid_device *hdev) | 1702 | void hid_disconnect(struct hid_device *hdev) |
| 1708 | { | 1703 | { |
| 1709 | device_remove_file(&hdev->dev, &dev_attr_country); | 1704 | device_remove_file(&hdev->dev, &dev_attr_country); |
| 1710 | device_remove_bin_file(&hdev->dev, &dev_bin_attr_report_desc); | ||
| 1711 | if (hdev->claimed & HID_CLAIMED_INPUT) | 1705 | if (hdev->claimed & HID_CLAIMED_INPUT) |
| 1712 | hidinput_disconnect(hdev); | 1706 | hidinput_disconnect(hdev); |
| 1713 | if (hdev->claimed & HID_CLAIMED_HIDDEV) | 1707 | if (hdev->claimed & HID_CLAIMED_HIDDEV) |
| @@ -1902,6 +1896,7 @@ static const struct hid_device_id hid_have_special_driver[] = { | |||
| 1902 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD) }, | 1896 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD) }, |
| 1903 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2_2) }, | 1897 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2_2) }, |
| 1904 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G29_WHEEL) }, | 1898 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G29_WHEEL) }, |
| 1899 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G920_WHEEL) }, | ||
| 1905 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_F3D) }, | 1900 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_F3D) }, |
| 1906 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_FFG ) }, | 1901 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_FFG ) }, |
| 1907 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_FORCE3D_PRO) }, | 1902 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_FORCE3D_PRO) }, |
| @@ -2076,7 +2071,7 @@ struct hid_dynid { | |||
| 2076 | static ssize_t store_new_id(struct device_driver *drv, const char *buf, | 2071 | static ssize_t store_new_id(struct device_driver *drv, const char *buf, |
| 2077 | size_t count) | 2072 | size_t count) |
| 2078 | { | 2073 | { |
| 2079 | struct hid_driver *hdrv = container_of(drv, struct hid_driver, driver); | 2074 | struct hid_driver *hdrv = to_hid_driver(drv); |
| 2080 | struct hid_dynid *dynid; | 2075 | struct hid_dynid *dynid; |
| 2081 | __u32 bus, vendor, product; | 2076 | __u32 bus, vendor, product; |
| 2082 | unsigned long driver_data = 0; | 2077 | unsigned long driver_data = 0; |
| @@ -2138,17 +2133,16 @@ static const struct hid_device_id *hid_match_device(struct hid_device *hdev, | |||
| 2138 | 2133 | ||
| 2139 | static int hid_bus_match(struct device *dev, struct device_driver *drv) | 2134 | static int hid_bus_match(struct device *dev, struct device_driver *drv) |
| 2140 | { | 2135 | { |
| 2141 | struct hid_driver *hdrv = container_of(drv, struct hid_driver, driver); | 2136 | struct hid_driver *hdrv = to_hid_driver(drv); |
| 2142 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 2137 | struct hid_device *hdev = to_hid_device(dev); |
| 2143 | 2138 | ||
| 2144 | return hid_match_device(hdev, hdrv) != NULL; | 2139 | return hid_match_device(hdev, hdrv) != NULL; |
| 2145 | } | 2140 | } |
| 2146 | 2141 | ||
| 2147 | static int hid_device_probe(struct device *dev) | 2142 | static int hid_device_probe(struct device *dev) |
| 2148 | { | 2143 | { |
| 2149 | struct hid_driver *hdrv = container_of(dev->driver, | 2144 | struct hid_driver *hdrv = to_hid_driver(dev->driver); |
| 2150 | struct hid_driver, driver); | 2145 | struct hid_device *hdev = to_hid_device(dev); |
| 2151 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | ||
| 2152 | const struct hid_device_id *id; | 2146 | const struct hid_device_id *id; |
| 2153 | int ret = 0; | 2147 | int ret = 0; |
| 2154 | 2148 | ||
| @@ -2190,7 +2184,7 @@ unlock_driver_lock: | |||
| 2190 | 2184 | ||
| 2191 | static int hid_device_remove(struct device *dev) | 2185 | static int hid_device_remove(struct device *dev) |
| 2192 | { | 2186 | { |
| 2193 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 2187 | struct hid_device *hdev = to_hid_device(dev); |
| 2194 | struct hid_driver *hdrv; | 2188 | struct hid_driver *hdrv; |
| 2195 | int ret = 0; | 2189 | int ret = 0; |
| 2196 | 2190 | ||
| @@ -2223,12 +2217,9 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *a, | |||
| 2223 | char *buf) | 2217 | char *buf) |
| 2224 | { | 2218 | { |
| 2225 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 2219 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); |
| 2226 | int len; | ||
| 2227 | |||
| 2228 | len = snprintf(buf, PAGE_SIZE, "hid:b%04Xg%04Xv%08Xp%08X\n", | ||
| 2229 | hdev->bus, hdev->group, hdev->vendor, hdev->product); | ||
| 2230 | 2220 | ||
| 2231 | return (len >= PAGE_SIZE) ? (PAGE_SIZE - 1) : len; | 2221 | return scnprintf(buf, PAGE_SIZE, "hid:b%04Xg%04Xv%08Xp%08X\n", |
| 2222 | hdev->bus, hdev->group, hdev->vendor, hdev->product); | ||
| 2232 | } | 2223 | } |
| 2233 | static DEVICE_ATTR_RO(modalias); | 2224 | static DEVICE_ATTR_RO(modalias); |
| 2234 | 2225 | ||
| @@ -2236,11 +2227,19 @@ static struct attribute *hid_dev_attrs[] = { | |||
| 2236 | &dev_attr_modalias.attr, | 2227 | &dev_attr_modalias.attr, |
| 2237 | NULL, | 2228 | NULL, |
| 2238 | }; | 2229 | }; |
| 2239 | ATTRIBUTE_GROUPS(hid_dev); | 2230 | static struct bin_attribute *hid_dev_bin_attrs[] = { |
| 2231 | &dev_bin_attr_report_desc, | ||
| 2232 | NULL | ||
| 2233 | }; | ||
| 2234 | static const struct attribute_group hid_dev_group = { | ||
| 2235 | .attrs = hid_dev_attrs, | ||
| 2236 | .bin_attrs = hid_dev_bin_attrs, | ||
| 2237 | }; | ||
| 2238 | __ATTRIBUTE_GROUPS(hid_dev); | ||
| 2240 | 2239 | ||
| 2241 | static int hid_uevent(struct device *dev, struct kobj_uevent_env *env) | 2240 | static int hid_uevent(struct device *dev, struct kobj_uevent_env *env) |
| 2242 | { | 2241 | { |
| 2243 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 2242 | struct hid_device *hdev = to_hid_device(dev); |
| 2244 | 2243 | ||
| 2245 | if (add_uevent_var(env, "HID_ID=%04X:%08X:%08X", | 2244 | if (add_uevent_var(env, "HID_ID=%04X:%08X:%08X", |
| 2246 | hdev->bus, hdev->vendor, hdev->product)) | 2245 | hdev->bus, hdev->vendor, hdev->product)) |
| @@ -2408,6 +2407,7 @@ static const struct hid_device_id hid_ignore_list[] = { | |||
| 2408 | { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT1) }, | 2407 | { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT1) }, |
| 2409 | { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT2) }, | 2408 | { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT2) }, |
| 2410 | { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICK16F1454) }, | 2409 | { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICK16F1454) }, |
| 2410 | { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICK16F1454_V2) }, | ||
| 2411 | { HID_USB_DEVICE(USB_VENDOR_ID_NATIONAL_SEMICONDUCTOR, USB_DEVICE_ID_N_S_HARMONY) }, | 2411 | { HID_USB_DEVICE(USB_VENDOR_ID_NATIONAL_SEMICONDUCTOR, USB_DEVICE_ID_N_S_HARMONY) }, |
| 2412 | { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100) }, | 2412 | { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100) }, |
| 2413 | { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 20) }, | 2413 | { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 20) }, |
| @@ -2660,6 +2660,7 @@ struct hid_device *hid_allocate_device(void) | |||
| 2660 | device_initialize(&hdev->dev); | 2660 | device_initialize(&hdev->dev); |
| 2661 | hdev->dev.release = hid_device_release; | 2661 | hdev->dev.release = hid_device_release; |
| 2662 | hdev->dev.bus = &hid_bus_type; | 2662 | hdev->dev.bus = &hid_bus_type; |
| 2663 | device_enable_async_suspend(&hdev->dev); | ||
| 2663 | 2664 | ||
| 2664 | hid_close_report(hdev); | 2665 | hid_close_report(hdev); |
| 2665 | 2666 | ||
diff --git a/drivers/hid/hid-corsair.c b/drivers/hid/hid-corsair.c index bcefb9ebb026..58551964ce86 100644 --- a/drivers/hid/hid-corsair.c +++ b/drivers/hid/hid-corsair.c | |||
| @@ -655,18 +655,7 @@ static struct hid_driver corsair_driver = { | |||
| 655 | .input_mapping = corsair_input_mapping, | 655 | .input_mapping = corsair_input_mapping, |
| 656 | }; | 656 | }; |
| 657 | 657 | ||
| 658 | static int __init corsair_init(void) | 658 | module_hid_driver(corsair_driver); |
| 659 | { | ||
| 660 | return hid_register_driver(&corsair_driver); | ||
| 661 | } | ||
| 662 | |||
| 663 | static void corsair_exit(void) | ||
| 664 | { | ||
| 665 | hid_unregister_driver(&corsair_driver); | ||
| 666 | } | ||
| 667 | |||
| 668 | module_init(corsair_init); | ||
| 669 | module_exit(corsair_exit); | ||
| 670 | 659 | ||
| 671 | MODULE_LICENSE("GPL"); | 660 | MODULE_LICENSE("GPL"); |
| 672 | MODULE_AUTHOR("Clement Vuchener"); | 661 | MODULE_AUTHOR("Clement Vuchener"); |
diff --git a/drivers/hid/hid-cp2112.c b/drivers/hid/hid-cp2112.c index 7afc3fcc122c..7c38bfa05fac 100644 --- a/drivers/hid/hid-cp2112.c +++ b/drivers/hid/hid-cp2112.c | |||
| @@ -807,7 +807,7 @@ static ssize_t name##_store(struct device *kdev, \ | |||
| 807 | struct device_attribute *attr, const char *buf, \ | 807 | struct device_attribute *attr, const char *buf, \ |
| 808 | size_t count) \ | 808 | size_t count) \ |
| 809 | { \ | 809 | { \ |
| 810 | struct hid_device *hdev = container_of(kdev, struct hid_device, dev); \ | 810 | struct hid_device *hdev = to_hid_device(kdev); \ |
| 811 | struct cp2112_usb_config_report cfg; \ | 811 | struct cp2112_usb_config_report cfg; \ |
| 812 | int ret = cp2112_get_usb_config(hdev, &cfg); \ | 812 | int ret = cp2112_get_usb_config(hdev, &cfg); \ |
| 813 | if (ret) \ | 813 | if (ret) \ |
| @@ -822,7 +822,7 @@ static ssize_t name##_store(struct device *kdev, \ | |||
| 822 | static ssize_t name##_show(struct device *kdev, \ | 822 | static ssize_t name##_show(struct device *kdev, \ |
| 823 | struct device_attribute *attr, char *buf) \ | 823 | struct device_attribute *attr, char *buf) \ |
| 824 | { \ | 824 | { \ |
| 825 | struct hid_device *hdev = container_of(kdev, struct hid_device, dev); \ | 825 | struct hid_device *hdev = to_hid_device(kdev); \ |
| 826 | struct cp2112_usb_config_report cfg; \ | 826 | struct cp2112_usb_config_report cfg; \ |
| 827 | int ret = cp2112_get_usb_config(hdev, &cfg); \ | 827 | int ret = cp2112_get_usb_config(hdev, &cfg); \ |
| 828 | if (ret) \ | 828 | if (ret) \ |
| @@ -887,7 +887,7 @@ static ssize_t pstr_store(struct device *kdev, | |||
| 887 | struct device_attribute *kattr, const char *buf, | 887 | struct device_attribute *kattr, const char *buf, |
| 888 | size_t count) | 888 | size_t count) |
| 889 | { | 889 | { |
| 890 | struct hid_device *hdev = container_of(kdev, struct hid_device, dev); | 890 | struct hid_device *hdev = to_hid_device(kdev); |
| 891 | struct cp2112_pstring_attribute *attr = | 891 | struct cp2112_pstring_attribute *attr = |
| 892 | container_of(kattr, struct cp2112_pstring_attribute, attr); | 892 | container_of(kattr, struct cp2112_pstring_attribute, attr); |
| 893 | struct cp2112_string_report report; | 893 | struct cp2112_string_report report; |
| @@ -918,7 +918,7 @@ static ssize_t pstr_store(struct device *kdev, | |||
| 918 | static ssize_t pstr_show(struct device *kdev, | 918 | static ssize_t pstr_show(struct device *kdev, |
| 919 | struct device_attribute *kattr, char *buf) | 919 | struct device_attribute *kattr, char *buf) |
| 920 | { | 920 | { |
| 921 | struct hid_device *hdev = container_of(kdev, struct hid_device, dev); | 921 | struct hid_device *hdev = to_hid_device(kdev); |
| 922 | struct cp2112_pstring_attribute *attr = | 922 | struct cp2112_pstring_attribute *attr = |
| 923 | container_of(kattr, struct cp2112_pstring_attribute, attr); | 923 | container_of(kattr, struct cp2112_pstring_attribute, attr); |
| 924 | struct cp2112_string_report report; | 924 | struct cp2112_string_report report; |
diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c index 2886b645ced7..acfb522a432a 100644 --- a/drivers/hid/hid-debug.c +++ b/drivers/hid/hid-debug.c | |||
| @@ -659,13 +659,13 @@ EXPORT_SYMBOL_GPL(hid_dump_device); | |||
| 659 | /* enqueue string to 'events' ring buffer */ | 659 | /* enqueue string to 'events' ring buffer */ |
| 660 | void hid_debug_event(struct hid_device *hdev, char *buf) | 660 | void hid_debug_event(struct hid_device *hdev, char *buf) |
| 661 | { | 661 | { |
| 662 | int i; | 662 | unsigned i; |
| 663 | struct hid_debug_list *list; | 663 | struct hid_debug_list *list; |
| 664 | unsigned long flags; | 664 | unsigned long flags; |
| 665 | 665 | ||
| 666 | spin_lock_irqsave(&hdev->debug_list_lock, flags); | 666 | spin_lock_irqsave(&hdev->debug_list_lock, flags); |
| 667 | list_for_each_entry(list, &hdev->debug_list, node) { | 667 | list_for_each_entry(list, &hdev->debug_list, node) { |
| 668 | for (i = 0; i < strlen(buf); i++) | 668 | for (i = 0; buf[i]; i++) |
| 669 | list->hid_debug_buf[(list->tail + i) % HID_DEBUG_BUFSIZE] = | 669 | list->hid_debug_buf[(list->tail + i) % HID_DEBUG_BUFSIZE] = |
| 670 | buf[i]; | 670 | buf[i]; |
| 671 | list->tail = (list->tail + i) % HID_DEBUG_BUFSIZE; | 671 | list->tail = (list->tail + i) % HID_DEBUG_BUFSIZE; |
diff --git a/drivers/hid/hid-gt683r.c b/drivers/hid/hid-gt683r.c index 0d6f135e266c..a298fbd8db6b 100644 --- a/drivers/hid/hid-gt683r.c +++ b/drivers/hid/hid-gt683r.c | |||
| @@ -70,7 +70,7 @@ static void gt683r_brightness_set(struct led_classdev *led_cdev, | |||
| 70 | { | 70 | { |
| 71 | int i; | 71 | int i; |
| 72 | struct device *dev = led_cdev->dev->parent; | 72 | struct device *dev = led_cdev->dev->parent; |
| 73 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 73 | struct hid_device *hdev = to_hid_device(dev); |
| 74 | struct gt683r_led *led = hid_get_drvdata(hdev); | 74 | struct gt683r_led *led = hid_get_drvdata(hdev); |
| 75 | 75 | ||
| 76 | for (i = 0; i < GT683R_LED_COUNT; i++) { | 76 | for (i = 0; i < GT683R_LED_COUNT; i++) { |
| @@ -89,8 +89,7 @@ static ssize_t mode_show(struct device *dev, | |||
| 89 | char *buf) | 89 | char *buf) |
| 90 | { | 90 | { |
| 91 | u8 sysfs_mode; | 91 | u8 sysfs_mode; |
| 92 | struct hid_device *hdev = container_of(dev->parent, | 92 | struct hid_device *hdev = to_hid_device(dev->parent); |
| 93 | struct hid_device, dev); | ||
| 94 | struct gt683r_led *led = hid_get_drvdata(hdev); | 93 | struct gt683r_led *led = hid_get_drvdata(hdev); |
| 95 | 94 | ||
| 96 | if (led->mode == GT683R_LED_NORMAL) | 95 | if (led->mode == GT683R_LED_NORMAL) |
| @@ -108,8 +107,7 @@ static ssize_t mode_store(struct device *dev, | |||
| 108 | const char *buf, size_t count) | 107 | const char *buf, size_t count) |
| 109 | { | 108 | { |
| 110 | u8 sysfs_mode; | 109 | u8 sysfs_mode; |
| 111 | struct hid_device *hdev = container_of(dev->parent, | 110 | struct hid_device *hdev = to_hid_device(dev->parent); |
| 112 | struct hid_device, dev); | ||
| 113 | struct gt683r_led *led = hid_get_drvdata(hdev); | 111 | struct gt683r_led *led = hid_get_drvdata(hdev); |
| 114 | 112 | ||
| 115 | 113 | ||
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index 8b78a7f1f779..b6ff6e78ac54 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h | |||
| @@ -510,6 +510,7 @@ | |||
| 510 | #define USB_VENDOR_ID_ITE 0x048d | 510 | #define USB_VENDOR_ID_ITE 0x048d |
| 511 | #define USB_DEVICE_ID_ITE_LENOVO_YOGA 0x8386 | 511 | #define USB_DEVICE_ID_ITE_LENOVO_YOGA 0x8386 |
| 512 | #define USB_DEVICE_ID_ITE_LENOVO_YOGA2 0x8350 | 512 | #define USB_DEVICE_ID_ITE_LENOVO_YOGA2 0x8350 |
| 513 | #define USB_DEVICE_ID_ITE_LENOVO_YOGA900 0x8396 | ||
| 513 | 514 | ||
| 514 | #define USB_VENDOR_ID_JABRA 0x0b0e | 515 | #define USB_VENDOR_ID_JABRA 0x0b0e |
| 515 | #define USB_DEVICE_ID_JABRA_SPEAK_410 0x0412 | 516 | #define USB_DEVICE_ID_JABRA_SPEAK_410 0x0412 |
| @@ -615,6 +616,7 @@ | |||
| 615 | #define USB_DEVICE_ID_LOGITECH_RUMBLEPAD2 0xc218 | 616 | #define USB_DEVICE_ID_LOGITECH_RUMBLEPAD2 0xc218 |
| 616 | #define USB_DEVICE_ID_LOGITECH_RUMBLEPAD2_2 0xc219 | 617 | #define USB_DEVICE_ID_LOGITECH_RUMBLEPAD2_2 0xc219 |
| 617 | #define USB_DEVICE_ID_LOGITECH_G29_WHEEL 0xc24f | 618 | #define USB_DEVICE_ID_LOGITECH_G29_WHEEL 0xc24f |
| 619 | #define USB_DEVICE_ID_LOGITECH_G920_WHEEL 0xc262 | ||
| 618 | #define USB_DEVICE_ID_LOGITECH_WINGMAN_F3D 0xc283 | 620 | #define USB_DEVICE_ID_LOGITECH_WINGMAN_F3D 0xc283 |
| 619 | #define USB_DEVICE_ID_LOGITECH_FORCE3D_PRO 0xc286 | 621 | #define USB_DEVICE_ID_LOGITECH_FORCE3D_PRO 0xc286 |
| 620 | #define USB_DEVICE_ID_LOGITECH_FLIGHT_SYSTEM_G940 0xc287 | 622 | #define USB_DEVICE_ID_LOGITECH_FLIGHT_SYSTEM_G940 0xc287 |
| @@ -664,6 +666,7 @@ | |||
| 664 | #define USB_DEVICE_ID_PICOLCD 0xc002 | 666 | #define USB_DEVICE_ID_PICOLCD 0xc002 |
| 665 | #define USB_DEVICE_ID_PICOLCD_BOOTLOADER 0xf002 | 667 | #define USB_DEVICE_ID_PICOLCD_BOOTLOADER 0xf002 |
| 666 | #define USB_DEVICE_ID_PICK16F1454 0x0042 | 668 | #define USB_DEVICE_ID_PICK16F1454 0x0042 |
| 669 | #define USB_DEVICE_ID_PICK16F1454_V2 0xf2f7 | ||
| 667 | 670 | ||
| 668 | #define USB_VENDOR_ID_MICROSOFT 0x045e | 671 | #define USB_VENDOR_ID_MICROSOFT 0x045e |
| 669 | #define USB_DEVICE_ID_SIDEWINDER_GV 0x003b | 672 | #define USB_DEVICE_ID_SIDEWINDER_GV 0x003b |
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c index 2ba6bf69b7d0..bcfaf32d9e5e 100644 --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c | |||
| @@ -303,6 +303,7 @@ static enum power_supply_property hidinput_battery_props[] = { | |||
| 303 | 303 | ||
| 304 | #define HID_BATTERY_QUIRK_PERCENT (1 << 0) /* always reports percent */ | 304 | #define HID_BATTERY_QUIRK_PERCENT (1 << 0) /* always reports percent */ |
| 305 | #define HID_BATTERY_QUIRK_FEATURE (1 << 1) /* ask for feature report */ | 305 | #define HID_BATTERY_QUIRK_FEATURE (1 << 1) /* ask for feature report */ |
| 306 | #define HID_BATTERY_QUIRK_IGNORE (1 << 2) /* completely ignore the battery */ | ||
| 306 | 307 | ||
| 307 | static const struct hid_device_id hid_battery_quirks[] = { | 308 | static const struct hid_device_id hid_battery_quirks[] = { |
| 308 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, | 309 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, |
| @@ -320,6 +321,9 @@ static const struct hid_device_id hid_battery_quirks[] = { | |||
| 320 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, | 321 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, |
| 321 | USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI), | 322 | USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI), |
| 322 | HID_BATTERY_QUIRK_PERCENT | HID_BATTERY_QUIRK_FEATURE }, | 323 | HID_BATTERY_QUIRK_PERCENT | HID_BATTERY_QUIRK_FEATURE }, |
| 324 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ELECOM, | ||
| 325 | USB_DEVICE_ID_ELECOM_BM084), | ||
| 326 | HID_BATTERY_QUIRK_IGNORE }, | ||
| 323 | {} | 327 | {} |
| 324 | }; | 328 | }; |
| 325 | 329 | ||
| @@ -408,6 +412,14 @@ static bool hidinput_setup_battery(struct hid_device *dev, unsigned report_type, | |||
| 408 | if (dev->battery != NULL) | 412 | if (dev->battery != NULL) |
| 409 | goto out; /* already initialized? */ | 413 | goto out; /* already initialized? */ |
| 410 | 414 | ||
| 415 | quirks = find_battery_quirk(dev); | ||
| 416 | |||
| 417 | hid_dbg(dev, "device %x:%x:%x %d quirks %d\n", | ||
| 418 | dev->bus, dev->vendor, dev->product, dev->version, quirks); | ||
| 419 | |||
| 420 | if (quirks & HID_BATTERY_QUIRK_IGNORE) | ||
| 421 | goto out; | ||
| 422 | |||
| 411 | psy_desc = kzalloc(sizeof(*psy_desc), GFP_KERNEL); | 423 | psy_desc = kzalloc(sizeof(*psy_desc), GFP_KERNEL); |
| 412 | if (psy_desc == NULL) | 424 | if (psy_desc == NULL) |
| 413 | goto out; | 425 | goto out; |
| @@ -424,11 +436,6 @@ static bool hidinput_setup_battery(struct hid_device *dev, unsigned report_type, | |||
| 424 | psy_desc->use_for_apm = 0; | 436 | psy_desc->use_for_apm = 0; |
| 425 | psy_desc->get_property = hidinput_get_battery_property; | 437 | psy_desc->get_property = hidinput_get_battery_property; |
| 426 | 438 | ||
| 427 | quirks = find_battery_quirk(dev); | ||
| 428 | |||
| 429 | hid_dbg(dev, "device %x:%x:%x %d quirks %d\n", | ||
| 430 | dev->bus, dev->vendor, dev->product, dev->version, quirks); | ||
| 431 | |||
| 432 | min = field->logical_minimum; | 439 | min = field->logical_minimum; |
| 433 | max = field->logical_maximum; | 440 | max = field->logical_maximum; |
| 434 | 441 | ||
| @@ -960,6 +967,10 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel | |||
| 960 | goto ignore; | 967 | goto ignore; |
| 961 | 968 | ||
| 962 | case HID_UP_LOGIVENDOR: | 969 | case HID_UP_LOGIVENDOR: |
| 970 | /* intentional fallback */ | ||
| 971 | case HID_UP_LOGIVENDOR2: | ||
| 972 | /* intentional fallback */ | ||
| 973 | case HID_UP_LOGIVENDOR3: | ||
| 963 | goto ignore; | 974 | goto ignore; |
| 964 | 975 | ||
| 965 | case HID_UP_PID: | 976 | case HID_UP_PID: |
diff --git a/drivers/hid/hid-lenovo.c b/drivers/hid/hid-lenovo.c index 8979f1fd5208..0125e356bd8d 100644 --- a/drivers/hid/hid-lenovo.c +++ b/drivers/hid/hid-lenovo.c | |||
| @@ -220,7 +220,7 @@ static ssize_t attr_fn_lock_show_cptkbd(struct device *dev, | |||
| 220 | struct device_attribute *attr, | 220 | struct device_attribute *attr, |
| 221 | char *buf) | 221 | char *buf) |
| 222 | { | 222 | { |
| 223 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 223 | struct hid_device *hdev = to_hid_device(dev); |
| 224 | struct lenovo_drvdata_cptkbd *cptkbd_data = hid_get_drvdata(hdev); | 224 | struct lenovo_drvdata_cptkbd *cptkbd_data = hid_get_drvdata(hdev); |
| 225 | 225 | ||
| 226 | return snprintf(buf, PAGE_SIZE, "%u\n", cptkbd_data->fn_lock); | 226 | return snprintf(buf, PAGE_SIZE, "%u\n", cptkbd_data->fn_lock); |
| @@ -231,7 +231,7 @@ static ssize_t attr_fn_lock_store_cptkbd(struct device *dev, | |||
| 231 | const char *buf, | 231 | const char *buf, |
| 232 | size_t count) | 232 | size_t count) |
| 233 | { | 233 | { |
| 234 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 234 | struct hid_device *hdev = to_hid_device(dev); |
| 235 | struct lenovo_drvdata_cptkbd *cptkbd_data = hid_get_drvdata(hdev); | 235 | struct lenovo_drvdata_cptkbd *cptkbd_data = hid_get_drvdata(hdev); |
| 236 | int value; | 236 | int value; |
| 237 | 237 | ||
| @@ -250,7 +250,7 @@ static ssize_t attr_sensitivity_show_cptkbd(struct device *dev, | |||
| 250 | struct device_attribute *attr, | 250 | struct device_attribute *attr, |
| 251 | char *buf) | 251 | char *buf) |
| 252 | { | 252 | { |
| 253 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 253 | struct hid_device *hdev = to_hid_device(dev); |
| 254 | struct lenovo_drvdata_cptkbd *cptkbd_data = hid_get_drvdata(hdev); | 254 | struct lenovo_drvdata_cptkbd *cptkbd_data = hid_get_drvdata(hdev); |
| 255 | 255 | ||
| 256 | return snprintf(buf, PAGE_SIZE, "%u\n", | 256 | return snprintf(buf, PAGE_SIZE, "%u\n", |
| @@ -262,7 +262,7 @@ static ssize_t attr_sensitivity_store_cptkbd(struct device *dev, | |||
| 262 | const char *buf, | 262 | const char *buf, |
| 263 | size_t count) | 263 | size_t count) |
| 264 | { | 264 | { |
| 265 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 265 | struct hid_device *hdev = to_hid_device(dev); |
| 266 | struct lenovo_drvdata_cptkbd *cptkbd_data = hid_get_drvdata(hdev); | 266 | struct lenovo_drvdata_cptkbd *cptkbd_data = hid_get_drvdata(hdev); |
| 267 | int value; | 267 | int value; |
| 268 | 268 | ||
| @@ -387,7 +387,7 @@ static ssize_t attr_press_to_select_show_tpkbd(struct device *dev, | |||
| 387 | struct device_attribute *attr, | 387 | struct device_attribute *attr, |
| 388 | char *buf) | 388 | char *buf) |
| 389 | { | 389 | { |
| 390 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 390 | struct hid_device *hdev = to_hid_device(dev); |
| 391 | struct lenovo_drvdata_tpkbd *data_pointer = hid_get_drvdata(hdev); | 391 | struct lenovo_drvdata_tpkbd *data_pointer = hid_get_drvdata(hdev); |
| 392 | 392 | ||
| 393 | return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->press_to_select); | 393 | return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->press_to_select); |
| @@ -398,7 +398,7 @@ static ssize_t attr_press_to_select_store_tpkbd(struct device *dev, | |||
| 398 | const char *buf, | 398 | const char *buf, |
| 399 | size_t count) | 399 | size_t count) |
| 400 | { | 400 | { |
| 401 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 401 | struct hid_device *hdev = to_hid_device(dev); |
| 402 | struct lenovo_drvdata_tpkbd *data_pointer = hid_get_drvdata(hdev); | 402 | struct lenovo_drvdata_tpkbd *data_pointer = hid_get_drvdata(hdev); |
| 403 | int value; | 403 | int value; |
| 404 | 404 | ||
| @@ -417,7 +417,7 @@ static ssize_t attr_dragging_show_tpkbd(struct device *dev, | |||
| 417 | struct device_attribute *attr, | 417 | struct device_attribute *attr, |
| 418 | char *buf) | 418 | char *buf) |
| 419 | { | 419 | { |
| 420 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 420 | struct hid_device *hdev = to_hid_device(dev); |
| 421 | struct lenovo_drvdata_tpkbd *data_pointer = hid_get_drvdata(hdev); | 421 | struct lenovo_drvdata_tpkbd *data_pointer = hid_get_drvdata(hdev); |
| 422 | 422 | ||
| 423 | return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->dragging); | 423 | return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->dragging); |
| @@ -428,7 +428,7 @@ static ssize_t attr_dragging_store_tpkbd(struct device *dev, | |||
| 428 | const char *buf, | 428 | const char *buf, |
| 429 | size_t count) | 429 | size_t count) |
| 430 | { | 430 | { |
| 431 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 431 | struct hid_device *hdev = to_hid_device(dev); |
| 432 | struct lenovo_drvdata_tpkbd *data_pointer = hid_get_drvdata(hdev); | 432 | struct lenovo_drvdata_tpkbd *data_pointer = hid_get_drvdata(hdev); |
| 433 | int value; | 433 | int value; |
| 434 | 434 | ||
| @@ -447,7 +447,7 @@ static ssize_t attr_release_to_select_show_tpkbd(struct device *dev, | |||
| 447 | struct device_attribute *attr, | 447 | struct device_attribute *attr, |
| 448 | char *buf) | 448 | char *buf) |
| 449 | { | 449 | { |
| 450 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 450 | struct hid_device *hdev = to_hid_device(dev); |
| 451 | struct lenovo_drvdata_tpkbd *data_pointer = hid_get_drvdata(hdev); | 451 | struct lenovo_drvdata_tpkbd *data_pointer = hid_get_drvdata(hdev); |
| 452 | 452 | ||
| 453 | return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->release_to_select); | 453 | return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->release_to_select); |
| @@ -458,7 +458,7 @@ static ssize_t attr_release_to_select_store_tpkbd(struct device *dev, | |||
| 458 | const char *buf, | 458 | const char *buf, |
| 459 | size_t count) | 459 | size_t count) |
| 460 | { | 460 | { |
| 461 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 461 | struct hid_device *hdev = to_hid_device(dev); |
| 462 | struct lenovo_drvdata_tpkbd *data_pointer = hid_get_drvdata(hdev); | 462 | struct lenovo_drvdata_tpkbd *data_pointer = hid_get_drvdata(hdev); |
| 463 | int value; | 463 | int value; |
| 464 | 464 | ||
| @@ -477,7 +477,7 @@ static ssize_t attr_select_right_show_tpkbd(struct device *dev, | |||
| 477 | struct device_attribute *attr, | 477 | struct device_attribute *attr, |
| 478 | char *buf) | 478 | char *buf) |
| 479 | { | 479 | { |
| 480 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 480 | struct hid_device *hdev = to_hid_device(dev); |
| 481 | struct lenovo_drvdata_tpkbd *data_pointer = hid_get_drvdata(hdev); | 481 | struct lenovo_drvdata_tpkbd *data_pointer = hid_get_drvdata(hdev); |
| 482 | 482 | ||
| 483 | return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->select_right); | 483 | return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->select_right); |
| @@ -488,7 +488,7 @@ static ssize_t attr_select_right_store_tpkbd(struct device *dev, | |||
| 488 | const char *buf, | 488 | const char *buf, |
| 489 | size_t count) | 489 | size_t count) |
| 490 | { | 490 | { |
| 491 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 491 | struct hid_device *hdev = to_hid_device(dev); |
| 492 | struct lenovo_drvdata_tpkbd *data_pointer = hid_get_drvdata(hdev); | 492 | struct lenovo_drvdata_tpkbd *data_pointer = hid_get_drvdata(hdev); |
| 493 | int value; | 493 | int value; |
| 494 | 494 | ||
| @@ -507,7 +507,7 @@ static ssize_t attr_sensitivity_show_tpkbd(struct device *dev, | |||
| 507 | struct device_attribute *attr, | 507 | struct device_attribute *attr, |
| 508 | char *buf) | 508 | char *buf) |
| 509 | { | 509 | { |
| 510 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 510 | struct hid_device *hdev = to_hid_device(dev); |
| 511 | struct lenovo_drvdata_tpkbd *data_pointer = hid_get_drvdata(hdev); | 511 | struct lenovo_drvdata_tpkbd *data_pointer = hid_get_drvdata(hdev); |
| 512 | 512 | ||
| 513 | return snprintf(buf, PAGE_SIZE, "%u\n", | 513 | return snprintf(buf, PAGE_SIZE, "%u\n", |
| @@ -519,7 +519,7 @@ static ssize_t attr_sensitivity_store_tpkbd(struct device *dev, | |||
| 519 | const char *buf, | 519 | const char *buf, |
| 520 | size_t count) | 520 | size_t count) |
| 521 | { | 521 | { |
| 522 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 522 | struct hid_device *hdev = to_hid_device(dev); |
| 523 | struct lenovo_drvdata_tpkbd *data_pointer = hid_get_drvdata(hdev); | 523 | struct lenovo_drvdata_tpkbd *data_pointer = hid_get_drvdata(hdev); |
| 524 | int value; | 524 | int value; |
| 525 | 525 | ||
| @@ -536,7 +536,7 @@ static ssize_t attr_press_speed_show_tpkbd(struct device *dev, | |||
| 536 | struct device_attribute *attr, | 536 | struct device_attribute *attr, |
| 537 | char *buf) | 537 | char *buf) |
| 538 | { | 538 | { |
| 539 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 539 | struct hid_device *hdev = to_hid_device(dev); |
| 540 | struct lenovo_drvdata_tpkbd *data_pointer = hid_get_drvdata(hdev); | 540 | struct lenovo_drvdata_tpkbd *data_pointer = hid_get_drvdata(hdev); |
| 541 | 541 | ||
| 542 | return snprintf(buf, PAGE_SIZE, "%u\n", | 542 | return snprintf(buf, PAGE_SIZE, "%u\n", |
| @@ -548,7 +548,7 @@ static ssize_t attr_press_speed_store_tpkbd(struct device *dev, | |||
| 548 | const char *buf, | 548 | const char *buf, |
| 549 | size_t count) | 549 | size_t count) |
| 550 | { | 550 | { |
| 551 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 551 | struct hid_device *hdev = to_hid_device(dev); |
| 552 | struct lenovo_drvdata_tpkbd *data_pointer = hid_get_drvdata(hdev); | 552 | struct lenovo_drvdata_tpkbd *data_pointer = hid_get_drvdata(hdev); |
| 553 | int value; | 553 | int value; |
| 554 | 554 | ||
| @@ -609,7 +609,7 @@ static enum led_brightness lenovo_led_brightness_get_tpkbd( | |||
| 609 | struct led_classdev *led_cdev) | 609 | struct led_classdev *led_cdev) |
| 610 | { | 610 | { |
| 611 | struct device *dev = led_cdev->dev->parent; | 611 | struct device *dev = led_cdev->dev->parent; |
| 612 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 612 | struct hid_device *hdev = to_hid_device(dev); |
| 613 | struct lenovo_drvdata_tpkbd *data_pointer = hid_get_drvdata(hdev); | 613 | struct lenovo_drvdata_tpkbd *data_pointer = hid_get_drvdata(hdev); |
| 614 | int led_nr = 0; | 614 | int led_nr = 0; |
| 615 | 615 | ||
| @@ -625,7 +625,7 @@ static void lenovo_led_brightness_set_tpkbd(struct led_classdev *led_cdev, | |||
| 625 | enum led_brightness value) | 625 | enum led_brightness value) |
| 626 | { | 626 | { |
| 627 | struct device *dev = led_cdev->dev->parent; | 627 | struct device *dev = led_cdev->dev->parent; |
| 628 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 628 | struct hid_device *hdev = to_hid_device(dev); |
| 629 | struct lenovo_drvdata_tpkbd *data_pointer = hid_get_drvdata(hdev); | 629 | struct lenovo_drvdata_tpkbd *data_pointer = hid_get_drvdata(hdev); |
| 630 | struct hid_report *report; | 630 | struct hid_report *report; |
| 631 | int led_nr = 0; | 631 | int led_nr = 0; |
diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c index fbddcb37ae98..af3a8ec8a746 100644 --- a/drivers/hid/hid-lg4ff.c +++ b/drivers/hid/hid-lg4ff.c | |||
| @@ -33,8 +33,6 @@ | |||
| 33 | #include "hid-lg4ff.h" | 33 | #include "hid-lg4ff.h" |
| 34 | #include "hid-ids.h" | 34 | #include "hid-ids.h" |
| 35 | 35 | ||
| 36 | #define to_hid_device(pdev) container_of(pdev, struct hid_device, dev) | ||
| 37 | |||
| 38 | #define LG4FF_MMODE_IS_MULTIMODE 0 | 36 | #define LG4FF_MMODE_IS_MULTIMODE 0 |
| 39 | #define LG4FF_MMODE_SWITCHED 1 | 37 | #define LG4FF_MMODE_SWITCHED 1 |
| 40 | #define LG4FF_MMODE_NOT_MULTIMODE 2 | 38 | #define LG4FF_MMODE_NOT_MULTIMODE 2 |
| @@ -1020,7 +1018,7 @@ static void lg4ff_led_set_brightness(struct led_classdev *led_cdev, | |||
| 1020 | enum led_brightness value) | 1018 | enum led_brightness value) |
| 1021 | { | 1019 | { |
| 1022 | struct device *dev = led_cdev->dev->parent; | 1020 | struct device *dev = led_cdev->dev->parent; |
| 1023 | struct hid_device *hid = container_of(dev, struct hid_device, dev); | 1021 | struct hid_device *hid = to_hid_device(dev); |
| 1024 | struct lg_drv_data *drv_data = hid_get_drvdata(hid); | 1022 | struct lg_drv_data *drv_data = hid_get_drvdata(hid); |
| 1025 | struct lg4ff_device_entry *entry; | 1023 | struct lg4ff_device_entry *entry; |
| 1026 | int i, state = 0; | 1024 | int i, state = 0; |
| @@ -1055,7 +1053,7 @@ static void lg4ff_led_set_brightness(struct led_classdev *led_cdev, | |||
| 1055 | static enum led_brightness lg4ff_led_get_brightness(struct led_classdev *led_cdev) | 1053 | static enum led_brightness lg4ff_led_get_brightness(struct led_classdev *led_cdev) |
| 1056 | { | 1054 | { |
| 1057 | struct device *dev = led_cdev->dev->parent; | 1055 | struct device *dev = led_cdev->dev->parent; |
| 1058 | struct hid_device *hid = container_of(dev, struct hid_device, dev); | 1056 | struct hid_device *hid = to_hid_device(dev); |
| 1059 | struct lg_drv_data *drv_data = hid_get_drvdata(hid); | 1057 | struct lg_drv_data *drv_data = hid_get_drvdata(hid); |
| 1060 | struct lg4ff_device_entry *entry; | 1058 | struct lg4ff_device_entry *entry; |
| 1061 | int i, value = 0; | 1059 | int i, value = 0; |
diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c index 5fd97860aec4..bd2ab476c65e 100644 --- a/drivers/hid/hid-logitech-hidpp.c +++ b/drivers/hid/hid-logitech-hidpp.c | |||
| @@ -40,18 +40,22 @@ MODULE_PARM_DESC(disable_tap_to_click, | |||
| 40 | 40 | ||
| 41 | #define REPORT_ID_HIDPP_SHORT 0x10 | 41 | #define REPORT_ID_HIDPP_SHORT 0x10 |
| 42 | #define REPORT_ID_HIDPP_LONG 0x11 | 42 | #define REPORT_ID_HIDPP_LONG 0x11 |
| 43 | #define REPORT_ID_HIDPP_VERY_LONG 0x12 | ||
| 43 | 44 | ||
| 44 | #define HIDPP_REPORT_SHORT_LENGTH 7 | 45 | #define HIDPP_REPORT_SHORT_LENGTH 7 |
| 45 | #define HIDPP_REPORT_LONG_LENGTH 20 | 46 | #define HIDPP_REPORT_LONG_LENGTH 20 |
| 47 | #define HIDPP_REPORT_VERY_LONG_LENGTH 64 | ||
| 46 | 48 | ||
| 47 | #define HIDPP_QUIRK_CLASS_WTP BIT(0) | 49 | #define HIDPP_QUIRK_CLASS_WTP BIT(0) |
| 48 | #define HIDPP_QUIRK_CLASS_M560 BIT(1) | 50 | #define HIDPP_QUIRK_CLASS_M560 BIT(1) |
| 49 | #define HIDPP_QUIRK_CLASS_K400 BIT(2) | 51 | #define HIDPP_QUIRK_CLASS_K400 BIT(2) |
| 52 | #define HIDPP_QUIRK_CLASS_G920 BIT(3) | ||
| 50 | 53 | ||
| 51 | /* bits 2..20 are reserved for classes */ | 54 | /* bits 2..20 are reserved for classes */ |
| 52 | #define HIDPP_QUIRK_CONNECT_EVENTS BIT(21) | 55 | #define HIDPP_QUIRK_CONNECT_EVENTS BIT(21) |
| 53 | #define HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS BIT(22) | 56 | #define HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS BIT(22) |
| 54 | #define HIDPP_QUIRK_NO_HIDINPUT BIT(23) | 57 | #define HIDPP_QUIRK_NO_HIDINPUT BIT(23) |
| 58 | #define HIDPP_QUIRK_FORCE_OUTPUT_REPORTS BIT(24) | ||
| 55 | 59 | ||
| 56 | #define HIDPP_QUIRK_DELAYED_INIT (HIDPP_QUIRK_NO_HIDINPUT | \ | 60 | #define HIDPP_QUIRK_DELAYED_INIT (HIDPP_QUIRK_NO_HIDINPUT | \ |
| 57 | HIDPP_QUIRK_CONNECT_EVENTS) | 61 | HIDPP_QUIRK_CONNECT_EVENTS) |
| @@ -81,13 +85,13 @@ MODULE_PARM_DESC(disable_tap_to_click, | |||
| 81 | struct fap { | 85 | struct fap { |
| 82 | u8 feature_index; | 86 | u8 feature_index; |
| 83 | u8 funcindex_clientid; | 87 | u8 funcindex_clientid; |
| 84 | u8 params[HIDPP_REPORT_LONG_LENGTH - 4U]; | 88 | u8 params[HIDPP_REPORT_VERY_LONG_LENGTH - 4U]; |
| 85 | }; | 89 | }; |
| 86 | 90 | ||
| 87 | struct rap { | 91 | struct rap { |
| 88 | u8 sub_id; | 92 | u8 sub_id; |
| 89 | u8 reg_address; | 93 | u8 reg_address; |
| 90 | u8 params[HIDPP_REPORT_LONG_LENGTH - 4U]; | 94 | u8 params[HIDPP_REPORT_VERY_LONG_LENGTH - 4U]; |
| 91 | }; | 95 | }; |
| 92 | 96 | ||
| 93 | struct hidpp_report { | 97 | struct hidpp_report { |
| @@ -144,8 +148,11 @@ static void hidpp_connect_event(struct hidpp_device *hidpp_dev); | |||
| 144 | static int __hidpp_send_report(struct hid_device *hdev, | 148 | static int __hidpp_send_report(struct hid_device *hdev, |
| 145 | struct hidpp_report *hidpp_report) | 149 | struct hidpp_report *hidpp_report) |
| 146 | { | 150 | { |
| 151 | struct hidpp_device *hidpp = hid_get_drvdata(hdev); | ||
| 147 | int fields_count, ret; | 152 | int fields_count, ret; |
| 148 | 153 | ||
| 154 | hidpp = hid_get_drvdata(hdev); | ||
| 155 | |||
| 149 | switch (hidpp_report->report_id) { | 156 | switch (hidpp_report->report_id) { |
| 150 | case REPORT_ID_HIDPP_SHORT: | 157 | case REPORT_ID_HIDPP_SHORT: |
| 151 | fields_count = HIDPP_REPORT_SHORT_LENGTH; | 158 | fields_count = HIDPP_REPORT_SHORT_LENGTH; |
| @@ -153,6 +160,9 @@ static int __hidpp_send_report(struct hid_device *hdev, | |||
| 153 | case REPORT_ID_HIDPP_LONG: | 160 | case REPORT_ID_HIDPP_LONG: |
| 154 | fields_count = HIDPP_REPORT_LONG_LENGTH; | 161 | fields_count = HIDPP_REPORT_LONG_LENGTH; |
| 155 | break; | 162 | break; |
| 163 | case REPORT_ID_HIDPP_VERY_LONG: | ||
| 164 | fields_count = HIDPP_REPORT_VERY_LONG_LENGTH; | ||
| 165 | break; | ||
| 156 | default: | 166 | default: |
| 157 | return -ENODEV; | 167 | return -ENODEV; |
| 158 | } | 168 | } |
| @@ -163,9 +173,13 @@ static int __hidpp_send_report(struct hid_device *hdev, | |||
| 163 | */ | 173 | */ |
| 164 | hidpp_report->device_index = 0xff; | 174 | hidpp_report->device_index = 0xff; |
| 165 | 175 | ||
| 166 | ret = hid_hw_raw_request(hdev, hidpp_report->report_id, | 176 | if (hidpp->quirks & HIDPP_QUIRK_FORCE_OUTPUT_REPORTS) { |
| 167 | (u8 *)hidpp_report, fields_count, HID_OUTPUT_REPORT, | 177 | ret = hid_hw_output_report(hdev, (u8 *)hidpp_report, fields_count); |
| 168 | HID_REQ_SET_REPORT); | 178 | } else { |
| 179 | ret = hid_hw_raw_request(hdev, hidpp_report->report_id, | ||
| 180 | (u8 *)hidpp_report, fields_count, HID_OUTPUT_REPORT, | ||
| 181 | HID_REQ_SET_REPORT); | ||
| 182 | } | ||
| 169 | 183 | ||
| 170 | return ret == fields_count ? 0 : -1; | 184 | return ret == fields_count ? 0 : -1; |
| 171 | } | 185 | } |
| @@ -217,8 +231,9 @@ static int hidpp_send_message_sync(struct hidpp_device *hidpp, | |||
| 217 | goto exit; | 231 | goto exit; |
| 218 | } | 232 | } |
| 219 | 233 | ||
| 220 | if (response->report_id == REPORT_ID_HIDPP_LONG && | 234 | if ((response->report_id == REPORT_ID_HIDPP_LONG || |
| 221 | response->fap.feature_index == HIDPP20_ERROR) { | 235 | response->report_id == REPORT_ID_HIDPP_VERY_LONG) && |
| 236 | response->fap.feature_index == HIDPP20_ERROR) { | ||
| 222 | ret = response->fap.params[1]; | 237 | ret = response->fap.params[1]; |
| 223 | dbg_hid("%s:got hidpp 2.0 error %02X\n", __func__, ret); | 238 | dbg_hid("%s:got hidpp 2.0 error %02X\n", __func__, ret); |
| 224 | goto exit; | 239 | goto exit; |
| @@ -243,7 +258,11 @@ static int hidpp_send_fap_command_sync(struct hidpp_device *hidpp, | |||
| 243 | message = kzalloc(sizeof(struct hidpp_report), GFP_KERNEL); | 258 | message = kzalloc(sizeof(struct hidpp_report), GFP_KERNEL); |
| 244 | if (!message) | 259 | if (!message) |
| 245 | return -ENOMEM; | 260 | return -ENOMEM; |
| 246 | message->report_id = REPORT_ID_HIDPP_LONG; | 261 | |
| 262 | if (param_count > (HIDPP_REPORT_LONG_LENGTH - 4)) | ||
| 263 | message->report_id = REPORT_ID_HIDPP_VERY_LONG; | ||
| 264 | else | ||
| 265 | message->report_id = REPORT_ID_HIDPP_LONG; | ||
| 247 | message->fap.feature_index = feat_index; | 266 | message->fap.feature_index = feat_index; |
| 248 | message->fap.funcindex_clientid = funcindex_clientid; | 267 | message->fap.funcindex_clientid = funcindex_clientid; |
| 249 | memcpy(&message->fap.params, params, param_count); | 268 | memcpy(&message->fap.params, params, param_count); |
| @@ -258,13 +277,23 @@ static int hidpp_send_rap_command_sync(struct hidpp_device *hidpp_dev, | |||
| 258 | struct hidpp_report *response) | 277 | struct hidpp_report *response) |
| 259 | { | 278 | { |
| 260 | struct hidpp_report *message; | 279 | struct hidpp_report *message; |
| 261 | int ret; | 280 | int ret, max_count; |
| 262 | 281 | ||
| 263 | if ((report_id != REPORT_ID_HIDPP_SHORT) && | 282 | switch (report_id) { |
| 264 | (report_id != REPORT_ID_HIDPP_LONG)) | 283 | case REPORT_ID_HIDPP_SHORT: |
| 284 | max_count = HIDPP_REPORT_SHORT_LENGTH - 4; | ||
| 285 | break; | ||
| 286 | case REPORT_ID_HIDPP_LONG: | ||
| 287 | max_count = HIDPP_REPORT_LONG_LENGTH - 4; | ||
| 288 | break; | ||
| 289 | case REPORT_ID_HIDPP_VERY_LONG: | ||
| 290 | max_count = HIDPP_REPORT_VERY_LONG_LENGTH - 4; | ||
| 291 | break; | ||
| 292 | default: | ||
| 265 | return -EINVAL; | 293 | return -EINVAL; |
| 294 | } | ||
| 266 | 295 | ||
| 267 | if (param_count > sizeof(message->rap.params)) | 296 | if (param_count > max_count) |
| 268 | return -EINVAL; | 297 | return -EINVAL; |
| 269 | 298 | ||
| 270 | message = kzalloc(sizeof(struct hidpp_report), GFP_KERNEL); | 299 | message = kzalloc(sizeof(struct hidpp_report), GFP_KERNEL); |
| @@ -508,10 +537,19 @@ static int hidpp_devicenametype_get_device_name(struct hidpp_device *hidpp, | |||
| 508 | if (ret) | 537 | if (ret) |
| 509 | return ret; | 538 | return ret; |
| 510 | 539 | ||
| 511 | if (response.report_id == REPORT_ID_HIDPP_LONG) | 540 | switch (response.report_id) { |
| 541 | case REPORT_ID_HIDPP_VERY_LONG: | ||
| 542 | count = HIDPP_REPORT_VERY_LONG_LENGTH - 4; | ||
| 543 | break; | ||
| 544 | case REPORT_ID_HIDPP_LONG: | ||
| 512 | count = HIDPP_REPORT_LONG_LENGTH - 4; | 545 | count = HIDPP_REPORT_LONG_LENGTH - 4; |
| 513 | else | 546 | break; |
| 547 | case REPORT_ID_HIDPP_SHORT: | ||
| 514 | count = HIDPP_REPORT_SHORT_LENGTH - 4; | 548 | count = HIDPP_REPORT_SHORT_LENGTH - 4; |
| 549 | break; | ||
| 550 | default: | ||
| 551 | return -EPROTO; | ||
| 552 | } | ||
| 515 | 553 | ||
| 516 | if (len_buf < count) | 554 | if (len_buf < count) |
| 517 | count = len_buf; | 555 | count = len_buf; |
| @@ -1257,6 +1295,131 @@ static int k400_connect(struct hid_device *hdev, bool connected) | |||
| 1257 | return k400_disable_tap_to_click(hidpp); | 1295 | return k400_disable_tap_to_click(hidpp); |
| 1258 | } | 1296 | } |
| 1259 | 1297 | ||
| 1298 | /* ------------------------------------------------------------------------- */ | ||
| 1299 | /* Logitech G920 Driving Force Racing Wheel for Xbox One */ | ||
| 1300 | /* ------------------------------------------------------------------------- */ | ||
| 1301 | |||
| 1302 | #define HIDPP_PAGE_G920_FORCE_FEEDBACK 0x8123 | ||
| 1303 | |||
| 1304 | /* Using session ID = 1 */ | ||
| 1305 | #define CMD_G920_FORCE_GET_APERTURE 0x51 | ||
| 1306 | #define CMD_G920_FORCE_SET_APERTURE 0x61 | ||
| 1307 | |||
| 1308 | struct g920_private_data { | ||
| 1309 | u8 force_feature; | ||
| 1310 | u16 range; | ||
| 1311 | }; | ||
| 1312 | |||
| 1313 | static ssize_t g920_range_show(struct device *dev, struct device_attribute *attr, | ||
| 1314 | char *buf) | ||
| 1315 | { | ||
| 1316 | struct hid_device *hid = to_hid_device(dev); | ||
| 1317 | struct hidpp_device *hidpp = hid_get_drvdata(hid); | ||
| 1318 | struct g920_private_data *pdata; | ||
| 1319 | |||
| 1320 | pdata = hidpp->private_data; | ||
| 1321 | if (!pdata) { | ||
| 1322 | hid_err(hid, "Private driver data not found!\n"); | ||
| 1323 | return -EINVAL; | ||
| 1324 | } | ||
| 1325 | |||
| 1326 | return scnprintf(buf, PAGE_SIZE, "%u\n", pdata->range); | ||
| 1327 | } | ||
| 1328 | |||
| 1329 | static ssize_t g920_range_store(struct device *dev, struct device_attribute *attr, | ||
| 1330 | const char *buf, size_t count) | ||
| 1331 | { | ||
| 1332 | struct hid_device *hid = to_hid_device(dev); | ||
| 1333 | struct hidpp_device *hidpp = hid_get_drvdata(hid); | ||
| 1334 | struct g920_private_data *pdata; | ||
| 1335 | struct hidpp_report response; | ||
| 1336 | u8 params[2]; | ||
| 1337 | int ret; | ||
| 1338 | u16 range = simple_strtoul(buf, NULL, 10); | ||
| 1339 | |||
| 1340 | pdata = hidpp->private_data; | ||
| 1341 | if (!pdata) { | ||
| 1342 | hid_err(hid, "Private driver data not found!\n"); | ||
| 1343 | return -EINVAL; | ||
| 1344 | } | ||
| 1345 | |||
| 1346 | if (range < 180) | ||
| 1347 | range = 180; | ||
| 1348 | else if (range > 900) | ||
| 1349 | range = 900; | ||
| 1350 | |||
| 1351 | params[0] = range >> 8; | ||
| 1352 | params[1] = range & 0x00FF; | ||
| 1353 | |||
| 1354 | ret = hidpp_send_fap_command_sync(hidpp, pdata->force_feature, | ||
| 1355 | CMD_G920_FORCE_SET_APERTURE, params, 2, &response); | ||
| 1356 | if (ret) | ||
| 1357 | return ret; | ||
| 1358 | |||
| 1359 | pdata->range = range; | ||
| 1360 | return count; | ||
| 1361 | } | ||
| 1362 | |||
| 1363 | static DEVICE_ATTR(range, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH, g920_range_show, g920_range_store); | ||
| 1364 | |||
| 1365 | static int g920_allocate(struct hid_device *hdev) | ||
| 1366 | { | ||
| 1367 | struct hidpp_device *hidpp = hid_get_drvdata(hdev); | ||
| 1368 | struct g920_private_data *pdata; | ||
| 1369 | |||
| 1370 | pdata = devm_kzalloc(&hdev->dev, sizeof(struct g920_private_data), | ||
| 1371 | GFP_KERNEL); | ||
| 1372 | if (!pdata) | ||
| 1373 | return -ENOMEM; | ||
| 1374 | |||
| 1375 | hidpp->private_data = pdata; | ||
| 1376 | |||
| 1377 | return 0; | ||
| 1378 | } | ||
| 1379 | |||
| 1380 | static int g920_get_config(struct hidpp_device *hidpp) | ||
| 1381 | { | ||
| 1382 | struct g920_private_data *pdata = hidpp->private_data; | ||
| 1383 | struct hidpp_report response; | ||
| 1384 | u8 feature_type; | ||
| 1385 | u8 feature_index; | ||
| 1386 | int ret; | ||
| 1387 | |||
| 1388 | pdata = hidpp->private_data; | ||
| 1389 | if (!pdata) { | ||
| 1390 | hid_err(hidpp->hid_dev, "Private driver data not found!\n"); | ||
| 1391 | return -EINVAL; | ||
| 1392 | } | ||
| 1393 | |||
| 1394 | /* Find feature and store for later use */ | ||
| 1395 | ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_G920_FORCE_FEEDBACK, | ||
| 1396 | &feature_index, &feature_type); | ||
| 1397 | if (ret) | ||
| 1398 | return ret; | ||
| 1399 | |||
| 1400 | pdata->force_feature = feature_index; | ||
| 1401 | |||
| 1402 | /* Read current Range */ | ||
| 1403 | ret = hidpp_send_fap_command_sync(hidpp, feature_index, | ||
| 1404 | CMD_G920_FORCE_GET_APERTURE, NULL, 0, &response); | ||
| 1405 | if (ret > 0) { | ||
| 1406 | hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", | ||
| 1407 | __func__, ret); | ||
| 1408 | return -EPROTO; | ||
| 1409 | } | ||
| 1410 | if (ret) | ||
| 1411 | return ret; | ||
| 1412 | |||
| 1413 | pdata->range = get_unaligned_be16(&response.fap.params[0]); | ||
| 1414 | |||
| 1415 | /* Create sysfs interface */ | ||
| 1416 | ret = device_create_file(&(hidpp->hid_dev->dev), &dev_attr_range); | ||
| 1417 | if (ret) | ||
| 1418 | hid_warn(hidpp->hid_dev, "Unable to create sysfs interface for \"range\", errno %d\n", ret); | ||
| 1419 | |||
| 1420 | return 0; | ||
| 1421 | } | ||
| 1422 | |||
| 1260 | /* -------------------------------------------------------------------------- */ | 1423 | /* -------------------------------------------------------------------------- */ |
| 1261 | /* Generic HID++ devices */ | 1424 | /* Generic HID++ devices */ |
| 1262 | /* -------------------------------------------------------------------------- */ | 1425 | /* -------------------------------------------------------------------------- */ |
| @@ -1276,6 +1439,25 @@ static int hidpp_input_mapping(struct hid_device *hdev, struct hid_input *hi, | |||
| 1276 | return 0; | 1439 | return 0; |
| 1277 | } | 1440 | } |
| 1278 | 1441 | ||
| 1442 | static int hidpp_input_mapped(struct hid_device *hdev, struct hid_input *hi, | ||
| 1443 | struct hid_field *field, struct hid_usage *usage, | ||
| 1444 | unsigned long **bit, int *max) | ||
| 1445 | { | ||
| 1446 | struct hidpp_device *hidpp = hid_get_drvdata(hdev); | ||
| 1447 | |||
| 1448 | /* Ensure that Logitech G920 is not given a default fuzz/flat value */ | ||
| 1449 | if (hidpp->quirks & HIDPP_QUIRK_CLASS_G920) { | ||
| 1450 | if (usage->type == EV_ABS && (usage->code == ABS_X || | ||
| 1451 | usage->code == ABS_Y || usage->code == ABS_Z || | ||
| 1452 | usage->code == ABS_RZ)) { | ||
| 1453 | field->application = HID_GD_MULTIAXIS; | ||
| 1454 | } | ||
| 1455 | } | ||
| 1456 | |||
| 1457 | return 0; | ||
| 1458 | } | ||
| 1459 | |||
| 1460 | |||
| 1279 | static void hidpp_populate_input(struct hidpp_device *hidpp, | 1461 | static void hidpp_populate_input(struct hidpp_device *hidpp, |
| 1280 | struct input_dev *input, bool origin_is_hid_core) | 1462 | struct input_dev *input, bool origin_is_hid_core) |
| 1281 | { | 1463 | { |
| @@ -1347,6 +1529,14 @@ static int hidpp_raw_event(struct hid_device *hdev, struct hid_report *report, | |||
| 1347 | 1529 | ||
| 1348 | /* Generic HID++ processing. */ | 1530 | /* Generic HID++ processing. */ |
| 1349 | switch (data[0]) { | 1531 | switch (data[0]) { |
| 1532 | case REPORT_ID_HIDPP_VERY_LONG: | ||
| 1533 | if (size != HIDPP_REPORT_VERY_LONG_LENGTH) { | ||
| 1534 | hid_err(hdev, "received hid++ report of bad size (%d)", | ||
| 1535 | size); | ||
| 1536 | return 1; | ||
| 1537 | } | ||
| 1538 | ret = hidpp_raw_hidpp_event(hidpp, data, size); | ||
| 1539 | break; | ||
| 1350 | case REPORT_ID_HIDPP_LONG: | 1540 | case REPORT_ID_HIDPP_LONG: |
| 1351 | if (size != HIDPP_REPORT_LONG_LENGTH) { | 1541 | if (size != HIDPP_REPORT_LONG_LENGTH) { |
| 1352 | hid_err(hdev, "received hid++ report of bad size (%d)", | 1542 | hid_err(hdev, "received hid++ report of bad size (%d)", |
| @@ -1393,10 +1583,12 @@ static void hidpp_overwrite_name(struct hid_device *hdev, bool use_unifying) | |||
| 1393 | else | 1583 | else |
| 1394 | name = hidpp_get_device_name(hidpp); | 1584 | name = hidpp_get_device_name(hidpp); |
| 1395 | 1585 | ||
| 1396 | if (!name) | 1586 | if (!name) { |
| 1397 | hid_err(hdev, "unable to retrieve the name of the device"); | 1587 | hid_err(hdev, "unable to retrieve the name of the device"); |
| 1398 | else | 1588 | } else { |
| 1589 | dbg_hid("HID++: Got name: %s\n", name); | ||
| 1399 | snprintf(hdev->name, sizeof(hdev->name), "%s", name); | 1590 | snprintf(hdev->name, sizeof(hdev->name), "%s", name); |
| 1591 | } | ||
| 1400 | 1592 | ||
| 1401 | kfree(name); | 1593 | kfree(name); |
| 1402 | } | 1594 | } |
| @@ -1547,6 +1739,10 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
| 1547 | ret = k400_allocate(hdev); | 1739 | ret = k400_allocate(hdev); |
| 1548 | if (ret) | 1740 | if (ret) |
| 1549 | goto allocate_fail; | 1741 | goto allocate_fail; |
| 1742 | } else if (hidpp->quirks & HIDPP_QUIRK_CLASS_G920) { | ||
| 1743 | ret = g920_allocate(hdev); | ||
| 1744 | if (ret) | ||
| 1745 | goto allocate_fail; | ||
| 1550 | } | 1746 | } |
| 1551 | 1747 | ||
| 1552 | INIT_WORK(&hidpp->work, delayed_work_cb); | 1748 | INIT_WORK(&hidpp->work, delayed_work_cb); |
| @@ -1559,6 +1755,25 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
| 1559 | goto hid_parse_fail; | 1755 | goto hid_parse_fail; |
| 1560 | } | 1756 | } |
| 1561 | 1757 | ||
| 1758 | if (hidpp->quirks & HIDPP_QUIRK_NO_HIDINPUT) | ||
| 1759 | connect_mask &= ~HID_CONNECT_HIDINPUT; | ||
| 1760 | |||
| 1761 | if (hidpp->quirks & HIDPP_QUIRK_CLASS_G920) { | ||
| 1762 | ret = hid_hw_start(hdev, connect_mask); | ||
| 1763 | if (ret) { | ||
| 1764 | hid_err(hdev, "hw start failed\n"); | ||
| 1765 | goto hid_hw_start_fail; | ||
| 1766 | } | ||
| 1767 | ret = hid_hw_open(hdev); | ||
| 1768 | if (ret < 0) { | ||
| 1769 | dev_err(&hdev->dev, "%s:hid_hw_open returned error:%d\n", | ||
| 1770 | __func__, ret); | ||
| 1771 | hid_hw_stop(hdev); | ||
| 1772 | goto hid_hw_start_fail; | ||
| 1773 | } | ||
| 1774 | } | ||
| 1775 | |||
| 1776 | |||
| 1562 | /* Allow incoming packets */ | 1777 | /* Allow incoming packets */ |
| 1563 | hid_device_io_start(hdev); | 1778 | hid_device_io_start(hdev); |
| 1564 | 1779 | ||
| @@ -1567,8 +1782,7 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
| 1567 | if (!connected) { | 1782 | if (!connected) { |
| 1568 | ret = -ENODEV; | 1783 | ret = -ENODEV; |
| 1569 | hid_err(hdev, "Device not connected"); | 1784 | hid_err(hdev, "Device not connected"); |
| 1570 | hid_device_io_stop(hdev); | 1785 | goto hid_hw_open_failed; |
| 1571 | goto hid_parse_fail; | ||
| 1572 | } | 1786 | } |
| 1573 | 1787 | ||
| 1574 | hid_info(hdev, "HID++ %u.%u device connected.\n", | 1788 | hid_info(hdev, "HID++ %u.%u device connected.\n", |
| @@ -1581,19 +1795,22 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
| 1581 | if (connected && (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP)) { | 1795 | if (connected && (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP)) { |
| 1582 | ret = wtp_get_config(hidpp); | 1796 | ret = wtp_get_config(hidpp); |
| 1583 | if (ret) | 1797 | if (ret) |
| 1584 | goto hid_parse_fail; | 1798 | goto hid_hw_open_failed; |
| 1799 | } else if (connected && (hidpp->quirks & HIDPP_QUIRK_CLASS_G920)) { | ||
| 1800 | ret = g920_get_config(hidpp); | ||
| 1801 | if (ret) | ||
| 1802 | goto hid_hw_open_failed; | ||
| 1585 | } | 1803 | } |
| 1586 | 1804 | ||
| 1587 | /* Block incoming packets */ | 1805 | /* Block incoming packets */ |
| 1588 | hid_device_io_stop(hdev); | 1806 | hid_device_io_stop(hdev); |
| 1589 | 1807 | ||
| 1590 | if (hidpp->quirks & HIDPP_QUIRK_NO_HIDINPUT) | 1808 | if (!(hidpp->quirks & HIDPP_QUIRK_CLASS_G920)) { |
| 1591 | connect_mask &= ~HID_CONNECT_HIDINPUT; | 1809 | ret = hid_hw_start(hdev, connect_mask); |
| 1592 | 1810 | if (ret) { | |
| 1593 | ret = hid_hw_start(hdev, connect_mask); | 1811 | hid_err(hdev, "%s:hid_hw_start returned error\n", __func__); |
| 1594 | if (ret) { | 1812 | goto hid_hw_start_fail; |
| 1595 | hid_err(hdev, "%s:hid_hw_start returned error\n", __func__); | 1813 | } |
| 1596 | goto hid_hw_start_fail; | ||
| 1597 | } | 1814 | } |
| 1598 | 1815 | ||
| 1599 | if (hidpp->quirks & HIDPP_QUIRK_CONNECT_EVENTS) { | 1816 | if (hidpp->quirks & HIDPP_QUIRK_CONNECT_EVENTS) { |
| @@ -1605,6 +1822,13 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
| 1605 | 1822 | ||
| 1606 | return ret; | 1823 | return ret; |
| 1607 | 1824 | ||
| 1825 | hid_hw_open_failed: | ||
| 1826 | hid_device_io_stop(hdev); | ||
| 1827 | if (hidpp->quirks & HIDPP_QUIRK_CLASS_G920) { | ||
| 1828 | device_remove_file(&hdev->dev, &dev_attr_range); | ||
| 1829 | hid_hw_close(hdev); | ||
| 1830 | hid_hw_stop(hdev); | ||
| 1831 | } | ||
| 1608 | hid_hw_start_fail: | 1832 | hid_hw_start_fail: |
| 1609 | hid_parse_fail: | 1833 | hid_parse_fail: |
| 1610 | cancel_work_sync(&hidpp->work); | 1834 | cancel_work_sync(&hidpp->work); |
| @@ -1618,9 +1842,13 @@ static void hidpp_remove(struct hid_device *hdev) | |||
| 1618 | { | 1842 | { |
| 1619 | struct hidpp_device *hidpp = hid_get_drvdata(hdev); | 1843 | struct hidpp_device *hidpp = hid_get_drvdata(hdev); |
| 1620 | 1844 | ||
| 1845 | if (hidpp->quirks & HIDPP_QUIRK_CLASS_G920) { | ||
| 1846 | device_remove_file(&hdev->dev, &dev_attr_range); | ||
| 1847 | hid_hw_close(hdev); | ||
| 1848 | } | ||
| 1849 | hid_hw_stop(hdev); | ||
| 1621 | cancel_work_sync(&hidpp->work); | 1850 | cancel_work_sync(&hidpp->work); |
| 1622 | mutex_destroy(&hidpp->send_mutex); | 1851 | mutex_destroy(&hidpp->send_mutex); |
| 1623 | hid_hw_stop(hdev); | ||
| 1624 | } | 1852 | } |
| 1625 | 1853 | ||
| 1626 | static const struct hid_device_id hidpp_devices[] = { | 1854 | static const struct hid_device_id hidpp_devices[] = { |
| @@ -1648,6 +1876,9 @@ static const struct hid_device_id hidpp_devices[] = { | |||
| 1648 | 1876 | ||
| 1649 | { HID_DEVICE(BUS_USB, HID_GROUP_LOGITECH_DJ_DEVICE, | 1877 | { HID_DEVICE(BUS_USB, HID_GROUP_LOGITECH_DJ_DEVICE, |
| 1650 | USB_VENDOR_ID_LOGITECH, HID_ANY_ID)}, | 1878 | USB_VENDOR_ID_LOGITECH, HID_ANY_ID)}, |
| 1879 | |||
| 1880 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G920_WHEEL), | ||
| 1881 | .driver_data = HIDPP_QUIRK_CLASS_G920 | HIDPP_QUIRK_FORCE_OUTPUT_REPORTS}, | ||
| 1651 | {} | 1882 | {} |
| 1652 | }; | 1883 | }; |
| 1653 | 1884 | ||
| @@ -1661,6 +1892,7 @@ static struct hid_driver hidpp_driver = { | |||
| 1661 | .raw_event = hidpp_raw_event, | 1892 | .raw_event = hidpp_raw_event, |
| 1662 | .input_configured = hidpp_input_configured, | 1893 | .input_configured = hidpp_input_configured, |
| 1663 | .input_mapping = hidpp_input_mapping, | 1894 | .input_mapping = hidpp_input_mapping, |
| 1895 | .input_mapped = hidpp_input_mapped, | ||
| 1664 | }; | 1896 | }; |
| 1665 | 1897 | ||
| 1666 | module_hid_driver(hidpp_driver); | 1898 | module_hid_driver(hidpp_driver); |
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c index 3d664d01305e..296d4991560e 100644 --- a/drivers/hid/hid-multitouch.c +++ b/drivers/hid/hid-multitouch.c | |||
| @@ -272,7 +272,7 @@ static ssize_t mt_show_quirks(struct device *dev, | |||
| 272 | struct device_attribute *attr, | 272 | struct device_attribute *attr, |
| 273 | char *buf) | 273 | char *buf) |
| 274 | { | 274 | { |
| 275 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 275 | struct hid_device *hdev = to_hid_device(dev); |
| 276 | struct mt_device *td = hid_get_drvdata(hdev); | 276 | struct mt_device *td = hid_get_drvdata(hdev); |
| 277 | 277 | ||
| 278 | return sprintf(buf, "%u\n", td->mtclass.quirks); | 278 | return sprintf(buf, "%u\n", td->mtclass.quirks); |
| @@ -282,7 +282,7 @@ static ssize_t mt_set_quirks(struct device *dev, | |||
| 282 | struct device_attribute *attr, | 282 | struct device_attribute *attr, |
| 283 | const char *buf, size_t count) | 283 | const char *buf, size_t count) |
| 284 | { | 284 | { |
| 285 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 285 | struct hid_device *hdev = to_hid_device(dev); |
| 286 | struct mt_device *td = hid_get_drvdata(hdev); | 286 | struct mt_device *td = hid_get_drvdata(hdev); |
| 287 | 287 | ||
| 288 | unsigned long val; | 288 | unsigned long val; |
| @@ -357,8 +357,19 @@ static void mt_feature_mapping(struct hid_device *hdev, | |||
| 357 | break; | 357 | break; |
| 358 | } | 358 | } |
| 359 | 359 | ||
| 360 | td->inputmode = field->report->id; | 360 | if (td->inputmode < 0) { |
| 361 | td->inputmode_index = usage->usage_index; | 361 | td->inputmode = field->report->id; |
| 362 | td->inputmode_index = usage->usage_index; | ||
| 363 | } else { | ||
| 364 | /* | ||
| 365 | * Some elan panels wrongly declare 2 input mode | ||
| 366 | * features, and silently ignore when we set the | ||
| 367 | * value in the second field. Skip the second feature | ||
| 368 | * and hope for the best. | ||
| 369 | */ | ||
| 370 | dev_info(&hdev->dev, | ||
| 371 | "Ignoring the extra HID_DG_INPUTMODE\n"); | ||
| 372 | } | ||
| 362 | 373 | ||
| 363 | break; | 374 | break; |
| 364 | case HID_DG_CONTACTMAX: | 375 | case HID_DG_CONTACTMAX: |
| @@ -486,6 +497,11 @@ static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi, | |||
| 486 | mt_store_field(usage, td, hi); | 497 | mt_store_field(usage, td, hi); |
| 487 | return 1; | 498 | return 1; |
| 488 | case HID_DG_CONFIDENCE: | 499 | case HID_DG_CONFIDENCE: |
| 500 | if (cls->name == MT_CLS_WIN_8 && | ||
| 501 | field->application == HID_DG_TOUCHPAD) { | ||
| 502 | cls->quirks &= ~MT_QUIRK_ALWAYS_VALID; | ||
| 503 | cls->quirks |= MT_QUIRK_VALID_IS_CONFIDENCE; | ||
| 504 | } | ||
| 489 | mt_store_field(usage, td, hi); | 505 | mt_store_field(usage, td, hi); |
| 490 | return 1; | 506 | return 1; |
| 491 | case HID_DG_TIPSWITCH: | 507 | case HID_DG_TIPSWITCH: |
diff --git a/drivers/hid/hid-ntrig.c b/drivers/hid/hid-ntrig.c index 756d1ef9bd99..1b0084d4af2e 100644 --- a/drivers/hid/hid-ntrig.c +++ b/drivers/hid/hid-ntrig.c | |||
| @@ -173,7 +173,7 @@ static ssize_t show_phys_width(struct device *dev, | |||
| 173 | struct device_attribute *attr, | 173 | struct device_attribute *attr, |
| 174 | char *buf) | 174 | char *buf) |
| 175 | { | 175 | { |
| 176 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 176 | struct hid_device *hdev = to_hid_device(dev); |
| 177 | struct ntrig_data *nd = hid_get_drvdata(hdev); | 177 | struct ntrig_data *nd = hid_get_drvdata(hdev); |
| 178 | 178 | ||
| 179 | return sprintf(buf, "%d\n", nd->sensor_physical_width); | 179 | return sprintf(buf, "%d\n", nd->sensor_physical_width); |
| @@ -185,7 +185,7 @@ static ssize_t show_phys_height(struct device *dev, | |||
| 185 | struct device_attribute *attr, | 185 | struct device_attribute *attr, |
| 186 | char *buf) | 186 | char *buf) |
| 187 | { | 187 | { |
| 188 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 188 | struct hid_device *hdev = to_hid_device(dev); |
| 189 | struct ntrig_data *nd = hid_get_drvdata(hdev); | 189 | struct ntrig_data *nd = hid_get_drvdata(hdev); |
| 190 | 190 | ||
| 191 | return sprintf(buf, "%d\n", nd->sensor_physical_height); | 191 | return sprintf(buf, "%d\n", nd->sensor_physical_height); |
| @@ -197,7 +197,7 @@ static ssize_t show_log_width(struct device *dev, | |||
| 197 | struct device_attribute *attr, | 197 | struct device_attribute *attr, |
| 198 | char *buf) | 198 | char *buf) |
| 199 | { | 199 | { |
| 200 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 200 | struct hid_device *hdev = to_hid_device(dev); |
| 201 | struct ntrig_data *nd = hid_get_drvdata(hdev); | 201 | struct ntrig_data *nd = hid_get_drvdata(hdev); |
| 202 | 202 | ||
| 203 | return sprintf(buf, "%d\n", nd->sensor_logical_width); | 203 | return sprintf(buf, "%d\n", nd->sensor_logical_width); |
| @@ -209,7 +209,7 @@ static ssize_t show_log_height(struct device *dev, | |||
| 209 | struct device_attribute *attr, | 209 | struct device_attribute *attr, |
| 210 | char *buf) | 210 | char *buf) |
| 211 | { | 211 | { |
| 212 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 212 | struct hid_device *hdev = to_hid_device(dev); |
| 213 | struct ntrig_data *nd = hid_get_drvdata(hdev); | 213 | struct ntrig_data *nd = hid_get_drvdata(hdev); |
| 214 | 214 | ||
| 215 | return sprintf(buf, "%d\n", nd->sensor_logical_height); | 215 | return sprintf(buf, "%d\n", nd->sensor_logical_height); |
| @@ -221,7 +221,7 @@ static ssize_t show_min_width(struct device *dev, | |||
| 221 | struct device_attribute *attr, | 221 | struct device_attribute *attr, |
| 222 | char *buf) | 222 | char *buf) |
| 223 | { | 223 | { |
| 224 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 224 | struct hid_device *hdev = to_hid_device(dev); |
| 225 | struct ntrig_data *nd = hid_get_drvdata(hdev); | 225 | struct ntrig_data *nd = hid_get_drvdata(hdev); |
| 226 | 226 | ||
| 227 | return sprintf(buf, "%d\n", nd->min_width * | 227 | return sprintf(buf, "%d\n", nd->min_width * |
| @@ -233,7 +233,7 @@ static ssize_t set_min_width(struct device *dev, | |||
| 233 | struct device_attribute *attr, | 233 | struct device_attribute *attr, |
| 234 | const char *buf, size_t count) | 234 | const char *buf, size_t count) |
| 235 | { | 235 | { |
| 236 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 236 | struct hid_device *hdev = to_hid_device(dev); |
| 237 | struct ntrig_data *nd = hid_get_drvdata(hdev); | 237 | struct ntrig_data *nd = hid_get_drvdata(hdev); |
| 238 | 238 | ||
| 239 | unsigned long val; | 239 | unsigned long val; |
| @@ -256,7 +256,7 @@ static ssize_t show_min_height(struct device *dev, | |||
| 256 | struct device_attribute *attr, | 256 | struct device_attribute *attr, |
| 257 | char *buf) | 257 | char *buf) |
| 258 | { | 258 | { |
| 259 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 259 | struct hid_device *hdev = to_hid_device(dev); |
| 260 | struct ntrig_data *nd = hid_get_drvdata(hdev); | 260 | struct ntrig_data *nd = hid_get_drvdata(hdev); |
| 261 | 261 | ||
| 262 | return sprintf(buf, "%d\n", nd->min_height * | 262 | return sprintf(buf, "%d\n", nd->min_height * |
| @@ -268,7 +268,7 @@ static ssize_t set_min_height(struct device *dev, | |||
| 268 | struct device_attribute *attr, | 268 | struct device_attribute *attr, |
| 269 | const char *buf, size_t count) | 269 | const char *buf, size_t count) |
| 270 | { | 270 | { |
| 271 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 271 | struct hid_device *hdev = to_hid_device(dev); |
| 272 | struct ntrig_data *nd = hid_get_drvdata(hdev); | 272 | struct ntrig_data *nd = hid_get_drvdata(hdev); |
| 273 | 273 | ||
| 274 | unsigned long val; | 274 | unsigned long val; |
| @@ -292,7 +292,7 @@ static ssize_t show_activate_slack(struct device *dev, | |||
| 292 | struct device_attribute *attr, | 292 | struct device_attribute *attr, |
| 293 | char *buf) | 293 | char *buf) |
| 294 | { | 294 | { |
| 295 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 295 | struct hid_device *hdev = to_hid_device(dev); |
| 296 | struct ntrig_data *nd = hid_get_drvdata(hdev); | 296 | struct ntrig_data *nd = hid_get_drvdata(hdev); |
| 297 | 297 | ||
| 298 | return sprintf(buf, "%d\n", nd->activate_slack); | 298 | return sprintf(buf, "%d\n", nd->activate_slack); |
| @@ -302,7 +302,7 @@ static ssize_t set_activate_slack(struct device *dev, | |||
| 302 | struct device_attribute *attr, | 302 | struct device_attribute *attr, |
| 303 | const char *buf, size_t count) | 303 | const char *buf, size_t count) |
| 304 | { | 304 | { |
| 305 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 305 | struct hid_device *hdev = to_hid_device(dev); |
| 306 | struct ntrig_data *nd = hid_get_drvdata(hdev); | 306 | struct ntrig_data *nd = hid_get_drvdata(hdev); |
| 307 | 307 | ||
| 308 | unsigned long val; | 308 | unsigned long val; |
| @@ -325,7 +325,7 @@ static ssize_t show_activation_width(struct device *dev, | |||
| 325 | struct device_attribute *attr, | 325 | struct device_attribute *attr, |
| 326 | char *buf) | 326 | char *buf) |
| 327 | { | 327 | { |
| 328 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 328 | struct hid_device *hdev = to_hid_device(dev); |
| 329 | struct ntrig_data *nd = hid_get_drvdata(hdev); | 329 | struct ntrig_data *nd = hid_get_drvdata(hdev); |
| 330 | 330 | ||
| 331 | return sprintf(buf, "%d\n", nd->activation_width * | 331 | return sprintf(buf, "%d\n", nd->activation_width * |
| @@ -337,7 +337,7 @@ static ssize_t set_activation_width(struct device *dev, | |||
| 337 | struct device_attribute *attr, | 337 | struct device_attribute *attr, |
| 338 | const char *buf, size_t count) | 338 | const char *buf, size_t count) |
| 339 | { | 339 | { |
| 340 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 340 | struct hid_device *hdev = to_hid_device(dev); |
| 341 | struct ntrig_data *nd = hid_get_drvdata(hdev); | 341 | struct ntrig_data *nd = hid_get_drvdata(hdev); |
| 342 | 342 | ||
| 343 | unsigned long val; | 343 | unsigned long val; |
| @@ -361,7 +361,7 @@ static ssize_t show_activation_height(struct device *dev, | |||
| 361 | struct device_attribute *attr, | 361 | struct device_attribute *attr, |
| 362 | char *buf) | 362 | char *buf) |
| 363 | { | 363 | { |
| 364 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 364 | struct hid_device *hdev = to_hid_device(dev); |
| 365 | struct ntrig_data *nd = hid_get_drvdata(hdev); | 365 | struct ntrig_data *nd = hid_get_drvdata(hdev); |
| 366 | 366 | ||
| 367 | return sprintf(buf, "%d\n", nd->activation_height * | 367 | return sprintf(buf, "%d\n", nd->activation_height * |
| @@ -373,7 +373,7 @@ static ssize_t set_activation_height(struct device *dev, | |||
| 373 | struct device_attribute *attr, | 373 | struct device_attribute *attr, |
| 374 | const char *buf, size_t count) | 374 | const char *buf, size_t count) |
| 375 | { | 375 | { |
| 376 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 376 | struct hid_device *hdev = to_hid_device(dev); |
| 377 | struct ntrig_data *nd = hid_get_drvdata(hdev); | 377 | struct ntrig_data *nd = hid_get_drvdata(hdev); |
| 378 | 378 | ||
| 379 | unsigned long val; | 379 | unsigned long val; |
| @@ -397,7 +397,7 @@ static ssize_t show_deactivate_slack(struct device *dev, | |||
| 397 | struct device_attribute *attr, | 397 | struct device_attribute *attr, |
| 398 | char *buf) | 398 | char *buf) |
| 399 | { | 399 | { |
| 400 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 400 | struct hid_device *hdev = to_hid_device(dev); |
| 401 | struct ntrig_data *nd = hid_get_drvdata(hdev); | 401 | struct ntrig_data *nd = hid_get_drvdata(hdev); |
| 402 | 402 | ||
| 403 | return sprintf(buf, "%d\n", -nd->deactivate_slack); | 403 | return sprintf(buf, "%d\n", -nd->deactivate_slack); |
| @@ -407,7 +407,7 @@ static ssize_t set_deactivate_slack(struct device *dev, | |||
| 407 | struct device_attribute *attr, | 407 | struct device_attribute *attr, |
| 408 | const char *buf, size_t count) | 408 | const char *buf, size_t count) |
| 409 | { | 409 | { |
| 410 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 410 | struct hid_device *hdev = to_hid_device(dev); |
| 411 | struct ntrig_data *nd = hid_get_drvdata(hdev); | 411 | struct ntrig_data *nd = hid_get_drvdata(hdev); |
| 412 | 412 | ||
| 413 | unsigned long val; | 413 | unsigned long val; |
diff --git a/drivers/hid/hid-picolcd_leds.c b/drivers/hid/hid-picolcd_leds.c index e994f9c29012..a802b4f49c7b 100644 --- a/drivers/hid/hid-picolcd_leds.c +++ b/drivers/hid/hid-picolcd_leds.c | |||
| @@ -66,7 +66,7 @@ static void picolcd_led_set_brightness(struct led_classdev *led_cdev, | |||
| 66 | int i, state = 0; | 66 | int i, state = 0; |
| 67 | 67 | ||
| 68 | dev = led_cdev->dev->parent; | 68 | dev = led_cdev->dev->parent; |
| 69 | hdev = container_of(dev, struct hid_device, dev); | 69 | hdev = to_hid_device(dev); |
| 70 | data = hid_get_drvdata(hdev); | 70 | data = hid_get_drvdata(hdev); |
| 71 | if (!data) | 71 | if (!data) |
| 72 | return; | 72 | return; |
| @@ -93,7 +93,7 @@ static enum led_brightness picolcd_led_get_brightness(struct led_classdev *led_c | |||
| 93 | int i, value = 0; | 93 | int i, value = 0; |
| 94 | 94 | ||
| 95 | dev = led_cdev->dev->parent; | 95 | dev = led_cdev->dev->parent; |
| 96 | hdev = container_of(dev, struct hid_device, dev); | 96 | hdev = to_hid_device(dev); |
| 97 | data = hid_get_drvdata(hdev); | 97 | data = hid_get_drvdata(hdev); |
| 98 | for (i = 0; i < 8; i++) | 98 | for (i = 0; i < 8; i++) |
| 99 | if (led_cdev == data->led[i]) { | 99 | if (led_cdev == data->led[i]) { |
diff --git a/drivers/hid/hid-prodikeys.c b/drivers/hid/hid-prodikeys.c index 3a207c0ac0e3..f095bf8a3aa9 100644 --- a/drivers/hid/hid-prodikeys.c +++ b/drivers/hid/hid-prodikeys.c | |||
| @@ -103,7 +103,7 @@ MODULE_PARM_DESC(enable, "Enable for the PC-MIDI virtual audio driver"); | |||
| 103 | static ssize_t show_channel(struct device *dev, | 103 | static ssize_t show_channel(struct device *dev, |
| 104 | struct device_attribute *attr, char *buf) | 104 | struct device_attribute *attr, char *buf) |
| 105 | { | 105 | { |
| 106 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 106 | struct hid_device *hdev = to_hid_device(dev); |
| 107 | struct pk_device *pk = hid_get_drvdata(hdev); | 107 | struct pk_device *pk = hid_get_drvdata(hdev); |
| 108 | 108 | ||
| 109 | dbg_hid("pcmidi sysfs read channel=%u\n", pk->pm->midi_channel); | 109 | dbg_hid("pcmidi sysfs read channel=%u\n", pk->pm->midi_channel); |
| @@ -116,7 +116,7 @@ static ssize_t show_channel(struct device *dev, | |||
| 116 | static ssize_t store_channel(struct device *dev, | 116 | static ssize_t store_channel(struct device *dev, |
| 117 | struct device_attribute *attr, const char *buf, size_t count) | 117 | struct device_attribute *attr, const char *buf, size_t count) |
| 118 | { | 118 | { |
| 119 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 119 | struct hid_device *hdev = to_hid_device(dev); |
| 120 | struct pk_device *pk = hid_get_drvdata(hdev); | 120 | struct pk_device *pk = hid_get_drvdata(hdev); |
| 121 | 121 | ||
| 122 | unsigned channel = 0; | 122 | unsigned channel = 0; |
| @@ -140,7 +140,7 @@ static struct device_attribute *sysfs_device_attr_channel = { | |||
| 140 | static ssize_t show_sustain(struct device *dev, | 140 | static ssize_t show_sustain(struct device *dev, |
| 141 | struct device_attribute *attr, char *buf) | 141 | struct device_attribute *attr, char *buf) |
| 142 | { | 142 | { |
| 143 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 143 | struct hid_device *hdev = to_hid_device(dev); |
| 144 | struct pk_device *pk = hid_get_drvdata(hdev); | 144 | struct pk_device *pk = hid_get_drvdata(hdev); |
| 145 | 145 | ||
| 146 | dbg_hid("pcmidi sysfs read sustain=%u\n", pk->pm->midi_sustain); | 146 | dbg_hid("pcmidi sysfs read sustain=%u\n", pk->pm->midi_sustain); |
| @@ -153,7 +153,7 @@ static ssize_t show_sustain(struct device *dev, | |||
| 153 | static ssize_t store_sustain(struct device *dev, | 153 | static ssize_t store_sustain(struct device *dev, |
| 154 | struct device_attribute *attr, const char *buf, size_t count) | 154 | struct device_attribute *attr, const char *buf, size_t count) |
| 155 | { | 155 | { |
| 156 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 156 | struct hid_device *hdev = to_hid_device(dev); |
| 157 | struct pk_device *pk = hid_get_drvdata(hdev); | 157 | struct pk_device *pk = hid_get_drvdata(hdev); |
| 158 | 158 | ||
| 159 | unsigned sustain = 0; | 159 | unsigned sustain = 0; |
| @@ -179,7 +179,7 @@ static struct device_attribute *sysfs_device_attr_sustain = { | |||
| 179 | static ssize_t show_octave(struct device *dev, | 179 | static ssize_t show_octave(struct device *dev, |
| 180 | struct device_attribute *attr, char *buf) | 180 | struct device_attribute *attr, char *buf) |
| 181 | { | 181 | { |
| 182 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 182 | struct hid_device *hdev = to_hid_device(dev); |
| 183 | struct pk_device *pk = hid_get_drvdata(hdev); | 183 | struct pk_device *pk = hid_get_drvdata(hdev); |
| 184 | 184 | ||
| 185 | dbg_hid("pcmidi sysfs read octave=%d\n", pk->pm->midi_octave); | 185 | dbg_hid("pcmidi sysfs read octave=%d\n", pk->pm->midi_octave); |
| @@ -192,7 +192,7 @@ static ssize_t show_octave(struct device *dev, | |||
| 192 | static ssize_t store_octave(struct device *dev, | 192 | static ssize_t store_octave(struct device *dev, |
| 193 | struct device_attribute *attr, const char *buf, size_t count) | 193 | struct device_attribute *attr, const char *buf, size_t count) |
| 194 | { | 194 | { |
| 195 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 195 | struct hid_device *hdev = to_hid_device(dev); |
| 196 | struct pk_device *pk = hid_get_drvdata(hdev); | 196 | struct pk_device *pk = hid_get_drvdata(hdev); |
| 197 | 197 | ||
| 198 | int octave = 0; | 198 | int octave = 0; |
diff --git a/drivers/hid/hid-roccat-arvo.c b/drivers/hid/hid-roccat-arvo.c index 1948208fe038..329c5d1270f9 100644 --- a/drivers/hid/hid-roccat-arvo.c +++ b/drivers/hid/hid-roccat-arvo.c | |||
| @@ -191,8 +191,7 @@ static ssize_t arvo_sysfs_write(struct file *fp, | |||
| 191 | struct kobject *kobj, void const *buf, | 191 | struct kobject *kobj, void const *buf, |
| 192 | loff_t off, size_t count, size_t real_size, uint command) | 192 | loff_t off, size_t count, size_t real_size, uint command) |
| 193 | { | 193 | { |
| 194 | struct device *dev = | 194 | struct device *dev = kobj_to_dev(kobj)->parent->parent; |
| 195 | container_of(kobj, struct device, kobj)->parent->parent; | ||
| 196 | struct arvo_device *arvo = hid_get_drvdata(dev_get_drvdata(dev)); | 195 | struct arvo_device *arvo = hid_get_drvdata(dev_get_drvdata(dev)); |
| 197 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); | 196 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); |
| 198 | int retval; | 197 | int retval; |
| @@ -211,8 +210,7 @@ static ssize_t arvo_sysfs_read(struct file *fp, | |||
| 211 | struct kobject *kobj, void *buf, loff_t off, | 210 | struct kobject *kobj, void *buf, loff_t off, |
| 212 | size_t count, size_t real_size, uint command) | 211 | size_t count, size_t real_size, uint command) |
| 213 | { | 212 | { |
| 214 | struct device *dev = | 213 | struct device *dev = kobj_to_dev(kobj)->parent->parent; |
| 215 | container_of(kobj, struct device, kobj)->parent->parent; | ||
| 216 | struct arvo_device *arvo = hid_get_drvdata(dev_get_drvdata(dev)); | 214 | struct arvo_device *arvo = hid_get_drvdata(dev_get_drvdata(dev)); |
| 217 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); | 215 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); |
| 218 | int retval; | 216 | int retval; |
diff --git a/drivers/hid/hid-roccat-common.c b/drivers/hid/hid-roccat-common.c index 02e28e9f4ea7..8155ac5fede2 100644 --- a/drivers/hid/hid-roccat-common.c +++ b/drivers/hid/hid-roccat-common.c | |||
| @@ -134,8 +134,7 @@ ssize_t roccat_common2_sysfs_read(struct file *fp, struct kobject *kobj, | |||
| 134 | char *buf, loff_t off, size_t count, | 134 | char *buf, loff_t off, size_t count, |
| 135 | size_t real_size, uint command) | 135 | size_t real_size, uint command) |
| 136 | { | 136 | { |
| 137 | struct device *dev = | 137 | struct device *dev = kobj_to_dev(kobj)->parent->parent; |
| 138 | container_of(kobj, struct device, kobj)->parent->parent; | ||
| 139 | struct roccat_common2_device *roccat_dev = hid_get_drvdata(dev_get_drvdata(dev)); | 138 | struct roccat_common2_device *roccat_dev = hid_get_drvdata(dev_get_drvdata(dev)); |
| 140 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); | 139 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); |
| 141 | int retval; | 140 | int retval; |
| @@ -158,8 +157,7 @@ ssize_t roccat_common2_sysfs_write(struct file *fp, struct kobject *kobj, | |||
| 158 | void const *buf, loff_t off, size_t count, | 157 | void const *buf, loff_t off, size_t count, |
| 159 | size_t real_size, uint command) | 158 | size_t real_size, uint command) |
| 160 | { | 159 | { |
| 161 | struct device *dev = | 160 | struct device *dev = kobj_to_dev(kobj)->parent->parent; |
| 162 | container_of(kobj, struct device, kobj)->parent->parent; | ||
| 163 | struct roccat_common2_device *roccat_dev = hid_get_drvdata(dev_get_drvdata(dev)); | 161 | struct roccat_common2_device *roccat_dev = hid_get_drvdata(dev_get_drvdata(dev)); |
| 164 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); | 162 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); |
| 165 | int retval; | 163 | int retval; |
diff --git a/drivers/hid/hid-roccat-isku.c b/drivers/hid/hid-roccat-isku.c index bc62ed91e451..02db537f8f3e 100644 --- a/drivers/hid/hid-roccat-isku.c +++ b/drivers/hid/hid-roccat-isku.c | |||
| @@ -121,8 +121,7 @@ static ssize_t isku_sysfs_read(struct file *fp, struct kobject *kobj, | |||
| 121 | char *buf, loff_t off, size_t count, | 121 | char *buf, loff_t off, size_t count, |
| 122 | size_t real_size, uint command) | 122 | size_t real_size, uint command) |
| 123 | { | 123 | { |
| 124 | struct device *dev = | 124 | struct device *dev = kobj_to_dev(kobj)->parent->parent; |
| 125 | container_of(kobj, struct device, kobj)->parent->parent; | ||
| 126 | struct isku_device *isku = hid_get_drvdata(dev_get_drvdata(dev)); | 125 | struct isku_device *isku = hid_get_drvdata(dev_get_drvdata(dev)); |
| 127 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); | 126 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); |
| 128 | int retval; | 127 | int retval; |
| @@ -144,8 +143,7 @@ static ssize_t isku_sysfs_write(struct file *fp, struct kobject *kobj, | |||
| 144 | void const *buf, loff_t off, size_t count, | 143 | void const *buf, loff_t off, size_t count, |
| 145 | size_t real_size, uint command) | 144 | size_t real_size, uint command) |
| 146 | { | 145 | { |
| 147 | struct device *dev = | 146 | struct device *dev = kobj_to_dev(kobj)->parent->parent; |
| 148 | container_of(kobj, struct device, kobj)->parent->parent; | ||
| 149 | struct isku_device *isku = hid_get_drvdata(dev_get_drvdata(dev)); | 147 | struct isku_device *isku = hid_get_drvdata(dev_get_drvdata(dev)); |
| 150 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); | 148 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); |
| 151 | int retval; | 149 | int retval; |
diff --git a/drivers/hid/hid-roccat-kone.c b/drivers/hid/hid-roccat-kone.c index c29265055ac1..bf4675a27396 100644 --- a/drivers/hid/hid-roccat-kone.c +++ b/drivers/hid/hid-roccat-kone.c | |||
| @@ -269,8 +269,7 @@ static int kone_get_firmware_version(struct usb_device *usb_dev, int *result) | |||
| 269 | static ssize_t kone_sysfs_read_settings(struct file *fp, struct kobject *kobj, | 269 | static ssize_t kone_sysfs_read_settings(struct file *fp, struct kobject *kobj, |
| 270 | struct bin_attribute *attr, char *buf, | 270 | struct bin_attribute *attr, char *buf, |
| 271 | loff_t off, size_t count) { | 271 | loff_t off, size_t count) { |
| 272 | struct device *dev = | 272 | struct device *dev = kobj_to_dev(kobj)->parent->parent; |
| 273 | container_of(kobj, struct device, kobj)->parent->parent; | ||
| 274 | struct kone_device *kone = hid_get_drvdata(dev_get_drvdata(dev)); | 273 | struct kone_device *kone = hid_get_drvdata(dev_get_drvdata(dev)); |
| 275 | 274 | ||
| 276 | if (off >= sizeof(struct kone_settings)) | 275 | if (off >= sizeof(struct kone_settings)) |
| @@ -294,8 +293,7 @@ static ssize_t kone_sysfs_read_settings(struct file *fp, struct kobject *kobj, | |||
| 294 | static ssize_t kone_sysfs_write_settings(struct file *fp, struct kobject *kobj, | 293 | static ssize_t kone_sysfs_write_settings(struct file *fp, struct kobject *kobj, |
| 295 | struct bin_attribute *attr, char *buf, | 294 | struct bin_attribute *attr, char *buf, |
| 296 | loff_t off, size_t count) { | 295 | loff_t off, size_t count) { |
| 297 | struct device *dev = | 296 | struct device *dev = kobj_to_dev(kobj)->parent->parent; |
| 298 | container_of(kobj, struct device, kobj)->parent->parent; | ||
| 299 | struct kone_device *kone = hid_get_drvdata(dev_get_drvdata(dev)); | 297 | struct kone_device *kone = hid_get_drvdata(dev_get_drvdata(dev)); |
| 300 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); | 298 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); |
| 301 | int retval = 0, difference, old_profile; | 299 | int retval = 0, difference, old_profile; |
| @@ -332,8 +330,7 @@ static BIN_ATTR(settings, 0660, kone_sysfs_read_settings, | |||
| 332 | static ssize_t kone_sysfs_read_profilex(struct file *fp, | 330 | static ssize_t kone_sysfs_read_profilex(struct file *fp, |
| 333 | struct kobject *kobj, struct bin_attribute *attr, | 331 | struct kobject *kobj, struct bin_attribute *attr, |
| 334 | char *buf, loff_t off, size_t count) { | 332 | char *buf, loff_t off, size_t count) { |
| 335 | struct device *dev = | 333 | struct device *dev = kobj_to_dev(kobj)->parent->parent; |
| 336 | container_of(kobj, struct device, kobj)->parent->parent; | ||
| 337 | struct kone_device *kone = hid_get_drvdata(dev_get_drvdata(dev)); | 334 | struct kone_device *kone = hid_get_drvdata(dev_get_drvdata(dev)); |
| 338 | 335 | ||
| 339 | if (off >= sizeof(struct kone_profile)) | 336 | if (off >= sizeof(struct kone_profile)) |
| @@ -353,8 +350,7 @@ static ssize_t kone_sysfs_read_profilex(struct file *fp, | |||
| 353 | static ssize_t kone_sysfs_write_profilex(struct file *fp, | 350 | static ssize_t kone_sysfs_write_profilex(struct file *fp, |
| 354 | struct kobject *kobj, struct bin_attribute *attr, | 351 | struct kobject *kobj, struct bin_attribute *attr, |
| 355 | char *buf, loff_t off, size_t count) { | 352 | char *buf, loff_t off, size_t count) { |
| 356 | struct device *dev = | 353 | struct device *dev = kobj_to_dev(kobj)->parent->parent; |
| 357 | container_of(kobj, struct device, kobj)->parent->parent; | ||
| 358 | struct kone_device *kone = hid_get_drvdata(dev_get_drvdata(dev)); | 354 | struct kone_device *kone = hid_get_drvdata(dev_get_drvdata(dev)); |
| 359 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); | 355 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); |
| 360 | struct kone_profile *profile; | 356 | struct kone_profile *profile; |
diff --git a/drivers/hid/hid-roccat-koneplus.c b/drivers/hid/hid-roccat-koneplus.c index 5e99fcdc71b9..09e8fc72aa1d 100644 --- a/drivers/hid/hid-roccat-koneplus.c +++ b/drivers/hid/hid-roccat-koneplus.c | |||
| @@ -87,8 +87,7 @@ static ssize_t koneplus_sysfs_read(struct file *fp, struct kobject *kobj, | |||
| 87 | char *buf, loff_t off, size_t count, | 87 | char *buf, loff_t off, size_t count, |
| 88 | size_t real_size, uint command) | 88 | size_t real_size, uint command) |
| 89 | { | 89 | { |
| 90 | struct device *dev = | 90 | struct device *dev = kobj_to_dev(kobj)->parent->parent; |
| 91 | container_of(kobj, struct device, kobj)->parent->parent; | ||
| 92 | struct koneplus_device *koneplus = hid_get_drvdata(dev_get_drvdata(dev)); | 91 | struct koneplus_device *koneplus = hid_get_drvdata(dev_get_drvdata(dev)); |
| 93 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); | 92 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); |
| 94 | int retval; | 93 | int retval; |
| @@ -113,8 +112,7 @@ static ssize_t koneplus_sysfs_write(struct file *fp, struct kobject *kobj, | |||
| 113 | void const *buf, loff_t off, size_t count, | 112 | void const *buf, loff_t off, size_t count, |
| 114 | size_t real_size, uint command) | 113 | size_t real_size, uint command) |
| 115 | { | 114 | { |
| 116 | struct device *dev = | 115 | struct device *dev = kobj_to_dev(kobj)->parent->parent; |
| 117 | container_of(kobj, struct device, kobj)->parent->parent; | ||
| 118 | struct koneplus_device *koneplus = hid_get_drvdata(dev_get_drvdata(dev)); | 116 | struct koneplus_device *koneplus = hid_get_drvdata(dev_get_drvdata(dev)); |
| 119 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); | 117 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); |
| 120 | int retval; | 118 | int retval; |
| @@ -193,8 +191,7 @@ static ssize_t koneplus_sysfs_read_profilex_settings(struct file *fp, | |||
| 193 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | 191 | struct kobject *kobj, struct bin_attribute *attr, char *buf, |
| 194 | loff_t off, size_t count) | 192 | loff_t off, size_t count) |
| 195 | { | 193 | { |
| 196 | struct device *dev = | 194 | struct device *dev = kobj_to_dev(kobj)->parent->parent; |
| 197 | container_of(kobj, struct device, kobj)->parent->parent; | ||
| 198 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); | 195 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); |
| 199 | ssize_t retval; | 196 | ssize_t retval; |
| 200 | 197 | ||
| @@ -212,8 +209,7 @@ static ssize_t koneplus_sysfs_read_profilex_buttons(struct file *fp, | |||
| 212 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | 209 | struct kobject *kobj, struct bin_attribute *attr, char *buf, |
| 213 | loff_t off, size_t count) | 210 | loff_t off, size_t count) |
| 214 | { | 211 | { |
| 215 | struct device *dev = | 212 | struct device *dev = kobj_to_dev(kobj)->parent->parent; |
| 216 | container_of(kobj, struct device, kobj)->parent->parent; | ||
| 217 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); | 213 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); |
| 218 | ssize_t retval; | 214 | ssize_t retval; |
| 219 | 215 | ||
diff --git a/drivers/hid/hid-roccat-kovaplus.c b/drivers/hid/hid-roccat-kovaplus.c index 966047711fbf..43617fb28b87 100644 --- a/drivers/hid/hid-roccat-kovaplus.c +++ b/drivers/hid/hid-roccat-kovaplus.c | |||
| @@ -128,8 +128,7 @@ static ssize_t kovaplus_sysfs_read(struct file *fp, struct kobject *kobj, | |||
| 128 | char *buf, loff_t off, size_t count, | 128 | char *buf, loff_t off, size_t count, |
| 129 | size_t real_size, uint command) | 129 | size_t real_size, uint command) |
| 130 | { | 130 | { |
| 131 | struct device *dev = | 131 | struct device *dev = kobj_to_dev(kobj)->parent->parent; |
| 132 | container_of(kobj, struct device, kobj)->parent->parent; | ||
| 133 | struct kovaplus_device *kovaplus = hid_get_drvdata(dev_get_drvdata(dev)); | 132 | struct kovaplus_device *kovaplus = hid_get_drvdata(dev_get_drvdata(dev)); |
| 134 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); | 133 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); |
| 135 | int retval; | 134 | int retval; |
| @@ -154,8 +153,7 @@ static ssize_t kovaplus_sysfs_write(struct file *fp, struct kobject *kobj, | |||
| 154 | void const *buf, loff_t off, size_t count, | 153 | void const *buf, loff_t off, size_t count, |
| 155 | size_t real_size, uint command) | 154 | size_t real_size, uint command) |
| 156 | { | 155 | { |
| 157 | struct device *dev = | 156 | struct device *dev = kobj_to_dev(kobj)->parent->parent; |
| 158 | container_of(kobj, struct device, kobj)->parent->parent; | ||
| 159 | struct kovaplus_device *kovaplus = hid_get_drvdata(dev_get_drvdata(dev)); | 157 | struct kovaplus_device *kovaplus = hid_get_drvdata(dev_get_drvdata(dev)); |
| 160 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); | 158 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); |
| 161 | int retval; | 159 | int retval; |
| @@ -221,8 +219,7 @@ static ssize_t kovaplus_sysfs_read_profilex_settings(struct file *fp, | |||
| 221 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | 219 | struct kobject *kobj, struct bin_attribute *attr, char *buf, |
| 222 | loff_t off, size_t count) | 220 | loff_t off, size_t count) |
| 223 | { | 221 | { |
| 224 | struct device *dev = | 222 | struct device *dev = kobj_to_dev(kobj)->parent->parent; |
| 225 | container_of(kobj, struct device, kobj)->parent->parent; | ||
| 226 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); | 223 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); |
| 227 | ssize_t retval; | 224 | ssize_t retval; |
| 228 | 225 | ||
| @@ -240,8 +237,7 @@ static ssize_t kovaplus_sysfs_read_profilex_buttons(struct file *fp, | |||
| 240 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | 237 | struct kobject *kobj, struct bin_attribute *attr, char *buf, |
| 241 | loff_t off, size_t count) | 238 | loff_t off, size_t count) |
| 242 | { | 239 | { |
| 243 | struct device *dev = | 240 | struct device *dev = kobj_to_dev(kobj)->parent->parent; |
| 244 | container_of(kobj, struct device, kobj)->parent->parent; | ||
| 245 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); | 241 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); |
| 246 | ssize_t retval; | 242 | ssize_t retval; |
| 247 | 243 | ||
diff --git a/drivers/hid/hid-roccat-lua.c b/drivers/hid/hid-roccat-lua.c index 65e2e76bf2fe..ac1a7313e259 100644 --- a/drivers/hid/hid-roccat-lua.c +++ b/drivers/hid/hid-roccat-lua.c | |||
| @@ -30,7 +30,7 @@ static ssize_t lua_sysfs_read(struct file *fp, struct kobject *kobj, | |||
| 30 | char *buf, loff_t off, size_t count, | 30 | char *buf, loff_t off, size_t count, |
| 31 | size_t real_size, uint command) | 31 | size_t real_size, uint command) |
| 32 | { | 32 | { |
| 33 | struct device *dev = container_of(kobj, struct device, kobj); | 33 | struct device *dev = kobj_to_dev(kobj); |
| 34 | struct lua_device *lua = hid_get_drvdata(dev_get_drvdata(dev)); | 34 | struct lua_device *lua = hid_get_drvdata(dev_get_drvdata(dev)); |
| 35 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); | 35 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); |
| 36 | int retval; | 36 | int retval; |
| @@ -52,7 +52,7 @@ static ssize_t lua_sysfs_write(struct file *fp, struct kobject *kobj, | |||
| 52 | void const *buf, loff_t off, size_t count, | 52 | void const *buf, loff_t off, size_t count, |
| 53 | size_t real_size, uint command) | 53 | size_t real_size, uint command) |
| 54 | { | 54 | { |
| 55 | struct device *dev = container_of(kobj, struct device, kobj); | 55 | struct device *dev = kobj_to_dev(kobj); |
| 56 | struct lua_device *lua = hid_get_drvdata(dev_get_drvdata(dev)); | 56 | struct lua_device *lua = hid_get_drvdata(dev_get_drvdata(dev)); |
| 57 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); | 57 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); |
| 58 | int retval; | 58 | int retval; |
diff --git a/drivers/hid/hid-roccat-pyra.c b/drivers/hid/hid-roccat-pyra.c index 47d7e74231e5..b30aa7b82bf8 100644 --- a/drivers/hid/hid-roccat-pyra.c +++ b/drivers/hid/hid-roccat-pyra.c | |||
| @@ -90,8 +90,7 @@ static ssize_t pyra_sysfs_read(struct file *fp, struct kobject *kobj, | |||
| 90 | char *buf, loff_t off, size_t count, | 90 | char *buf, loff_t off, size_t count, |
| 91 | size_t real_size, uint command) | 91 | size_t real_size, uint command) |
| 92 | { | 92 | { |
| 93 | struct device *dev = | 93 | struct device *dev = kobj_to_dev(kobj)->parent->parent; |
| 94 | container_of(kobj, struct device, kobj)->parent->parent; | ||
| 95 | struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); | 94 | struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); |
| 96 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); | 95 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); |
| 97 | int retval; | 96 | int retval; |
| @@ -116,8 +115,7 @@ static ssize_t pyra_sysfs_write(struct file *fp, struct kobject *kobj, | |||
| 116 | void const *buf, loff_t off, size_t count, | 115 | void const *buf, loff_t off, size_t count, |
| 117 | size_t real_size, uint command) | 116 | size_t real_size, uint command) |
| 118 | { | 117 | { |
| 119 | struct device *dev = | 118 | struct device *dev = kobj_to_dev(kobj)->parent->parent; |
| 120 | container_of(kobj, struct device, kobj)->parent->parent; | ||
| 121 | struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); | 119 | struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); |
| 122 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); | 120 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); |
| 123 | int retval; | 121 | int retval; |
| @@ -191,8 +189,7 @@ static ssize_t pyra_sysfs_read_profilex_settings(struct file *fp, | |||
| 191 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | 189 | struct kobject *kobj, struct bin_attribute *attr, char *buf, |
| 192 | loff_t off, size_t count) | 190 | loff_t off, size_t count) |
| 193 | { | 191 | { |
| 194 | struct device *dev = | 192 | struct device *dev = kobj_to_dev(kobj)->parent->parent; |
| 195 | container_of(kobj, struct device, kobj)->parent->parent; | ||
| 196 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); | 193 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); |
| 197 | ssize_t retval; | 194 | ssize_t retval; |
| 198 | 195 | ||
| @@ -210,8 +207,7 @@ static ssize_t pyra_sysfs_read_profilex_buttons(struct file *fp, | |||
| 210 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | 207 | struct kobject *kobj, struct bin_attribute *attr, char *buf, |
| 211 | loff_t off, size_t count) | 208 | loff_t off, size_t count) |
| 212 | { | 209 | { |
| 213 | struct device *dev = | 210 | struct device *dev = kobj_to_dev(kobj)->parent->parent; |
| 214 | container_of(kobj, struct device, kobj)->parent->parent; | ||
| 215 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); | 211 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); |
| 216 | ssize_t retval; | 212 | ssize_t retval; |
| 217 | 213 | ||
| @@ -248,8 +244,7 @@ static ssize_t pyra_sysfs_write_settings(struct file *fp, | |||
| 248 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | 244 | struct kobject *kobj, struct bin_attribute *attr, char *buf, |
| 249 | loff_t off, size_t count) | 245 | loff_t off, size_t count) |
| 250 | { | 246 | { |
| 251 | struct device *dev = | 247 | struct device *dev = kobj_to_dev(kobj)->parent->parent; |
| 252 | container_of(kobj, struct device, kobj)->parent->parent; | ||
| 253 | struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); | 248 | struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); |
| 254 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); | 249 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); |
| 255 | int retval = 0; | 250 | int retval = 0; |
diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c index 92870cdb52d9..58ed8f25ab21 100644 --- a/drivers/hid/hid-sensor-hub.c +++ b/drivers/hid/hid-sensor-hub.c | |||
| @@ -794,6 +794,9 @@ static const struct hid_device_id sensor_hub_devices[] = { | |||
| 794 | { HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, USB_VENDOR_ID_ITE, | 794 | { HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, USB_VENDOR_ID_ITE, |
| 795 | USB_DEVICE_ID_ITE_LENOVO_YOGA2), | 795 | USB_DEVICE_ID_ITE_LENOVO_YOGA2), |
| 796 | .driver_data = HID_SENSOR_HUB_ENUM_QUIRK}, | 796 | .driver_data = HID_SENSOR_HUB_ENUM_QUIRK}, |
| 797 | { HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, USB_VENDOR_ID_ITE, | ||
| 798 | USB_DEVICE_ID_ITE_LENOVO_YOGA900), | ||
| 799 | .driver_data = HID_SENSOR_HUB_ENUM_QUIRK}, | ||
| 797 | { HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, HID_ANY_ID, | 800 | { HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, HID_ANY_ID, |
| 798 | HID_ANY_ID) }, | 801 | HID_ANY_ID) }, |
| 799 | { } | 802 | { } |
diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c index 774cd2210566..9b8db0e0ef1c 100644 --- a/drivers/hid/hid-sony.c +++ b/drivers/hid/hid-sony.c | |||
| @@ -1028,6 +1028,7 @@ struct sony_sc { | |||
| 1028 | struct led_classdev *leds[MAX_LEDS]; | 1028 | struct led_classdev *leds[MAX_LEDS]; |
| 1029 | unsigned long quirks; | 1029 | unsigned long quirks; |
| 1030 | struct work_struct state_worker; | 1030 | struct work_struct state_worker; |
| 1031 | void(*send_output_report)(struct sony_sc*); | ||
| 1031 | struct power_supply *battery; | 1032 | struct power_supply *battery; |
| 1032 | struct power_supply_desc battery_desc; | 1033 | struct power_supply_desc battery_desc; |
| 1033 | int device_id; | 1034 | int device_id; |
| @@ -1044,6 +1045,7 @@ struct sony_sc { | |||
| 1044 | __u8 battery_charging; | 1045 | __u8 battery_charging; |
| 1045 | __u8 battery_capacity; | 1046 | __u8 battery_capacity; |
| 1046 | __u8 led_state[MAX_LEDS]; | 1047 | __u8 led_state[MAX_LEDS]; |
| 1048 | __u8 resume_led_state[MAX_LEDS]; | ||
| 1047 | __u8 led_delay_on[MAX_LEDS]; | 1049 | __u8 led_delay_on[MAX_LEDS]; |
| 1048 | __u8 led_delay_off[MAX_LEDS]; | 1050 | __u8 led_delay_off[MAX_LEDS]; |
| 1049 | __u8 led_count; | 1051 | __u8 led_count; |
| @@ -1137,11 +1139,11 @@ static __u8 *sony_report_fixup(struct hid_device *hdev, __u8 *rdesc, | |||
| 1137 | * the gyroscope values to corresponding axes so we need a | 1139 | * the gyroscope values to corresponding axes so we need a |
| 1138 | * modified one. | 1140 | * modified one. |
| 1139 | */ | 1141 | */ |
| 1140 | if ((sc->quirks & DUALSHOCK4_CONTROLLER_USB) && *rsize == 467) { | 1142 | if (sc->quirks & DUALSHOCK4_CONTROLLER_USB) { |
| 1141 | hid_info(hdev, "Using modified Dualshock 4 report descriptor with gyroscope axes\n"); | 1143 | hid_info(hdev, "Using modified Dualshock 4 report descriptor with gyroscope axes\n"); |
| 1142 | rdesc = dualshock4_usb_rdesc; | 1144 | rdesc = dualshock4_usb_rdesc; |
| 1143 | *rsize = sizeof(dualshock4_usb_rdesc); | 1145 | *rsize = sizeof(dualshock4_usb_rdesc); |
| 1144 | } else if ((sc->quirks & DUALSHOCK4_CONTROLLER_BT) && *rsize == 357) { | 1146 | } else if (sc->quirks & DUALSHOCK4_CONTROLLER_BT) { |
| 1145 | hid_info(hdev, "Using modified Dualshock 4 Bluetooth report descriptor\n"); | 1147 | hid_info(hdev, "Using modified Dualshock 4 Bluetooth report descriptor\n"); |
| 1146 | rdesc = dualshock4_bt_rdesc; | 1148 | rdesc = dualshock4_bt_rdesc; |
| 1147 | *rsize = sizeof(dualshock4_bt_rdesc); | 1149 | *rsize = sizeof(dualshock4_bt_rdesc); |
| @@ -1549,7 +1551,7 @@ static void sony_led_set_brightness(struct led_classdev *led, | |||
| 1549 | enum led_brightness value) | 1551 | enum led_brightness value) |
| 1550 | { | 1552 | { |
| 1551 | struct device *dev = led->dev->parent; | 1553 | struct device *dev = led->dev->parent; |
| 1552 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 1554 | struct hid_device *hdev = to_hid_device(dev); |
| 1553 | struct sony_sc *drv_data; | 1555 | struct sony_sc *drv_data; |
| 1554 | 1556 | ||
| 1555 | int n; | 1557 | int n; |
| @@ -1591,7 +1593,7 @@ static void sony_led_set_brightness(struct led_classdev *led, | |||
| 1591 | static enum led_brightness sony_led_get_brightness(struct led_classdev *led) | 1593 | static enum led_brightness sony_led_get_brightness(struct led_classdev *led) |
| 1592 | { | 1594 | { |
| 1593 | struct device *dev = led->dev->parent; | 1595 | struct device *dev = led->dev->parent; |
| 1594 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 1596 | struct hid_device *hdev = to_hid_device(dev); |
| 1595 | struct sony_sc *drv_data; | 1597 | struct sony_sc *drv_data; |
| 1596 | 1598 | ||
| 1597 | int n; | 1599 | int n; |
| @@ -1614,7 +1616,7 @@ static int sony_led_blink_set(struct led_classdev *led, unsigned long *delay_on, | |||
| 1614 | unsigned long *delay_off) | 1616 | unsigned long *delay_off) |
| 1615 | { | 1617 | { |
| 1616 | struct device *dev = led->dev->parent; | 1618 | struct device *dev = led->dev->parent; |
| 1617 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 1619 | struct hid_device *hdev = to_hid_device(dev); |
| 1618 | struct sony_sc *drv_data = hid_get_drvdata(hdev); | 1620 | struct sony_sc *drv_data = hid_get_drvdata(hdev); |
| 1619 | int n; | 1621 | int n; |
| 1620 | __u8 new_on, new_off; | 1622 | __u8 new_on, new_off; |
| @@ -1789,7 +1791,7 @@ error_leds: | |||
| 1789 | return ret; | 1791 | return ret; |
| 1790 | } | 1792 | } |
| 1791 | 1793 | ||
| 1792 | static void sixaxis_state_worker(struct work_struct *work) | 1794 | static void sixaxis_send_output_report(struct sony_sc *sc) |
| 1793 | { | 1795 | { |
| 1794 | static const union sixaxis_output_report_01 default_report = { | 1796 | static const union sixaxis_output_report_01 default_report = { |
| 1795 | .buf = { | 1797 | .buf = { |
| @@ -1803,7 +1805,6 @@ static void sixaxis_state_worker(struct work_struct *work) | |||
| 1803 | 0x00, 0x00, 0x00, 0x00, 0x00 | 1805 | 0x00, 0x00, 0x00, 0x00, 0x00 |
| 1804 | } | 1806 | } |
| 1805 | }; | 1807 | }; |
| 1806 | struct sony_sc *sc = container_of(work, struct sony_sc, state_worker); | ||
| 1807 | struct sixaxis_output_report *report = | 1808 | struct sixaxis_output_report *report = |
| 1808 | (struct sixaxis_output_report *)sc->output_report_dmabuf; | 1809 | (struct sixaxis_output_report *)sc->output_report_dmabuf; |
| 1809 | int n; | 1810 | int n; |
| @@ -1846,9 +1847,8 @@ static void sixaxis_state_worker(struct work_struct *work) | |||
| 1846 | HID_OUTPUT_REPORT, HID_REQ_SET_REPORT); | 1847 | HID_OUTPUT_REPORT, HID_REQ_SET_REPORT); |
| 1847 | } | 1848 | } |
| 1848 | 1849 | ||
| 1849 | static void dualshock4_state_worker(struct work_struct *work) | 1850 | static void dualshock4_send_output_report(struct sony_sc *sc) |
| 1850 | { | 1851 | { |
| 1851 | struct sony_sc *sc = container_of(work, struct sony_sc, state_worker); | ||
| 1852 | struct hid_device *hdev = sc->hdev; | 1852 | struct hid_device *hdev = sc->hdev; |
| 1853 | __u8 *buf = sc->output_report_dmabuf; | 1853 | __u8 *buf = sc->output_report_dmabuf; |
| 1854 | int offset; | 1854 | int offset; |
| @@ -1893,9 +1893,8 @@ static void dualshock4_state_worker(struct work_struct *work) | |||
| 1893 | HID_OUTPUT_REPORT, HID_REQ_SET_REPORT); | 1893 | HID_OUTPUT_REPORT, HID_REQ_SET_REPORT); |
| 1894 | } | 1894 | } |
| 1895 | 1895 | ||
| 1896 | static void motion_state_worker(struct work_struct *work) | 1896 | static void motion_send_output_report(struct sony_sc *sc) |
| 1897 | { | 1897 | { |
| 1898 | struct sony_sc *sc = container_of(work, struct sony_sc, state_worker); | ||
| 1899 | struct hid_device *hdev = sc->hdev; | 1898 | struct hid_device *hdev = sc->hdev; |
| 1900 | struct motion_output_report_02 *report = | 1899 | struct motion_output_report_02 *report = |
| 1901 | (struct motion_output_report_02 *)sc->output_report_dmabuf; | 1900 | (struct motion_output_report_02 *)sc->output_report_dmabuf; |
| @@ -1914,6 +1913,18 @@ static void motion_state_worker(struct work_struct *work) | |||
| 1914 | hid_hw_output_report(hdev, (__u8 *)report, MOTION_REPORT_0x02_SIZE); | 1913 | hid_hw_output_report(hdev, (__u8 *)report, MOTION_REPORT_0x02_SIZE); |
| 1915 | } | 1914 | } |
| 1916 | 1915 | ||
| 1916 | static inline void sony_send_output_report(struct sony_sc *sc) | ||
| 1917 | { | ||
| 1918 | if (sc->send_output_report) | ||
| 1919 | sc->send_output_report(sc); | ||
| 1920 | } | ||
| 1921 | |||
| 1922 | static void sony_state_worker(struct work_struct *work) | ||
| 1923 | { | ||
| 1924 | struct sony_sc *sc = container_of(work, struct sony_sc, state_worker); | ||
| 1925 | sc->send_output_report(sc); | ||
| 1926 | } | ||
| 1927 | |||
| 1917 | static int sony_allocate_output_report(struct sony_sc *sc) | 1928 | static int sony_allocate_output_report(struct sony_sc *sc) |
| 1918 | { | 1929 | { |
| 1919 | if ((sc->quirks & SIXAXIS_CONTROLLER) || | 1930 | if ((sc->quirks & SIXAXIS_CONTROLLER) || |
| @@ -2241,11 +2252,13 @@ static void sony_release_device_id(struct sony_sc *sc) | |||
| 2241 | } | 2252 | } |
| 2242 | } | 2253 | } |
| 2243 | 2254 | ||
| 2244 | static inline void sony_init_work(struct sony_sc *sc, | 2255 | static inline void sony_init_output_report(struct sony_sc *sc, |
| 2245 | void (*worker)(struct work_struct *)) | 2256 | void(*send_output_report)(struct sony_sc*)) |
| 2246 | { | 2257 | { |
| 2258 | sc->send_output_report = send_output_report; | ||
| 2259 | |||
| 2247 | if (!sc->worker_initialized) | 2260 | if (!sc->worker_initialized) |
| 2248 | INIT_WORK(&sc->state_worker, worker); | 2261 | INIT_WORK(&sc->state_worker, sony_state_worker); |
| 2249 | 2262 | ||
| 2250 | sc->worker_initialized = 1; | 2263 | sc->worker_initialized = 1; |
| 2251 | } | 2264 | } |
| @@ -2319,7 +2332,7 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
| 2319 | hdev->quirks |= HID_QUIRK_NO_OUTPUT_REPORTS_ON_INTR_EP; | 2332 | hdev->quirks |= HID_QUIRK_NO_OUTPUT_REPORTS_ON_INTR_EP; |
| 2320 | hdev->quirks |= HID_QUIRK_SKIP_OUTPUT_REPORT_ID; | 2333 | hdev->quirks |= HID_QUIRK_SKIP_OUTPUT_REPORT_ID; |
| 2321 | ret = sixaxis_set_operational_usb(hdev); | 2334 | ret = sixaxis_set_operational_usb(hdev); |
| 2322 | sony_init_work(sc, sixaxis_state_worker); | 2335 | sony_init_output_report(sc, sixaxis_send_output_report); |
| 2323 | } else if ((sc->quirks & SIXAXIS_CONTROLLER_BT) || | 2336 | } else if ((sc->quirks & SIXAXIS_CONTROLLER_BT) || |
| 2324 | (sc->quirks & NAVIGATION_CONTROLLER_BT)) { | 2337 | (sc->quirks & NAVIGATION_CONTROLLER_BT)) { |
| 2325 | /* | 2338 | /* |
| @@ -2328,7 +2341,7 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
| 2328 | */ | 2341 | */ |
| 2329 | hdev->quirks |= HID_QUIRK_NO_OUTPUT_REPORTS_ON_INTR_EP; | 2342 | hdev->quirks |= HID_QUIRK_NO_OUTPUT_REPORTS_ON_INTR_EP; |
| 2330 | ret = sixaxis_set_operational_bt(hdev); | 2343 | ret = sixaxis_set_operational_bt(hdev); |
| 2331 | sony_init_work(sc, sixaxis_state_worker); | 2344 | sony_init_output_report(sc, sixaxis_send_output_report); |
| 2332 | } else if (sc->quirks & DUALSHOCK4_CONTROLLER) { | 2345 | } else if (sc->quirks & DUALSHOCK4_CONTROLLER) { |
| 2333 | if (sc->quirks & DUALSHOCK4_CONTROLLER_BT) { | 2346 | if (sc->quirks & DUALSHOCK4_CONTROLLER_BT) { |
| 2334 | /* | 2347 | /* |
| @@ -2343,9 +2356,9 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
| 2343 | } | 2356 | } |
| 2344 | } | 2357 | } |
| 2345 | 2358 | ||
| 2346 | sony_init_work(sc, dualshock4_state_worker); | 2359 | sony_init_output_report(sc, dualshock4_send_output_report); |
| 2347 | } else if (sc->quirks & MOTION_CONTROLLER) { | 2360 | } else if (sc->quirks & MOTION_CONTROLLER) { |
| 2348 | sony_init_work(sc, motion_state_worker); | 2361 | sony_init_output_report(sc, motion_send_output_report); |
| 2349 | } else { | 2362 | } else { |
| 2350 | ret = 0; | 2363 | ret = 0; |
| 2351 | } | 2364 | } |
| @@ -2421,6 +2434,56 @@ static void sony_remove(struct hid_device *hdev) | |||
| 2421 | hid_hw_stop(hdev); | 2434 | hid_hw_stop(hdev); |
| 2422 | } | 2435 | } |
| 2423 | 2436 | ||
| 2437 | #ifdef CONFIG_PM | ||
| 2438 | |||
| 2439 | static int sony_suspend(struct hid_device *hdev, pm_message_t message) | ||
| 2440 | { | ||
| 2441 | /* | ||
| 2442 | * On suspend save the current LED state, | ||
| 2443 | * stop running force-feedback and blank the LEDS. | ||
| 2444 | */ | ||
| 2445 | if (SONY_LED_SUPPORT || SONY_FF_SUPPORT) { | ||
| 2446 | struct sony_sc *sc = hid_get_drvdata(hdev); | ||
| 2447 | |||
| 2448 | #ifdef CONFIG_SONY_FF | ||
| 2449 | sc->left = sc->right = 0; | ||
| 2450 | #endif | ||
| 2451 | |||
| 2452 | memcpy(sc->resume_led_state, sc->led_state, | ||
| 2453 | sizeof(sc->resume_led_state)); | ||
| 2454 | memset(sc->led_state, 0, sizeof(sc->led_state)); | ||
| 2455 | |||
| 2456 | sony_send_output_report(sc); | ||
| 2457 | } | ||
| 2458 | |||
| 2459 | return 0; | ||
| 2460 | } | ||
| 2461 | |||
| 2462 | static int sony_resume(struct hid_device *hdev) | ||
| 2463 | { | ||
| 2464 | /* Restore the state of controller LEDs on resume */ | ||
| 2465 | if (SONY_LED_SUPPORT) { | ||
| 2466 | struct sony_sc *sc = hid_get_drvdata(hdev); | ||
| 2467 | |||
| 2468 | memcpy(sc->led_state, sc->resume_led_state, | ||
| 2469 | sizeof(sc->led_state)); | ||
| 2470 | |||
| 2471 | /* | ||
| 2472 | * The Sixaxis and navigation controllers on USB need to be | ||
| 2473 | * reinitialized on resume or they won't behave properly. | ||
| 2474 | */ | ||
| 2475 | if ((sc->quirks & SIXAXIS_CONTROLLER_USB) || | ||
| 2476 | (sc->quirks & NAVIGATION_CONTROLLER_USB)) | ||
| 2477 | sixaxis_set_operational_usb(sc->hdev); | ||
| 2478 | |||
| 2479 | sony_set_leds(sc); | ||
| 2480 | } | ||
| 2481 | |||
| 2482 | return 0; | ||
| 2483 | } | ||
| 2484 | |||
| 2485 | #endif | ||
| 2486 | |||
| 2424 | static const struct hid_device_id sony_devices[] = { | 2487 | static const struct hid_device_id sony_devices[] = { |
| 2425 | { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER), | 2488 | { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER), |
| 2426 | .driver_data = SIXAXIS_CONTROLLER_USB }, | 2489 | .driver_data = SIXAXIS_CONTROLLER_USB }, |
| @@ -2470,7 +2533,13 @@ static struct hid_driver sony_driver = { | |||
| 2470 | .probe = sony_probe, | 2533 | .probe = sony_probe, |
| 2471 | .remove = sony_remove, | 2534 | .remove = sony_remove, |
| 2472 | .report_fixup = sony_report_fixup, | 2535 | .report_fixup = sony_report_fixup, |
| 2473 | .raw_event = sony_raw_event | 2536 | .raw_event = sony_raw_event, |
| 2537 | |||
| 2538 | #ifdef CONFIG_PM | ||
| 2539 | .suspend = sony_suspend, | ||
| 2540 | .resume = sony_resume, | ||
| 2541 | .reset_resume = sony_resume, | ||
| 2542 | #endif | ||
| 2474 | }; | 2543 | }; |
| 2475 | 2544 | ||
| 2476 | static int __init sony_init(void) | 2545 | static int __init sony_init(void) |
diff --git a/drivers/hid/hid-steelseries.c b/drivers/hid/hid-steelseries.c index 3edd4ac36494..ec18768b124a 100644 --- a/drivers/hid/hid-steelseries.c +++ b/drivers/hid/hid-steelseries.c | |||
| @@ -141,7 +141,7 @@ static void steelseries_srws1_led_all_set_brightness(struct led_classdev *led_cd | |||
| 141 | enum led_brightness value) | 141 | enum led_brightness value) |
| 142 | { | 142 | { |
| 143 | struct device *dev = led_cdev->dev->parent; | 143 | struct device *dev = led_cdev->dev->parent; |
| 144 | struct hid_device *hid = container_of(dev, struct hid_device, dev); | 144 | struct hid_device *hid = to_hid_device(dev); |
| 145 | struct steelseries_srws1_data *drv_data = hid_get_drvdata(hid); | 145 | struct steelseries_srws1_data *drv_data = hid_get_drvdata(hid); |
| 146 | 146 | ||
| 147 | if (!drv_data) { | 147 | if (!drv_data) { |
| @@ -160,7 +160,7 @@ static void steelseries_srws1_led_all_set_brightness(struct led_classdev *led_cd | |||
| 160 | static enum led_brightness steelseries_srws1_led_all_get_brightness(struct led_classdev *led_cdev) | 160 | static enum led_brightness steelseries_srws1_led_all_get_brightness(struct led_classdev *led_cdev) |
| 161 | { | 161 | { |
| 162 | struct device *dev = led_cdev->dev->parent; | 162 | struct device *dev = led_cdev->dev->parent; |
| 163 | struct hid_device *hid = container_of(dev, struct hid_device, dev); | 163 | struct hid_device *hid = to_hid_device(dev); |
| 164 | struct steelseries_srws1_data *drv_data; | 164 | struct steelseries_srws1_data *drv_data; |
| 165 | 165 | ||
| 166 | drv_data = hid_get_drvdata(hid); | 166 | drv_data = hid_get_drvdata(hid); |
| @@ -177,7 +177,7 @@ static void steelseries_srws1_led_set_brightness(struct led_classdev *led_cdev, | |||
| 177 | enum led_brightness value) | 177 | enum led_brightness value) |
| 178 | { | 178 | { |
| 179 | struct device *dev = led_cdev->dev->parent; | 179 | struct device *dev = led_cdev->dev->parent; |
| 180 | struct hid_device *hid = container_of(dev, struct hid_device, dev); | 180 | struct hid_device *hid = to_hid_device(dev); |
| 181 | struct steelseries_srws1_data *drv_data = hid_get_drvdata(hid); | 181 | struct steelseries_srws1_data *drv_data = hid_get_drvdata(hid); |
| 182 | int i, state = 0; | 182 | int i, state = 0; |
| 183 | 183 | ||
| @@ -205,7 +205,7 @@ static void steelseries_srws1_led_set_brightness(struct led_classdev *led_cdev, | |||
| 205 | static enum led_brightness steelseries_srws1_led_get_brightness(struct led_classdev *led_cdev) | 205 | static enum led_brightness steelseries_srws1_led_get_brightness(struct led_classdev *led_cdev) |
| 206 | { | 206 | { |
| 207 | struct device *dev = led_cdev->dev->parent; | 207 | struct device *dev = led_cdev->dev->parent; |
| 208 | struct hid_device *hid = container_of(dev, struct hid_device, dev); | 208 | struct hid_device *hid = to_hid_device(dev); |
| 209 | struct steelseries_srws1_data *drv_data; | 209 | struct steelseries_srws1_data *drv_data; |
| 210 | int i, value = 0; | 210 | int i, value = 0; |
| 211 | 211 | ||
diff --git a/drivers/hid/hid-wiimote-modules.c b/drivers/hid/hid-wiimote-modules.c index 05e23c417d50..4390eee2ce84 100644 --- a/drivers/hid/hid-wiimote-modules.c +++ b/drivers/hid/hid-wiimote-modules.c | |||
| @@ -296,14 +296,12 @@ static const struct wiimod_ops wiimod_battery = { | |||
| 296 | 296 | ||
| 297 | static enum led_brightness wiimod_led_get(struct led_classdev *led_dev) | 297 | static enum led_brightness wiimod_led_get(struct led_classdev *led_dev) |
| 298 | { | 298 | { |
| 299 | struct wiimote_data *wdata; | ||
| 300 | struct device *dev = led_dev->dev->parent; | 299 | struct device *dev = led_dev->dev->parent; |
| 300 | struct wiimote_data *wdata = dev_to_wii(dev); | ||
| 301 | int i; | 301 | int i; |
| 302 | unsigned long flags; | 302 | unsigned long flags; |
| 303 | bool value = false; | 303 | bool value = false; |
| 304 | 304 | ||
| 305 | wdata = hid_get_drvdata(container_of(dev, struct hid_device, dev)); | ||
| 306 | |||
| 307 | for (i = 0; i < 4; ++i) { | 305 | for (i = 0; i < 4; ++i) { |
| 308 | if (wdata->leds[i] == led_dev) { | 306 | if (wdata->leds[i] == led_dev) { |
| 309 | spin_lock_irqsave(&wdata->state.lock, flags); | 307 | spin_lock_irqsave(&wdata->state.lock, flags); |
| @@ -319,14 +317,12 @@ static enum led_brightness wiimod_led_get(struct led_classdev *led_dev) | |||
| 319 | static void wiimod_led_set(struct led_classdev *led_dev, | 317 | static void wiimod_led_set(struct led_classdev *led_dev, |
| 320 | enum led_brightness value) | 318 | enum led_brightness value) |
| 321 | { | 319 | { |
| 322 | struct wiimote_data *wdata; | ||
| 323 | struct device *dev = led_dev->dev->parent; | 320 | struct device *dev = led_dev->dev->parent; |
| 321 | struct wiimote_data *wdata = dev_to_wii(dev); | ||
| 324 | int i; | 322 | int i; |
| 325 | unsigned long flags; | 323 | unsigned long flags; |
| 326 | __u8 state, flag; | 324 | __u8 state, flag; |
| 327 | 325 | ||
| 328 | wdata = hid_get_drvdata(container_of(dev, struct hid_device, dev)); | ||
| 329 | |||
| 330 | for (i = 0; i < 4; ++i) { | 326 | for (i = 0; i < 4; ++i) { |
| 331 | if (wdata->leds[i] == led_dev) { | 327 | if (wdata->leds[i] == led_dev) { |
| 332 | flag = WIIPROTO_FLAG_LED(i + 1); | 328 | flag = WIIPROTO_FLAG_LED(i + 1); |
diff --git a/drivers/hid/hid-wiimote.h b/drivers/hid/hid-wiimote.h index 875694d43e4d..510ca77fe14e 100644 --- a/drivers/hid/hid-wiimote.h +++ b/drivers/hid/hid-wiimote.h | |||
| @@ -256,8 +256,7 @@ enum wiiproto_reqs { | |||
| 256 | WIIPROTO_REQ_MAX | 256 | WIIPROTO_REQ_MAX |
| 257 | }; | 257 | }; |
| 258 | 258 | ||
| 259 | #define dev_to_wii(pdev) hid_get_drvdata(container_of(pdev, struct hid_device, \ | 259 | #define dev_to_wii(pdev) hid_get_drvdata(to_hid_device(pdev)) |
| 260 | dev)) | ||
| 261 | 260 | ||
| 262 | void __wiimote_schedule(struct wiimote_data *wdata); | 261 | void __wiimote_schedule(struct wiimote_data *wdata); |
| 263 | 262 | ||
diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c index 10bd8e6e4c9c..b9216938a718 100644 --- a/drivers/hid/i2c-hid/i2c-hid.c +++ b/drivers/hid/i2c-hid/i2c-hid.c | |||
| @@ -151,6 +151,7 @@ struct i2c_hid { | |||
| 151 | struct i2c_hid_platform_data pdata; | 151 | struct i2c_hid_platform_data pdata; |
| 152 | 152 | ||
| 153 | bool irq_wake_enabled; | 153 | bool irq_wake_enabled; |
| 154 | struct mutex reset_lock; | ||
| 154 | }; | 155 | }; |
| 155 | 156 | ||
| 156 | static int __i2c_hid_command(struct i2c_client *client, | 157 | static int __i2c_hid_command(struct i2c_client *client, |
| @@ -356,9 +357,16 @@ static int i2c_hid_hwreset(struct i2c_client *client) | |||
| 356 | 357 | ||
| 357 | i2c_hid_dbg(ihid, "%s\n", __func__); | 358 | i2c_hid_dbg(ihid, "%s\n", __func__); |
| 358 | 359 | ||
| 360 | /* | ||
| 361 | * This prevents sending feature reports while the device is | ||
| 362 | * being reset. Otherwise we may lose the reset complete | ||
| 363 | * interrupt. | ||
| 364 | */ | ||
| 365 | mutex_lock(&ihid->reset_lock); | ||
| 366 | |||
| 359 | ret = i2c_hid_set_power(client, I2C_HID_PWR_ON); | 367 | ret = i2c_hid_set_power(client, I2C_HID_PWR_ON); |
| 360 | if (ret) | 368 | if (ret) |
| 361 | return ret; | 369 | goto out_unlock; |
| 362 | 370 | ||
| 363 | i2c_hid_dbg(ihid, "resetting...\n"); | 371 | i2c_hid_dbg(ihid, "resetting...\n"); |
| 364 | 372 | ||
| @@ -366,10 +374,11 @@ static int i2c_hid_hwreset(struct i2c_client *client) | |||
| 366 | if (ret) { | 374 | if (ret) { |
| 367 | dev_err(&client->dev, "failed to reset device.\n"); | 375 | dev_err(&client->dev, "failed to reset device.\n"); |
| 368 | i2c_hid_set_power(client, I2C_HID_PWR_SLEEP); | 376 | i2c_hid_set_power(client, I2C_HID_PWR_SLEEP); |
| 369 | return ret; | ||
| 370 | } | 377 | } |
| 371 | 378 | ||
| 372 | return 0; | 379 | out_unlock: |
| 380 | mutex_unlock(&ihid->reset_lock); | ||
| 381 | return ret; | ||
| 373 | } | 382 | } |
| 374 | 383 | ||
| 375 | static void i2c_hid_get_input(struct i2c_hid *ihid) | 384 | static void i2c_hid_get_input(struct i2c_hid *ihid) |
| @@ -587,12 +596,15 @@ static int i2c_hid_output_raw_report(struct hid_device *hid, __u8 *buf, | |||
| 587 | size_t count, unsigned char report_type, bool use_data) | 596 | size_t count, unsigned char report_type, bool use_data) |
| 588 | { | 597 | { |
| 589 | struct i2c_client *client = hid->driver_data; | 598 | struct i2c_client *client = hid->driver_data; |
| 599 | struct i2c_hid *ihid = i2c_get_clientdata(client); | ||
| 590 | int report_id = buf[0]; | 600 | int report_id = buf[0]; |
| 591 | int ret; | 601 | int ret; |
| 592 | 602 | ||
| 593 | if (report_type == HID_INPUT_REPORT) | 603 | if (report_type == HID_INPUT_REPORT) |
| 594 | return -EINVAL; | 604 | return -EINVAL; |
| 595 | 605 | ||
| 606 | mutex_lock(&ihid->reset_lock); | ||
| 607 | |||
| 596 | if (report_id) { | 608 | if (report_id) { |
| 597 | buf++; | 609 | buf++; |
| 598 | count--; | 610 | count--; |
| @@ -605,6 +617,8 @@ static int i2c_hid_output_raw_report(struct hid_device *hid, __u8 *buf, | |||
| 605 | if (report_id && ret >= 0) | 617 | if (report_id && ret >= 0) |
| 606 | ret++; /* add report_id to the number of transfered bytes */ | 618 | ret++; /* add report_id to the number of transfered bytes */ |
| 607 | 619 | ||
| 620 | mutex_unlock(&ihid->reset_lock); | ||
| 621 | |||
| 608 | return ret; | 622 | return ret; |
| 609 | } | 623 | } |
| 610 | 624 | ||
| @@ -990,6 +1004,7 @@ static int i2c_hid_probe(struct i2c_client *client, | |||
| 990 | ihid->wHIDDescRegister = cpu_to_le16(hidRegister); | 1004 | ihid->wHIDDescRegister = cpu_to_le16(hidRegister); |
| 991 | 1005 | ||
| 992 | init_waitqueue_head(&ihid->wait); | 1006 | init_waitqueue_head(&ihid->wait); |
| 1007 | mutex_init(&ihid->reset_lock); | ||
| 993 | 1008 | ||
| 994 | /* we need to allocate the command buffer without knowing the maximum | 1009 | /* we need to allocate the command buffer without knowing the maximum |
| 995 | * size of the reports. Let's use HID_MIN_BUFFER_SIZE, then we do the | 1010 | * size of the reports. Let's use HID_MIN_BUFFER_SIZE, then we do the |
| @@ -1184,7 +1199,6 @@ MODULE_DEVICE_TABLE(i2c, i2c_hid_id_table); | |||
| 1184 | static struct i2c_driver i2c_hid_driver = { | 1199 | static struct i2c_driver i2c_hid_driver = { |
| 1185 | .driver = { | 1200 | .driver = { |
| 1186 | .name = "i2c_hid", | 1201 | .name = "i2c_hid", |
| 1187 | .owner = THIS_MODULE, | ||
| 1188 | .pm = &i2c_hid_pm, | 1202 | .pm = &i2c_hid_pm, |
| 1189 | .acpi_match_table = ACPI_PTR(i2c_hid_acpi_match), | 1203 | .acpi_match_table = ACPI_PTR(i2c_hid_acpi_match), |
| 1190 | .of_match_table = of_match_ptr(i2c_hid_of_match), | 1204 | .of_match_table = of_match_ptr(i2c_hid_of_match), |
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c index 36712e9f56c2..ad71160b9ea4 100644 --- a/drivers/hid/usbhid/hid-core.c +++ b/drivers/hid/usbhid/hid-core.c | |||
| @@ -274,10 +274,10 @@ static void hid_irq_in(struct urb *urb) | |||
| 274 | 274 | ||
| 275 | switch (urb->status) { | 275 | switch (urb->status) { |
| 276 | case 0: /* success */ | 276 | case 0: /* success */ |
| 277 | usbhid_mark_busy(usbhid); | ||
| 278 | usbhid->retry_delay = 0; | 277 | usbhid->retry_delay = 0; |
| 279 | if ((hid->quirks & HID_QUIRK_ALWAYS_POLL) && !hid->open) | 278 | if ((hid->quirks & HID_QUIRK_ALWAYS_POLL) && !hid->open) |
| 280 | break; | 279 | break; |
| 280 | usbhid_mark_busy(usbhid); | ||
| 281 | if (!test_bit(HID_RESUME_RUNNING, &usbhid->iofl)) { | 281 | if (!test_bit(HID_RESUME_RUNNING, &usbhid->iofl)) { |
| 282 | hid_input_report(urb->context, HID_INPUT_REPORT, | 282 | hid_input_report(urb->context, HID_INPUT_REPORT, |
| 283 | urb->transfer_buffer, | 283 | urb->transfer_buffer, |
| @@ -477,8 +477,6 @@ static void hid_ctrl(struct urb *urb) | |||
| 477 | struct usbhid_device *usbhid = hid->driver_data; | 477 | struct usbhid_device *usbhid = hid->driver_data; |
| 478 | int unplug = 0, status = urb->status; | 478 | int unplug = 0, status = urb->status; |
| 479 | 479 | ||
| 480 | spin_lock(&usbhid->lock); | ||
| 481 | |||
| 482 | switch (status) { | 480 | switch (status) { |
| 483 | case 0: /* success */ | 481 | case 0: /* success */ |
| 484 | if (usbhid->ctrl[usbhid->ctrltail].dir == USB_DIR_IN) | 482 | if (usbhid->ctrl[usbhid->ctrltail].dir == USB_DIR_IN) |
| @@ -498,6 +496,8 @@ static void hid_ctrl(struct urb *urb) | |||
| 498 | hid_warn(urb->dev, "ctrl urb status %d received\n", status); | 496 | hid_warn(urb->dev, "ctrl urb status %d received\n", status); |
| 499 | } | 497 | } |
| 500 | 498 | ||
| 499 | spin_lock(&usbhid->lock); | ||
| 500 | |||
| 501 | if (unplug) { | 501 | if (unplug) { |
| 502 | usbhid->ctrltail = usbhid->ctrlhead; | 502 | usbhid->ctrltail = usbhid->ctrlhead; |
| 503 | } else { | 503 | } else { |
diff --git a/drivers/hid/usbhid/usbhid.h b/drivers/hid/usbhid/usbhid.h index 807922b49aa4..fa47d666cfcf 100644 --- a/drivers/hid/usbhid/usbhid.h +++ b/drivers/hid/usbhid/usbhid.h | |||
| @@ -96,7 +96,7 @@ struct usbhid_device { | |||
| 96 | }; | 96 | }; |
| 97 | 97 | ||
| 98 | #define hid_to_usb_dev(hid_dev) \ | 98 | #define hid_to_usb_dev(hid_dev) \ |
| 99 | container_of(hid_dev->dev.parent->parent, struct usb_device, dev) | 99 | to_usb_device(hid_dev->dev.parent->parent) |
| 100 | 100 | ||
| 101 | #endif | 101 | #endif |
| 102 | 102 | ||
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c index e06af5b9f59e..5cb21dd91094 100644 --- a/drivers/hid/wacom_sys.c +++ b/drivers/hid/wacom_sys.c | |||
| @@ -686,7 +686,7 @@ out: | |||
| 686 | static ssize_t wacom_led_select_store(struct device *dev, int set_id, | 686 | static ssize_t wacom_led_select_store(struct device *dev, int set_id, |
| 687 | const char *buf, size_t count) | 687 | const char *buf, size_t count) |
| 688 | { | 688 | { |
| 689 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 689 | struct hid_device *hdev = to_hid_device(dev); |
| 690 | struct wacom *wacom = hid_get_drvdata(hdev); | 690 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 691 | unsigned int id; | 691 | unsigned int id; |
| 692 | int err; | 692 | int err; |
| @@ -714,7 +714,7 @@ static ssize_t wacom_led##SET_ID##_select_store(struct device *dev, \ | |||
| 714 | static ssize_t wacom_led##SET_ID##_select_show(struct device *dev, \ | 714 | static ssize_t wacom_led##SET_ID##_select_show(struct device *dev, \ |
| 715 | struct device_attribute *attr, char *buf) \ | 715 | struct device_attribute *attr, char *buf) \ |
| 716 | { \ | 716 | { \ |
| 717 | struct hid_device *hdev = container_of(dev, struct hid_device, dev);\ | 717 | struct hid_device *hdev = to_hid_device(dev);\ |
| 718 | struct wacom *wacom = hid_get_drvdata(hdev); \ | 718 | struct wacom *wacom = hid_get_drvdata(hdev); \ |
| 719 | return scnprintf(buf, PAGE_SIZE, "%d\n", \ | 719 | return scnprintf(buf, PAGE_SIZE, "%d\n", \ |
| 720 | wacom->led.select[SET_ID]); \ | 720 | wacom->led.select[SET_ID]); \ |
| @@ -750,7 +750,7 @@ static ssize_t wacom_luminance_store(struct wacom *wacom, u8 *dest, | |||
| 750 | static ssize_t wacom_##name##_luminance_store(struct device *dev, \ | 750 | static ssize_t wacom_##name##_luminance_store(struct device *dev, \ |
| 751 | struct device_attribute *attr, const char *buf, size_t count) \ | 751 | struct device_attribute *attr, const char *buf, size_t count) \ |
| 752 | { \ | 752 | { \ |
| 753 | struct hid_device *hdev = container_of(dev, struct hid_device, dev);\ | 753 | struct hid_device *hdev = to_hid_device(dev);\ |
| 754 | struct wacom *wacom = hid_get_drvdata(hdev); \ | 754 | struct wacom *wacom = hid_get_drvdata(hdev); \ |
| 755 | \ | 755 | \ |
| 756 | return wacom_luminance_store(wacom, &wacom->led.field, \ | 756 | return wacom_luminance_store(wacom, &wacom->led.field, \ |
| @@ -773,7 +773,7 @@ DEVICE_LUMINANCE_ATTR(buttons, img_lum); | |||
| 773 | static ssize_t wacom_button_image_store(struct device *dev, int button_id, | 773 | static ssize_t wacom_button_image_store(struct device *dev, int button_id, |
| 774 | const char *buf, size_t count) | 774 | const char *buf, size_t count) |
| 775 | { | 775 | { |
| 776 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 776 | struct hid_device *hdev = to_hid_device(dev); |
| 777 | struct wacom *wacom = hid_get_drvdata(hdev); | 777 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 778 | int err; | 778 | int err; |
| 779 | unsigned len; | 779 | unsigned len; |
| @@ -1097,7 +1097,7 @@ static ssize_t wacom_show_speed(struct device *dev, | |||
| 1097 | struct device_attribute | 1097 | struct device_attribute |
| 1098 | *attr, char *buf) | 1098 | *attr, char *buf) |
| 1099 | { | 1099 | { |
| 1100 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 1100 | struct hid_device *hdev = to_hid_device(dev); |
| 1101 | struct wacom *wacom = hid_get_drvdata(hdev); | 1101 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 1102 | 1102 | ||
| 1103 | return snprintf(buf, PAGE_SIZE, "%i\n", wacom->wacom_wac.bt_high_speed); | 1103 | return snprintf(buf, PAGE_SIZE, "%i\n", wacom->wacom_wac.bt_high_speed); |
| @@ -1107,7 +1107,7 @@ static ssize_t wacom_store_speed(struct device *dev, | |||
| 1107 | struct device_attribute *attr, | 1107 | struct device_attribute *attr, |
| 1108 | const char *buf, size_t count) | 1108 | const char *buf, size_t count) |
| 1109 | { | 1109 | { |
| 1110 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 1110 | struct hid_device *hdev = to_hid_device(dev); |
| 1111 | struct wacom *wacom = hid_get_drvdata(hdev); | 1111 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 1112 | u8 new_speed; | 1112 | u8 new_speed; |
| 1113 | 1113 | ||
| @@ -1130,8 +1130,8 @@ static ssize_t wacom_show_remote_mode(struct kobject *kobj, | |||
| 1130 | struct kobj_attribute *kattr, | 1130 | struct kobj_attribute *kattr, |
| 1131 | char *buf, int index) | 1131 | char *buf, int index) |
| 1132 | { | 1132 | { |
| 1133 | struct device *dev = container_of(kobj->parent, struct device, kobj); | 1133 | struct device *dev = kobj_to_dev(kobj->parent); |
| 1134 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 1134 | struct hid_device *hdev = to_hid_device(dev); |
| 1135 | struct wacom *wacom = hid_get_drvdata(hdev); | 1135 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 1136 | u8 mode; | 1136 | u8 mode; |
| 1137 | 1137 | ||
| @@ -1241,8 +1241,8 @@ static ssize_t wacom_store_unpair_remote(struct kobject *kobj, | |||
| 1241 | const char *buf, size_t count) | 1241 | const char *buf, size_t count) |
| 1242 | { | 1242 | { |
| 1243 | unsigned char selector = 0; | 1243 | unsigned char selector = 0; |
| 1244 | struct device *dev = container_of(kobj->parent, struct device, kobj); | 1244 | struct device *dev = kobj_to_dev(kobj->parent); |
| 1245 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 1245 | struct hid_device *hdev = to_hid_device(dev); |
| 1246 | struct wacom *wacom = hid_get_drvdata(hdev); | 1246 | struct wacom *wacom = hid_get_drvdata(hdev); |
| 1247 | int err; | 1247 | int err; |
| 1248 | 1248 | ||
| @@ -1353,8 +1353,7 @@ static void wacom_clean_inputs(struct wacom *wacom) | |||
| 1353 | else | 1353 | else |
| 1354 | input_free_device(wacom->wacom_wac.pad_input); | 1354 | input_free_device(wacom->wacom_wac.pad_input); |
| 1355 | } | 1355 | } |
| 1356 | if (wacom->remote_dir) | 1356 | kobject_put(wacom->remote_dir); |
| 1357 | kobject_put(wacom->remote_dir); | ||
| 1358 | wacom->wacom_wac.pen_input = NULL; | 1357 | wacom->wacom_wac.pen_input = NULL; |
| 1359 | wacom->wacom_wac.touch_input = NULL; | 1358 | wacom->wacom_wac.touch_input = NULL; |
| 1360 | wacom->wacom_wac.pad_input = NULL; | 1359 | wacom->wacom_wac.pad_input = NULL; |
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index 01a4f05c1642..99ef77fcfb80 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c | |||
| @@ -34,6 +34,9 @@ | |||
| 34 | */ | 34 | */ |
| 35 | #define WACOM_CONTACT_AREA_SCALE 2607 | 35 | #define WACOM_CONTACT_AREA_SCALE 2607 |
| 36 | 36 | ||
| 37 | static void wacom_report_numbered_buttons(struct input_dev *input_dev, | ||
| 38 | int button_count, int mask); | ||
| 39 | |||
| 37 | /* | 40 | /* |
| 38 | * Percent of battery capacity for Graphire. | 41 | * Percent of battery capacity for Graphire. |
| 39 | * 8th value means AC online and show 100% capacity. | 42 | * 8th value means AC online and show 100% capacity. |
| @@ -436,16 +439,142 @@ exit: | |||
| 436 | static void wacom_intuos_schedule_prox_event(struct wacom_wac *wacom_wac) | 439 | static void wacom_intuos_schedule_prox_event(struct wacom_wac *wacom_wac) |
| 437 | { | 440 | { |
| 438 | struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac); | 441 | struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac); |
| 442 | struct wacom_features *features = &wacom_wac->features; | ||
| 439 | struct hid_report *r; | 443 | struct hid_report *r; |
| 440 | struct hid_report_enum *re; | 444 | struct hid_report_enum *re; |
| 441 | 445 | ||
| 442 | re = &(wacom->hdev->report_enum[HID_FEATURE_REPORT]); | 446 | re = &(wacom->hdev->report_enum[HID_FEATURE_REPORT]); |
| 443 | r = re->report_id_hash[WACOM_REPORT_INTUOSREAD]; | 447 | if (features->type == INTUOSHT2) |
| 448 | r = re->report_id_hash[WACOM_REPORT_INTUOSHT2_ID]; | ||
| 449 | else | ||
| 450 | r = re->report_id_hash[WACOM_REPORT_INTUOS_ID1]; | ||
| 444 | if (r) { | 451 | if (r) { |
| 445 | hid_hw_request(wacom->hdev, r, HID_REQ_GET_REPORT); | 452 | hid_hw_request(wacom->hdev, r, HID_REQ_GET_REPORT); |
| 446 | } | 453 | } |
| 447 | } | 454 | } |
| 448 | 455 | ||
| 456 | static int wacom_intuos_pad(struct wacom_wac *wacom) | ||
| 457 | { | ||
| 458 | struct wacom_features *features = &wacom->features; | ||
| 459 | unsigned char *data = wacom->data; | ||
| 460 | struct input_dev *input = wacom->pad_input; | ||
| 461 | int i; | ||
| 462 | int buttons = 0, nbuttons = features->numbered_buttons; | ||
| 463 | int keys = 0, nkeys = 0; | ||
| 464 | int ring1 = 0, ring2 = 0; | ||
| 465 | int strip1 = 0, strip2 = 0; | ||
| 466 | bool prox = false; | ||
| 467 | |||
| 468 | /* pad packets. Works as a second tool and is always in prox */ | ||
| 469 | if (!(data[0] == WACOM_REPORT_INTUOSPAD || data[0] == WACOM_REPORT_INTUOS5PAD || | ||
| 470 | data[0] == WACOM_REPORT_CINTIQPAD)) | ||
| 471 | return 0; | ||
| 472 | |||
| 473 | if (features->type >= INTUOS4S && features->type <= INTUOS4L) { | ||
| 474 | buttons = (data[3] << 1) | (data[2] & 0x01); | ||
| 475 | ring1 = data[1]; | ||
| 476 | } else if (features->type == DTK) { | ||
| 477 | buttons = data[6]; | ||
| 478 | } else if (features->type == WACOM_13HD) { | ||
| 479 | buttons = (data[4] << 1) | (data[3] & 0x01); | ||
| 480 | } else if (features->type == WACOM_24HD) { | ||
| 481 | buttons = (data[8] << 8) | data[6]; | ||
| 482 | ring1 = data[1]; | ||
| 483 | ring2 = data[2]; | ||
| 484 | |||
| 485 | /* | ||
| 486 | * Three "buttons" are available on the 24HD which are | ||
| 487 | * physically implemented as a touchstrip. Each button | ||
| 488 | * is approximately 3 bits wide with a 2 bit spacing. | ||
| 489 | * The raw touchstrip bits are stored at: | ||
| 490 | * ((data[3] & 0x1f) << 8) | data[4]) | ||
| 491 | */ | ||
| 492 | nkeys = 3; | ||
| 493 | keys = ((data[3] & 0x1C) ? 1<<2 : 0) | | ||
| 494 | ((data[4] & 0xE0) ? 1<<1 : 0) | | ||
| 495 | ((data[4] & 0x07) ? 1<<0 : 0); | ||
| 496 | } else if (features->type == WACOM_27QHD) { | ||
| 497 | nkeys = 3; | ||
| 498 | keys = data[2] & 0x07; | ||
| 499 | |||
| 500 | input_report_abs(input, ABS_X, be16_to_cpup((__be16 *)&data[4])); | ||
| 501 | input_report_abs(input, ABS_Y, be16_to_cpup((__be16 *)&data[6])); | ||
| 502 | input_report_abs(input, ABS_Z, be16_to_cpup((__be16 *)&data[8])); | ||
| 503 | } else if (features->type == CINTIQ_HYBRID) { | ||
| 504 | /* | ||
| 505 | * Do not send hardware buttons under Android. They | ||
| 506 | * are already sent to the system through GPIO (and | ||
| 507 | * have different meaning). | ||
| 508 | * | ||
| 509 | * d-pad right -> data[4] & 0x10 | ||
| 510 | * d-pad up -> data[4] & 0x20 | ||
| 511 | * d-pad left -> data[4] & 0x40 | ||
| 512 | * d-pad down -> data[4] & 0x80 | ||
| 513 | * d-pad center -> data[3] & 0x01 | ||
| 514 | */ | ||
| 515 | buttons = (data[4] << 1) | (data[3] & 0x01); | ||
| 516 | } else if (features->type == CINTIQ_COMPANION_2) { | ||
| 517 | /* d-pad right -> data[4] & 0x10 | ||
| 518 | * d-pad up -> data[4] & 0x20 | ||
| 519 | * d-pad left -> data[4] & 0x40 | ||
| 520 | * d-pad down -> data[4] & 0x80 | ||
| 521 | * d-pad center -> data[3] & 0x01 | ||
| 522 | */ | ||
| 523 | buttons = ((data[2] >> 4) << 7) | | ||
| 524 | ((data[1] & 0x04) << 6) | | ||
| 525 | ((data[2] & 0x0F) << 2) | | ||
| 526 | (data[1] & 0x03); | ||
| 527 | } else if (features->type >= INTUOS5S && features->type <= INTUOSPL) { | ||
| 528 | /* | ||
| 529 | * ExpressKeys on Intuos5/Intuos Pro have a capacitive sensor in | ||
| 530 | * addition to the mechanical switch. Switch data is | ||
| 531 | * stored in data[4], capacitive data in data[5]. | ||
| 532 | * | ||
| 533 | * Touch ring mode switch (data[3]) has no capacitive sensor | ||
| 534 | */ | ||
| 535 | buttons = (data[4] << 1) | (data[3] & 0x01); | ||
| 536 | ring1 = data[2]; | ||
| 537 | } else { | ||
| 538 | if (features->type == WACOM_21UX2 || features->type == WACOM_22HD) { | ||
| 539 | buttons = (data[8] << 10) | ((data[7] & 0x01) << 9) | | ||
| 540 | (data[6] << 1) | (data[5] & 0x01); | ||
| 541 | |||
| 542 | if (features->type == WACOM_22HD) { | ||
| 543 | nkeys = 3; | ||
| 544 | keys = data[9] & 0x07; | ||
| 545 | } | ||
| 546 | } else { | ||
| 547 | buttons = ((data[6] & 0x10) << 10) | | ||
| 548 | ((data[5] & 0x10) << 9) | | ||
| 549 | ((data[6] & 0x0F) << 4) | | ||
| 550 | (data[5] & 0x0F); | ||
| 551 | } | ||
| 552 | strip1 = ((data[1] & 0x1f) << 8) | data[2]; | ||
| 553 | strip2 = ((data[3] & 0x1f) << 8) | data[4]; | ||
| 554 | } | ||
| 555 | |||
| 556 | prox = (buttons & ~(~0 << nbuttons)) | (keys & ~(~0 << nkeys)) | | ||
| 557 | (ring1 & 0x80) | (ring2 & 0x80) | strip1 | strip2; | ||
| 558 | |||
| 559 | wacom_report_numbered_buttons(input, nbuttons, buttons); | ||
| 560 | |||
| 561 | for (i = 0; i < nkeys; i++) | ||
| 562 | input_report_key(input, KEY_PROG1 + i, keys & (1 << i)); | ||
| 563 | |||
| 564 | input_report_abs(input, ABS_RX, strip1); | ||
| 565 | input_report_abs(input, ABS_RY, strip2); | ||
| 566 | |||
| 567 | input_report_abs(input, ABS_WHEEL, (ring1 & 0x80) ? (ring1 & 0x7f) : 0); | ||
| 568 | input_report_abs(input, ABS_THROTTLE, (ring2 & 0x80) ? (ring2 & 0x7f) : 0); | ||
| 569 | |||
| 570 | input_report_key(input, wacom->tool[1], prox ? 1 : 0); | ||
| 571 | input_report_abs(input, ABS_MISC, prox ? PAD_DEVICE_ID : 0); | ||
| 572 | |||
| 573 | input_event(input, EV_MSC, MSC_SERIAL, 0xffffffff); | ||
| 574 | |||
| 575 | return 1; | ||
| 576 | } | ||
| 577 | |||
| 449 | static int wacom_intuos_inout(struct wacom_wac *wacom) | 578 | static int wacom_intuos_inout(struct wacom_wac *wacom) |
| 450 | { | 579 | { |
| 451 | struct wacom_features *features = &wacom->features; | 580 | struct wacom_features *features = &wacom->features; |
| @@ -755,19 +884,40 @@ static int wacom_remote_status_irq(struct wacom_wac *wacom_wac, size_t len) | |||
| 755 | return 0; | 884 | return 0; |
| 756 | } | 885 | } |
| 757 | 886 | ||
| 758 | static void wacom_intuos_general(struct wacom_wac *wacom) | 887 | static int wacom_intuos_general(struct wacom_wac *wacom) |
| 759 | { | 888 | { |
| 760 | struct wacom_features *features = &wacom->features; | 889 | struct wacom_features *features = &wacom->features; |
| 761 | unsigned char *data = wacom->data; | 890 | unsigned char *data = wacom->data; |
| 762 | struct input_dev *input = wacom->pen_input; | 891 | struct input_dev *input = wacom->pen_input; |
| 763 | unsigned int t; | 892 | int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0; |
| 893 | unsigned char type = (data[1] >> 1) & 0x0F; | ||
| 894 | unsigned int x, y, distance, t; | ||
| 764 | 895 | ||
| 765 | /* general pen packet */ | 896 | if (data[0] != WACOM_REPORT_PENABLED && data[0] != WACOM_REPORT_CINTIQ && |
| 766 | if ((data[1] & 0xb8) == 0xa0) { | 897 | data[0] != WACOM_REPORT_INTUOS_PEN) |
| 767 | t = (data[6] << 2) | ((data[7] >> 6) & 3); | 898 | return 0; |
| 768 | if (features->pressure_max == 2047) { | 899 | |
| 769 | t = (t << 1) | (data[1] & 1); | 900 | x = (be16_to_cpup((__be16 *)&data[2]) << 1) | ((data[9] >> 1) & 1); |
| 770 | } | 901 | y = (be16_to_cpup((__be16 *)&data[4]) << 1) | (data[9] & 1); |
| 902 | distance = data[9] >> 2; | ||
| 903 | if (features->type < INTUOS3S) { | ||
| 904 | x >>= 1; | ||
| 905 | y >>= 1; | ||
| 906 | distance >>= 1; | ||
| 907 | } | ||
| 908 | input_report_abs(input, ABS_X, x); | ||
| 909 | input_report_abs(input, ABS_Y, y); | ||
| 910 | input_report_abs(input, ABS_DISTANCE, distance); | ||
| 911 | |||
| 912 | switch (type) { | ||
| 913 | case 0x00: | ||
| 914 | case 0x01: | ||
| 915 | case 0x02: | ||
| 916 | case 0x03: | ||
| 917 | /* general pen packet */ | ||
| 918 | t = (data[6] << 3) | ((data[7] & 0xC0) >> 5) | (data[1] & 1); | ||
| 919 | if (features->pressure_max < 2047) | ||
| 920 | t >>= 1; | ||
| 771 | input_report_abs(input, ABS_PRESSURE, t); | 921 | input_report_abs(input, ABS_PRESSURE, t); |
| 772 | if (features->type != INTUOSHT2) { | 922 | if (features->type != INTUOSHT2) { |
| 773 | input_report_abs(input, ABS_TILT_X, | 923 | input_report_abs(input, ABS_TILT_X, |
| @@ -777,29 +927,112 @@ static void wacom_intuos_general(struct wacom_wac *wacom) | |||
| 777 | input_report_key(input, BTN_STYLUS, data[1] & 2); | 927 | input_report_key(input, BTN_STYLUS, data[1] & 2); |
| 778 | input_report_key(input, BTN_STYLUS2, data[1] & 4); | 928 | input_report_key(input, BTN_STYLUS2, data[1] & 4); |
| 779 | input_report_key(input, BTN_TOUCH, t > 10); | 929 | input_report_key(input, BTN_TOUCH, t > 10); |
| 780 | } | 930 | break; |
| 781 | 931 | ||
| 782 | /* airbrush second packet */ | 932 | case 0x0a: |
| 783 | if ((data[1] & 0xbc) == 0xb4) { | 933 | /* airbrush second packet */ |
| 784 | input_report_abs(input, ABS_WHEEL, | 934 | input_report_abs(input, ABS_WHEEL, |
| 785 | (data[6] << 2) | ((data[7] >> 6) & 3)); | 935 | (data[6] << 2) | ((data[7] >> 6) & 3)); |
| 786 | input_report_abs(input, ABS_TILT_X, | 936 | input_report_abs(input, ABS_TILT_X, |
| 787 | (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64); | 937 | (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64); |
| 788 | input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64); | 938 | input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64); |
| 939 | break; | ||
| 940 | |||
| 941 | case 0x05: | ||
| 942 | /* Rotation packet */ | ||
| 943 | if (features->type >= INTUOS3S) { | ||
| 944 | /* I3 marker pen rotation */ | ||
| 945 | t = (data[6] << 3) | ((data[7] >> 5) & 7); | ||
| 946 | t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) : | ||
| 947 | ((t-1) / 2 + 450)) : (450 - t / 2) ; | ||
| 948 | input_report_abs(input, ABS_Z, t); | ||
| 949 | } else { | ||
| 950 | /* 4D mouse 2nd packet */ | ||
| 951 | t = (data[6] << 3) | ((data[7] >> 5) & 7); | ||
| 952 | input_report_abs(input, ABS_RZ, (data[7] & 0x20) ? | ||
| 953 | ((t - 1) / 2) : -t / 2); | ||
| 954 | } | ||
| 955 | break; | ||
| 956 | |||
| 957 | case 0x04: | ||
| 958 | /* 4D mouse 1st packet */ | ||
| 959 | input_report_key(input, BTN_LEFT, data[8] & 0x01); | ||
| 960 | input_report_key(input, BTN_MIDDLE, data[8] & 0x02); | ||
| 961 | input_report_key(input, BTN_RIGHT, data[8] & 0x04); | ||
| 962 | |||
| 963 | input_report_key(input, BTN_SIDE, data[8] & 0x20); | ||
| 964 | input_report_key(input, BTN_EXTRA, data[8] & 0x10); | ||
| 965 | t = (data[6] << 2) | ((data[7] >> 6) & 3); | ||
| 966 | input_report_abs(input, ABS_THROTTLE, (data[8] & 0x08) ? -t : t); | ||
| 967 | break; | ||
| 968 | |||
| 969 | case 0x06: | ||
| 970 | /* I4 mouse */ | ||
| 971 | input_report_key(input, BTN_LEFT, data[6] & 0x01); | ||
| 972 | input_report_key(input, BTN_MIDDLE, data[6] & 0x02); | ||
| 973 | input_report_key(input, BTN_RIGHT, data[6] & 0x04); | ||
| 974 | input_report_rel(input, REL_WHEEL, ((data[7] & 0x80) >> 7) | ||
| 975 | - ((data[7] & 0x40) >> 6)); | ||
| 976 | input_report_key(input, BTN_SIDE, data[6] & 0x08); | ||
| 977 | input_report_key(input, BTN_EXTRA, data[6] & 0x10); | ||
| 978 | |||
| 979 | input_report_abs(input, ABS_TILT_X, | ||
| 980 | (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64); | ||
| 981 | input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64); | ||
| 982 | break; | ||
| 983 | |||
| 984 | case 0x08: | ||
| 985 | if (wacom->tool[idx] == BTN_TOOL_MOUSE) { | ||
| 986 | /* 2D mouse packet */ | ||
| 987 | input_report_key(input, BTN_LEFT, data[8] & 0x04); | ||
| 988 | input_report_key(input, BTN_MIDDLE, data[8] & 0x08); | ||
| 989 | input_report_key(input, BTN_RIGHT, data[8] & 0x10); | ||
| 990 | input_report_rel(input, REL_WHEEL, (data[8] & 0x01) | ||
| 991 | - ((data[8] & 0x02) >> 1)); | ||
| 992 | |||
| 993 | /* I3 2D mouse side buttons */ | ||
| 994 | if (features->type >= INTUOS3S && features->type <= INTUOS3L) { | ||
| 995 | input_report_key(input, BTN_SIDE, data[8] & 0x40); | ||
| 996 | input_report_key(input, BTN_EXTRA, data[8] & 0x20); | ||
| 997 | } | ||
| 998 | } | ||
| 999 | else if (wacom->tool[idx] == BTN_TOOL_LENS) { | ||
| 1000 | /* Lens cursor packets */ | ||
| 1001 | input_report_key(input, BTN_LEFT, data[8] & 0x01); | ||
| 1002 | input_report_key(input, BTN_MIDDLE, data[8] & 0x02); | ||
| 1003 | input_report_key(input, BTN_RIGHT, data[8] & 0x04); | ||
| 1004 | input_report_key(input, BTN_SIDE, data[8] & 0x10); | ||
| 1005 | input_report_key(input, BTN_EXTRA, data[8] & 0x08); | ||
| 1006 | } | ||
| 1007 | break; | ||
| 1008 | |||
| 1009 | case 0x07: | ||
| 1010 | case 0x09: | ||
| 1011 | case 0x0b: | ||
| 1012 | case 0x0c: | ||
| 1013 | case 0x0d: | ||
| 1014 | case 0x0e: | ||
| 1015 | case 0x0f: | ||
| 1016 | /* unhandled */ | ||
| 1017 | break; | ||
| 789 | } | 1018 | } |
| 1019 | |||
| 1020 | input_report_abs(input, ABS_MISC, wacom->id[idx]); /* report tool id */ | ||
| 1021 | input_report_key(input, wacom->tool[idx], 1); | ||
| 1022 | input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]); | ||
| 1023 | wacom->reporting_data = true; | ||
| 1024 | return 2; | ||
| 790 | } | 1025 | } |
| 791 | 1026 | ||
| 792 | static int wacom_intuos_irq(struct wacom_wac *wacom) | 1027 | static int wacom_intuos_irq(struct wacom_wac *wacom) |
| 793 | { | 1028 | { |
| 794 | struct wacom_features *features = &wacom->features; | ||
| 795 | unsigned char *data = wacom->data; | 1029 | unsigned char *data = wacom->data; |
| 796 | struct input_dev *input = wacom->pen_input; | 1030 | struct input_dev *input = wacom->pen_input; |
| 797 | unsigned int t; | 1031 | int result; |
| 798 | int idx = 0, result; | ||
| 799 | 1032 | ||
| 800 | if (data[0] != WACOM_REPORT_PENABLED && | 1033 | if (data[0] != WACOM_REPORT_PENABLED && |
| 801 | data[0] != WACOM_REPORT_INTUOSREAD && | 1034 | data[0] != WACOM_REPORT_INTUOS_ID1 && |
| 802 | data[0] != WACOM_REPORT_INTUOSWRITE && | 1035 | data[0] != WACOM_REPORT_INTUOS_ID2 && |
| 803 | data[0] != WACOM_REPORT_INTUOSPAD && | 1036 | data[0] != WACOM_REPORT_INTUOSPAD && |
| 804 | data[0] != WACOM_REPORT_INTUOS_PEN && | 1037 | data[0] != WACOM_REPORT_INTUOS_PEN && |
| 805 | data[0] != WACOM_REPORT_CINTIQ && | 1038 | data[0] != WACOM_REPORT_CINTIQ && |
| @@ -810,339 +1043,22 @@ static int wacom_intuos_irq(struct wacom_wac *wacom) | |||
| 810 | return 0; | 1043 | return 0; |
| 811 | } | 1044 | } |
| 812 | 1045 | ||
| 813 | /* tool number */ | 1046 | /* process pad events */ |
| 814 | if (features->type == INTUOS) | 1047 | result = wacom_intuos_pad(wacom); |
| 815 | idx = data[1] & 0x01; | 1048 | if (result) |
| 816 | 1049 | return result; | |
| 817 | /* pad packets. Works as a second tool and is always in prox */ | ||
| 818 | if (data[0] == WACOM_REPORT_INTUOSPAD || data[0] == WACOM_REPORT_INTUOS5PAD || | ||
| 819 | data[0] == WACOM_REPORT_CINTIQPAD) { | ||
| 820 | input = wacom->pad_input; | ||
| 821 | if (features->type >= INTUOS4S && features->type <= INTUOS4L) { | ||
| 822 | input_report_key(input, BTN_0, (data[2] & 0x01)); | ||
| 823 | input_report_key(input, BTN_1, (data[3] & 0x01)); | ||
| 824 | input_report_key(input, BTN_2, (data[3] & 0x02)); | ||
| 825 | input_report_key(input, BTN_3, (data[3] & 0x04)); | ||
| 826 | input_report_key(input, BTN_4, (data[3] & 0x08)); | ||
| 827 | input_report_key(input, BTN_5, (data[3] & 0x10)); | ||
| 828 | input_report_key(input, BTN_6, (data[3] & 0x20)); | ||
| 829 | if (data[1] & 0x80) { | ||
| 830 | input_report_abs(input, ABS_WHEEL, (data[1] & 0x7f)); | ||
| 831 | } else { | ||
| 832 | /* Out of proximity, clear wheel value. */ | ||
| 833 | input_report_abs(input, ABS_WHEEL, 0); | ||
| 834 | } | ||
| 835 | if (features->type != INTUOS4S) { | ||
| 836 | input_report_key(input, BTN_7, (data[3] & 0x40)); | ||
| 837 | input_report_key(input, BTN_8, (data[3] & 0x80)); | ||
| 838 | } | ||
| 839 | if (data[1] | (data[2] & 0x01) | data[3]) { | ||
| 840 | input_report_abs(input, ABS_MISC, PAD_DEVICE_ID); | ||
| 841 | } else { | ||
| 842 | input_report_abs(input, ABS_MISC, 0); | ||
| 843 | } | ||
| 844 | } else if (features->type == DTK) { | ||
| 845 | input_report_key(input, BTN_0, (data[6] & 0x01)); | ||
| 846 | input_report_key(input, BTN_1, (data[6] & 0x02)); | ||
| 847 | input_report_key(input, BTN_2, (data[6] & 0x04)); | ||
| 848 | input_report_key(input, BTN_3, (data[6] & 0x08)); | ||
| 849 | input_report_key(input, BTN_4, (data[6] & 0x10)); | ||
| 850 | input_report_key(input, BTN_5, (data[6] & 0x20)); | ||
| 851 | if (data[6] & 0x3f) { | ||
| 852 | input_report_abs(input, ABS_MISC, PAD_DEVICE_ID); | ||
| 853 | } else { | ||
| 854 | input_report_abs(input, ABS_MISC, 0); | ||
| 855 | } | ||
| 856 | } else if (features->type == WACOM_13HD) { | ||
| 857 | input_report_key(input, BTN_0, (data[3] & 0x01)); | ||
| 858 | input_report_key(input, BTN_1, (data[4] & 0x01)); | ||
| 859 | input_report_key(input, BTN_2, (data[4] & 0x02)); | ||
| 860 | input_report_key(input, BTN_3, (data[4] & 0x04)); | ||
| 861 | input_report_key(input, BTN_4, (data[4] & 0x08)); | ||
| 862 | input_report_key(input, BTN_5, (data[4] & 0x10)); | ||
| 863 | input_report_key(input, BTN_6, (data[4] & 0x20)); | ||
| 864 | input_report_key(input, BTN_7, (data[4] & 0x40)); | ||
| 865 | input_report_key(input, BTN_8, (data[4] & 0x80)); | ||
| 866 | if ((data[3] & 0x01) | data[4]) { | ||
| 867 | input_report_abs(input, ABS_MISC, PAD_DEVICE_ID); | ||
| 868 | } else { | ||
| 869 | input_report_abs(input, ABS_MISC, 0); | ||
| 870 | } | ||
| 871 | } else if (features->type == WACOM_24HD) { | ||
| 872 | input_report_key(input, BTN_0, (data[6] & 0x01)); | ||
| 873 | input_report_key(input, BTN_1, (data[6] & 0x02)); | ||
| 874 | input_report_key(input, BTN_2, (data[6] & 0x04)); | ||
| 875 | input_report_key(input, BTN_3, (data[6] & 0x08)); | ||
| 876 | input_report_key(input, BTN_4, (data[6] & 0x10)); | ||
| 877 | input_report_key(input, BTN_5, (data[6] & 0x20)); | ||
| 878 | input_report_key(input, BTN_6, (data[6] & 0x40)); | ||
| 879 | input_report_key(input, BTN_7, (data[6] & 0x80)); | ||
| 880 | input_report_key(input, BTN_8, (data[8] & 0x01)); | ||
| 881 | input_report_key(input, BTN_9, (data[8] & 0x02)); | ||
| 882 | input_report_key(input, BTN_A, (data[8] & 0x04)); | ||
| 883 | input_report_key(input, BTN_B, (data[8] & 0x08)); | ||
| 884 | input_report_key(input, BTN_C, (data[8] & 0x10)); | ||
| 885 | input_report_key(input, BTN_X, (data[8] & 0x20)); | ||
| 886 | input_report_key(input, BTN_Y, (data[8] & 0x40)); | ||
| 887 | input_report_key(input, BTN_Z, (data[8] & 0x80)); | ||
| 888 | |||
| 889 | /* | ||
| 890 | * Three "buttons" are available on the 24HD which are | ||
| 891 | * physically implemented as a touchstrip. Each button | ||
| 892 | * is approximately 3 bits wide with a 2 bit spacing. | ||
| 893 | * The raw touchstrip bits are stored at: | ||
| 894 | * ((data[3] & 0x1f) << 8) | data[4]) | ||
| 895 | */ | ||
| 896 | input_report_key(input, KEY_PROG1, data[4] & 0x07); | ||
| 897 | input_report_key(input, KEY_PROG2, data[4] & 0xE0); | ||
| 898 | input_report_key(input, KEY_PROG3, data[3] & 0x1C); | ||
| 899 | |||
| 900 | if (data[1] & 0x80) { | ||
| 901 | input_report_abs(input, ABS_WHEEL, (data[1] & 0x7f)); | ||
| 902 | } else { | ||
| 903 | /* Out of proximity, clear wheel value. */ | ||
| 904 | input_report_abs(input, ABS_WHEEL, 0); | ||
| 905 | } | ||
| 906 | |||
| 907 | if (data[2] & 0x80) { | ||
| 908 | input_report_abs(input, ABS_THROTTLE, (data[2] & 0x7f)); | ||
| 909 | } else { | ||
| 910 | /* Out of proximity, clear second wheel value. */ | ||
| 911 | input_report_abs(input, ABS_THROTTLE, 0); | ||
| 912 | } | ||
| 913 | |||
| 914 | if (data[1] | data[2] | (data[3] & 0x1f) | data[4] | data[6] | data[8]) { | ||
| 915 | input_report_abs(input, ABS_MISC, PAD_DEVICE_ID); | ||
| 916 | } else { | ||
| 917 | input_report_abs(input, ABS_MISC, 0); | ||
| 918 | } | ||
| 919 | } else if (features->type == WACOM_27QHD) { | ||
| 920 | input_report_key(input, KEY_PROG1, data[2] & 0x01); | ||
| 921 | input_report_key(input, KEY_PROG2, data[2] & 0x02); | ||
| 922 | input_report_key(input, KEY_PROG3, data[2] & 0x04); | ||
| 923 | |||
| 924 | input_report_abs(input, ABS_X, be16_to_cpup((__be16 *)&data[4])); | ||
| 925 | input_report_abs(input, ABS_Y, be16_to_cpup((__be16 *)&data[6])); | ||
| 926 | input_report_abs(input, ABS_Z, be16_to_cpup((__be16 *)&data[8])); | ||
| 927 | if ((data[2] & 0x07) | data[4] | data[5] | data[6] | data[7] | data[8] | data[9]) { | ||
| 928 | input_report_abs(input, ABS_MISC, PAD_DEVICE_ID); | ||
| 929 | } else { | ||
| 930 | input_report_abs(input, ABS_MISC, 0); | ||
| 931 | } | ||
| 932 | } else if (features->type == CINTIQ_HYBRID) { | ||
| 933 | /* | ||
| 934 | * Do not send hardware buttons under Android. They | ||
| 935 | * are already sent to the system through GPIO (and | ||
| 936 | * have different meaning). | ||
| 937 | */ | ||
| 938 | input_report_key(input, BTN_1, (data[4] & 0x01)); | ||
| 939 | input_report_key(input, BTN_2, (data[4] & 0x02)); | ||
| 940 | input_report_key(input, BTN_3, (data[4] & 0x04)); | ||
| 941 | input_report_key(input, BTN_4, (data[4] & 0x08)); | ||
| 942 | |||
| 943 | input_report_key(input, BTN_5, (data[4] & 0x10)); /* Right */ | ||
| 944 | input_report_key(input, BTN_6, (data[4] & 0x20)); /* Up */ | ||
| 945 | input_report_key(input, BTN_7, (data[4] & 0x40)); /* Left */ | ||
| 946 | input_report_key(input, BTN_8, (data[4] & 0x80)); /* Down */ | ||
| 947 | input_report_key(input, BTN_0, (data[3] & 0x01)); /* Center */ | ||
| 948 | |||
| 949 | if (data[4] | (data[3] & 0x01)) { | ||
| 950 | input_report_abs(input, ABS_MISC, PAD_DEVICE_ID); | ||
| 951 | } else { | ||
| 952 | input_report_abs(input, ABS_MISC, 0); | ||
| 953 | } | ||
| 954 | |||
| 955 | } else if (features->type == CINTIQ_COMPANION_2) { | ||
| 956 | input_report_key(input, BTN_1, (data[1] & 0x02)); | ||
| 957 | input_report_key(input, BTN_2, (data[2] & 0x01)); | ||
| 958 | input_report_key(input, BTN_3, (data[2] & 0x02)); | ||
| 959 | input_report_key(input, BTN_4, (data[2] & 0x04)); | ||
| 960 | input_report_key(input, BTN_5, (data[2] & 0x08)); | ||
| 961 | input_report_key(input, BTN_6, (data[1] & 0x04)); | ||
| 962 | |||
| 963 | input_report_key(input, BTN_7, (data[2] & 0x10)); /* Right */ | ||
| 964 | input_report_key(input, BTN_8, (data[2] & 0x20)); /* Up */ | ||
| 965 | input_report_key(input, BTN_9, (data[2] & 0x40)); /* Left */ | ||
| 966 | input_report_key(input, BTN_A, (data[2] & 0x80)); /* Down */ | ||
| 967 | input_report_key(input, BTN_0, (data[1] & 0x01)); /* Center */ | ||
| 968 | |||
| 969 | if (data[2] | (data[1] & 0x07)) { | ||
| 970 | input_report_abs(input, ABS_MISC, PAD_DEVICE_ID); | ||
| 971 | } else { | ||
| 972 | input_report_abs(input, ABS_MISC, 0); | ||
| 973 | } | ||
| 974 | |||
| 975 | } else if (features->type >= INTUOS5S && features->type <= INTUOSPL) { | ||
| 976 | int i; | ||
| 977 | |||
| 978 | /* Touch ring mode switch has no capacitive sensor */ | ||
| 979 | input_report_key(input, BTN_0, (data[3] & 0x01)); | ||
| 980 | |||
| 981 | /* | ||
| 982 | * ExpressKeys on Intuos5/Intuos Pro have a capacitive sensor in | ||
| 983 | * addition to the mechanical switch. Switch data is | ||
| 984 | * stored in data[4], capacitive data in data[5]. | ||
| 985 | */ | ||
| 986 | for (i = 0; i < 8; i++) | ||
| 987 | input_report_key(input, BTN_1 + i, data[4] & (1 << i)); | ||
| 988 | |||
| 989 | if (data[2] & 0x80) { | ||
| 990 | input_report_abs(input, ABS_WHEEL, (data[2] & 0x7f)); | ||
| 991 | } else { | ||
| 992 | /* Out of proximity, clear wheel value. */ | ||
| 993 | input_report_abs(input, ABS_WHEEL, 0); | ||
| 994 | } | ||
| 995 | |||
| 996 | if (data[2] | (data[3] & 0x01) | data[4] | data[5]) { | ||
| 997 | input_report_abs(input, ABS_MISC, PAD_DEVICE_ID); | ||
| 998 | } else { | ||
| 999 | input_report_abs(input, ABS_MISC, 0); | ||
| 1000 | } | ||
| 1001 | } else { | ||
| 1002 | if (features->type == WACOM_21UX2 || features->type == WACOM_22HD) { | ||
| 1003 | input_report_key(input, BTN_0, (data[5] & 0x01)); | ||
| 1004 | input_report_key(input, BTN_1, (data[6] & 0x01)); | ||
| 1005 | input_report_key(input, BTN_2, (data[6] & 0x02)); | ||
| 1006 | input_report_key(input, BTN_3, (data[6] & 0x04)); | ||
| 1007 | input_report_key(input, BTN_4, (data[6] & 0x08)); | ||
| 1008 | input_report_key(input, BTN_5, (data[6] & 0x10)); | ||
| 1009 | input_report_key(input, BTN_6, (data[6] & 0x20)); | ||
| 1010 | input_report_key(input, BTN_7, (data[6] & 0x40)); | ||
| 1011 | input_report_key(input, BTN_8, (data[6] & 0x80)); | ||
| 1012 | input_report_key(input, BTN_9, (data[7] & 0x01)); | ||
| 1013 | input_report_key(input, BTN_A, (data[8] & 0x01)); | ||
| 1014 | input_report_key(input, BTN_B, (data[8] & 0x02)); | ||
| 1015 | input_report_key(input, BTN_C, (data[8] & 0x04)); | ||
| 1016 | input_report_key(input, BTN_X, (data[8] & 0x08)); | ||
| 1017 | input_report_key(input, BTN_Y, (data[8] & 0x10)); | ||
| 1018 | input_report_key(input, BTN_Z, (data[8] & 0x20)); | ||
| 1019 | input_report_key(input, BTN_BASE, (data[8] & 0x40)); | ||
| 1020 | input_report_key(input, BTN_BASE2, (data[8] & 0x80)); | ||
| 1021 | |||
| 1022 | if (features->type == WACOM_22HD) { | ||
| 1023 | input_report_key(input, KEY_PROG1, data[9] & 0x01); | ||
| 1024 | input_report_key(input, KEY_PROG2, data[9] & 0x02); | ||
| 1025 | input_report_key(input, KEY_PROG3, data[9] & 0x04); | ||
| 1026 | } | ||
| 1027 | } else { | ||
| 1028 | input_report_key(input, BTN_0, (data[5] & 0x01)); | ||
| 1029 | input_report_key(input, BTN_1, (data[5] & 0x02)); | ||
| 1030 | input_report_key(input, BTN_2, (data[5] & 0x04)); | ||
| 1031 | input_report_key(input, BTN_3, (data[5] & 0x08)); | ||
| 1032 | input_report_key(input, BTN_4, (data[6] & 0x01)); | ||
| 1033 | input_report_key(input, BTN_5, (data[6] & 0x02)); | ||
| 1034 | input_report_key(input, BTN_6, (data[6] & 0x04)); | ||
| 1035 | input_report_key(input, BTN_7, (data[6] & 0x08)); | ||
| 1036 | input_report_key(input, BTN_8, (data[5] & 0x10)); | ||
| 1037 | input_report_key(input, BTN_9, (data[6] & 0x10)); | ||
| 1038 | } | ||
| 1039 | input_report_abs(input, ABS_RX, ((data[1] & 0x1f) << 8) | data[2]); | ||
| 1040 | input_report_abs(input, ABS_RY, ((data[3] & 0x1f) << 8) | data[4]); | ||
| 1041 | |||
| 1042 | if ((data[5] & 0x1f) | data[6] | (data[1] & 0x1f) | | ||
| 1043 | data[2] | (data[3] & 0x1f) | data[4] | data[8] | | ||
| 1044 | (data[7] & 0x01)) { | ||
| 1045 | input_report_abs(input, ABS_MISC, PAD_DEVICE_ID); | ||
| 1046 | } else { | ||
| 1047 | input_report_abs(input, ABS_MISC, 0); | ||
| 1048 | } | ||
| 1049 | } | ||
| 1050 | return 1; | ||
| 1051 | } | ||
| 1052 | 1050 | ||
| 1053 | /* process in/out prox events */ | 1051 | /* process in/out prox events */ |
| 1054 | result = wacom_intuos_inout(wacom); | 1052 | result = wacom_intuos_inout(wacom); |
| 1055 | if (result) | 1053 | if (result) |
| 1056 | return result - 1; | 1054 | return result - 1; |
| 1057 | |||
| 1058 | if (features->type >= INTUOS3S) { | ||
| 1059 | input_report_abs(input, ABS_X, (data[2] << 9) | (data[3] << 1) | ((data[9] >> 1) & 1)); | ||
| 1060 | input_report_abs(input, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1)); | ||
| 1061 | input_report_abs(input, ABS_DISTANCE, ((data[9] >> 2) & 0x3f)); | ||
| 1062 | } else { | ||
| 1063 | input_report_abs(input, ABS_X, be16_to_cpup((__be16 *)&data[2])); | ||
| 1064 | input_report_abs(input, ABS_Y, be16_to_cpup((__be16 *)&data[4])); | ||
| 1065 | input_report_abs(input, ABS_DISTANCE, ((data[9] >> 3) & 0x1f)); | ||
| 1066 | } | ||
| 1067 | 1055 | ||
| 1068 | /* process general packets */ | 1056 | /* process general packets */ |
| 1069 | wacom_intuos_general(wacom); | 1057 | result = wacom_intuos_general(wacom); |
| 1070 | 1058 | if (result) | |
| 1071 | /* 4D mouse, 2D mouse, marker pen rotation, tilt mouse, or Lens cursor packets */ | 1059 | return result - 1; |
| 1072 | if ((data[1] & 0xbc) == 0xa8 || (data[1] & 0xbe) == 0xb0 || (data[1] & 0xbc) == 0xac) { | ||
| 1073 | |||
| 1074 | if (data[1] & 0x02) { | ||
| 1075 | /* Rotation packet */ | ||
| 1076 | if (features->type >= INTUOS3S) { | ||
| 1077 | /* I3 marker pen rotation */ | ||
| 1078 | t = (data[6] << 3) | ((data[7] >> 5) & 7); | ||
| 1079 | t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) : | ||
| 1080 | ((t-1) / 2 + 450)) : (450 - t / 2) ; | ||
| 1081 | input_report_abs(input, ABS_Z, t); | ||
| 1082 | } else { | ||
| 1083 | /* 4D mouse rotation packet */ | ||
| 1084 | t = (data[6] << 3) | ((data[7] >> 5) & 7); | ||
| 1085 | input_report_abs(input, ABS_RZ, (data[7] & 0x20) ? | ||
| 1086 | ((t - 1) / 2) : -t / 2); | ||
| 1087 | } | ||
| 1088 | |||
| 1089 | } else if (!(data[1] & 0x10) && features->type < INTUOS3S) { | ||
| 1090 | /* 4D mouse packet */ | ||
| 1091 | input_report_key(input, BTN_LEFT, data[8] & 0x01); | ||
| 1092 | input_report_key(input, BTN_MIDDLE, data[8] & 0x02); | ||
| 1093 | input_report_key(input, BTN_RIGHT, data[8] & 0x04); | ||
| 1094 | |||
| 1095 | input_report_key(input, BTN_SIDE, data[8] & 0x20); | ||
| 1096 | input_report_key(input, BTN_EXTRA, data[8] & 0x10); | ||
| 1097 | t = (data[6] << 2) | ((data[7] >> 6) & 3); | ||
| 1098 | input_report_abs(input, ABS_THROTTLE, (data[8] & 0x08) ? -t : t); | ||
| 1099 | |||
| 1100 | } else if (wacom->tool[idx] == BTN_TOOL_MOUSE) { | ||
| 1101 | /* I4 mouse */ | ||
| 1102 | if (features->type >= INTUOS4S && features->type <= INTUOSPL) { | ||
| 1103 | input_report_key(input, BTN_LEFT, data[6] & 0x01); | ||
| 1104 | input_report_key(input, BTN_MIDDLE, data[6] & 0x02); | ||
| 1105 | input_report_key(input, BTN_RIGHT, data[6] & 0x04); | ||
| 1106 | input_report_rel(input, REL_WHEEL, ((data[7] & 0x80) >> 7) | ||
| 1107 | - ((data[7] & 0x40) >> 6)); | ||
| 1108 | input_report_key(input, BTN_SIDE, data[6] & 0x08); | ||
| 1109 | input_report_key(input, BTN_EXTRA, data[6] & 0x10); | ||
| 1110 | |||
| 1111 | input_report_abs(input, ABS_TILT_X, | ||
| 1112 | (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64); | ||
| 1113 | input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64); | ||
| 1114 | } else { | ||
| 1115 | /* 2D mouse packet */ | ||
| 1116 | input_report_key(input, BTN_LEFT, data[8] & 0x04); | ||
| 1117 | input_report_key(input, BTN_MIDDLE, data[8] & 0x08); | ||
| 1118 | input_report_key(input, BTN_RIGHT, data[8] & 0x10); | ||
| 1119 | input_report_rel(input, REL_WHEEL, (data[8] & 0x01) | ||
| 1120 | - ((data[8] & 0x02) >> 1)); | ||
| 1121 | |||
| 1122 | /* I3 2D mouse side buttons */ | ||
| 1123 | if (features->type >= INTUOS3S && features->type <= INTUOS3L) { | ||
| 1124 | input_report_key(input, BTN_SIDE, data[8] & 0x40); | ||
| 1125 | input_report_key(input, BTN_EXTRA, data[8] & 0x20); | ||
| 1126 | } | ||
| 1127 | } | ||
| 1128 | } else if ((features->type < INTUOS3S || features->type == INTUOS3L || | ||
| 1129 | features->type == INTUOS4L || features->type == INTUOS5L || | ||
| 1130 | features->type == INTUOSPL) && | ||
| 1131 | wacom->tool[idx] == BTN_TOOL_LENS) { | ||
| 1132 | /* Lens cursor packets */ | ||
| 1133 | input_report_key(input, BTN_LEFT, data[8] & 0x01); | ||
| 1134 | input_report_key(input, BTN_MIDDLE, data[8] & 0x02); | ||
| 1135 | input_report_key(input, BTN_RIGHT, data[8] & 0x04); | ||
| 1136 | input_report_key(input, BTN_SIDE, data[8] & 0x10); | ||
| 1137 | input_report_key(input, BTN_EXTRA, data[8] & 0x08); | ||
| 1138 | } | ||
| 1139 | } | ||
| 1140 | 1060 | ||
| 1141 | input_report_abs(input, ABS_MISC, wacom->id[idx]); /* report tool id */ | 1061 | return 0; |
| 1142 | input_report_key(input, wacom->tool[idx], 1); | ||
| 1143 | input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]); | ||
| 1144 | wacom->reporting_data = true; | ||
| 1145 | return 1; | ||
| 1146 | } | 1062 | } |
| 1147 | 1063 | ||
| 1148 | static int int_dist(int x1, int y1, int x2, int y2) | 1064 | static int int_dist(int x1, int y1, int x2, int y2) |
| @@ -2509,7 +2425,7 @@ void wacom_setup_device_quirks(struct wacom *wacom) | |||
| 2509 | features->quirks |= WACOM_QUIRK_BATTERY; | 2425 | features->quirks |= WACOM_QUIRK_BATTERY; |
| 2510 | 2426 | ||
| 2511 | /* quirk for bamboo touch with 2 low res touches */ | 2427 | /* quirk for bamboo touch with 2 low res touches */ |
| 2512 | if (features->type == BAMBOO_PT && | 2428 | if ((features->type == BAMBOO_PT || features->type == BAMBOO_TOUCH) && |
| 2513 | features->pktlen == WACOM_PKGLEN_BBTOUCH) { | 2429 | features->pktlen == WACOM_PKGLEN_BBTOUCH) { |
| 2514 | features->x_max <<= 5; | 2430 | features->x_max <<= 5; |
| 2515 | features->y_max <<= 5; | 2431 | features->y_max <<= 5; |
| @@ -2806,6 +2722,19 @@ static void wacom_setup_numbered_buttons(struct input_dev *input_dev, | |||
| 2806 | __set_bit(BTN_BASE + (i-16), input_dev->keybit); | 2722 | __set_bit(BTN_BASE + (i-16), input_dev->keybit); |
| 2807 | } | 2723 | } |
| 2808 | 2724 | ||
| 2725 | static void wacom_report_numbered_buttons(struct input_dev *input_dev, | ||
| 2726 | int button_count, int mask) | ||
| 2727 | { | ||
| 2728 | int i; | ||
| 2729 | |||
| 2730 | for (i = 0; i < button_count && i < 10; i++) | ||
| 2731 | input_report_key(input_dev, BTN_0 + i, mask & (1 << i)); | ||
| 2732 | for (i = 10; i < button_count && i < 16; i++) | ||
| 2733 | input_report_key(input_dev, BTN_A + (i-10), mask & (1 << i)); | ||
| 2734 | for (i = 16; i < button_count && i < 18; i++) | ||
| 2735 | input_report_key(input_dev, BTN_BASE + (i-16), mask & (1 << i)); | ||
| 2736 | } | ||
| 2737 | |||
| 2809 | int wacom_setup_pad_input_capabilities(struct input_dev *input_dev, | 2738 | int wacom_setup_pad_input_capabilities(struct input_dev *input_dev, |
| 2810 | struct wacom_wac *wacom_wac) | 2739 | struct wacom_wac *wacom_wac) |
| 2811 | { | 2740 | { |
diff --git a/drivers/hid/wacom_wac.h b/drivers/hid/wacom_wac.h index 877c24a5df94..25baa7f29599 100644 --- a/drivers/hid/wacom_wac.h +++ b/drivers/hid/wacom_wac.h | |||
| @@ -47,8 +47,8 @@ | |||
| 47 | /* wacom data packet report IDs */ | 47 | /* wacom data packet report IDs */ |
| 48 | #define WACOM_REPORT_PENABLED 2 | 48 | #define WACOM_REPORT_PENABLED 2 |
| 49 | #define WACOM_REPORT_PENABLED_BT 3 | 49 | #define WACOM_REPORT_PENABLED_BT 3 |
| 50 | #define WACOM_REPORT_INTUOSREAD 5 | 50 | #define WACOM_REPORT_INTUOS_ID1 5 |
| 51 | #define WACOM_REPORT_INTUOSWRITE 6 | 51 | #define WACOM_REPORT_INTUOS_ID2 6 |
| 52 | #define WACOM_REPORT_INTUOSPAD 12 | 52 | #define WACOM_REPORT_INTUOSPAD 12 |
| 53 | #define WACOM_REPORT_INTUOS5PAD 3 | 53 | #define WACOM_REPORT_INTUOS5PAD 3 |
| 54 | #define WACOM_REPORT_DTUSPAD 21 | 54 | #define WACOM_REPORT_DTUSPAD 21 |
| @@ -70,6 +70,7 @@ | |||
| 70 | #define WACOM_REPORT_DEVICE_LIST 16 | 70 | #define WACOM_REPORT_DEVICE_LIST 16 |
| 71 | #define WACOM_REPORT_INTUOS_PEN 16 | 71 | #define WACOM_REPORT_INTUOS_PEN 16 |
| 72 | #define WACOM_REPORT_REMOTE 17 | 72 | #define WACOM_REPORT_REMOTE 17 |
| 73 | #define WACOM_REPORT_INTUOSHT2_ID 8 | ||
| 73 | 74 | ||
| 74 | /* device quirks */ | 75 | /* device quirks */ |
| 75 | #define WACOM_QUIRK_BBTOUCH_LOWRES 0x0001 | 76 | #define WACOM_QUIRK_BBTOUCH_LOWRES 0x0001 |
diff --git a/include/linux/hid.h b/include/linux/hid.h index 251a1d382e23..75b66eccc692 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h | |||
| @@ -168,6 +168,8 @@ struct hid_item { | |||
| 168 | #define HID_UP_MSVENDOR 0xff000000 | 168 | #define HID_UP_MSVENDOR 0xff000000 |
| 169 | #define HID_UP_CUSTOM 0x00ff0000 | 169 | #define HID_UP_CUSTOM 0x00ff0000 |
| 170 | #define HID_UP_LOGIVENDOR 0xffbc0000 | 170 | #define HID_UP_LOGIVENDOR 0xffbc0000 |
| 171 | #define HID_UP_LOGIVENDOR2 0xff090000 | ||
| 172 | #define HID_UP_LOGIVENDOR3 0xff430000 | ||
| 171 | #define HID_UP_LNVENDOR 0xffa00000 | 173 | #define HID_UP_LNVENDOR 0xffa00000 |
| 172 | #define HID_UP_SENSOR 0x00200000 | 174 | #define HID_UP_SENSOR 0x00200000 |
| 173 | 175 | ||
| @@ -563,6 +565,9 @@ struct hid_device { /* device report descriptor */ | |||
| 563 | wait_queue_head_t debug_wait; | 565 | wait_queue_head_t debug_wait; |
| 564 | }; | 566 | }; |
| 565 | 567 | ||
| 568 | #define to_hid_device(pdev) \ | ||
| 569 | container_of(pdev, struct hid_device, dev) | ||
| 570 | |||
| 566 | static inline void *hid_get_drvdata(struct hid_device *hdev) | 571 | static inline void *hid_get_drvdata(struct hid_device *hdev) |
| 567 | { | 572 | { |
| 568 | return dev_get_drvdata(&hdev->dev); | 573 | return dev_get_drvdata(&hdev->dev); |
| @@ -712,6 +717,9 @@ struct hid_driver { | |||
| 712 | struct device_driver driver; | 717 | struct device_driver driver; |
| 713 | }; | 718 | }; |
| 714 | 719 | ||
| 720 | #define to_hid_driver(pdrv) \ | ||
| 721 | container_of(pdrv, struct hid_driver, driver) | ||
| 722 | |||
| 715 | /** | 723 | /** |
| 716 | * hid_ll_driver - low level driver callbacks | 724 | * hid_ll_driver - low level driver callbacks |
| 717 | * @start: called on probe to start the device | 725 | * @start: called on probe to start the device |
