diff mbox series

[v3,2/6] net: eth-phy: use dev_dbg and log_notice

Message ID 20210720200940.v3.2.I523f439458f0ff2d770a2b8e8a7c8e0969e783dd@changeid
State Accepted
Commit 880ecb09b9d14ca3f3653e7ad8f92c1c8ca89690
Delegated to: Ramon Fried
Headers show
Series net: dwc_eth_qos: add support of device tree configuration for reset delay | expand

Commit Message

Patrick Delaunay July 20, 2021, 6:09 p.m. UTC
Replace debug trace and printf to log macros:
- debug() replaced by dev_dbg() when device is available, this macro
indicate the device name since commit ceb70bb870ac ("dm: Print device
name in dev_xxx like Linux")
- printf() replaced by log_notice() to allow  dispatch to log backends.

Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
---

(no changes since v2)

Changes in v2:
- use log macro in eth-phy driver (NEW)

 drivers/net/eth-phy-uclass.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

Comments

Ramon Fried July 22, 2021, 7:06 p.m. UTC | #1
On Tue, Jul 20, 2021 at 9:10 PM Patrick Delaunay
<patrick.delaunay@foss.st.com> wrote:
>
> Replace debug trace and printf to log macros:
> - debug() replaced by dev_dbg() when device is available, this macro
> indicate the device name since commit ceb70bb870ac ("dm: Print device
> name in dev_xxx like Linux")
> - printf() replaced by log_notice() to allow  dispatch to log backends.
>
> Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
> ---
>
> (no changes since v2)
>
> Changes in v2:
> - use log macro in eth-phy driver (NEW)
>
>  drivers/net/eth-phy-uclass.c | 20 +++++++++++---------
>  1 file changed, 11 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/net/eth-phy-uclass.c b/drivers/net/eth-phy-uclass.c
> index 7abed14392..aa5b05abc8 100644
> --- a/drivers/net/eth-phy-uclass.c
> +++ b/drivers/net/eth-phy-uclass.c
> @@ -5,8 +5,10 @@
>
>  #include <common.h>
>  #include <dm.h>
> +#include <log.h>
>  #include <net.h>
>  #include <asm-generic/gpio.h>
> +#include <dm/device_compat.h>
>  #include <dm/device-internal.h>
>  #include <dm/uclass-internal.h>
>  #include <dm/lists.h>
> @@ -27,25 +29,25 @@ int eth_phy_binds_nodes(struct udevice *eth_dev)
>
>         mdio_node = dev_read_subnode(eth_dev, "mdio");
>         if (!ofnode_valid(mdio_node)) {
> -               debug("%s: %s mdio subnode not found!", __func__,
> -                     eth_dev->name);
> +               dev_dbg(eth_dev, "%s: %s mdio subnode not found!", __func__,
> +                       eth_dev->name);
>                 return -ENXIO;
>         }
>
>         ofnode_for_each_subnode(phy_node, mdio_node) {
>                 node_name = ofnode_get_name(phy_node);
>
> -               debug("* Found child node: '%s'\n", node_name);
> +               dev_dbg(eth_dev, "* Found child node: '%s'\n", node_name);
>
>                 ret = device_bind_driver_to_node(eth_dev,
>                                                  "eth_phy_generic_drv",
>                                                  node_name, phy_node, NULL);
>                 if (ret) {
> -                       debug("  - Eth phy binding error: %d\n", ret);
> +                       dev_dbg(eth_dev, "  - Eth phy binding error: %d\n", ret);
>                         continue;
>                 }
>
> -               debug("  - bound phy device: '%s'\n", node_name);
> +               dev_dbg(eth_dev, "  - bound phy device: '%s'\n", node_name);
>         }
>
>         return 0;
> @@ -86,14 +88,14 @@ struct mii_dev *eth_phy_get_mdio_bus(struct udevice *eth_dev)
>                          */
>                         uc_priv = (struct eth_phy_device_priv *)(dev_get_uclass_priv(phy_dev));
>                         if (uc_priv->mdio_bus)
> -                               printf("Get shared mii bus on %s\n", eth_dev->name);
> +                               log_notice("Get shared mii bus on %s\n", eth_dev->name);
>                         else
> -                               printf("Can't get shared mii bus on %s\n", eth_dev->name);
> +                               log_notice("Can't get shared mii bus on %s\n", eth_dev->name);
>
>                         return uc_priv->mdio_bus;
>                 }
>         } else {
> -               printf("FEC: can't find phy-handle\n");
> +               log_notice("FEC: can't find phy-handle\n");
>         }
>
>         return NULL;
> @@ -106,7 +108,7 @@ int eth_phy_get_addr(struct udevice *dev)
>
>         if (dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0,
>                                        &phandle_args)) {
> -               debug("Failed to find phy-handle");
> +               dev_dbg(dev, "Failed to find phy-handle");
>                 return -ENODEV;
>         }
>
> --
> 2.25.1
>
Applied to u-boot-net/network-master
Thanks,
Ramon.
diff mbox series

