Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2097216ybl; Thu, 30 Jan 2020 11:18:20 -0800 (PST) X-Google-Smtp-Source: APXvYqz42rGZz1HvOENAovx5q8B3IW4f6+xJN3LnmxsGbNUL8XLjhThiYATuC7FuIYeCd3zYo13M X-Received: by 2002:aca:1b17:: with SMTP id b23mr2212938oib.95.1580411899884; Thu, 30 Jan 2020 11:18:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580411899; cv=none; d=google.com; s=arc-20160816; b=azT1jyCZnrKwomGkdMG+kZ2Loepl2ILugV2RauhWXM+sZotr+MIunzOyXmh5NfBM4A xqQTgCJVKkc5EI0OWsjQSjj3oomnlPfyOITltsb47l2Idx7/z23ttAR7OzFwDH5bDoVx XrBpfuDdFnHfKMX5t5+3J3+Gh5O8fjs5x1CUjQfxFr2KcDqQu+zcBcZtF8H34JN1uTYb /FV17tYM4xfT/FLWDbysn8KcK3hVDk4ruEduxSGpv8znLlZkHDmQVSq06aIetVXE1rSU HrGVqtT2t+wx9isCdtWIV9Y/wLa6q0g8wmFiXiKxlYdTnUlK1e2o+SAZt1iKOqdP6cZ4 eSnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=VICDuxRzevtc8T007eQ6hHu20sNFwvau2l9eQ9+8K+w=; b=nJWodVZQjvEspOcNdpgUbSSOFyJoOoKibQYPfGl3GrAenrowC7KnpmMp3O1FwnB/ua PZfGETuFAi50rHhHfWFDJnpDBxpu+AGZGXVH5yQCIBp6Btb8PUfOkOmg3jjpv3UX5JK+ HxslKXsB28tKyEPWmRr1rG7bnWFnzyiRXLw5EmbyEPBZ4+gSmWuWloABi0hdAKAwqwLf vpY8Hf67fETq9D78t4xaKsm5PRzcMKf107PVnloh1smXX96g1RWP1Buk0Q0fSt0LSJCu 6oeAgxHcIWs4MF5GEzrHYiRT+trzHKKL37HjQpnxtin0XKHi7qGAgP9QUL0AyTr5WjIT oHCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=L3Ua14NK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r8si3546622ota.288.2020.01.30.11.18.06; Thu, 30 Jan 2020 11:18:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=L3Ua14NK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730734AbgA3Sn7 (ORCPT + 99 others); Thu, 30 Jan 2020 13:43:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:52808 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730718AbgA3Sny (ORCPT ); Thu, 30 Jan 2020 13:43:54 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EAB4B2082E; Thu, 30 Jan 2020 18:43:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580409834; bh=i+RdHtL84J3HaSt93jwmuWMUHa7Qj4PRLkFeyniDzSg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L3Ua14NKkMxKFtz1hCa8PEA9mIB+0lgWjXvRVbGJi734bQbp+xiaN0GmyeY/SnkYu gXNw9lI1e6MSrEGxWc/MavLwaEYQQS2Vc6kOJYOqts5SlPIHpfdkPhTY5VYolYrxRW 5bdRdP4Un8UdlLTU6bps3aqnjQFqBy/ASYMqlgs0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Balan , Jiri Kosina , Sasha Levin Subject: [PATCH 5.4 049/110] HID: Add quirk for incorrect input length on Lenovo Y720 Date: Thu, 30 Jan 2020 19:38:25 +0100 Message-Id: <20200130183620.976033235@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200130183613.810054545@linuxfoundation.org> References: <20200130183613.810054545@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pavel Balan [ Upstream commit fd0913768701612fc2b8ab9c8a5c019133e8d978 ] Apply it to the Lenovo Y720 gaming laptop I2C peripheral then. This fixes dmesg being flooded with errors visible on un-suspend in Linux Mint 19 Cinnamon. Example of error log: <...> [ 4.326588] i2c_hid i2c-ITE33D1:00: i2c_hid_get_input: incomplete report (2/4) [ 4.326845] i2c_hid i2c-ITE33D1:00: i2c_hid_get_input: incomplete report (2/4) [ 4.327095] i2c_hid i2c-ITE33D1:00: i2c_hid_get_input: incomplete report (2/4) [ 4.327341] i2c_hid i2c-ITE33D1:00: i2c_hid_get_input: incomplete report (2/4) [ 4.327609] i2c_hid i2c-ITE33D1:00: i2c_hid_get_input: incomplete report (2/4) <...> Example of fixed log (debug on) <...> [ 3731.333183] i2c_hid i2c-ITE33D1:00: input: 02 00 [ 3731.333581] i2c_hid i2c-ITE33D1:00: input: 02 00 [ 3731.333842] i2c_hid i2c-ITE33D1:00: input: 02 00 [ 3731.334107] i2c_hid i2c-ITE33D1:00: input: 02 00 [ 3731.334367] i2c_hid i2c-ITE33D1:00: input: 02 00 <...> [jkosina@suse.cz: rebase onto more recent codebase] Signed-off-by: Pavel Balan Signed-off-by: Jiri Kosina Signed-off-by: Sasha Levin --- drivers/hid/hid-ids.h | 1 + drivers/hid/i2c-hid/i2c-hid-core.c | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index 27795eac93e35..5fc82029a03b7 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -631,6 +631,7 @@ #define USB_VENDOR_ID_ITE 0x048d #define USB_DEVICE_ID_ITE_LENOVO_YOGA 0x8386 #define USB_DEVICE_ID_ITE_LENOVO_YOGA2 0x8350 +#define I2C_DEVICE_ID_ITE_LENOVO_LEGION_Y720 0x837a #define USB_DEVICE_ID_ITE_LENOVO_YOGA900 0x8396 #define USB_DEVICE_ID_ITE8595 0x8595 diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c index ac44bf752ff1f..479934f7d2411 100644 --- a/drivers/hid/i2c-hid/i2c-hid-core.c +++ b/drivers/hid/i2c-hid/i2c-hid-core.c @@ -49,6 +49,8 @@ #define I2C_HID_QUIRK_NO_IRQ_AFTER_RESET BIT(1) #define I2C_HID_QUIRK_BOGUS_IRQ BIT(4) #define I2C_HID_QUIRK_RESET_ON_RESUME BIT(5) +#define I2C_HID_QUIRK_BAD_INPUT_SIZE BIT(6) + /* flags */ #define I2C_HID_STARTED 0 @@ -177,6 +179,8 @@ static const struct i2c_hid_quirks { I2C_HID_QUIRK_BOGUS_IRQ }, { USB_VENDOR_ID_ALPS_JP, HID_ANY_ID, I2C_HID_QUIRK_RESET_ON_RESUME }, + { USB_VENDOR_ID_ITE, I2C_DEVICE_ID_ITE_LENOVO_LEGION_Y720, + I2C_HID_QUIRK_BAD_INPUT_SIZE }, { 0, 0 } }; @@ -498,9 +502,15 @@ static void i2c_hid_get_input(struct i2c_hid *ihid) } if ((ret_size > size) || (ret_size < 2)) { - dev_err(&ihid->client->dev, "%s: incomplete report (%d/%d)\n", - __func__, size, ret_size); - return; + if (ihid->quirks & I2C_HID_QUIRK_BAD_INPUT_SIZE) { + ihid->inbuf[0] = size & 0xff; + ihid->inbuf[1] = size >> 8; + ret_size = size; + } else { + dev_err(&ihid->client->dev, "%s: incomplete report (%d/%d)\n", + __func__, size, ret_size); + return; + } } i2c_hid_dbg(ihid, "input: %*ph\n", ret_size, ihid->inbuf); -- 2.20.1