Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3756024pxt; Tue, 10 Aug 2021 10:34:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzW7y8Hcm+Hq8o2AWW/XrL1ZUJ2Ld51is3R9KbBeB1otCSjA8Lu4lllQyufHsARwNFxDzRA X-Received: by 2002:a92:870b:: with SMTP id m11mr523671ild.132.1628616866801; Tue, 10 Aug 2021 10:34:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628616866; cv=none; d=google.com; s=arc-20160816; b=hm/Qs8z9jwcyQIFNILLqUbOdyMoA9pp1j+SrnD0+NLD3OxsGUbqPJXaKHiWocWEidT FWHmtWX8bsSBTnKZRNg1NvnvAG1Mk+wuxYB3SXioGVcHWCK/dhw6BlGqw8IanrzfGmOK c2bxTKn33TzOhhf1SfLjo6GYiRaxgNpZEnzuJrrK0/g8k18e2z4GXZC3GkD8uZ9S0hNt YT/XMhjIPCeITojm1/yKGrCivHwRtMnjfOLaR+ORZsY03XswbAkIFbvcBCHPjACfWmt+ r9YFBXFPWk1X6dU+OJe7BNK6ipu4sKY5Q+E17wkostF7assVBxlDpwRTxEPM04L4VnGw MIYg== 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=VCmDrRl7dYJ2GLSDJKXVc3er54WiBYKZGNyiBzmK7+Dt8i/StReOu6Jb7dj5GufinE fA14wPHMeL/UG69vJeGwzhgjFkmwZHA9oAFKbD6tuW4AAPciSRHmN/x56Qtm/WZvexNu C6A4nL6KLRKAE1oMeqbFE0GDwEfgRj6VenZTz8qiTyeCDVA2CLqu+xqmatEkeup92wQs vUr+uypeBYnXuVHT3XLbuXJV/n2NqikrTcRklyMR2ZFmkuMdzADhw10Ollm7W/dC+W6+ OMokDZYeN1rN/ltG/vEJux6IgeQq/rHIFyLH2GAdFFgV/vcNDc+nhdQ7RJxVrnt917jc djpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="BR/F+WVT"; 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 x26si11398473jai.112.2021.08.10.10.34.15; Tue, 10 Aug 2021 10:34:26 -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="BR/F+WVT"; 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 S229760AbhHJRdH (ORCPT + 99 others); Tue, 10 Aug 2021 13:33:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:33530 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231822AbhHJRcs (ORCPT ); Tue, 10 Aug 2021 13:32:48 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1F15F60F35; Tue, 10 Aug 2021 17:32:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1628616746; bh=ERX0QMlh4p07jgq2Pb5VAZYDdbT8+gREyoer7GZBAsw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BR/F+WVTzifaV8kI6F7JGN4IRon/E7Q2LRS3kCo77QWXxfsHfSXlqpVe5tCjETv+7 Kw40Jkop6+EJuNpE3Ms+Xos0RP29lhWJtAt2hI5L2IUnFEKBlBiS/stA+oMxNshQsP Rr0tnG7jXm4iyDZIa0zftFu+bWke8ZI5ORIZ/er0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Felipe Balbi , Maxim Devaev Subject: [PATCH 4.19 28/54] usb: gadget: f_hid: added GET_IDLE and SET_IDLE handlers Date: Tue, 10 Aug 2021 19:30:22 +0200 Message-Id: <20210810172945.099464175@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210810172944.179901509@linuxfoundation.org> References: <20210810172944.179901509@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);