]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
ASoC: davinci-mcasp.c: Return error code in failure
authorJulia Lawall <julia@diku.dk>
Mon, 18 Oct 2010 14:11:13 +0000 (16:11 +0200)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Mon, 18 Oct 2010 23:29:24 +0000 (16:29 -0700)
In this code, 0 is returned on failure, even though other
failures return -ENOMEM or other similar values.

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

// <smpl>
@a@
identifier alloc;
identifier ret;
constant C;
expression x;
@@

x = alloc(...);
if (x == NULL) { <+... \(ret = -C; \| return -C; \) ...+> }

@@
identifier f, a.alloc;
expression ret;
expression x,e1,e2,e3;
@@

ret = 0
... when != ret = e1
*x = alloc(...)
... when != ret = e2
if (x == NULL) { ... when != ret = e3
  return ret;
}
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
sound/soc/davinci/davinci-mcasp.c

index c8e97dcbfff4df849f13d539784ce0d2f3bb6ce7..86918ee12419e7fd3ff626bdb2ccd18a1bd09021 100644 (file)
@@ -898,6 +898,7 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
        res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
        if (!res) {
                dev_err(&pdev->dev, "no DMA resource\n");
+               ret = -ENODEV;
                goto err_release_region;
        }
 
@@ -912,6 +913,7 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
        res = platform_get_resource(pdev, IORESOURCE_DMA, 1);
        if (!res) {
                dev_err(&pdev->dev, "no DMA resource\n");
+               ret = -ENODEV;
                goto err_release_region;
        }