Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp6383404ybv; Tue, 18 Feb 2020 15:56:33 -0800 (PST) X-Google-Smtp-Source: APXvYqxj7/ot9wJfafDyNDrNpejMiKPsoHhnh9cJ7txA61OUeSn/L/p6HAqEcC5c8Wy3VmHNvnou X-Received: by 2002:a05:6830:124b:: with SMTP id s11mr17241315otp.333.1582070193509; Tue, 18 Feb 2020 15:56:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582070193; cv=none; d=google.com; s=arc-20160816; b=YakNFsPxMv1UZfmzrsdcgrOGemriG4H9GEvBe49Gg9Vd0OOybubwWgo6RgQ8rLJV9r oYkHbnj8u9HPLq4/eNKCIIA6RMvyPtjOB9EgAvzJFkNGkbGsXHxq01dpxheYhnT7Mo7w KbF3rkC+DLxegnqUSWv7aYxj6S+zbN2e2W82rOezVL0tWeLtwKnh2/YpNlb0th7HYlpv acijRVXni6J3avZcbZwujD6QLIcCcJOAP/QJOjXi0u0S+k67gt2c9jG2nIgYbtVOg4ec wh65Qvs9TxsFOBhyqmKuFQL0mTv4l8Ry57ucz7c0dJAm+NI3I51ChOGZssZrfCaquBU9 kwXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=i3Cj6jCmg8Re6HCriaAPvQ8Bt49I/I/XDNaSdtPwqac=; b=OL2LXjE4Cx6kFYzhFk8V028vooH7tEYmCHQ1adhxhNyzvx7EX/6852S1TR0HGozSe4 mmPCXEJZxwv2L2i3WGklKTy4eiEb1mPS6Nn40q+9EjOp0yW23RPxEe6H8M/NnleJNBCU ipY2uBofkTk3ska09aQITmgjwcCgigIYkKn0ITLOdSAl6QssrDwsN17wWyRc/L8xiCxv U62msXtgcS1fn+JcpnrOq+bWLO6S4DNuP2aGiDqgd1EhmDgzhC8OQ34HKpqY2NkXkkGA 5zuSQVYzOCkFoAICJWigjJmx3jjMwz1RZmv9SBUOtdskQMc5mCyvZi8G+bss40Pkdhyt ez3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=iRujqTRI; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v7si8818154oic.208.2020.02.18.15.56.21; Tue, 18 Feb 2020 15:56:33 -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=@gmail.com header.s=20161025 header.b=iRujqTRI; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728111AbgBRX4O (ORCPT + 99 others); Tue, 18 Feb 2020 18:56:14 -0500 Received: from mail-pj1-f68.google.com ([209.85.216.68]:33701 "EHLO mail-pj1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727021AbgBRX4M (ORCPT ); Tue, 18 Feb 2020 18:56:12 -0500 Received: by mail-pj1-f68.google.com with SMTP id m7so1084015pjs.0; Tue, 18 Feb 2020 15:56:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=i3Cj6jCmg8Re6HCriaAPvQ8Bt49I/I/XDNaSdtPwqac=; b=iRujqTRISwGHP3FrC4HAQHsTqDffJ+OB/WFIZ8dqRIiGjwCWFYx4CFAxupO5MWnQXa d3rVvJuJ5l8SnEwqdviSYlBmdGgcTPNrJ+HoZjxBX3FD5N5KwNg6Uf6tqtQXnUncRDOq jLIj/xFZWknt1R9cPThVquMLLvfvrcYv2Uf7hJeZvSTPJhIDGCqxRfPs2bnTyR2epNpd UEgRa+bMcUOxFlXK1TxWRcNJZ4NPwbm3OoPBi0oKhBT+TiNY9TualZ12pSy/JimnF80b ZlgWdEDQin+GsFR91+qUeWx8iM7XRGb92vgjdn/oUQsUiZ2adrDA3p3WXLX9iW+rZHR0 dbnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=i3Cj6jCmg8Re6HCriaAPvQ8Bt49I/I/XDNaSdtPwqac=; b=FRQzFCpqYEiCnXHg9HTotBPEN1y2qaehazZlIQ4cszIwbADVeGgEWqvte0wVOKVLt9 9WM2cHyrneVOi0T0CpCIWJAVQDFkZgVX7tv3ltH9xIPVNSkGj3GjB+a/ZfeaNv6zyq8Q Zk3WXVWERbUTAMFcUHIAAzUOwZMn0J0ymSgq2M5sv20pJJhVCRBEF7dvRId7YmsfIKjJ XkPMn1196CjZECQOgZ4LXanW+MJ5C6Fo58DiTEVyqZ0AzYCal/U70ybDDjKWM06mBlhF jgwXe4QzuiuJFWTWDIWU+wqW9+dGqyDBRYuME7U3MIbYaN31A8fUbxfuL5dC6WccLVxp R/+w== X-Gm-Message-State: APjAAAUmms9zEHpqZN1QJl+sDpbFi3rrLJrC+clFUBD0IRMqMpeqpe9e E9oUdJxwROOqJLnbFPAugpU/PWa5bhc= X-Received: by 2002:a17:902:aa0b:: with SMTP id be11mr22317242plb.181.1582070172122; Tue, 18 Feb 2020 15:56:12 -0800 (PST) Received: from taoren-ubuntu-R90MNF91.thefacebook.com ([2620:10d:c090:500::5:1718]) by smtp.gmail.com with ESMTPSA id d3sm80558pjx.10.2020.02.18.15.56.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Feb 2020 15:56:11 -0800 (PST) From: rentao.bupt@gmail.com To: Felipe Balbi , Greg Kroah-Hartman , Joel Stanley , Andrew Jeffery , Benjamin Herrenschmidt , Chunfeng Yun , Colin Ian King , Stephen Boyd , Rob Herring , Mark Rutland , linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org, taoren@fb.com Cc: Tao Ren Subject: [PATCH 2/2] usb: gadget: aspeed: fixup usb1 device descriptor at init time Date: Tue, 18 Feb 2020 15:56:00 -0800 Message-Id: <20200218235600.6763-3-rentao.bupt@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200218235600.6763-1-rentao.bupt@gmail.com> References: <20200218235600.6763-1-rentao.bupt@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tao Ren This patch moves fixup-usb1-device-descriptor logic from get_descriptor handler to "ast_vhub_fixup_dev_desc" function so the device descriptor is only patched once (at vhub init time). Signed-off-by: Tao Ren --- drivers/usb/gadget/udc/aspeed-vhub/hub.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/usb/gadget/udc/aspeed-vhub/hub.c b/drivers/usb/gadget/udc/aspeed-vhub/hub.c index 4e3ef83283a6..b8bf54b12adc 100644 --- a/drivers/usb/gadget/udc/aspeed-vhub/hub.c +++ b/drivers/usb/gadget/udc/aspeed-vhub/hub.c @@ -76,13 +76,6 @@ static struct usb_device_descriptor ast_vhub_dev_desc = { .bNumConfigurations = 1, }; -/* Patches to the above when forcing USB1 mode */ -static void ast_vhub_patch_dev_desc_usb1(struct usb_device_descriptor *desc) -{ - desc->bcdUSB = cpu_to_le16(0x0100); - desc->bDeviceProtocol = 0; -} - /* * Configuration descriptor: same comments as above * regarding handling USB1 mode. @@ -316,10 +309,6 @@ static int ast_vhub_rep_desc(struct ast_vhub_ep *ep, if (len > dsize) len = dsize; - /* Patch it if forcing USB1 */ - if (desc_type == USB_DT_DEVICE && ep->vhub->force_usb1) - ast_vhub_patch_dev_desc_usb1(ep->buf); - /* Shoot it from the EP buffer */ return ast_vhub_reply(ep, NULL, len); } @@ -878,6 +867,15 @@ static void ast_vhub_fixup_dev_desc(struct ast_vhub *vhub) if (of_str[id]) ast_vhub_str_array[i].s = of_str[id]; } + + /* + * Update USB Release Number and Protocol code if vhub is running + * at USB 1.x speed. + */ + if (vhub->force_usb1) { + ast_vhub_dev_desc.bcdUSB = cpu_to_le16(0x0100); + ast_vhub_dev_desc.bDeviceProtocol = 0; + } } void ast_vhub_init_hub(struct ast_vhub *vhub) -- 2.17.1