Skip to content

Commit

Permalink
avr32: fix error return code
Browse files Browse the repository at this point in the history
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>
@@
identifier ret; expression e1,e2;
@@
(
if (\(ret < 0\|ret != 0\))
 { ... return ret; }
|
ret = 0
)
... when != ret = e1
    when != &ret
*if(...)
{
  ... when != ret = e2
      when forall
 return ret;
}
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Acked-by: Hans-Christian Egtvedt <egtvedt@samfundet.no>
  • Loading branch information
Julia Lawall authored and Hans-Christian Egtvedt committed Aug 7, 2014
1 parent 19583ca commit 686913a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions arch/avr32/boards/hammerhead/flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,19 @@ static int __init hammerhead_usbh_init(void)

/* setup gclk0 to run from osc1 */
gclk = clk_get(NULL, "gclk0");
if (IS_ERR(gclk))
if (IS_ERR(gclk)) {
ret = PTR_ERR(gclk);
goto err_gclk;
}

osc = clk_get(NULL, "osc1");
if (IS_ERR(osc))
if (IS_ERR(osc)) {
ret = PTR_ERR(osc);
goto err_osc;
}

if (clk_set_parent(gclk, osc)) {
ret = clk_set_parent(gclk, osc);
if (ret < 0) {
pr_debug("hammerhead: failed to set osc1 for USBH clock\n");
goto err_set_clk;
}
Expand Down

0 comments on commit 686913a

Please sign in to comment.