From patchwork Thu Feb 27 13:37:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 230249 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 82365C52D26 for ; Thu, 27 Feb 2020 14:32:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 508F424688 for ; Thu, 27 Feb 2020 14:32:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582813958; bh=6JQIeC3p571KwbSsfp3AYlA5E/yDzEXxt3O17tixMHw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Uebu3V5A29zPHPSvN1CyKWza8+fSTUhJYQnYYWEd1z3ma8SqLdiRIOiJvI244lrQE 3+cYEGS7fgSgHNXpHanGvfYPBOBRJZNhCEskkTEu8T5ZMO5eWdLucy1tYI3j/37Kx5 XWwv7i4aX75g4bhszrt2N+KIUrCUAw5pZj5rWKPE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732714AbgB0OBw (ORCPT ); Thu, 27 Feb 2020 09:01:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:36126 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733008AbgB0OBv (ORCPT ); Thu, 27 Feb 2020 09:01:51 -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 3E28921556; Thu, 27 Feb 2020 14:01:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582812110; bh=6JQIeC3p571KwbSsfp3AYlA5E/yDzEXxt3O17tixMHw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BafJueaBzHzI6IMSDKMid9Hp4YKfKwEDV74p+E6UTmyS6k6Cv7zvHeRcvZZvuMTx9 e7PH/5iGR350+ifO4arvttjT+HiZrO0lLqCwau57hvh/8BsMZeCzuoSbGMezHhIb9i El26uzSDGa5k3QVMAm8Sn1KlkvdwoHvgCm4hlY7Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jack Pham , Felipe Balbi Subject: [PATCH 4.14 225/237] usb: gadget: composite: Fix bMaxPower for SuperSpeedPlus Date: Thu, 27 Feb 2020 14:37:19 +0100 Message-Id: <20200227132312.689255909@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200227132255.285644406@linuxfoundation.org> References: <20200227132255.285644406@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Jack Pham commit c724417baf162bd3e035659e22cdf990cfb0d917 upstream. SuperSpeedPlus peripherals must report their bMaxPower of the configuration descriptor in units of 8mA as per the USB 3.2 specification. The current switch statement in encode_bMaxPower() only checks for USB_SPEED_SUPER but not USB_SPEED_SUPER_PLUS so the latter falls back to USB 2.0 encoding which uses 2mA units. Replace the switch with a simple if/else. Fixes: eae5820b852f ("usb: gadget: composite: Write SuperSpeedPlus config descriptors") Signed-off-by: Jack Pham Signed-off-by: Felipe Balbi Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/composite.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -440,12 +440,10 @@ static u8 encode_bMaxPower(enum usb_devi val = CONFIG_USB_GADGET_VBUS_DRAW; if (!val) return 0; - switch (speed) { - case USB_SPEED_SUPER: - return DIV_ROUND_UP(val, 8); - default: + if (speed < USB_SPEED_SUPER) return DIV_ROUND_UP(val, 2); - } + else + return DIV_ROUND_UP(val, 8); } static int config_buf(struct usb_configuration *config,