From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-dm3nam03on0101.outbound.protection.outlook.com ([104.47.41.101]:12851 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728858AbeJAHNd (ORCPT ); Mon, 1 Oct 2018 03:13:33 -0400 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Hans de Goede , Srinivas Pandruvada , Fernando D S Lima , Jiri Kosina , Sasha Levin Subject: [PATCH AUTOSEL 4.18 22/65] HID: sensor-hub: Restore fixup for Lenovo ThinkPad Helix 2 sensor hub report Date: Mon, 1 Oct 2018 00:38:16 +0000 Message-ID: <20181001003754.146961-22-alexander.levin@microsoft.com> References: <20181001003754.146961-1-alexander.levin@microsoft.com> In-Reply-To: <20181001003754.146961-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Hans de Goede [ Upstream commit ade573eb1e03d1ee5abcb3359b1259469ab6e8ed ] Commit b0f847e16c1e ("HID: hid-sensor-hub: Force logical minimum to 1 for power and report state") not only replaced the descriptor fixup done for devices with the HID_SENSOR_HUB_ENUM_QUIRK with a generic fix, but also accidentally removed the unrelated descriptor fixup for the Lenovo ThinkPad Helix 2 sensor hub. This commit restores this fixup. Restoring this fixup not only fixes the Lenovo ThinkPad Helix 2's sensors, but also the Lenovo ThinkPad 8's sensors. Fixes: b0f847e16c1e ("HID: hid-sensor-hub: Force logical minimum ...") Cc: Srinivas Pandruvada Cc: Fernando D S Lima Acked-by: Srinivas Pandruvada Signed-off-by: Hans de Goede Signed-off-by: Jiri Kosina Signed-off-by: Sasha Levin --- drivers/hid/hid-sensor-hub.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c index 50af72baa5ca..2b63487057c2 100644 --- a/drivers/hid/hid-sensor-hub.c +++ b/drivers/hid/hid-sensor-hub.c @@ -579,6 +579,28 @@ void sensor_hub_device_close(struct hid_sensor_hub_dev= ice *hsdev) } EXPORT_SYMBOL_GPL(sensor_hub_device_close); =20 +static __u8 *sensor_hub_report_fixup(struct hid_device *hdev, __u8 *rdesc, + unsigned int *rsize) +{ + /* + * Checks if the report descriptor of Thinkpad Helix 2 has a logical + * minimum for magnetic flux axis greater than the maximum. + */ + if (hdev->product =3D=3D USB_DEVICE_ID_TEXAS_INSTRUMENTS_LENOVO_YOGA && + *rsize =3D=3D 2558 && rdesc[913] =3D=3D 0x17 && rdesc[914] =3D=3D 0x40 &= & + rdesc[915] =3D=3D 0x81 && rdesc[916] =3D=3D 0x08 && + rdesc[917] =3D=3D 0x00 && rdesc[918] =3D=3D 0x27 && + rdesc[921] =3D=3D 0x07 && rdesc[922] =3D=3D 0x00) { + /* Sets negative logical minimum for mag x, y and z */ + rdesc[914] =3D rdesc[935] =3D rdesc[956] =3D 0xc0; + rdesc[915] =3D rdesc[936] =3D rdesc[957] =3D 0x7e; + rdesc[916] =3D rdesc[937] =3D rdesc[958] =3D 0xf7; + rdesc[917] =3D rdesc[938] =3D rdesc[959] =3D 0xff; + } + + return rdesc; +} + static int sensor_hub_probe(struct hid_device *hdev, const struct hid_device_id *id) { @@ -743,6 +765,7 @@ static struct hid_driver sensor_hub_driver =3D { .probe =3D sensor_hub_probe, .remove =3D sensor_hub_remove, .raw_event =3D sensor_hub_raw_event, + .report_fixup =3D sensor_hub_report_fixup, #ifdef CONFIG_PM .suspend =3D sensor_hub_suspend, .resume =3D sensor_hub_resume, --=20 2.17.1