netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] net: w5300: Use devm_ioremap_resource()
@ 2014-02-27 10:30 Jingoo Han
  2014-02-27 10:30 ` [PATCH 2/2] net: w5100: " Jingoo Han
  2014-02-27 22:06 ` [PATCH 1/2] net: w5300: " David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Jingoo Han @ 2014-02-27 10:30 UTC (permalink / raw)
  To: 'David Miller'
  Cc: netdev, 'Jingoo Han', 'Mike Sinkovsky'

Use devm_ioremap_resource() in order to make the code simpler,
and remove redundant return value check of platform_get_resource()
because the value is checked by devm_ioremap_resource().

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
 drivers/net/ethernet/wiznet/w5300.c |   11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/wiznet/w5300.c b/drivers/net/ethernet/wiznet/w5300.c
index 71c27b3..1c3a5a5 100644
--- a/drivers/net/ethernet/wiznet/w5300.c
+++ b/drivers/net/ethernet/wiznet/w5300.c
@@ -558,14 +558,11 @@ static int w5300_hw_probe(struct platform_device *pdev)
 	}
 
 	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!mem)
-		return -ENXIO;
+	priv->base = devm_ioremap_resource(&pdev->dev, mem);
+	if (IS_ERR(priv->base))
+		return PTR_ERR(priv->base);
+
 	mem_size = resource_size(mem);
-	if (!devm_request_mem_region(&pdev->dev, mem->start, mem_size, name))
-		return -EBUSY;
-	priv->base = devm_ioremap(&pdev->dev, mem->start, mem_size);
-	if (!priv->base)
-		return -EBUSY;
 
 	spin_lock_init(&priv->reg_lock);
 	priv->indirect = mem_size < W5300_BUS_DIRECT_SIZE;
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] net: w5100: Use devm_ioremap_resource()
  2014-02-27 10:30 [PATCH 1/2] net: w5300: Use devm_ioremap_resource() Jingoo Han
@ 2014-02-27 10:30 ` Jingoo Han
  2014-02-27 22:06 ` [PATCH 1/2] net: w5300: " David Miller
  1 sibling, 0 replies; 4+ messages in thread
From: Jingoo Han @ 2014-02-27 10:30 UTC (permalink / raw)
  To: 'David Miller'
  Cc: netdev, 'Jingoo Han', 'Mike Sinkovsky'

Use devm_ioremap_resource() in order to make the code simpler,
and remove redundant return value check of platform_get_resource()
because the value is checked by devm_ioremap_resource().

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
 drivers/net/ethernet/wiznet/w5100.c |   11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/wiznet/w5100.c b/drivers/net/ethernet/wiznet/w5100.c
index 0df36c6..ffbd02c 100644
--- a/drivers/net/ethernet/wiznet/w5100.c
+++ b/drivers/net/ethernet/wiznet/w5100.c
@@ -638,14 +638,11 @@ static int w5100_hw_probe(struct platform_device *pdev)
 	}
 
 	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!mem)
-		return -ENXIO;
+	priv->base = devm_ioremap_resource(&pdev->dev, mem);
+	if (IS_ERR(priv->base))
+		return PTR_ERR(priv->base);
+
 	mem_size = resource_size(mem);
-	if (!devm_request_mem_region(&pdev->dev, mem->start, mem_size, name))
-		return -EBUSY;
-	priv->base = devm_ioremap(&pdev->dev, mem->start, mem_size);
-	if (!priv->base)
-		return -EBUSY;
 
 	spin_lock_init(&priv->reg_lock);
 	priv->indirect = mem_size < W5100_BUS_DIRECT_SIZE;
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] net: w5300: Use devm_ioremap_resource()
  2014-02-27 10:30 [PATCH 1/2] net: w5300: Use devm_ioremap_resource() Jingoo Han
  2014-02-27 10:30 ` [PATCH 2/2] net: w5100: " Jingoo Han
@ 2014-02-27 22:06 ` David Miller
  2014-02-28  5:40   ` Jingoo Han
  1 sibling, 1 reply; 4+ messages in thread
From: David Miller @ 2014-02-27 22:06 UTC (permalink / raw)
  To: jg1.han; +Cc: netdev, msink

From: Jingoo Han <jg1.han@samsung.com>
Date: Thu, 27 Feb 2014 19:30:04 +0900

> Use devm_ioremap_resource() in order to make the code simpler,
> and remove redundant return value check of platform_get_resource()
> because the value is checked by devm_ioremap_resource().
> 
> Signed-off-by: Jingoo Han <jg1.han@samsung.com>

I think the code with the NULL check removed is harder for semantic
checkers to figure out, because of what will look like a blind
dereference via resource_size(mem).

Unless all semantic checkers are going to learn the complete semantics
of devm_ioremap_resource(), in particular that it will signal an error
on a NULL second argument, and then the semantic checker will see
the complete control flow in the call site, I think we should keep
the NULL check.

Maybe recode this as:

	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);

Same goes for your other patch.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] net: w5300: Use devm_ioremap_resource()
  2014-02-27 22:06 ` [PATCH 1/2] net: w5300: " David Miller
@ 2014-02-28  5:40   ` Jingoo Han
  0 siblings, 0 replies; 4+ messages in thread
From: Jingoo Han @ 2014-02-28  5:40 UTC (permalink / raw)
  To: 'David Miller'; +Cc: netdev, msink, 'Jingoo Han'

On Friday, February 28, 2014 7:07 AM, David Miller wrote:
> From: Jingoo Han <jg1.han@samsung.com>
> Date: Thu, 27 Feb 2014 19:30:04 +0900
> 
> > Use devm_ioremap_resource() in order to make the code simpler,
> > and remove redundant return value check of platform_get_resource()
> > because the value is checked by devm_ioremap_resource().
> >
> > Signed-off-by: Jingoo Han <jg1.han@samsung.com>
> 
> I think the code with the NULL check removed is harder for semantic
> checkers to figure out, because of what will look like a blind
> dereference via resource_size(mem).
> 
> Unless all semantic checkers are going to learn the complete semantics
> of devm_ioremap_resource(), in particular that it will signal an error
> on a NULL second argument, and then the semantic checker will see
> the complete control flow in the call site, I think we should keep
> the NULL check.

OK, I see.
I agree with your opinion. I will send v2 patch, soon.
Thank you for your comment.

Best regards,
Jingoo Han

> 
> Maybe recode this as:
> 
> 	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);
> 
> Same goes for your other patch.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-02-28  5:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-27 10:30 [PATCH 1/2] net: w5300: Use devm_ioremap_resource() Jingoo Han
2014-02-27 10:30 ` [PATCH 2/2] net: w5100: " Jingoo Han
2014-02-27 22:06 ` [PATCH 1/2] net: w5300: " David Miller
2014-02-28  5:40   ` Jingoo Han

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).