Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D07ECC4332F for ; Tue, 16 Nov 2021 20:08:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B96E163217 for ; Tue, 16 Nov 2021 20:08:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240301AbhKPULB (ORCPT ); Tue, 16 Nov 2021 15:11:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240238AbhKPUKv (ORCPT ); Tue, 16 Nov 2021 15:10:51 -0500 Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69AE0C061570 for ; Tue, 16 Nov 2021 12:07:54 -0800 (PST) Received: by mail-pf1-x42e.google.com with SMTP id g18so426963pfk.5 for ; Tue, 16 Nov 2021 12:07:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WxpPTzyFDwq6+OnmCeJvt7beFH+6rbdWDksNNHEd3mQ=; b=HkQX/VX7RF0p6hLc8boU3brpPqjzARQyd09xWpBB3EY4F5F5sfMsvz/xcYZFrKNw/R emx0NkdEMLDE1Hwvf+I/KogKaNzspe5uyF88wE4NTepIOobfmD4Dk+dDN8J6fja86674 DphgdsppZnq8HHSVosn/lifgiTn1/OfuMXRA0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WxpPTzyFDwq6+OnmCeJvt7beFH+6rbdWDksNNHEd3mQ=; b=a0W1A13tTwzL7hS7N+9qItYNE924id962hfajKxCCGWXaBPVpbk7oFYn5kkTRcaEir eI9aGiI//6OG4jpWsrFPoqvFRxjPvgulg+1BqcPNdeys+cGkI9vii1f772hc3kVcLoqe fyciFzumyePnFzhURcpUOV98BPetVQv+zIq+D8SaO2t0TeZ0fJS2PtKtusqR9/5So1V6 D3rrVegMDRunT2FCOrwqLFTQy/lXAAb8zCTMr9qFle8Hwh7HF2OFCdaL2sTy64ulTQcW WBMrvovEvA5DhJGaWV2s0sqmwEGivL7mmhejzngRYnleNX3kLdPtrAJypmUtqRlS+ANz O0IQ== X-Gm-Message-State: AOAM530OpkFLkuOdtNWSoC60POQSZITRdHgyFB7F0zGAIkGZP+fB+MpV C1Pf9dCkq9iLbwQ8XmUnNg4xcA== X-Google-Smtp-Source: ABdhPJxvTeb9YHcGi6ywMgrLy/Jqg7ZbdoaTRoqhxZswWm9x96JcucmOmFtbulGOYbqeYvsw0VwYjA== X-Received: by 2002:a05:6a00:2387:b0:49f:af00:d5d0 with SMTP id f7-20020a056a00238700b0049faf00d5d0mr42534511pfc.1.1637093274023; Tue, 16 Nov 2021 12:07:54 -0800 (PST) Received: from localhost ([2620:15c:202:201:54aa:73ab:b480:41e2]) by smtp.gmail.com with UTF8SMTPSA id d17sm18379226pfo.40.2021.11.16.12.07.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 16 Nov 2021 12:07:53 -0800 (PST) From: Matthias Kaehlcke To: Greg Kroah-Hartman , Alan Stern , Rob Herring , Frank Rowand , Mathias Nyman , Felipe Balbi Cc: linux-kernel@vger.kernel.org, Krzysztof Kozlowski , Stephen Boyd , Peter Chen , linux-usb@vger.kernel.org, devicetree@vger.kernel.org, Douglas Anderson , Roger Quadros , Michal Simek , Ravi Chandra Sadineni , Bastien Nocera , Matthias Kaehlcke , Andrey Konovalov , Kishon Vijay Abraham I , Li Jun , Peter Chen , Sasha Levin Subject: [PATCH v17 3/7] usb: core: hcd: Create platform devices for onboard hubs in probe() Date: Tue, 16 Nov 2021 12:07:35 -0800 Message-Id: <20211116120642.v17.3.I7a3a7d9d2126c34079b1cab87aa0b2ec3030f9b7@changeid> X-Mailer: git-send-email 2.34.0.rc1.387.gb447b232ab-goog In-Reply-To: <20211116200739.924401-1-mka@chromium.org> References: <20211116200739.924401-1-mka@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Call onboard_hub_create/destroy_pdevs() from usb_add/remove_hcd() for primary HCDs to create/destroy platform devices for onboard USB hubs that may be connected to the root hub of the controller. These functions are a NOP unless CONFIG_USB_ONBOARD_HUB=y/m. Also add a field to struct usb_hcd to keep track of the onboard hub platform devices that are owned by the HCD. Signed-off-by: Matthias Kaehlcke --- Changes in v17: - create the platform devices in the generic HCD code instead of the xhci_platform driver - updated subject and commit message to reflect the above change - dropped initialization of platform device list, which is now done in onboard_hub_create_pdevs() Changes in v16: - none Changes in v15: - none Changes in v14: - none Changes in v13: - added comment for 'depends on USB_ONBOARD_HUB || !USB_ONBOARD_HUB' construct Changes in v12: - none Changes in v11: - use onboard_hub_create/destroy_pdevs() to support multiple onboard hubs that are connected to the same root hub - moved field/list to keep track of platform devices from struct usb_hcd to struct xhci_hcd - updated commit message Changes in v10: - none Changes in v9: - added dependency on USB_ONBOARD_HUB (or !!USB_ONBOARD_HUB) to USB_XHCI_PLATFORM Changes in v8: - none Changes in v7: - none Changes in v6: - none Changes in v5: - patch added to the series drivers/usb/core/hcd.c | 6 ++++++ include/linux/usb/hcd.h | 1 + 2 files changed, 7 insertions(+) diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 4d326ee12c36..b8220e411e07 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include "usb.h" @@ -2963,6 +2964,9 @@ int usb_add_hcd(struct usb_hcd *hcd, if (hcd->uses_new_polling && HCD_POLL_RH(hcd)) usb_hcd_poll_rh_status(hcd); + if (usb_hcd_is_primary_hcd(hcd)) + onboard_hub_create_pdevs(hcd->self.root_hub, &hcd->onboard_hub_devs); + return retval; err_register_root_hub: @@ -3041,6 +3045,8 @@ void usb_remove_hcd(struct usb_hcd *hcd) if (usb_hcd_is_primary_hcd(hcd)) { if (hcd->irq > 0) free_irq(hcd->irq, hcd); + + onboard_hub_destroy_pdevs(&hcd->onboard_hub_devs); } usb_deregister_bus(&hcd->self); diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h index 548a028f2dab..4ebc91c09182 100644 --- a/include/linux/usb/hcd.h +++ b/include/linux/usb/hcd.h @@ -198,6 +198,7 @@ struct usb_hcd { struct usb_hcd *shared_hcd; struct usb_hcd *primary_hcd; + struct list_head onboard_hub_devs; #define HCD_BUFFER_POOLS 4 struct dma_pool *pool[HCD_BUFFER_POOLS]; -- 2.34.0.rc1.387.gb447b232ab-goog