diff mbox

[1/14] i2c: mpc: delete unneeded test before of_node_put

Message ID 1407492475-26283-1-git-send-email-Julia.Lawall@lip6.fr
State Accepted
Headers show

Commit Message

Julia Lawall Aug. 8, 2014, 10:07 a.m. UTC
From: Julia Lawall <Julia.Lawall@lip6.fr>

Of_node_put supports NULL as its argument, so the initial test is not
necessary.

Suggested by Uwe Kleine-König.

The semantic patch that fixes this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression e;
@@

-if (e)
   of_node_put(e);
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/i2c/busses/i2c-mpc.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)


--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Uwe Kleine-König Aug. 8, 2014, 10:25 a.m. UTC | #1
Hello,

On Fri, Aug 08, 2014 at 12:07:42PM +0200, Julia Lawall wrote:
> From: Julia Lawall <Julia.Lawall@lip6.fr>
> 
> Of_node_put supports NULL as its argument, so the initial test is not
> necessary.
> 
> Suggested by Uwe Kleine-König.
Thanks for picking up my suggestion.

> The semantic patch that fixes this problem is as follows:
> (http://coccinelle.lip6.fr/)
> 
> // <smpl>
> @@
> expression e;
> @@
> 
> -if (e)
>    of_node_put(e);
> // </smpl>
> 

I added devicetree@vger.kernel.org to Cc. Maybe they want to comment the
series? If it's acceptable the logical next step is to add the patch to
the collection of semantic patches, right?

Best regards
Uwe

> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
> 
> ---
>  drivers/i2c/busses/i2c-mpc.c |    3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
> index 6a32aa0..0edf630 100644
> --- a/drivers/i2c/busses/i2c-mpc.c
> +++ b/drivers/i2c/busses/i2c-mpc.c
> @@ -341,8 +341,7 @@ static u32 mpc_i2c_get_sec_cfg_8xxx(void)
>  			iounmap(reg);
>  		}
>  	}
> -	if (node)
> -		of_node_put(node);
> +	of_node_put(node);
>  
>  	return val;
>  }
> 
>
Julia Lawall Aug. 8, 2014, 10:27 a.m. UTC | #2
On Fri, 8 Aug 2014, Uwe Kleine-König wrote:

> Hello,
>
> On Fri, Aug 08, 2014 at 12:07:42PM +0200, Julia Lawall wrote:
> > From: Julia Lawall <Julia.Lawall@lip6.fr>
> >
> > Of_node_put supports NULL as its argument, so the initial test is not
> > necessary.
> >
> > Suggested by Uwe Kleine-König.
> Thanks for picking up my suggestion.
>
> > The semantic patch that fixes this problem is as follows:
> > (http://coccinelle.lip6.fr/)
> >
> > // <smpl>
> > @@
> > expression e;
> > @@
> >
> > -if (e)
> >    of_node_put(e);
> > // </smpl>
> >
>
> I added devicetree@vger.kernel.org to Cc. Maybe they want to comment the
> series? If it's acceptable the logical next step is to add the patch to
> the collection of semantic patches, right?

Yes, I will do that.

julia
Wolfram Sang Aug. 8, 2014, 4:50 p.m. UTC | #3
On Fri, Aug 08, 2014 at 12:07:42PM +0200, Julia Lawall wrote:
> From: Julia Lawall <Julia.Lawall@lip6.fr>
> 
> Of_node_put supports NULL as its argument, so the initial test is not
> necessary.
> 
> Suggested by Uwe Kleine-König.
> 
> The semantic patch that fixes this problem is as follows:
> (http://coccinelle.lip6.fr/)
> 
> // <smpl>
> @@
> expression e;
> @@
> 
> -if (e)
>    of_node_put(e);
> // </smpl>
> 
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
> 

Applied to for-next, thanks!
diff mbox

Patch

diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index 6a32aa0..0edf630 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -341,8 +341,7 @@  static u32 mpc_i2c_get_sec_cfg_8xxx(void)
 			iounmap(reg);
 		}
 	}
-	if (node)
-		of_node_put(node);
+	of_node_put(node);
 
 	return val;
 }