Probing a device with physical buttons modifies the static platform data
template directly, altering GPIO configuration for any devices probed
afterward.
Make the shared template read-only and adjust the per-device platform
data copy instead.
Fixes: 0b2c7a897378 ("HID: rmi: Make hid-rmi a transport driver for synaptics-rmi4")
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/hid/hid-rmi.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/hid/hid-rmi.c b/drivers/hid/hid-rmi.c
index a4406bc6af43..0a5d32dbe881 100644
--- a/drivers/hid/hid-rmi.c
+++ b/drivers/hid/hid-rmi.c
@@ -613,7 +613,7 @@ static int rmi_check_valid_report_id(struct hid_device *hdev, unsigned type,
return 0;
}
-static struct rmi_device_platform_data rmi_hid_pdata = {
+static const struct rmi_device_platform_data rmi_hid_pdata = {
.sensor_pdata = {
.sensor_type = rmi_sensor_touchpad,
.axis_align.flip_y = true,@@ -776,12 +776,12 @@ static int rmi_probe(struct hid_device *hdev, const struct hid_device_id *id)
return ret;
}
- if (data->device_flags & RMI_DEVICE_HAS_PHYS_BUTTONS)
- rmi_hid_pdata.gpio_data.disable = true;
-
data->xport.dev = hdev->dev.parent;
data->xport.pdata = rmi_hid_pdata;
data->xport.pdata.irq = data->rmi_irq;
+ if (data->device_flags & RMI_DEVICE_HAS_PHYS_BUTTONS)
+ data->xport.pdata.gpio_data.disable = true;
+
data->xport.proto_name = "hid";
data->xport.ops = &hid_rmi_ops;
--
2.56.0.679.gc527c65306-goog