Commit 8d240260 authored by Heiner Kallweit's avatar Heiner Kallweit Committed by Linus Walleij

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: default avatarHeiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 43960b47
...@@ -579,34 +579,20 @@ EXPORT_SYMBOL_GPL(bgpio_init); ...@@ -579,34 +579,20 @@ EXPORT_SYMBOL_GPL(bgpio_init);
static void __iomem *bgpio_map(struct platform_device *pdev, static void __iomem *bgpio_map(struct platform_device *pdev,
const char *name, const char *name,
resource_size_t sane_sz, resource_size_t sane_sz)
int *err)
{ {
struct resource *r; struct resource *r;
resource_size_t sz; resource_size_t sz;
void __iomem *ret;
*err = 0;
r = platform_get_resource_byname(pdev, IORESOURCE_MEM, name); r = platform_get_resource_byname(pdev, IORESOURCE_MEM, name);
if (!r) { if (!r)
*err = -EINVAL; return IOMEM_ERR_PTR(-EINVAL);
return NULL;
}
sz = resource_size(r); sz = resource_size(r);
if (sz != sane_sz) { if (sz != sane_sz)
*err = -EINVAL; return IOMEM_ERR_PTR(-EINVAL);
return NULL;
}
ret = devm_ioremap_resource(&pdev->dev, r); return devm_ioremap_resource(&pdev->dev, r);
if (IS_ERR(ret)) {
*err = PTR_ERR(ret);
return NULL;
}
return ret;
} }
static int bgpio_pdev_probe(struct platform_device *pdev) static int bgpio_pdev_probe(struct platform_device *pdev)
...@@ -630,25 +616,25 @@ static int bgpio_pdev_probe(struct platform_device *pdev) ...@@ -630,25 +616,25 @@ static int bgpio_pdev_probe(struct platform_device *pdev)
sz = resource_size(r); sz = resource_size(r);
dat = bgpio_map(pdev, "dat", sz, &err); dat = bgpio_map(pdev, "dat", sz);
if (err) if (IS_ERR(dat))
return err; return PTR_ERR(dat);
set = bgpio_map(pdev, "set", sz, &err); set = bgpio_map(pdev, "set", sz);
if (err) if (IS_ERR(set))
return err; return PTR_ERR(set);
clr = bgpio_map(pdev, "clr", sz, &err); clr = bgpio_map(pdev, "clr", sz);
if (err) if (IS_ERR(clr))
return err; return PTR_ERR(clr);
dirout = bgpio_map(pdev, "dirout", sz, &err); dirout = bgpio_map(pdev, "dirout", sz);
if (err) if (IS_ERR(dirout))
return err; return PTR_ERR(dirout);
dirin = bgpio_map(pdev, "dirin", sz, &err); dirin = bgpio_map(pdev, "dirin", sz);
if (err) if (IS_ERR(dirin))
return err; return PTR_ERR(dirin);
bgc = devm_kzalloc(&pdev->dev, sizeof(*bgc), GFP_KERNEL); bgc = devm_kzalloc(&pdev->dev, sizeof(*bgc), GFP_KERNEL);
if (!bgc) if (!bgc)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment