[PATCH] stmmac: dwmac-loongson: change the pr_info() to dev_err() in loongson_dwmac_probe()

Subsystems: networking drivers, stmmac ethernet driver, the rest

STALE1805d

3 messages, 2 authors, 2021-08-30 · open the first message on its own page

[PATCH] stmmac: dwmac-loongson: change the pr_info() to dev_err() in loongson_dwmac_probe()

From: zhaoxiao <hidden>
Date: 2021-08-27 08:56:10

- Change the pr_info/dev_info to dev_err.
- Add the dev_err to improve readability.

Signed-off-by: zhaoxiao <redacted>
---
 .../net/ethernet/stmicro/stmmac/dwmac-loongson.c  | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
index 4c9a37dd0d3f..495c94e7929f 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
@@ -54,20 +54,21 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id
 	bool mdio = false;
 
 	np = dev_of_node(&pdev->dev);
-
 	if (!np) {
-		pr_info("dwmac_loongson_pci: No OF node\n");
+		dev_err(&pdev->dev, "dwmac_loongson_pci: No OF node\n");
 		return -ENODEV;
 	}
 
 	if (!of_device_is_compatible(np, "loongson, pci-gmac")) {
-		pr_info("dwmac_loongson_pci: Incompatible OF node\n");
+		dev_err(&pdev->dev, "dwmac_loongson_pci: Incompatible OF node\n");
 		return -ENODEV;
 	}
 
 	plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL);
-	if (!plat)
+	if (!plat) {
+		dev_err(&pdev->dev, "memory allocation failed\n");
 		return -ENOMEM;
+	}
 
 	if (plat->mdio_node) {
 		dev_err(&pdev->dev, "Found MDIO subnode\n");
@@ -109,8 +110,10 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id
 		plat->bus_id = pci_dev_id(pdev);
 
 	phy_mode = device_get_phy_mode(&pdev->dev);
-	if (phy_mode < 0)
+	if (phy_mode < 0) {
 		dev_err(&pdev->dev, "phy_mode not found\n");
+		return phy_mode;
+	}
 
 	plat->phy_interface = phy_mode;
 	plat->interface = PHY_INTERFACE_MODE_GMII;
@@ -130,7 +133,7 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id
 
 	res.wol_irq = of_irq_get_byname(np, "eth_wake_irq");
 	if (res.wol_irq < 0) {
-		dev_info(&pdev->dev, "IRQ eth_wake_irq not found, using macirq\n");
+		dev_err(&pdev->dev, "IRQ eth_wake_irq not found, using macirq\n");
 		res.wol_irq = res.irq;
 	}
 
-- 
2.20.1




_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Re: [PATCH] stmmac: dwmac-loongson: change the pr_info() to dev_err() in loongson_dwmac_probe()

From: Jakub Kicinski <kuba@kernel.org>
Date: 2021-08-27 14:02:42

On Fri, 27 Aug 2021 16:55:50 +0800 zhaoxiao wrote:
quoted hunk
- Change the pr_info/dev_info to dev_err.
- Add the dev_err to improve readability.

Signed-off-by: zhaoxiao <redacted>
---
 .../net/ethernet/stmicro/stmmac/dwmac-loongson.c  | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
index 4c9a37dd0d3f..495c94e7929f 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
@@ -54,20 +54,21 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id
 	bool mdio = false;
 
 	np = dev_of_node(&pdev->dev);
-
 	if (!np) {
-		pr_info("dwmac_loongson_pci: No OF node\n");
+		dev_err(&pdev->dev, "dwmac_loongson_pci: No OF node\n");
 		return -ENODEV;
 	}
 
 	if (!of_device_is_compatible(np, "loongson, pci-gmac")) {
-		pr_info("dwmac_loongson_pci: Incompatible OF node\n");
+		dev_err(&pdev->dev, "dwmac_loongson_pci: Incompatible OF node\n");
 		return -ENODEV;
 	}
 
 	plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL);