Patch

diff --git a/drivers/net/eth-phy-uclass.c b/drivers/net/eth-phy-uclass.c
index 7abed14392..aa5b05abc8 100644
--- a/drivers/net/eth-phy-uclass.c
+++ b/drivers/net/eth-phy-uclass.c
@@ -5,8 +5,10 @@ 
 
 #include <common.h>
 #include <dm.h>
+#include <log.h>
 #include <net.h>
 #include <asm-generic/gpio.h>
+#include <dm/device_compat.h>
 #include <dm/device-internal.h>
 #include <dm/uclass-internal.h>
 #include <dm/lists.h>
@@ -27,25 +29,25 @@  int eth_phy_binds_nodes(struct udevice *eth_dev)
 
 	mdio_node = dev_read_subnode(eth_dev, "mdio");
 	if (!ofnode_valid(mdio_node)) {
-		debug("%s: %s mdio subnode not found!", __func__,
-		      eth_dev->name);
+		dev_dbg(eth_dev, "%s: %s mdio subnode not found!", __func__,
+			eth_dev->name);
 		return -ENXIO;
 	}
 
 	ofnode_for_each_subnode(phy_node, mdio_node) {
 		node_name = ofnode_get_name(phy_node);
 
-		debug("* Found child node: '%s'\n", node_name);
+		dev_dbg(eth_dev, "* Found child node: '%s'\n", node_name);
 
 		ret = device_bind_driver_to_node(eth_dev,
 						 "eth_phy_generic_drv",
 						 node_name, phy_node, NULL);
 		if (ret) {
-			debug("  - Eth phy binding error: %d\n", ret);
+			dev_dbg(eth_dev, "  - Eth phy binding error: %d\n", ret);
 			continue;
 		}
 
-		debug("  - bound phy device: '%s'\n", node_name);
+		dev_dbg(eth_dev, "  - bound phy device: '%s'\n", node_name);
 	}
 
 	return 0;
@@ -86,14 +88,14 @@  struct mii_dev *eth_phy_get_mdio_bus(struct udevice *eth_dev)
 			 */
 			uc_priv = (struct eth_phy_device_priv *)(dev_get_uclass_priv(phy_dev));
 			if (uc_priv->mdio_bus)
-				printf("Get shared mii bus on %s\n", eth_dev->name);
+				log_notice("Get shared mii bus on %s\n", eth_dev->name);
 			else
-				printf("Can't get shared mii bus on %s\n", eth_dev->name);
+				log_notice("Can't get shared mii bus on %s\n", eth_dev->name);
 
 			return uc_priv->mdio_bus;
 		}
 	} else {
-		printf("FEC: can't find phy-handle\n");
+		log_notice("FEC: can't find phy-handle\n");
 	}
 
 	return NULL;
@@ -106,7 +108,7 @@  int eth_phy_get_addr(struct udevice *dev)
 
 	if (dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0,
 				       &phandle_args)) {
-		debug("Failed to find phy-handle");
+		dev_dbg(dev, "Failed to find phy-handle");
 		return -ENODEV;
 	}