diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2019-08-09 18:31:19 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-08-09 18:31:19 -0400 |
commit | 15abf14202a2fe7e5c5fc0e815587f45de4fd500 (patch) | |
tree | 69598abcefddb7670ce2c6505b7bcba54aae6291 | |
parent | 2226fb57a908330c7e2b83d363d450f2000de837 (diff) | |
parent | 849f5ae3a513c550cad741c68dd3d7eb2bcc2a2c (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
Pull input updates from Dmitry Torokhov:
- newer systems with Elan touchpads will be switched over to SMBus
- HP Spectre X360 will be using SMbus/RMI4
- checks for invalid USB descriptors in kbtab and iforce
- build fixes for applespi driver (misconfigs)
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input:
Input: iforce - add sanity checks
Input: applespi - use struct_size() helper
Input: kbtab - sanity check for endpoint type
Input: usbtouchscreen - initialize PM mutex before using it
Input: applespi - add dependency on LEDS_CLASS
Input: synaptics - enable RMI mode for HP Spectre X360
Input: elantech - annotate fall-through case in elantech_use_host_notify()
Input: elantech - enable SMBus on new (2018+) systems
Input: applespi - fix trivial typo in struct description
Input: applespi - select CRC16 module
Input: applespi - fix warnings detected by sparse
-rw-r--r-- | drivers/input/joystick/iforce/iforce-usb.c | 5 | ||||
-rw-r--r-- | drivers/input/keyboard/Kconfig | 2 | ||||
-rw-r--r-- | drivers/input/keyboard/applespi.c | 29 | ||||
-rw-r--r-- | drivers/input/mouse/elantech.c | 55 | ||||
-rw-r--r-- | drivers/input/mouse/synaptics.c | 1 | ||||
-rw-r--r-- | drivers/input/tablet/kbtab.c | 6 | ||||
-rw-r--r-- | drivers/input/touchscreen/usbtouchscreen.c | 2 |
7 files changed, 56 insertions, 44 deletions
diff --git a/drivers/input/joystick/iforce/iforce-usb.c b/drivers/input/joystick/iforce/iforce-usb.c index 29abfeeef9a5..6c554c11a7ac 100644 --- a/drivers/input/joystick/iforce/iforce-usb.c +++ b/drivers/input/joystick/iforce/iforce-usb.c | |||
@@ -201,7 +201,12 @@ static int iforce_usb_probe(struct usb_interface *intf, | |||
201 | return -ENODEV; | 201 | return -ENODEV; |
202 | 202 | ||
203 | epirq = &interface->endpoint[0].desc; | 203 | epirq = &interface->endpoint[0].desc; |
204 | if (!usb_endpoint_is_int_in(epirq)) | ||
205 | return -ENODEV; | ||
206 | |||
204 | epout = &interface->endpoint[1].desc; | 207 | epout = &interface->endpoint[1].desc; |
208 | if (!usb_endpoint_is_int_out(epout)) | ||
209 | return -ENODEV; | ||
205 | 210 | ||
206 | iforce_usb = kzalloc(sizeof(*iforce_usb), GFP_KERNEL); | 211 | iforce_usb = kzalloc(sizeof(*iforce_usb), GFP_KERNEL); |
207 | if (!iforce_usb) | 212 | if (!iforce_usb) |
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig index 8e9c3ea9d5e7..90e8a7f2f07c 100644 --- a/drivers/input/keyboard/Kconfig +++ b/drivers/input/keyboard/Kconfig | |||
@@ -76,6 +76,8 @@ config KEYBOARD_APPLESPI | |||
76 | depends on ACPI && EFI | 76 | depends on ACPI && EFI |
77 | depends on SPI | 77 | depends on SPI |
78 | depends on X86 || COMPILE_TEST | 78 | depends on X86 || COMPILE_TEST |
79 | depends on LEDS_CLASS | ||
80 | select CRC16 | ||
79 | help | 81 | help |
80 | Say Y here if you are running Linux on any Apple MacBook8,1 or later, | 82 | Say Y here if you are running Linux on any Apple MacBook8,1 or later, |
81 | or any MacBookPro13,* or MacBookPro14,*. | 83 | or any MacBookPro13,* or MacBookPro14,*. |
diff --git a/drivers/input/keyboard/applespi.c b/drivers/input/keyboard/applespi.c index 548737e7aeda..584289b67fb3 100644 --- a/drivers/input/keyboard/applespi.c +++ b/drivers/input/keyboard/applespi.c | |||
@@ -134,10 +134,10 @@ struct keyboard_protocol { | |||
134 | * struct tp_finger - single trackpad finger structure, le16-aligned | 134 | * struct tp_finger - single trackpad finger structure, le16-aligned |
135 | * | 135 | * |
136 | * @origin: zero when switching track finger | 136 | * @origin: zero when switching track finger |
137 | * @abs_x: absolute x coodinate | 137 | * @abs_x: absolute x coordinate |
138 | * @abs_y: absolute y coodinate | 138 | * @abs_y: absolute y coordinate |
139 | * @rel_x: relative x coodinate | 139 | * @rel_x: relative x coordinate |
140 | * @rel_y: relative y coodinate | 140 | * @rel_y: relative y coordinate |
141 | * @tool_major: tool area, major axis | 141 | * @tool_major: tool area, major axis |
142 | * @tool_minor: tool area, minor axis | 142 | * @tool_minor: tool area, minor axis |
143 | * @orientation: 16384 when point, else 15 bit angle | 143 | * @orientation: 16384 when point, else 15 bit angle |
@@ -944,10 +944,14 @@ static inline int le16_to_int(__le16 x) | |||
944 | static void applespi_debug_update_dimensions(struct applespi_data *applespi, | 944 | static void applespi_debug_update_dimensions(struct applespi_data *applespi, |
945 | const struct tp_finger *f) | 945 | const struct tp_finger *f) |
946 | { | 946 | { |
947 | applespi->tp_dim_min_x = min_t(int, applespi->tp_dim_min_x, f->abs_x); | 947 | applespi->tp_dim_min_x = min(applespi->tp_dim_min_x, |
948 | applespi->tp_dim_max_x = max_t(int, applespi->tp_dim_max_x, f->abs_x); | 948 | le16_to_int(f->abs_x)); |
949 | applespi->tp_dim_min_y = min_t(int, applespi->tp_dim_min_y, f->abs_y); | 949 | applespi->tp_dim_max_x = max(applespi->tp_dim_max_x, |
950 | applespi->tp_dim_max_y = max_t(int, applespi->tp_dim_max_y, f->abs_y); | 950 | le16_to_int(f->abs_x)); |
951 | applespi->tp_dim_min_y = min(applespi->tp_dim_min_y, | ||
952 | le16_to_int(f->abs_y)); | ||
953 | applespi->tp_dim_max_y = max(applespi->tp_dim_max_y, | ||
954 | le16_to_int(f->abs_y)); | ||
951 | } | 955 | } |
952 | 956 | ||
953 | static int applespi_tp_dim_open(struct inode *inode, struct file *file) | 957 | static int applespi_tp_dim_open(struct inode *inode, struct file *file) |
@@ -1490,8 +1494,7 @@ static void applespi_got_data(struct applespi_data *applespi) | |||
1490 | size_t tp_len; | 1494 | size_t tp_len; |
1491 | 1495 | ||
1492 | tp = &message->touchpad; | 1496 | tp = &message->touchpad; |
1493 | tp_len = sizeof(*tp) + | 1497 | tp_len = struct_size(tp, fingers, tp->number_of_fingers); |
1494 | tp->number_of_fingers * sizeof(tp->fingers[0]); | ||
1495 | 1498 | ||
1496 | if (le16_to_cpu(message->length) + 2 != tp_len) { | 1499 | if (le16_to_cpu(message->length) + 2 != tp_len) { |
1497 | dev_warn_ratelimited(&applespi->spi->dev, | 1500 | dev_warn_ratelimited(&applespi->spi->dev, |
@@ -1611,8 +1614,8 @@ static void applespi_save_bl_level(struct applespi_data *applespi, | |||
1611 | efi_attr = EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | | 1614 | efi_attr = EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | |
1612 | EFI_VARIABLE_RUNTIME_ACCESS; | 1615 | EFI_VARIABLE_RUNTIME_ACCESS; |
1613 | 1616 | ||
1614 | sts = efivar_entry_set_safe(EFI_BL_LEVEL_NAME, efi_guid, efi_attr, true, | 1617 | sts = efivar_entry_set_safe((efi_char16_t *)EFI_BL_LEVEL_NAME, efi_guid, |
1615 | efi_data_len, &efi_data); | 1618 | efi_attr, true, efi_data_len, &efi_data); |
1616 | if (sts) | 1619 | if (sts) |
1617 | dev_warn(&applespi->spi->dev, | 1620 | dev_warn(&applespi->spi->dev, |
1618 | "Error saving backlight level to EFI vars: %d\n", sts); | 1621 | "Error saving backlight level to EFI vars: %d\n", sts); |
@@ -1953,7 +1956,7 @@ static const struct acpi_device_id applespi_acpi_match[] = { | |||
1953 | }; | 1956 | }; |
1954 | MODULE_DEVICE_TABLE(acpi, applespi_acpi_match); | 1957 | MODULE_DEVICE_TABLE(acpi, applespi_acpi_match); |
1955 | 1958 | ||
1956 | const struct dev_pm_ops applespi_pm_ops = { | 1959 | static const struct dev_pm_ops applespi_pm_ops = { |
1957 | SET_SYSTEM_SLEEP_PM_OPS(applespi_suspend, applespi_resume) | 1960 | SET_SYSTEM_SLEEP_PM_OPS(applespi_suspend, applespi_resume) |
1958 | .poweroff_late = applespi_poweroff_late, | 1961 | .poweroff_late = applespi_poweroff_late, |
1959 | }; | 1962 | }; |
diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c index 2d8434b7b623..04fe43440a3c 100644 --- a/drivers/input/mouse/elantech.c +++ b/drivers/input/mouse/elantech.c | |||
@@ -1827,6 +1827,31 @@ static int elantech_create_smbus(struct psmouse *psmouse, | |||
1827 | leave_breadcrumbs); | 1827 | leave_breadcrumbs); |
1828 | } | 1828 | } |
1829 | 1829 | ||
1830 | static bool elantech_use_host_notify(struct psmouse *psmouse, | ||
1831 | struct elantech_device_info *info) | ||
1832 | { | ||
1833 | if (ETP_NEW_IC_SMBUS_HOST_NOTIFY(info->fw_version)) | ||
1834 | return true; | ||
1835 | |||
1836 | switch (info->bus) { | ||
1837 | case ETP_BUS_PS2_ONLY: | ||
1838 | /* expected case */ | ||
1839 | break; | ||
1840 | case ETP_BUS_SMB_HST_NTFY_ONLY: | ||
1841 | case ETP_BUS_PS2_SMB_HST_NTFY: | ||
1842 | /* SMbus implementation is stable since 2018 */ | ||
1843 | if (dmi_get_bios_year() >= 2018) | ||
1844 | return true; | ||
1845 | /* fall through */ | ||
1846 | default: | ||
1847 | psmouse_dbg(psmouse, | ||
1848 | "Ignoring SMBus bus provider %d\n", info->bus); | ||
1849 | break; | ||
1850 | } | ||
1851 | |||
1852 | return false; | ||
1853 | } | ||
1854 | |||
1830 | /** | 1855 | /** |
1831 | * elantech_setup_smbus - called once the PS/2 devices are enumerated | 1856 | * elantech_setup_smbus - called once the PS/2 devices are enumerated |
1832 | * and decides to instantiate a SMBus InterTouch device. | 1857 | * and decides to instantiate a SMBus InterTouch device. |
@@ -1846,7 +1871,7 @@ static int elantech_setup_smbus(struct psmouse *psmouse, | |||
1846 | * i2c_blacklist_pnp_ids. | 1871 | * i2c_blacklist_pnp_ids. |
1847 | * Old ICs are up to the user to decide. | 1872 | * Old ICs are up to the user to decide. |
1848 | */ | 1873 | */ |
1849 | if (!ETP_NEW_IC_SMBUS_HOST_NOTIFY(info->fw_version) || | 1874 | if (!elantech_use_host_notify(psmouse, info) || |
1850 | psmouse_matches_pnp_id(psmouse, i2c_blacklist_pnp_ids)) | 1875 | psmouse_matches_pnp_id(psmouse, i2c_blacklist_pnp_ids)) |
1851 | return -ENXIO; | 1876 | return -ENXIO; |
1852 | } | 1877 | } |
@@ -1866,34 +1891,6 @@ static int elantech_setup_smbus(struct psmouse *psmouse, | |||
1866 | return 0; | 1891 | return 0; |
1867 | } | 1892 | } |
1868 | 1893 | ||
1869 | static bool elantech_use_host_notify(struct psmouse *psmouse, | ||
1870 | struct elantech_device_info *info) | ||
1871 | { | ||
1872 | if (ETP_NEW_IC_SMBUS_HOST_NOTIFY(info->fw_version)) | ||
1873 | return true; | ||
1874 | |||
1875 | switch (info->bus) { | ||
1876 | case ETP_BUS_PS2_ONLY: | ||
1877 | /* expected case */ | ||
1878 | break; | ||
1879 | case ETP_BUS_SMB_ALERT_ONLY: | ||
1880 | /* fall-through */ | ||
1881 | case ETP_BUS_PS2_SMB_ALERT: | ||
1882 | psmouse_dbg(psmouse, "Ignoring SMBus provider through alert protocol.\n"); | ||
1883 | break; | ||
1884 | case ETP_BUS_SMB_HST_NTFY_ONLY: | ||
1885 | /* fall-through */ | ||
1886 | case ETP_BUS_PS2_SMB_HST_NTFY: | ||
1887 | return true; | ||
1888 | default: | ||
1889 | psmouse_dbg(psmouse, | ||
1890 | "Ignoring SMBus bus provider %d.\n", | ||
1891 | info->bus); | ||
1892 | } | ||
1893 | |||
1894 | return false; | ||
1895 | } | ||
1896 | |||
1897 | int elantech_init_smbus(struct psmouse *psmouse) | 1894 | int elantech_init_smbus(struct psmouse *psmouse) |
1898 | { | 1895 | { |
1899 | struct elantech_device_info info; | 1896 | struct elantech_device_info info; |
diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c index b1956ed4c0dd..46bbe99d6511 100644 --- a/drivers/input/mouse/synaptics.c +++ b/drivers/input/mouse/synaptics.c | |||
@@ -182,6 +182,7 @@ static const char * const smbus_pnp_ids[] = { | |||
182 | "LEN2055", /* E580 */ | 182 | "LEN2055", /* E580 */ |
183 | "SYN3052", /* HP EliteBook 840 G4 */ | 183 | "SYN3052", /* HP EliteBook 840 G4 */ |
184 | "SYN3221", /* HP 15-ay000 */ | 184 | "SYN3221", /* HP 15-ay000 */ |
185 | "SYN323d", /* HP Spectre X360 13-w013dx */ | ||
185 | NULL | 186 | NULL |
186 | }; | 187 | }; |
187 | 188 | ||
diff --git a/drivers/input/tablet/kbtab.c b/drivers/input/tablet/kbtab.c index 04b85571f41e..aa577898e952 100644 --- a/drivers/input/tablet/kbtab.c +++ b/drivers/input/tablet/kbtab.c | |||
@@ -117,6 +117,10 @@ static int kbtab_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
117 | if (intf->cur_altsetting->desc.bNumEndpoints < 1) | 117 | if (intf->cur_altsetting->desc.bNumEndpoints < 1) |
118 | return -ENODEV; | 118 | return -ENODEV; |
119 | 119 | ||
120 | endpoint = &intf->cur_altsetting->endpoint[0].desc; | ||
121 | if (!usb_endpoint_is_int_in(endpoint)) | ||
122 | return -ENODEV; | ||
123 | |||
120 | kbtab = kzalloc(sizeof(struct kbtab), GFP_KERNEL); | 124 | kbtab = kzalloc(sizeof(struct kbtab), GFP_KERNEL); |
121 | input_dev = input_allocate_device(); | 125 | input_dev = input_allocate_device(); |
122 | if (!kbtab || !input_dev) | 126 | if (!kbtab || !input_dev) |
@@ -155,8 +159,6 @@ static int kbtab_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
155 | input_set_abs_params(input_dev, ABS_Y, 0, 0x1750, 4, 0); | 159 | input_set_abs_params(input_dev, ABS_Y, 0, 0x1750, 4, 0); |
156 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, 0xff, 0, 0); | 160 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, 0xff, 0, 0); |
157 | 161 | ||
158 | endpoint = &intf->cur_altsetting->endpoint[0].desc; | ||
159 | |||
160 | usb_fill_int_urb(kbtab->irq, dev, | 162 | usb_fill_int_urb(kbtab->irq, dev, |
161 | usb_rcvintpipe(dev, endpoint->bEndpointAddress), | 163 | usb_rcvintpipe(dev, endpoint->bEndpointAddress), |
162 | kbtab->data, 8, | 164 | kbtab->data, 8, |
diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c index a2cec6cacf57..16d70201de4a 100644 --- a/drivers/input/touchscreen/usbtouchscreen.c +++ b/drivers/input/touchscreen/usbtouchscreen.c | |||
@@ -1659,6 +1659,8 @@ static int usbtouch_probe(struct usb_interface *intf, | |||
1659 | if (!usbtouch || !input_dev) | 1659 | if (!usbtouch || !input_dev) |
1660 | goto out_free; | 1660 | goto out_free; |
1661 | 1661 | ||
1662 | mutex_init(&usbtouch->pm_mutex); | ||
1663 | |||
1662 | type = &usbtouch_dev_info[id->driver_info]; | 1664 | type = &usbtouch_dev_info[id->driver_info]; |
1663 | usbtouch->type = type; | 1665 | usbtouch->type = type; |
1664 | if (!type->process_pkt) | 1666 | if (!type->process_pkt) |