Re: [PATCH 25/31] usb: Drop dm.h header file

2020-08-04 Thread Tom Rini
On Sun, Jul 19, 2020 at 10:15:55AM -0600, Simon Glass wrote:

> 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 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


[PATCH 25/31] usb: Drop dm.h header file

2020-07-19 Thread Simon Glass
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 988071a61d..8ac2f0a78a 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 
@@ -452,3 +453,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 74a841af46..2fbe9bebf1 100644
--- a/drivers/usb/musb-new/pic32.c
+++ b/drivers/usb/musb-new/pic32.c
@@ -10,6 +10,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
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__ */
-- 
2.28.0.rc0.105.gf9edc3c819-goog