Commit d6a2b7ba67334a7e72cd153c142c449831557cb9

Authored by Julia Lawall
Committed by Linus Walleij
1 parent f7093f3e7a

drivers/gpio/gpio-langwell.c: fix error return code

Convert a 0 error return code 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 e,e1,e2,e3,e4,x;
@@

(
if (\(ret != 0\|ret < 0\) || ...) { ... return ...; }
|
ret = 0
)
... when != ret = e1
*x = \(kmalloc\|kzalloc\|kcalloc\|devm_kzalloc\|ioremap\|ioremap_nocache\|devm_ioremap\|devm_ioremap_nocache\)(...);
... when != x = e2
    when != ret = e3
*if (x == NULL || ...)
{
  ... when != ret = e4
*  return ret;
}
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

Showing 1 changed file with 5 additions and 2 deletions Side-by-side Diff

drivers/gpio/gpio-langwell.c
... ... @@ -339,7 +339,7 @@
339 339 resource_size_t start, len;
340 340 struct lnw_gpio *lnw;
341 341 u32 gpio_base;
342   - int retval = 0;
  342 + int retval;
343 343 int ngpio = id->driver_data;
344 344  
345 345 retval = pci_enable_device(pdev);
... ... @@ -357,6 +357,7 @@
357 357 base = ioremap_nocache(start, len);
358 358 if (!base) {
359 359 dev_err(&pdev->dev, "error mapping bar1\n");
  360 + retval = -EFAULT;
360 361 goto err3;
361 362 }
362 363 gpio_base = *((u32 *)base + 1);
363 364  
... ... @@ -381,8 +382,10 @@
381 382  
382 383 lnw->domain = irq_domain_add_linear(pdev->dev.of_node, ngpio,
383 384 &lnw_gpio_irq_ops, lnw);
384   - if (!lnw->domain)
  385 + if (!lnw->domain) {
  386 + retval = -ENOMEM;
385 387 goto err3;
  388 + }
386 389  
387 390 lnw->reg_base = base;
388 391 lnw->chip.label = dev_name(&pdev->dev);