-	if (!plat)
+	if (!plat) {
+		dev_err(&pdev->dev, "memory allocation failed\n");
Please don't add error messages after allocation failures. OOM will
produce a lot of kernel messages and a stack trace already.
quoted hunk
 		return -ENOMEM;
+	}
 
 	if (plat->mdio_node) {
 		dev_err(&pdev->dev, "Found MDIO subnode\n");
@@ -109,8 +110,10 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id
 		plat->bus_id = pci_dev_id(pdev);
 
 	phy_mode = device_get_phy_mode(&pdev->dev);
-	if (phy_mode < 0)
+	if (phy_mode < 0) {
 		dev_err(&pdev->dev, "phy_mode not found\n");
+		return phy_mode;
You're adding a return here, it should be a separate patch with its own
justification.
quoted hunk
+	}
 
 	plat->phy_interface = phy_mode;
 	plat->interface = PHY_INTERFACE_MODE_GMII;
@@ -130,7 +133,7 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id
 
 	res.wol_irq = of_irq_get_byname(np, "eth_wake_irq");
 	if (res.wol_irq < 0) {
-		dev_info(&pdev->dev, "IRQ eth_wake_irq not found, using macirq\n");
+		dev_err(&pdev->dev, "IRQ eth_wake_irq not found, using macirq\n");
Why upgrade to an error, isn't wol_irq optional?
 		res.wol_irq = res.irq;
 	}
 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Re: [PATCH] stmmac: dwmac-loongson: change the pr_info() to dev_err() in loongson_dwmac_probe()

From: zhaoxiao <hidden>
Date: 2021-08-30 01:42:16

Thanks for your advices, and I change the patch and commit again.

在 2021/8/27 下午10:02, Jakub Kicinski 写道:
On Fri, 27 Aug 2021 16:55:50 +0800 zhaoxiao wrote:
quoted
- Change the pr_info/dev_info to dev_err.
- Add the dev_err to improve readability.

Signed-off-by: zhaoxiao <redacted>
---
  .../net/ethernet/stmicro/stmmac/dwmac-loongson.c  | 15 +++++++++------
  1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
index 4c9a37dd0d3f..495c94e7929f 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
@@ -54,20 +54,21 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id
  	bool mdio = false;
  
  	np = dev_of_node(&pdev->dev);
-
  	if (!np) {
-		pr_info("dwmac_loongson_pci: No OF node\n");
+		dev_err(&pdev->dev, "dwmac_loongson_pci: No OF node\n");
  		return -ENODEV;
  	}
  
  	if (!of_device_is_compatible(np, "loongson, pci-gmac")) {
-		pr_info("dwmac_loongson_pci: Incompatible OF node\n");
+		dev_err(&pdev->dev, "dwmac_loongson_pci: Incompatible OF node\n");
  		return -ENODEV;
  	}
  
  	plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL);
-	if (!plat)
+	if (!plat) {
+		dev_err(&pdev->dev, "memory allocation failed\n");
Please don't add error messages after allocation failures. OOM will
produce a lot of kernel messages and a stack trace already.
quoted
  		return -ENOMEM;
+	}
  
  	if (plat->mdio_node) {
  		dev_err(&pdev->dev, "Found MDIO subnode\n");
@@ -109,8 +110,10 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id
  		plat->bus_id = pci_dev_id(pdev);
  
  	phy_mode = device_get_phy_mode(&pdev->dev);
-	if (phy_mode < 0)
+	if (phy_mode < 0) {
  		dev_err(&pdev->dev, "phy_mode not found\n");
+		return phy_mode;
You're adding a return here, it should be a separate patch with its own
justification.
quoted
+	}
  
  	plat->phy_interface = phy_mode;
  	plat->interface = PHY_INTERFACE_MODE_GMII;
@@ -130,7 +133,7 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id
  
  	res.wol_irq = of_irq_get_byname(np, "eth_wake_irq");
  	if (res.wol_irq < 0) {
-		dev_info(&pdev->dev, "IRQ eth_wake_irq not found, using macirq\n");
+		dev_err(&pdev->dev, "IRQ eth_wake_irq not found, using macirq\n");
Why upgrade to an error, isn't wol_irq optional?
quoted
  		res.wol_irq = res.irq;
  	}
  


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help