Skip to contentSkip to conversation

cleanup on resource check

PATCH Superseded Varka Bhadram 2 participants 10 messages Oct 23, 2014 – Oct 24, 2014

Subsystems (6)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover cleanup on resource check

This series removes the duplication of sanity check for platform_get_resource() return resource. It will be checked with devm_ioremap_resource()

changes since v1:
- remove NULL dereference on resource_size()

Varka Bhadram (6):
ethernet: wiznet: remove unnecessary check
ethernet: wiznet: remove unnecessary check
ethernet: apm: xgene: remove unnecessary check
ethernet: marvell: remove unnecessary check
ethernet: renesas: remove unnecessary check
ethernet: samsung: sxgbe: remove unnecessary check

 drivers/net/ethernet/apm/xgene/xgene_enet_main.c   |   12 ------------
 drivers/net/ethernet/marvell/pxa168_eth.c          |    6 ++----
 drivers/net/ethernet/renesas/sh_eth.c              |    9 +++------
 .../net/ethernet/samsung/sxgbe/sxgbe_platform.c    |    3 ---
 drivers/net/ethernet/wiznet/w5100.c                |    6 ++----
 drivers/net/ethernet/wiznet/w5300.c                |    6 ++----
 6 files changed, 9 insertions(+), 33 deletions(-)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v2 1/6 ethernet: wiznet: remove unnecessary check

devm_ioremap_resource checks platform_get_resource() return value. We can remove the duplicate check here.

---
 drivers/net/ethernet/wiznet/w5100.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/ethernet/wiznet/w5100.c +2 -4
index 0f56b1c..70a930a 100644
@@ -638,14 +638,12 @@ static int w5100_hw_probe(struct platform_device *pdev)
 	}
 
 	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!mem)
-		return -ENXIO;
-	mem_size = resource_size(mem);
-
 	priv->base = devm_ioremap_resource(&pdev->dev, mem);
 	if (IS_ERR(priv->base))
 		return PTR_ERR(priv->base);
 
+	mem_size = resource_size(mem);
+
 	spin_lock_init(&priv->reg_lock);
 	priv->indirect = mem_size < W5100_BUS_DIRECT_SIZE;
 	if (priv->indirect) {
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH v2 2/6 ethernet: wiznet: remove unnecessary check

In reply to Varka Bhadram

devm_ioremap_resource checks platform_get_resource() return value. We can remove the duplicate check here.

---
 drivers/net/ethernet/wiznet/w5300.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/ethernet/wiznet/w5300.c +2 -4
index f961f14..7974b7d 100644
@@ -558,14 +558,12 @@ static int w5300_hw_probe(struct platform_device *pdev)
 	}
 
 	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!mem)
-		return -ENXIO;
-	mem_size = resource_size(mem);
-
 	priv->base = devm_ioremap_resource(&pdev->dev, mem);
 	if (IS_ERR(priv->base))
 		return PTR_ERR(priv->base);
 
+	mem_size = resource_size(mem);
+
 	spin_lock_init(&priv->reg_lock);
 	priv->indirect = mem_size < W5300_BUS_DIRECT_SIZE;
 	if (priv->indirect) {
Signature · 1 line
1.7.9.5
#3 lore raw

Re: [PATCH net-next v2 2/6] ethernet: wiznet: remove unnecessary check

Hello.

Quoted 7 lines · Varka Bhadram

devm_ioremap_resource checks platform_get_resource() return value. We can remove the duplicate check here.

---
  drivers/net/ethernet/wiznet/w5300.c |    6 ++----
  1 file changed, 2 insertions(+), 4 deletions(-)

Don't do 2 patches with the same subject. Either merge them, or include
the driver name (which is different in both cases) in the subject.

WBR, Sergei

#4 lore raw

PATCH v2 3/6 ethernet: apm: xgene: remove unnecessary check

In reply to Varka Bhadram

devm_ioremap_resource checks platform_get_resource() return value. We can remove the duplicate check here.

---
 drivers/net/ethernet/apm/xgene/xgene_enet_main.c |   12 ------------
 1 file changed, 12 deletions(-)
drivers/net/ethernet/apm/xgene/xgene_enet_main.c +0 -12
index 3c208cc..f226594 100644
@@ -761,10 +761,6 @@ static int xgene_enet_get_resources(struct xgene_enet_pdata *pdata)
 	ndev = pdata->ndev;
 
 	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "enet_csr");
