Skip to content

Commit 15abf14

Browse files
committed
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
2 parents 2226fb5 + 849f5ae commit 15abf14

7 files changed

Lines changed: 56 additions & 44 deletions

File tree

‎drivers/input/joystick/iforce/iforce-usb.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,12 @@ static int iforce_usb_probe(struct usb_interface *intf,
201201
return -ENODEV;
202202

203203
epirq = &interface->endpoint[0].desc;
204+
if (!usb_endpoint_is_int_in(epirq))
205+
return -ENODEV;
206+
204207
epout = &interface->endpoint[1].desc;
208+
if (!usb_endpoint_is_int_out(epout))
209+
return -ENODEV;
205210

206211
iforce_usb = kzalloc(sizeof(*iforce_usb), GFP_KERNEL);
207212
if (!iforce_usb)

‎drivers/input/keyboard/Kconfig‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ config KEYBOARD_APPLESPI
7676
depends on ACPI && EFI
7777
depends on SPI
7878
depends on X86 || COMPILE_TEST
79+
depends on LEDS_CLASS
80+
select CRC16
7981
help
8082
Say Y here if you are running Linux on any Apple MacBook8,1 or later,
8183
or any MacBookPro13,* or MacBookPro14,*.

‎drivers/input/keyboard/applespi.c‎

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,10 @@ struct keyboard_protocol {
134134
* struct tp_finger - single trackpad finger structure, le16-aligned
135135
*
136136
* @origin: zero when switching track finger
137-
* @abs_x: absolute x coodinate
138-
* @abs_y: absolute y coodinate
139-
* @rel_x: relative x coodinate
140-
* @rel_y: relative y coodinate
137+
* @abs_x: absolute x coordinate
138+
* @abs_y: absolute y coordinate
139+
* @rel_x: relative x coordinate
140+
* @rel_y: relative y coordinate
141141
* @tool_major: tool area, major axis
142142
* @tool_minor: tool area, minor axis
143143
* @orientation: 16384 when point, else 15 bit angle
@@ -944,10 +944,14 @@ static inline int le16_to_int(__le16 x)
944944
static void applespi_debug_update_dimensions(struct applespi_data *applespi,
945945
const struct tp_finger *f)
946946
{
947-
applespi->tp_dim_min_x = min_t(int, applespi->tp_dim_min_x, f->abs_x);
948-
applespi->tp_dim_max_x = max_t(int, applespi->tp_dim_max_x, f->abs_x);
949-
applespi->tp_dim_min_y = min_t(int, applespi->tp_dim_min_y, f->abs_y);
950-
applespi->tp_dim_max_y = max_t(int, applespi->tp_dim_max_y, f->abs_y);
947+
applespi->tp_dim_min_x = min(applespi->tp_dim_min_x,
948+
le16_to_int(f->abs_x));
949+
applespi->tp_dim_max_x = max(applespi->tp_dim_max_x,
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));
951955
}
952956

953957
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)
14901494
size_t tp_len;
14911495

14921496
tp = &message->touchpad;
1493-
tp_len = sizeof(*tp) +
1494-
tp->number_of_fingers * sizeof(tp->fingers[0]);
1497+
tp_len = struct_size(tp, fingers, tp->number_of_fingers);
14951498

