Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3760032pxt; Tue, 10 Aug 2021 10:40:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz2toRCEdsz3tdT3T3G3Bex/354yjYbSzGQK0m/iX5VE7wx27kcOdq1nFYlFyCvri+eQP8D X-Received: by 2002:a17:906:7b53:: with SMTP id n19mr28820021ejo.14.1628617227850; Tue, 10 Aug 2021 10:40:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628617227; cv=none; d=google.com; s=arc-20160816; b=KZr9bpQ9eKbOp1Qzaj1lyGhOM9mKB0mmBOSi8ARB9/F+PoWBoO+j0D9fDbkIDhASzD nO28Sx1zsnU9AWhYIuyvg9m/jdCedP4pcWPt41WpNeGSz9zE56lQLBJ9zTOEAhyi1ed+ ObDQWNJlYDon8JA8WwySucosnillCSCoXCUqE1ZHzvNBsWUn04Lwusx2KdTeh/MbjYG0 T/WIDsnKRTg6M3eJgoTKp7ffvBjmagt468HLdGMeAl/dprmdPJeSNluZfgJsv9scXCrQ 9fTa1skX8YSv96+D+iANiImEh678YcvCdEB9v7e1PN2o+ETmDVsDhCV944TitSWQ4f6r L4xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=tvCVCb3AXsjNP2sYbJlJNzRa/ZdggdWxv+mAwzy5xKw=; b=RoY95FPaNmZqaCE+mqCXuqGMzUwT5IvZwsay8WHNbNdXNGfeTwnIUGO2Zq0KJws/6N d7o9oTO2Lw1N8UaysuzoBJ1H+TduXtsllv/HEIzuVfrCw1bAt4scRAE7NPw3GUWOmwTl dD6icuMPuqoItw+Mfb+aBbFIKeT7SIUBxW9iBFCwxE2JK48Ku5Xo7+2ab4lacRLfNDRN 7YPOjZ3bP+oKkPJK6YHSZEAQiLI8Lhtow9LZE2uh1pBULvv84Uakp3MJCY2n4efBog3v Wy77LbHuIYcRnYXM9W4lXEL/f8Er9ekA37RzalY5bbIgiF6/Ify0PutX3C8co5RsU4HE rV1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=y6l35nNV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i5si21546719ejd.224.2021.08.10.10.40.02; Tue, 10 Aug 2021 10:40:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=y6l35nNV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234414AbhHJRhY (ORCPT + 99 others); Tue, 10 Aug 2021 13:37:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:42464 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233105AbhHJRfm (ORCPT ); Tue, 10 Aug 2021 13:35:42 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4C8DD61107; Tue, 10 Aug 2021 17:35:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1628616910; bh=ERX0QMlh4p07jgq2Pb5VAZYDdbT8+gREyoer7GZBAsw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=y6l35nNVe20XEfhlMtm5EYK2A+oNrgv6iW6bSIrlw8uFf61OQq1OKXo0ZHJNbFyfM W4l6kmyKEFkVI5HWrdSyPPvcfddBt6fZPw4WC/gWSk5QCeg+GQ4TJYmi+1eCKPYDyU 3/5fqmNqfTDXZcl8VleW1+mDjVxVSn3aDS8IJzs0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Felipe Balbi , Maxim Devaev Subject: [PATCH 5.4 45/85] usb: gadget: f_hid: added GET_IDLE and SET_IDLE handlers Date: Tue, 10 Aug 2021 19:30:18 +0200 Message-Id: <20210810172949.761894531@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210810172948.192298392@linuxfoundation.org> References: <20210810172948.192298392@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Maxim Devaev commit afcff6dc690e24d636a41fd4bee6057e7c70eebd upstream. The USB HID standard declares mandatory support for GET_IDLE and SET_IDLE requests for Boot Keyboard. Most hosts can handle their absence, but others like some old/strange UEFIs and BIOSes consider this a critical error and refuse to work with f_hid. This primitive implementation of saving and returning idle is sufficient to meet the requirements of the standard and these devices. Acked-by: Felipe Balbi Cc: stable Signed-off-by: Maxim Devaev Link: https://lore.kernel.org/r/20210721180351.129450-1-mdevaev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/function/f_hid.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) --- a/drivers/usb/gadget/function/f_hid.c +++ b/drivers/usb/gadget/function/f_hid.c @@ -41,6 +41,7 @@ struct f_hidg { unsigned char bInterfaceSubClass; unsigned char bInterfaceProtocol; unsigned char protocol; + unsigned char idle; unsigned short report_desc_length; char *report_desc; unsigned short report_length; @@ -529,6 +530,14 @@ static int hidg_setup(struct usb_functio goto respond; break; + case ((USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8 + | HID_REQ_GET_IDLE): + VDBG(cdev, "get_idle\n"); + length = min_t(unsigned int, length, 1); + ((u8 *) req->buf)[0] = hidg->idle; + goto respond; + break; + case ((USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8 | HID_REQ_SET_REPORT): VDBG(cdev, "set_report | wLength=%d\n", ctrl->wLength); @@ -552,6 +561,14 @@ static int hidg_setup(struct usb_functio goto stall; break; + case ((USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8 + | HID_REQ_SET_IDLE): + VDBG(cdev, "set_idle\n"); + length = 0; + hidg->idle = value; + goto respond; + break; + case ((USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_INTERFACE) << 8 | USB_REQ_GET_DESCRIPTOR): switch (value >> 8) { @@ -779,6 +796,7 @@ static int hidg_bind(struct usb_configur hidg_interface_desc.bInterfaceSubClass = hidg->bInterfaceSubClass; hidg_interface_desc.bInterfaceProtocol = hidg->bInterfaceProtocol; hidg->protocol = HID_REPORT_PROTOCOL; + hidg->idle = 1; hidg_ss_in_ep_desc.wMaxPacketSize = cpu_to_le16(hidg->report_length); hidg_ss_in_comp_desc.wBytesPerInterval = cpu_to_le16(hidg->report_length);