-	if (!res) {
-		dev_err(dev, "Resource enet_csr not defined\n");
-		return -ENODEV;
-	}
 	pdata->base_addr = devm_ioremap_resource(dev, res);
 	if (IS_ERR(pdata->base_addr)) {
 		dev_err(dev, "Unable to retrieve ENET Port CSR region\n");
@@ -772,10 +768,6 @@ static int xgene_enet_get_resources(struct xgene_enet_pdata *pdata)
 	}
 
 	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ring_csr");
-	if (!res) {
-		dev_err(dev, "Resource ring_csr not defined\n");
-		return -ENODEV;
-	}
 	pdata->ring_csr_addr = devm_ioremap_resource(dev, res);
 	if (IS_ERR(pdata->ring_csr_addr)) {
 		dev_err(dev, "Unable to retrieve ENET Ring CSR region\n");
@@ -783,10 +775,6 @@ static int xgene_enet_get_resources(struct xgene_enet_pdata *pdata)
 	}
 
 	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ring_cmd");
-	if (!res) {
-		dev_err(dev, "Resource ring_cmd not defined\n");
-		return -ENODEV;
-	}
 	pdata->ring_cmd_addr = devm_ioremap_resource(dev, res);
 	if (IS_ERR(pdata->ring_cmd_addr)) {
 		dev_err(dev, "Unable to retrieve ENET Ring command region\n");
Signature · 1 line
1.7.9.5
#5 lore raw

PATCH v2 4/6 ethernet: marvell: remove unnecessary check

In reply to Varka Bhadram

devm_ioremap_resource checks platform_get_resource() return value. We can remove the duplicate check here.

---
 drivers/net/ethernet/marvell/pxa168_eth.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/ethernet/marvell/pxa168_eth.c +2 -4
index c3b209c..a378c92 100644
@@ -1505,16 +1505,14 @@ static int pxa168_eth_probe(struct platform_device *pdev)
 	pep = netdev_priv(dev);
 	pep->dev = dev;
 	pep->clk = clk;
+
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (res == NULL) {
-		err = -ENODEV;
-		goto err_netdev;
-	}
 	pep->base = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(pep->base)) {
 		err = -ENOMEM;
 		goto err_netdev;
 	}
+
 	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 	BUG_ON(!res);
 	dev->irq = res->start;
Signature · 1 line
1.7.9.5
#6 lore raw

PATCH v2 5/6 ethernet: renesas: remove unnecessary check

In reply to Varka Bhadram

devm_ioremap_resource checks platform_get_resource() return value. We can remove the duplicate check here.

---
 drivers/net/ethernet/renesas/sh_eth.c |    9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/net/ethernet/renesas/sh_eth.c +3 -6
index 60e9c2c..ffb49f3 100644
@@ -2769,10 +2769,6 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
 
 	/* get base addr */
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (unlikely(res == NULL)) {
-		dev_err(&pdev->dev, "invalid resource\n");
-		return -EINVAL;
-	}
 
 	ndev = alloc_etherdev(sizeof(struct sh_eth_private));
 	if (!ndev)
@@ -2781,8 +2777,6 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
 	pm_runtime_enable(&pdev->dev);
 	pm_runtime_get_sync(&pdev->dev);
 
-	/* The sh Ether-specific entries in the device structure. */
-	ndev->base_addr = res->start;
 	devno = pdev->id;
 	if (devno < 0)
 		devno = 0;
@@ -2806,6 +2800,9 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
 		goto out_release;
 	}
 
+	/* The sh Ether-specific entries in the device structure. */
+	ndev->base_addr = res->start;
+
 	spin_lock_init(&mdp->lock);
 	mdp->pdev = pdev;
 
Signature · 1 line
1.7.9.5
#7 lore raw

Re: [PATCH net-next v2 5/6] ethernet: renesas: remove unnecessary check

Quoted 12 lines · Varka Bhadram

devm_ioremap_resource checks platform_get_resource() return value. We can remove the duplicate check here.

---
  drivers/net/ethernet/renesas/sh_eth.c |    9 +++------
  1 file changed, 3 insertions(+), 6 deletions(-)