14961499
if (le16_to_cpu(message->length) + 2 != tp_len) {
14971500
dev_warn_ratelimited(&applespi->spi->dev,
@@ -1611,8 +1614,8 @@ static void applespi_save_bl_level(struct applespi_data *applespi,
16111614
efi_attr = EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS |
16121615
EFI_VARIABLE_RUNTIME_ACCESS;
16131616

1614-
sts = efivar_entry_set_safe(EFI_BL_LEVEL_NAME, efi_guid, efi_attr, true,
1615-
efi_data_len, &efi_data);
1617+
sts = efivar_entry_set_safe((efi_char16_t *)EFI_BL_LEVEL_NAME, efi_guid,
1618+
efi_attr, true, efi_data_len, &efi_data);
16161619
if (sts)
16171620
dev_warn(&applespi->spi->dev,
16181621
"Error saving backlight level to EFI vars: %d\n", sts);
@@ -1953,7 +1956,7 @@ static const struct acpi_device_id applespi_acpi_match[] = {
19531956
};
19541957
MODULE_DEVICE_TABLE(acpi, applespi_acpi_match);
19551958

1956-
const struct dev_pm_ops applespi_pm_ops = {
1959+
static const struct dev_pm_ops applespi_pm_ops = {
19571960
SET_SYSTEM_SLEEP_PM_OPS(applespi_suspend, applespi_resume)
19581961
.poweroff_late = applespi_poweroff_late,
19591962
};

‎drivers/input/mouse/elantech.c‎

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1827,6 +1827,31 @@ static int elantech_create_smbus(struct psmouse *psmouse,
18271827
leave_breadcrumbs);
18281828
}
18291829

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+
18301855
/**
18311856
* elantech_setup_smbus - called once the PS/2 devices are enumerated
18321857
* and decides to instantiate a SMBus InterTouch device.
@@ -1846,7 +1871,7 @@ static int elantech_setup_smbus(struct psmouse *psmouse,
18461871
* i2c_blacklist_pnp_ids.
18471872
* Old ICs are up to the user to decide.
18481873
*/
1849-
if (!ETP_NEW_IC_SMBUS_HOST_NOTIFY(info->fw_version) ||
1874+
if (!elantech_use_host_notify(psmouse, info) ||
18501875
psmouse_matches_pnp_id(psmouse, i2c_blacklist_pnp_ids))
18511876
return -ENXIO;
18521877
}
@@ -1866,34 +1891,6 @@ static int elantech_setup_smbus(struct psmouse *psmouse,
18661891
return 0;
18671892
}
18681893

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-
18971894
int elantech_init_smbus(struct psmouse *psmouse)
18981895
{
18991896
struct elantech_device_info info;

‎drivers/input/mouse/synaptics.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ static const char * const smbus_pnp_ids[] = {
182182
"LEN2055", /* E580 */
183183
"SYN3052", /* HP EliteBook 840 G4 */
184184
"SYN3221", /* HP 15-ay000 */
185+
"SYN323d", /* HP Spectre X360 13-w013dx */
185186
NULL
186187
};
187188

‎drivers/input/tablet/kbtab.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ static int kbtab_probe(struct usb_interface *intf, const struct usb_device_id *i
117117
if (intf->cur_altsetting->desc.bNumEndpoints < 1)
118118
return -ENODEV;
119119

120+
endpoint = &intf->cur_altsetting->endpoint[0].desc;
121+
if (!usb_endpoint_is_int_in(endpoint))
122+
return -ENODEV;
123+
120124
kbtab = kzalloc(sizeof(struct kbtab), GFP_KERNEL);
121125
input_dev = input_allocate_device();
122126
if (!kbtab || !input_dev)
@@ -155,8 +159,6 @@ static int kbtab_probe(struct usb_interface *intf, const struct usb_device_id *i
155159
input_set_abs_params(input_dev, ABS_Y, 0, 0x1750, 4, 0);
156160
input_set_abs_params(input_dev, ABS_PRESSURE, 0, 0xff, 0, 0);
157161

158-
endpoint = &intf->cur_altsetting->endpoint[0].desc;
159-
160162
usb_fill_int_urb(kbtab->irq, dev,
161163
usb_rcvintpipe(dev, endpoint->bEndpointAddress),
162164
kbtab->data, 8,

‎drivers/input/touchscreen/usbtouchscreen.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,6 +1659,8 @@ static int usbtouch_probe(struct usb_interface *intf,
16591659
if (!usbtouch || !input_dev)
16601660
goto out_free;
16611661

1662+
mutex_init(&usbtouch->pm_mutex);
1663+
16621664
type = &usbtouch_dev_info[id->driver_info];
16631665
usbtouch->type = type;
16641666
if (!type->process_pkt)

0 commit comments

Comments
 (0)