From patchwork Thu Feb 17 18:42:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Kaehlcke X-Patchwork-Id: 12750561 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B23EFC433F5 for ; Thu, 17 Feb 2022 18:43:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244551AbiBQSnb (ORCPT ); Thu, 17 Feb 2022 13:43:31 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:45842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244550AbiBQSn3 (ORCPT ); Thu, 17 Feb 2022 13:43:29 -0500 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CFCD14008 for ; Thu, 17 Feb 2022 10:43:11 -0800 (PST) Received: by mail-pl1-x62a.google.com with SMTP id j4so5260035plj.8 for ; Thu, 17 Feb 2022 10:43:11 -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=150I8tSeoQEdnBW/+p+7xnMkqFAoe9hccra7knV3Q/4=; b=IYb9C99Nd6cqeKKYhs2ozW0LnPOclIeM4t/tKWk6bkI+Equaz+baO4EDzHyi/JQU0P se6ly5U3jlSjwllXuSHZ3QZFzn+CziSet1m6jCRZmVohXCsYhCiAwX8T5gJM69XAyDGy zTmMIZ3amYHU83M6ELcTYQrYi9HJu9Fmmo0pQ= 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=150I8tSeoQEdnBW/+p+7xnMkqFAoe9hccra7knV3Q/4=; b=jEwhFVfTxMxkuYasC6nfJC4JesZgaEBnF6JL1IvpUOolIolpyDSoS3M8BlyRbC2ZWi pbsIJR0vfi0QNRtm1P66Ga5BblLZEKoVL4PF/NeedldvZon5WLyz+GcIwabNXkJepZ5J A7w/tOD0srCad5B8noIeVDyByg5TvF6OIfehsUrjN2kfVCvRyUQlQyqCpVD0YKoXofQ1 9J/qyGE6abSYO+rwNA5Mw3BZc2aeEEgouyEfAhIADn3dsN0o1UWgpI4Bw2uEHo++9kVs 6pkHJLN82JUAOJMXoOUliajKUH8HwquJkkkuNF2OUuPDxphRKNWFj0syNi6LqxlhXH7q ZRdA== X-Gm-Message-State: AOAM531HQlYacnjARfLkoVGxvw33ic754FES9BodARpabd5Pk4Q09k0B 5ckrHTy1D05vJH2yt/N3VlYHWg== X-Google-Smtp-Source: ABdhPJxMRjgoWIhXnCig3kodTead2c1ZzrN0DvXCm90tES5J+jMe+RRD3wJbABP/1Kwa+4t6DsbNxA== X-Received: by 2002:a17:90a:7845:b0:1b9:159c:148e with SMTP id y5-20020a17090a784500b001b9159c148emr4338987pjl.136.1645123391193; Thu, 17 Feb 2022 10:43:11 -0800 (PST) Received: from localhost ([2620:15c:202:201:b42d:98cc:5dcc:5ef5]) by smtp.gmail.com with UTF8SMTPSA id l21sm317135pfu.120.2022.02.17.10.43.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 17 Feb 2022 10:43:10 -0800 (PST) From: Matthias Kaehlcke To: Greg Kroah-Hartman , Alan Stern , Rob Herring , Frank Rowand , Mathias Nyman , Felipe Balbi Cc: linux-usb@vger.kernel.org, Ravi Chandra Sadineni , Roger Quadros , linux-kernel@vger.kernel.org, Bastien Nocera , Douglas Anderson , Michal Simek , Stephen Boyd , devicetree@vger.kernel.org, Krzysztof Kozlowski , Peter Chen , Matthias Kaehlcke , Guo Zhengkui , Kishon Vijay Abraham I , Li Jun , Peter Chen , Thinh Nguyen Subject: [PATCH v21 3/3] usb: core: hcd: Create platform devices for onboard hubs in probe() Date: Thu, 17 Feb 2022 10:42:54 -0800 Message-Id: <20220217104219.v21.3.I7a3a7d9d2126c34079b1cab87aa0b2ec3030f9b7@changeid> X-Mailer: git-send-email 2.35.1.473.g83b2b277ed-goog In-Reply-To: <20220217184254.4141705-1-mka@chromium.org> References: <20220217184254.4141705-1-mka@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@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 Reviewed-by: Douglas Anderson Reviewed-by: Stephen Boyd --- Changes in v21: - none Changes in v20: - added 'Reviewed-by' tags from Doug and Stephen Changes in v19: - none Changes in v18: - none 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 d9712c2602af..81785072fafb 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" @@ -2984,6 +2985,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: @@ -3062,6 +3066,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];