* [PATCH] staging: netlogic: Simplify use of devm_ioremap_resource
@ 2016-02-23 15:01 Amitoj Kaur Chawla
2016-02-23 15:45 ` [Outreachy kernel] " Julia Lawall
0 siblings, 1 reply; 3+ messages in thread
From: Amitoj Kaur Chawla @ 2016-02-23 15:01 UTC (permalink / raw)
To: outreachy-kernel
Remove unneeded error handling on the result of a call to
platform_get_resource when the value is passed to
devm_ioremap_resource.
Move the call to platform_get_resource adjacent to the call to
devm_ioremap_resource to make the connection between them more clear.
The Coccinelle semantic patch that makes this change is as follows:
// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@
- res = platform_get_resource(pdev, IORESOURCE_MEM, n);
... when != res
- if (res == NULL) { ... \(goto l;\|return ret;\) }
... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n);
e = devm_ioremap_resource(e1, res);
// </smpl>
Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
---
drivers/staging/netlogic/xlr_net.c | 7 -------
1 file changed, 7 deletions(-)
diff --git a/drivers/staging/netlogic/xlr_net.c b/drivers/staging/netlogic/xlr_net.c
index 0015847..3a6de47 100644
--- a/drivers/staging/netlogic/xlr_net.c
+++ b/drivers/staging/netlogic/xlr_net.c
@@ -1038,13 +1038,6 @@ static int xlr_net_probe(struct platform_device *pdev)
priv->port_id = (pdev->id * 4) + port;
priv->nd = (struct xlr_net_data *)pdev->dev.platform_data;
res = platform_get_resource(pdev, IORESOURCE_MEM, port);
-
- if (res == NULL) {
- pr_err("No memory resource for MAC %d\n",
- priv->port_id);
- err = -ENODEV;
- goto err_gmac;
- }
priv->base_addr = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(priv->base_addr)) {
err = PTR_ERR(priv->base_addr);
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Outreachy kernel] [PATCH] staging: netlogic: Simplify use of devm_ioremap_resource
2016-02-23 15:01 [PATCH] staging: netlogic: Simplify use of devm_ioremap_resource Amitoj Kaur Chawla
@ 2016-02-23 15:45 ` Julia Lawall
2016-02-23 16:39 ` Amitoj Kaur Chawla
0 siblings, 1 reply; 3+ messages in thread
From: Julia Lawall @ 2016-02-23 15:45 UTC (permalink / raw)
To: Amitoj Kaur Chawla; +Cc: outreachy-kernel
On Tue, 23 Feb 2016, Amitoj Kaur Chawla wrote:
> Remove unneeded error handling on the result of a call to
> platform_get_resource when the value is passed to
> devm_ioremap_resource.
>
> Move the call to platform_get_resource adjacent to the call to
> devm_ioremap_resource to make the connection between them more clear.
You didn't do anything for the latter. It was already in the right place.
julia
> The Coccinelle semantic patch that makes this change is as follows:
>
> // <smpl>
> @@
> expression pdev,res,n,e,e1;
> expression ret != 0;
> identifier l;
> @@
>
> - res = platform_get_resource(pdev, IORESOURCE_MEM, n);
> ... when != res
> - if (res == NULL) { ... \(goto l;\|return ret;\) }
> ... when != res
> + res = platform_get_resource(pdev, IORESOURCE_MEM, n);
> e = devm_ioremap_resource(e1, res);
> // </smpl>
>
> Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
> ---
> drivers/staging/netlogic/xlr_net.c | 7 -------
> 1 file changed, 7 deletions(-)
>
> diff --git a/drivers/staging/netlogic/xlr_net.c b/drivers/staging/netlogic/xlr_net.c
> index 0015847..3a6de47 100644
> --- a/drivers/staging/netlogic/xlr_net.c
> +++ b/drivers/staging/netlogic/xlr_net.c
> @@ -1038,13 +1038,6 @@ static int xlr_net_probe(struct platform_device *pdev)
> priv->port_id = (pdev->id * 4) + port;
> priv->nd = (struct xlr_net_data *)pdev->dev.platform_data;
> res = platform_get_resource(pdev, IORESOURCE_MEM, port);
> -
> - if (res == NULL) {
> - pr_err("No memory resource for MAC %d\n",
> - priv->port_id);
> - err = -ENODEV;
> - goto err_gmac;
> - }
> priv->base_addr = devm_ioremap_resource(&pdev->dev, res);
> if (IS_ERR(priv->base_addr)) {
> err = PTR_ERR(priv->base_addr);
> --
> 1.9.1
>
> --
> You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20160223150151.GA11902%40amitoj-Inspiron-3542.
> For more options, visit https://groups.google.com/d/optout.
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Outreachy kernel] [PATCH] staging: netlogic: Simplify use of devm_ioremap_resource
2016-02-23 15:45 ` [Outreachy kernel] " Julia Lawall
@ 2016-02-23 16:39 ` Amitoj Kaur Chawla
0 siblings, 0 replies; 3+ messages in thread
From: Amitoj Kaur Chawla @ 2016-02-23 16:39 UTC (permalink / raw)
To: Julia Lawall; +Cc: outreachy-kernel
On Tue, Feb 23, 2016 at 9:15 PM, Julia Lawall <julia.lawall@lip6.fr> wrote:
>
>
> On Tue, 23 Feb 2016, Amitoj Kaur Chawla wrote:
>
>> Remove unneeded error handling on the result of a call to
>> platform_get_resource when the value is passed to
>> devm_ioremap_resource.
>>
>> Move the call to platform_get_resource adjacent to the call to
>> devm_ioremap_resource to make the connection between them more clear.
>
> You didn't do anything for the latter. It was already in the right place.
>
> julia
>
Yes, the deletion automatically made it adjacent. I'll revise the
message and send v2.
Amitoj
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-02-23 16:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-23 15:01 [PATCH] staging: netlogic: Simplify use of devm_ioremap_resource Amitoj Kaur Chawla
2016-02-23 15:45 ` [Outreachy kernel] " Julia Lawall
2016-02-23 16:39 ` Amitoj Kaur Chawla
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.