Skip to content

Commit 8d24026

Browse files
hkallweitLinus Walleij
authored andcommitted
gpio: generic: use error pointers
Use the ERRPTR standard way to return an error code in a pointer thus simplifiying the code. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent 43960b4 commit 8d24026

File tree

1 file changed

+21
-35
lines changed

1 file changed

+21
-35
lines changed

drivers/gpio/gpio-generic.c

Lines changed: 21 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -579,34 +579,20 @@ EXPORT_SYMBOL_GPL(bgpio_init);
579579

580580
static void __iomem *bgpio_map(struct platform_device *pdev,
581581
const char *name,
582-
resource_size_t sane_sz,
583-
int *err)
582+
resource_size_t sane_sz)
584583
{
585584
struct resource *r;
586585
resource_size_t sz;
587-
void __iomem *ret;
588-
589-
*err = 0;
590586

591587
r = platform_get_resource_byname(pdev, IORESOURCE_MEM, name);
592-
if (!r) {
593-
*err = -EINVAL;
594-
return NULL;
595-
}
588+
if (!r)
589+
return IOMEM_ERR_PTR(-EINVAL);
596590

597591
sz = resource_size(r);
598-
if (sz != sane_sz) {
599-
*err = -EINVAL;
600-
return NULL;
601-
}
592+
if (sz != sane_sz)
593+
return IOMEM_ERR_PTR(-EINVAL);
602594

603-
ret = devm_ioremap_resource(&pdev->dev, r);
604-
if (IS_ERR(ret)) {
605-
*err = PTR_ERR(ret);
606-
return NULL;
607-
}
608-
609-
return ret;
595+
return devm_ioremap_resource(&pdev->dev, r);
610596
}
611597

612598
static int bgpio_pdev_probe(struct platform_device *pdev)
@@ -630,25 +616,25 @@ static int bgpio_pdev_probe(struct platform_device *pdev)
630616

631617
sz = resource_size(r);
632618

633-
dat = bgpio_map(pdev, "dat", sz, &err);
634-
if (err)
635-
return err;
619+
dat = bgpio_map(pdev, "dat", sz);
620+
if (IS_ERR(dat))
621+
return PTR_ERR(dat);
636622

637-
set = bgpio_map(pdev, "set", sz, &err);
638-
if (err)
639-
return err;
623+
set = bgpio_map(pdev, "set", sz);
624+
if (IS_ERR(set))
625+
return PTR_ERR(set);
640626

641-
clr = bgpio_map(pdev, "clr", sz, &err);
642-
if (err)
643-
return err;
627+
clr = bgpio_map(pdev, "clr", sz);
628+
if (IS_ERR(clr))
629+
return PTR_ERR(clr);
644630

645-
dirout = bgpio_map(pdev, "dirout", sz, &err);
646-
if (err)
647-
return err;
631+
dirout = bgpio_map(pdev, "dirout", sz);
632+
if (IS_ERR(dirout))
633+
return PTR_ERR(dirout);
648634

649-
dirin = bgpio_map(pdev, "dirin", sz, &err);
650-
if (err)
651-
return err;
635+
dirin = bgpio_map(pdev, "dirin", sz);
636+
if (IS_ERR(dirin))
637+
return PTR_ERR(dirin);
652638

653639
bgc = devm_kzalloc(&pdev->dev, sizeof(*bgc), GFP_KERNEL);
654640
if (!bgc)

0 commit comments

Comments
 (0)