diff mbox series

[09/10] usb: Use ofnode as usb_get_dr_mode() parameter

Message ID 20200219015447.19392-10-kever.yang@rock-chips.com
State Superseded
Headers show
Series usb: Covert to support Live DT | expand

Commit Message

Kever Yang Feb. 19, 2020, 1:54 a.m. UTC
ofnode is more common and no need to convert to offset after we migrate
other API to use ofnode.

Signed-off-by: Kever Yang <kever.yang at rock-chips.com>
---

 drivers/usb/cdns3/core.c           | 2 +-
 drivers/usb/common/common.c        | 7 +++----
 drivers/usb/dwc3/dwc3-generic.c    | 6 +++---
 drivers/usb/dwc3/dwc3-meson-g12a.c | 2 +-
 drivers/usb/gadget/dwc2_udc_otg.c  | 5 ++---
 drivers/usb/host/dwc3-sti-glue.c   | 2 +-
 drivers/usb/host/ehci-mx6.c        | 2 +-
 drivers/usb/host/xhci-dwc3.c       | 3 +--
 drivers/usb/musb-new/ti-musb.c     | 2 +-
 include/linux/usb/otg.h            | 4 ++--
 10 files changed, 16 insertions(+), 19 deletions(-)

Comments

Neil Armstrong Feb. 19, 2020, 7:49 a.m. UTC | #1
On 19/02/2020 02:54, Kever Yang wrote:
> ofnode is more common and no need to convert to offset after we migrate
> other API to use ofnode.
> 
> Signed-off-by: Kever Yang <kever.yang at rock-chips.com>
> ---
> 
>  drivers/usb/cdns3/core.c           | 2 +-
>  drivers/usb/common/common.c        | 7 +++----
>  drivers/usb/dwc3/dwc3-generic.c    | 6 +++---
>  drivers/usb/dwc3/dwc3-meson-g12a.c | 2 +-
>  drivers/usb/gadget/dwc2_udc_otg.c  | 5 ++---
>  drivers/usb/host/dwc3-sti-glue.c   | 2 +-
>  drivers/usb/host/ehci-mx6.c        | 2 +-
>  drivers/usb/host/xhci-dwc3.c       | 3 +--
>  drivers/usb/musb-new/ti-musb.c     | 2 +-
>  include/linux/usb/otg.h            | 4 ++--
>  10 files changed, 16 insertions(+), 19 deletions(-)
> 

[...]

> diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c
> index a55def5aba..4300f711a9 100644
> --- a/drivers/usb/common/common.c
> +++ b/drivers/usb/common/common.c
> @@ -7,7 +7,7 @@
>   */
>  
>  #include <common.h>
> -#include <linux/libfdt.h>
> +#include <dm.h>
>  #include <linux/usb/otg.h>
>  #include <linux/usb/ch9.h>
>  
> @@ -20,13 +20,12 @@ static const char *const usb_dr_modes[] = {
>  	[USB_DR_MODE_OTG]		= "otg",
>  };
>  
> -enum usb_dr_mode usb_get_dr_mode(int node)
> +enum usb_dr_mode usb_get_dr_mode(ofnode node)
>  {
> -	const void *fdt = gd->fdt_blob;
>  	const char *dr_mode;
>  	int i;
>  
> -	dr_mode = fdt_getprop(fdt, node, "dr_mode", NULL);
> +	dr_mode = ofnode_read_string(node, "dr_mode");
>  	if (!dr_mode) {
>  		pr_err("usb dr_mode not found\n");
>  		return USB_DR_MODE_UNKNOWN;
> diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
> index ced0f53bfd..7178f12b47 100644

[..]

> diff --git a/drivers/usb/dwc3/dwc3-meson-g12a.c b/drivers/usb/dwc3/dwc3-meson-g12a.c
> index 832bcd70ff..d4453f8784 100644
> --- a/drivers/usb/dwc3/dwc3-meson-g12a.c
> +++ b/drivers/usb/dwc3/dwc3-meson-g12a.c
> @@ -393,7 +393,7 @@ static int dwc3_meson_g12a_probe(struct udevice *dev)
>  	}
>  #endif
>  
> -	priv->otg_mode = usb_get_dr_mode(dev_of_offset(dev));
> +	priv->otg_mode = usb_get_dr_mode(dev->node);
>  
>  	ret = dwc3_meson_g12a_usb_init(priv);
>  	if (ret)

For drivers/usb/dwc3/dwc3-meson-g12a.c:
Acked-by: Neil Armstrong <narmstrong at baylibre.com>
diff mbox series

Patch

diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c
index d6ccd3e73c..0b543fed3d 100644
--- a/drivers/usb/cdns3/core.c
+++ b/drivers/usb/cdns3/core.c
@@ -106,7 +106,7 @@  static int cdns3_core_init_role(struct cdns3 *cdns)
 	enum usb_dr_mode dr_mode;
 	int ret = 0;
 
-	dr_mode = usb_get_dr_mode(dev_of_offset(dev));
+	dr_mode = usb_get_dr_mode(dev->node);
 	cdns->role = USB_ROLE_NONE;
 
 	/*
diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c
index a55def5aba..4300f711a9 100644
--- a/drivers/usb/common/common.c
+++ b/drivers/usb/common/common.c
@@ -7,7 +7,7 @@ 
  */
 
 #include <common.h>
-#include <linux/libfdt.h>
+#include <dm.h>
 #include <linux/usb/otg.h>
 #include <linux/usb/ch9.h>
 
@@ -20,13 +20,12 @@  static const char *const usb_dr_modes[] = {
 	[USB_DR_MODE_OTG]		= "otg",
 };
 
-enum usb_dr_mode usb_get_dr_mode(int node)
+enum usb_dr_mode usb_get_dr_mode(ofnode node)
 {
-	const void *fdt = gd->fdt_blob;
 	const char *dr_mode;
 	int i;
 
-	dr_mode = fdt_getprop(fdt, node, "dr_mode", NULL);
+	dr_mode = ofnode_read_string(node, "dr_mode");
 	if (!dr_mode) {
 		pr_err("usb dr_mode not found\n");
 		return USB_DR_MODE_UNKNOWN;
diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
index ced0f53bfd..7178f12b47 100644
--- a/drivers/usb/dwc3/dwc3-generic.c
+++ b/drivers/usb/dwc3/dwc3-generic.c
@@ -98,7 +98,7 @@  static int dwc3_generic_ofdata_to_platdata(struct udevice *dev)
 		plat->maximum_speed = USB_SPEED_SUPER;
 	}
 
-	plat->dr_mode = usb_get_dr_mode(ofnode_to_offset(node));
+	plat->dr_mode = usb_get_dr_mode(node);
 	if (plat->dr_mode == USB_DR_MODE_UNKNOWN) {
 		pr_err("Invalid usb mode setup\n");
 		return -ENODEV;
@@ -295,7 +295,7 @@  static int dwc3_glue_bind(struct udevice *parent)
 
 		debug("%s: subnode name: %s\n", __func__, name);
 
-		dr_mode = usb_get_dr_mode(ofnode_to_offset(node));
+		dr_mode = usb_get_dr_mode(node);
 
 		switch (dr_mode) {
 		case USB_DR_MODE_PERIPHERAL:
@@ -398,7 +398,7 @@  static int dwc3_glue_probe(struct udevice *dev)
 	while (child) {
 		enum usb_dr_mode dr_mode;
 
-		dr_mode = usb_get_dr_mode(dev_of_offset(child));
+		dr_mode = usb_get_dr_mode(child->node);
 		device_find_next_child(&child);
 		if (ops && ops->select_dr_mode)
 			ops->select_dr_mode(dev, index, dr_mode);
diff --git a/drivers/usb/dwc3/dwc3-meson-g12a.c b/drivers/usb/dwc3/dwc3-meson-g12a.c
index 832bcd70ff..d4453f8784 100644
--- a/drivers/usb/dwc3/dwc3-meson-g12a.c
+++ b/drivers/usb/dwc3/dwc3-meson-g12a.c
@@ -393,7 +393,7 @@  static int dwc3_meson_g12a_probe(struct udevice *dev)
 	}
 #endif
 
-	priv->otg_mode = usb_get_dr_mode(dev_of_offset(dev));
+	priv->otg_mode = usb_get_dr_mode(dev->node);
 
 	ret = dwc3_meson_g12a_usb_init(priv);
 	if (ret)
diff --git a/drivers/usb/gadget/dwc2_udc_otg.c b/drivers/usb/gadget/dwc2_udc_otg.c
index 35f4147840..70a7313244 100644
--- a/drivers/usb/gadget/dwc2_udc_otg.c
+++ b/drivers/usb/gadget/dwc2_udc_otg.c
@@ -1036,13 +1036,12 @@  void dwc2_phy_shutdown(struct udevice *dev, struct phy *usb_phys, int num_phys)
 static int dwc2_udc_otg_ofdata_to_platdata(struct udevice *dev)
 {
 	struct dwc2_plat_otg_data *platdata = dev_get_platdata(dev);
-	int node = dev_of_offset(dev);
 	ulong drvdata;
 	void (*set_params)(struct dwc2_plat_otg_data *data);
 	int ret;
 
-	if (usb_get_dr_mode(node) != USB_DR_MODE_PERIPHERAL &&
-	    usb_get_dr_mode(node) != USB_DR_MODE_OTG) {
+	if (usb_get_dr_mode(dev->node) != USB_DR_MODE_PERIPHERAL &&
+	    usb_get_dr_mode(dev->node) != USB_DR_MODE_OTG) {
 		dev_dbg(dev, "Invalid mode\n");
 		return -ENODEV;
 	}
diff --git a/drivers/usb/host/dwc3-sti-glue.c b/drivers/usb/host/dwc3-sti-glue.c
index 36c7d4037c..1cbf0df1ea 100644
--- a/drivers/usb/host/dwc3-sti-glue.c
+++ b/drivers/usb/host/dwc3-sti-glue.c
@@ -164,7 +164,7 @@  static int sti_dwc3_glue_bind(struct udevice *dev)
 	}
 
 	/* retrieve the DWC3 dual role mode */
-	plat->mode = usb_get_dr_mode(ofnode_to_offset(dwc3_node));
+	plat->mode = usb_get_dr_mode(dwc3_node);
 	if (plat->mode == USB_DR_MODE_UNKNOWN)
 		/* by default set dual role mode to HOST */
 		plat->mode = USB_DR_MODE_HOST;
diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c
index 1993ad620a..f2ceb51310 100644
--- a/drivers/usb/host/ehci-mx6.c
+++ b/drivers/usb/host/ehci-mx6.c
@@ -513,7 +513,7 @@  static int ehci_usb_ofdata_to_platdata(struct udevice *dev)
 	struct usb_platdata *plat = dev_get_platdata(dev);
 	enum usb_dr_mode dr_mode;
 
-	dr_mode = usb_get_dr_mode(dev_of_offset(dev));
+	dr_mode = usb_get_dr_mode(dev->node);
 
 	switch (dr_mode) {
 	case USB_DR_MODE_HOST:
diff --git a/drivers/usb/host/xhci-dwc3.c b/drivers/usb/host/xhci-dwc3.c
index c1c681ca6c..9fcfa39d4b 100644
--- a/drivers/usb/host/xhci-dwc3.c
+++ b/drivers/usb/host/xhci-dwc3.c
@@ -9,7 +9,6 @@ 
 
 #include <common.h>
 #include <dm.h>
-#include <fdtdec.h>
 #include <generic-phy.h>
 #include <usb.h>
 #include <dwc3-uboot.h>
@@ -155,7 +154,7 @@  static int xhci_dwc3_probe(struct udevice *dev)
 
 	writel(reg, &dwc3_reg->g_usb2phycfg[0]);
 
-	dr_mode = usb_get_dr_mode(dev_of_offset(dev));
+	dr_mode = usb_get_dr_mode(dev->node);
 	if (dr_mode == USB_DR_MODE_UNKNOWN)
 		/* by default set dual role mode to HOST */
 		dr_mode = USB_DR_MODE_HOST;
diff --git a/drivers/usb/musb-new/ti-musb.c b/drivers/usb/musb-new/ti-musb.c
index 28172c9c99..6dca0b5f17 100644
--- a/drivers/usb/musb-new/ti-musb.c
+++ b/drivers/usb/musb-new/ti-musb.c
@@ -296,7 +296,7 @@  static int ti_musb_wrapper_bind(struct udevice *parent)
 		if (strncmp(name, "usb@", 4))
 			continue;
 
-		dr_mode = usb_get_dr_mode(ofnode_to_offset(node));
+		dr_mode = usb_get_dr_mode(node);
 		switch (dr_mode) {
 		case USB_DR_MODE_PERIPHERAL:
 			/* Bind MUSB device */
diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h
index d2604c5caf..6ba53fc598 100644
--- a/include/linux/usb/otg.h
+++ b/include/linux/usb/otg.h
@@ -18,12 +18,12 @@  enum usb_dr_mode {
 
 /**
  * usb_get_dr_mode() - Get dual role mode for given device
- * @node: Node offset to the given device
+ * @node: ofnode of the given device
  *
  * The function gets phy interface string from property 'dr_mode',
  * and returns the correspondig enum usb_dr_mode
  */
-enum usb_dr_mode usb_get_dr_mode(int node);
+enum usb_dr_mode usb_get_dr_mode(ofnode node);
 
 /**
  * usb_get_maximum_speed() - Get maximum speed for given device