* [PATCH 3/3] gpio: generic: replace error variable with errptr functionality in bgpio_map
@ 2015-09-30 21:52 Heiner Kallweit
2015-10-05 7:17 ` Linus Walleij
0 siblings, 1 reply; 2+ messages in thread
From: Heiner Kallweit @ 2015-09-30 21:52 UTC (permalink / raw)
To: Linus Walleij; +Cc: linux-gpio
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>
---
drivers/gpio/gpio-generic.c | 56 +++++++++++++++++----------------------------
1 file changed, 21 insertions(+), 35 deletions(-)
diff --git a/drivers/gpio/gpio-generic.c b/drivers/gpio/gpio-generic.c
index 0cdbe10..d8b1700 100644
--- a/drivers/gpio/gpio-generic.c
+++ b/drivers/gpio/gpio-generic.c
@@ -579,34 +579,20 @@ EXPORT_SYMBOL_GPL(bgpio_init);
static void __iomem *bgpio_map(struct platform_device *pdev,
const char *name,
- resource_size_t sane_sz,
- int *err)
+ resource_size_t sane_sz)
{
struct resource *r;
resource_size_t sz;
- void __iomem *ret;
-
- *err = 0;
r = platform_get_resource_byname(pdev, IORESOURCE_MEM, name);
- if (!r) {
- *err = -EINVAL;
- return NULL;
- }
+ if (!r)
+ return IOMEM_ERR_PTR(-EINVAL);
sz = resource_size(r);
- if (sz != sane_sz) {
- *err = -EINVAL;
- return NULL;
- }
+ if (sz != sane_sz)
+ return IOMEM_ERR_PTR(-EINVAL);
- ret = devm_ioremap_resource(&pdev->dev, r);
- if (IS_ERR(ret)) {
- *err = PTR_ERR(ret);
- return NULL;
- }
-
- return ret;
+ return devm_ioremap_resource(&pdev->dev, r);
}
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);
- dat = bgpio_map(pdev, "dat", sz, &err);
- if (err)
- return err;
+ dat = bgpio_map(pdev, "dat", sz);
+ if (IS_ERR(dat))
+ return PTR_ERR(dat);
- set = bgpio_map(pdev, "set", sz, &err);
- if (err)
- return err;
+ set = bgpio_map(pdev, "set", sz);
+ if (IS_ERR(set))
+ return PTR_ERR(set);
- clr = bgpio_map(pdev, "clr", sz, &err);
- if (err)
- return err;
+ clr = bgpio_map(pdev, "clr", sz);
+ if (IS_ERR(clr))
+ return PTR_ERR(clr);
- dirout = bgpio_map(pdev, "dirout", sz, &err);
- if (err)
- return err;
+ dirout = bgpio_map(pdev, "dirout", sz);
+ if (IS_ERR(dirout))
+ return PTR_ERR(dirout);
- dirin = bgpio_map(pdev, "dirin", sz, &err);
- if (err)
- return err;
+ dirin = bgpio_map(pdev, "dirin", sz);
+ if (IS_ERR(dirin))
+ return PTR_ERR(dirin);
bgc = devm_kzalloc(&pdev->dev, sizeof(*bgc), GFP_KERNEL);
if (!bgc)
--
2.6.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 3/3] gpio: generic: replace error variable with errptr functionality in bgpio_map
2015-09-30 21:52 [PATCH 3/3] gpio: generic: replace error variable with errptr functionality in bgpio_map Heiner Kallweit
@ 2015-10-05 7:17 ` Linus Walleij
0 siblings, 0 replies; 2+ messages in thread
From: Linus Walleij @ 2015-10-05 7:17 UTC (permalink / raw)
To: Heiner Kallweit; +Cc: linux-gpio@vger.kernel.org
On Wed, Sep 30, 2015 at 11:52 PM, Heiner Kallweit <hkallweit1@gmail.com> wrote:
> 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>
Patch applied after shortening subject.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-10-05 7:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-30 21:52 [PATCH 3/3] gpio: generic: replace error variable with errptr functionality in bgpio_map Heiner Kallweit
2015-10-05 7:17 ` Linus Walleij
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).