Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1838270ybh; Sun, 15 Mar 2020 12:17:58 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtrFGC95BmYrM7Q0XcGMu0hiI2Sz8UobtnhMxBQA2T7bDxIVQ+N4rTS9VyAJdq2cZy9SU67 X-Received: by 2002:a54:400a:: with SMTP id x10mr4413738oie.37.1584299878160; Sun, 15 Mar 2020 12:17:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584299878; cv=none; d=google.com; s=arc-20160816; b=WO8eK8B/cd9kAZuNIAudQgmeCSREyRoBghndMFw4yJYq1IYWy60aj06QjsuQSLt5EM 5Rrq2DTFiW0tEIM3/BlgnKGaTfAn3lVhfsoOswRK5ZeDU0g6QhR4sQ+Ywrd/MByQh9lX 2RBb6fM3fY/WyhWxBB0ZZ9mT8rLZsN4Q42qEL5Nw+X9QWjgYGeo8PMDTG2/BhdKNQ2VB OlTcolpPVhWaTLXYAXpWLM+bLaFiBzoi45kxF7CHWFQChqTkX9wvSxLxfRzZig1yClPA W4nXd6Z4I65fxU1WfhiceEzq2qCWs2c6PmVxTLOTiKJNDlLoEb3mn7IpkopbWjdb9Utn rGPg== 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=3ftgzhaTcHumF1wl+zxzORyRVylT4QiROgG963NJrxE=; b=MnPNLpM4oV8w2Nfi7+RD5EPAhokCTLsHQvQyNU/bGAn45/om3zZ4DijwvsbsDQNWOx Yt+hEFE52P/FLi6isNBV/zz69jvswMIaLgGhnMtDCc71g4w5sP7v1gTpGb9gKZb2HseI MfM0c9LyIt1TVCP40KwTYrVQfR8Bl9jYuzsbrFAhcJ0st2xXspr2JW77rflE75FnDIxS NvQbU1PJCI5MoWBHktTh0eHmhGIG5ZI92L+xRgHWv69BoiB0s5MdLQQGKIXi6s8tExGO 5KHCzZKbHrJkmvFHV6g2hU+mt21XZvQb7uxOV7NWkOgh5uZ5RD/yLETGOQTzIU8GDP2O MMyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hdX3ezZp; 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 k1si3678342otr.52.2020.03.15.12.17.46; Sun, 15 Mar 2020 12:17:58 -0700 (PDT) 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=hdX3ezZp; 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 S1729017AbgCOTQz (ORCPT + 99 others); Sun, 15 Mar 2020 15:16:55 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:36456 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729008AbgCOTQu (ORCPT ); Sun, 15 Mar 2020 15:16:50 -0400 Received: by mail-pg1-f194.google.com with SMTP id z4so2581051pgu.3; Sun, 15 Mar 2020 12:16:49 -0700 (PDT) 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=3ftgzhaTcHumF1wl+zxzORyRVylT4QiROgG963NJrxE=; b=hdX3ezZpi2YDHwnAS48I6J3zhHF57KyVQEBULjcqbwkHFINN8RzdAuYHF+cUFowEes mdKXHoyh+/52Pe0RTFxqWSExz0pu/J1uqEIGvu19LZNHKRFNhFNrAjO0vGFl7ju3D8N8 77cefLPQeOOi6MRIAHATQ6Av1T4CfP7YABlRNQ3VuqYtLcHIensCUFskH3AjIFmx2/No fGKi2qeuqm79wR+0YyTzJx+aLGCbK/llUxsSLHGJ1DP2USQs7vPJ4jdTOmPbFlxHNCgo jKyeGjUFj/HvPHvWh6CeAiC2JdKCGtyNRN6JWKOVXQOdGlv8azQgRm7fvYfyDcK+L3sy iEAw== 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=3ftgzhaTcHumF1wl+zxzORyRVylT4QiROgG963NJrxE=; b=lh/K1iXLKs+NVkCLpiHeD5cvogUHUo73rJW0997Zbv7u81Pwauj3MTRyzqM7nEYCAJ oh+LAck3zYNyfEyAOp1mSOfIf8Pk6+zM3W0LHkG5oGBCAfgFSVEaeBY+k74mzey7vfGb 7AWQtOJR4/iXvuInLoOhWVhQbYjw5Co8xcW2A9qgA5y00ulrMO2itvsuC6JvXunsi0Pi Y10qZgxCK6fvo6ELUyR0lu/7SuLXKkQBIbjllx+rKWqKJ3WyS3UbNxIUCCUtpCc/rP3b bos67ncEDLjp2F09+HRObc3lv6fUQMEkN191d4aaYwqFoFw5QlScOpIZ/Xmw0hiyOjni 05XA== X-Gm-Message-State: ANhLgQ2HFn4p7JZo8Wka6toUKxrmSL6yEB9vCt/ZuJ3tDZIshCZeleyE NTGGJxwYC46IT31pojXCSoA= X-Received: by 2002:a63:3d45:: with SMTP id k66mr23203589pga.56.1584299808334; Sun, 15 Mar 2020 12:16:48 -0700 (PDT) Received: from taoren-ubuntu-R90MNF91.thefacebook.com (c-24-4-25-55.hsd1.ca.comcast.net. [24.4.25.55]) by smtp.gmail.com with ESMTPSA id 13sm61431882pgo.13.2020.03.15.12.16.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Mar 2020 12:16:47 -0700 (PDT) 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 v2 5/6] usb: gadget: aspeed: fixup usb1 device descriptor at init time Date: Sun, 15 Mar 2020 12:16:31 -0700 Message-Id: <20200315191632.12536-6-rentao.bupt@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200315191632.12536-1-rentao.bupt@gmail.com> References: <20200315191632.12536-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 patch-usb1-dev-desc logic from get-descriptor handler to "ast_vhub_fixup_usb1_dev_desc" function so the code is executed only once (at vhub initial time). Signed-off-by: Tao Ren --- Changes in v2: - update per-vhub device descriptor instance instead of the global default descriptor. drivers/usb/gadget/udc/aspeed-vhub/hub.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/usb/gadget/udc/aspeed-vhub/hub.c b/drivers/usb/gadget/udc/aspeed-vhub/hub.c index 13fba91aad6a..6497185ec4e7 100644 --- a/drivers/usb/gadget/udc/aspeed-vhub/hub.c +++ b/drivers/usb/gadget/udc/aspeed-vhub/hub.c @@ -73,13 +73,6 @@ static const 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. @@ -303,10 +296,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); } @@ -907,6 +896,12 @@ static void ast_vhub_of_parse_dev_desc(struct ast_vhub *vhub, } } +static void ast_vhub_fixup_usb1_dev_desc(struct ast_vhub *vhub) +{ + vhub->vhub_dev_desc.bcdUSB = cpu_to_le16(0x0100); + vhub->vhub_dev_desc.bDeviceProtocol = 0; +} + static struct usb_gadget_string_container* ast_vhub_str_container_alloc(struct ast_vhub *vhub) { @@ -1021,6 +1016,8 @@ static int ast_vhub_init_desc(struct ast_vhub *vhub) memcpy(&vhub->vhub_dev_desc, &ast_vhub_dev_desc, sizeof(vhub->vhub_dev_desc)); ast_vhub_of_parse_dev_desc(vhub, vhub_np); + if (vhub->force_usb1) + ast_vhub_fixup_usb1_dev_desc(vhub); /* Initialize vhub Configuration Descriptor. */ memcpy(&vhub->vhub_conf_desc, &ast_vhub_conf_desc, -- 2.17.1