From patchwork Sun Oct 27 15:54:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1185069 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Z4OrxIMA"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 471N7B46S1z9sPK for ; Mon, 28 Oct 2019 03:08:22 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 4101FC21DA1; Sun, 27 Oct 2019 16:01:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 0BF8AC21EDC; Sun, 27 Oct 2019 15:56:20 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 80302C21E5B; Sun, 27 Oct 2019 15:56:14 +0000 (UTC) Received: from mail-il1-f196.google.com (mail-il1-f196.google.com [209.85.166.196]) by lists.denx.de (Postfix) with ESMTPS id E46C7C21E36 for ; Sun, 27 Oct 2019 15:55:35 +0000 (UTC) Received: by mail-il1-f196.google.com with SMTP id y5so5867990ilb.5 for ; Sun, 27 Oct 2019 08:55:35 -0700 (PDT) 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=5OB40e4V2omxBBLur0y8zAqGWJl11VZLIpLetCIYUNs=; b=Z4OrxIMAqAqT7H++H4fgORYqcCPL6vi7Hz+9Os1UpbJmpAohsPIphNQsk5rGVRkM4/ VHQFhxcPUN4m2nTD1aUXglLsY0ivkxq88t4Sh7paiGillg0KRMQ3rchRC30WPbP89Vjc 2uISFYviMpxuYq70/MNRzUt9QG29J5sZxGENU= 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:mime-version:content-transfer-encoding; bh=5OB40e4V2omxBBLur0y8zAqGWJl11VZLIpLetCIYUNs=; b=FzhNlFSSmo7fvId130Yhhmq/QDFU2q1ajhaKIBY9Ur2uSlhxObKRslSIrwjibSOUYS fx4vlyn+QEFROGHlwgJJBKG3HuesZ7IcEIhzOTHQ5XwDY6erL+4RjdHhwSUgYXchCZv1 3DNMvUN2KyLrr6sd2EbNKUoaRJvn21FWaR99x0TEU9l6IKO3JerHyScaLNs7jbmZD6/E emNjNJ9YgI0tmOeJQvgJ88atGFPvO5nsM8k3Z3X29Mzm/0mY4YYuDOhwgPEXD75kDT01 HCtjyQ35dDY/Yi3F57qaV7TIAcFQwc2VcQr6MBjLvee9c7BLhatjZkTQaQbPyn5kH8Tt F+JA== X-Gm-Message-State: APjAAAVeWFdms64iZZ5MOtwMMo6n1fdW2H2tTFNwKxnXBDLSQRKVRvCR SQ0siS06Wz9yusupRZ5UFkU6pGbv2ixRwQ== X-Google-Smtp-Source: APXvYqyNzOcrmIrBH99sT/GNXMjWBW8rFmUAh5ojB/keZ3FwwHPlrSGTihjjZJJMWY4nmNMQBL34ig== X-Received: by 2002:a92:1907:: with SMTP id 7mr16066477ilz.72.1572191734722; Sun, 27 Oct 2019 08:55:34 -0700 (PDT) Received: from kiwi.bld.corp.google.com ([2620:15c:183:0:8223:87c:a681:66aa]) by smtp.gmail.com with ESMTPSA id n3sm1215070ilm.8.2019.10.27.08.55.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Oct 2019 08:55:34 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Sun, 27 Oct 2019 09:54:09 -0600 Message-Id: <20191027155410.187957-29-sjg@chromium.org> X-Mailer: git-send-email 2.24.0.rc0.303.g954a862665-goog In-Reply-To: <20191027155410.187957-1-sjg@chromium.org> References: <20191027155410.187957-1-sjg@chromium.org> MIME-Version: 1.0 Cc: Marek Vasut , Tom Rini , Remy Bohmer , Sven Schwermer , Michal Suchanek Subject: [U-Boot] [PATCH 29/30] usb: Drop dm.h header file X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This header file should not be included in other header files. Remove it and use a forward declaration instead. Also move the inline function out into a C file. We should not include C code in headers. Signed-off-by: Simon Glass --- drivers/usb/musb-new/musb_uboot.c | 37 +++++++++++++++++++++++++ drivers/usb/musb-new/pic32.c | 1 + drivers/usb/musb-new/usb-compat.h | 45 +++++++------------------------ 3 files changed, 47 insertions(+), 36 deletions(-) diff --git a/drivers/usb/musb-new/musb_uboot.c b/drivers/usb/musb-new/musb_uboot.c index 9eb593402e..98df080e50 100644 --- a/drivers/usb/musb-new/musb_uboot.c +++ b/drivers/usb/musb-new/musb_uboot.c @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -449,3 +450,39 @@ struct musb *musb_register(struct musb_hdrc_platform_data *plat, void *bdata, return *musbp; } + +#if CONFIG_IS_ENABLED(DM_USB) +struct usb_device *usb_dev_get_parent(struct usb_device *udev) +{ + struct udevice *parent = udev->dev->parent; + + /* + * When called from usb-uclass.c: usb_scan_device() udev->dev points + * to the parent udevice, not the actual udevice belonging to the + * udev as the device is not instantiated yet. + * + * If dev is an usb-bus, then we are called from usb_scan_device() for + * an usb-device plugged directly into the root port, return NULL. + */ + if (device_get_uclass_id(udev->dev) == UCLASS_USB) + return NULL; + + /* + * If these 2 are not the same we are being called from + * usb_scan_device() and udev itself is the parent. + */ + if (dev_get_parent_priv(udev->dev) != udev) + return udev; + + /* We are being called normally, use the parent pointer */ + if (device_get_uclass_id(parent) == UCLASS_USB_HUB) + return dev_get_parent_priv(parent); + + return NULL; +} +#else +struct usb_device *usb_dev_get_parent(struct usb_device *udev) +{ + return udev->parent; +} +#endif diff --git a/drivers/usb/musb-new/pic32.c b/drivers/usb/musb-new/pic32.c index 3a19900e21..b41b7ee154 100644 --- a/drivers/usb/musb-new/pic32.c +++ b/drivers/usb/musb-new/pic32.c @@ -10,6 +10,7 @@ */ #include +#include #include #include "linux-compat.h" #include "musb_core.h" diff --git a/drivers/usb/musb-new/usb-compat.h b/drivers/usb/musb-new/usb-compat.h index f2c18ad3a2..1c66c4fe36 100644 --- a/drivers/usb/musb-new/usb-compat.h +++ b/drivers/usb/musb-new/usb-compat.h @@ -1,9 +1,10 @@ #ifndef __USB_COMPAT_H__ #define __USB_COMPAT_H__ -#include #include "usb.h" +struct udevice; + struct usb_hcd { void *hcd_priv; }; @@ -67,40 +68,12 @@ static inline int usb_hcd_unmap_urb_for_dma(struct usb_hcd *hcd, return 0; } -#if CONFIG_IS_ENABLED(DM_USB) -static inline struct usb_device *usb_dev_get_parent(struct usb_device *udev) -{ - struct udevice *parent = udev->dev->parent; - - /* - * When called from usb-uclass.c: usb_scan_device() udev->dev points - * to the parent udevice, not the actual udevice belonging to the - * udev as the device is not instantiated yet. - * - * If dev is an usb-bus, then we are called from usb_scan_device() for - * an usb-device plugged directly into the root port, return NULL. - */ - if (device_get_uclass_id(udev->dev) == UCLASS_USB) - return NULL; - - /* - * If these 2 are not the same we are being called from - * usb_scan_device() and udev itself is the parent. - */ - if (dev_get_parent_priv(udev->dev) != udev) - return udev; - - /* We are being called normally, use the parent pointer */ - if (device_get_uclass_id(parent) == UCLASS_USB_HUB) - return dev_get_parent_priv(parent); - - return NULL; -} -#else -static inline struct usb_device *usb_dev_get_parent(struct usb_device *dev) -{ - return dev->parent; -} -#endif +/** + * usb_dev_get_parent() - Get the parent of a USB device + * + * @udev: USB struct containing information about the device + * @return associated device for which udev == dev_get_parent_priv(dev) + */ +struct usb_device *usb_dev_get_parent(struct usb_device *udev); #endif /* __USB_COMPAT_H__ */