Commit 2479790b2970ee386174431af2ad9c948b328b95

Authored by Julia Lawall
Committed by Mark Brown
1 parent 7668c29407

spi/sirf: simplify use of devm_ioremap_resource

Remove unneeded error handling on the result of a call to
platform_get_resource when the value is passed to devm_ioremap_resource.

Move the call to platform_get_resource adjacent to the call to
devm_ioremap_resource to make the connection between them more clear.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n);
  ... when != res
- if (res == NULL) { ... \(goto l;\|return ret;\) }
  ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n);
  e = devm_ioremap_resource(e1, res);
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Acked-by: Barry Song <Baohua.Song@csr.com>
Signed-off-by: Mark Brown <broonie@linaro.org>

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

drivers/spi/spi-sirf.c
... ... @@ -588,12 +588,6 @@
588 588 platform_set_drvdata(pdev, master);
589 589 sspi = spi_master_get_devdata(master);
590 590  
591   - mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
592   - if (!mem_res) {
593   - dev_err(&pdev->dev, "Unable to get IO resource\n");
594   - ret = -ENODEV;
595   - goto free_master;
596   - }
597 591 master->num_chipselect = num_cs;
598 592  
599 593 for (i = 0; i < master->num_chipselect; i++) {
... ... @@ -620,6 +614,7 @@
620 614 }
621 615 }
622 616  
  617 + mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
623 618 sspi->base = devm_ioremap_resource(&pdev->dev, mem_res);
624 619 if (IS_ERR(sspi->base)) {
625 620 ret = PTR_ERR(sspi->base);