drivers/net/ethernet/renesas/sh_eth.c +0 -0
index 60e9c2c..ffb49f3 100644

[...]

Quoted 10 lines
drivers/net/ethernet/renesas/sh_eth.c +0 -2
@@ -2781,8 +2777,6 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
  	pm_runtime_enable(&pdev->dev);
  	pm_runtime_get_sync(&pdev->dev);
 
-	/* The sh Ether-specific entries in the device structure. */
-	ndev->base_addr = res->start;
  	devno = pdev->id;
  	if (devno < 0)
  		devno = 0;

drivers/net/ethernet/renesas/sh_eth.c static int sh_eth_drv_probe(struct platform_device *pdev) · line 2803

Quoted 4 lines
drivers/net/ethernet/renesas/sh_eth.c +1 -0
@@ -2806,6 +2800,9 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
  		goto out_release;
  	}
 
+	/* The sh Ether-specific entries in the device structure. */

No need to move the comment, at least not there.

drivers/net/ethernet/renesas/sh_eth.c static int sh_eth_drv_probe(struct platform_device *pdev) · line 2807

Quoted 4 lines
drivers/net/ethernet/renesas/sh_eth.c +2 -0
+	ndev->base_addr = res->start;
+
  	spin_lock_init(&mdp->lock);
  	mdp->pdev = pdev;

WBR, Sergei

#8 lore raw

Re: [PATCH net-next v2 5/6] ethernet: renesas: remove unnecessary check

Quoted 34 lines · Sergei Shtylyov
Quoted 12 lines · Varka Bhadram

devm_ioremap_resource checks platform_get_resource() return value. We can remove the duplicate check here.

---
  drivers/net/ethernet/renesas/sh_eth.c |    9 +++------
  1 file changed, 3 insertions(+), 6 deletions(-)
drivers/net/ethernet/renesas/sh_eth.c +0 -0
index 60e9c2c..ffb49f3 100644

[...]

Quoted 11 lines
drivers/net/ethernet/renesas/sh_eth.c +0 -2
@@ -2781,8 +2777,6 @@ static int sh_eth_drv_probe(struct 
 platform_device *pdev)
      pm_runtime_enable(&pdev->dev);
      pm_runtime_get_sync(&pdev->dev);
 
-    /* The sh Ether-specific entries in the device structure. */
-    ndev->base_addr = res->start;
      devno = pdev->id;
      if (devno < 0)
          devno = 0;

drivers/net/ethernet/renesas/sh_eth.c static int sh_eth_drv_probe(struct · line 2804

Quoted 5 lines
drivers/net/ethernet/renesas/sh_eth.c +1 -0
@@ -2806,6 +2800,9 @@ static int sh_eth_drv_probe(struct 
 platform_device *pdev)
          goto out_release;
      }
 
+    /* The sh Ether-specific entries in the device structure. */

No need to move the comment, at least not there.

Quoted 7 lines

drivers/net/ethernet/renesas/sh_eth.c static int sh_eth_drv_probe(struct platform_device *pdev) · line 2807

Quoted 4 lines
drivers/net/ethernet/renesas/sh_eth.c +2 -0
+    ndev->base_addr = res->start;
+
      spin_lock_init(&mdp->lock);
      mdp->pdev = pdev;

WBR, Sergei

thanks for the review. In v3 i will address these issues.

Signature · 2 lines
Thanks and Regards,
Varka Bhadram.
#9 lore raw

PATCH v2 6/6 ethernet: samsung: sxgbe: remove unnecessary check

In reply to Varka Bhadram

devm_ioremap_resource checks platform_get_resource() return value. We can remove the duplicate check here.

---
 .../net/ethernet/samsung/sxgbe/sxgbe_platform.c    |    3 ---
 1 file changed, 3 deletions(-)
drivers/net/ethernet/samsung/sxgbe/sxgbe_platform.c +0 -3
index b147d46..7fd6e27 100644
@@ -90,9 +90,6 @@ static int sxgbe_platform_probe(struct platform_device *pdev)
 
 	/* Get memory resource */
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res)
-		goto err_out;
-
 	addr = devm_ioremap_resource(dev, res);
 	if (IS_ERR(addr))
 		return PTR_ERR(addr);
Signature · 1 line
1.7.9.5