public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/4] mfd: twl6040: fix error return code
@ 2014-08-06 20:12 Julia Lawall
  2014-08-21  8:20 ` Lee Jones
  0 siblings, 1 reply; 2+ messages in thread
From: Julia Lawall @ 2014-08-06 20:12 UTC (permalink / raw)
  To: Samuel Ortiz; +Cc: kernel-janitors, Lee Jones, linux-kernel

From: Julia Lawall <Julia.Lawall@lip6.fr>

Convert a zero return value on error to a negative one, as returned
elsewhere in the function.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
(
if@p1 (\(ret < 0\|ret != 0\))
 { ... return ret; }
|
ret@p1 = 0
)
... when != ret = e1
    when != &ret
*if(...)
{
  ... when != ret = e2
      when forall
 return ret;
}

// </smpl>

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

---
 drivers/mfd/twl6040.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mfd/twl6040.c b/drivers/mfd/twl6040.c
index f9c06c5..9687645 100644
--- a/drivers/mfd/twl6040.c
+++ b/drivers/mfd/twl6040.c
@@ -679,6 +679,7 @@ static int twl6040_probe(struct i2c_client *client,
 	if (twl6040->rev < 0) {
 		dev_err(&client->dev, "Failed to read revision register: %d\n",
 			twl6040->rev);
+		ret = twl6040->rev;
 		goto gpio_err;
 	}
 


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

end of thread, other threads:[~2014-08-21  8:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-06 20:12 [PATCH 2/4] mfd: twl6040: fix error return code Julia Lawall
2014-08-21  8:20 ` Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox