summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2014-07-31 08:21:07 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2014-09-16 08:32:06 +0200
commit92cc1b1f9e3363046583962859a3a8c054f4b94d (patch)
tree087a6fcf3e62943e8828386f25bedcccbc8b5dec
parentdbea5e0e353773544094d7e73aa41ef369d081a5 (diff)
downloadbarebox-92cc1b1f9e3363046583962859a3a8c054f4b94d.tar.gz
barebox-92cc1b1f9e3363046583962859a3a8c054f4b94d.tar.xz
resource: Let dev_get_resource_by_name return an error pointer
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--drivers/base/driver.c7
-rw-r--r--drivers/gpio/gpio-generic.c7
2 files changed, 8 insertions, 6 deletions
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 2cf3ee689..00b3046be 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -32,6 +32,7 @@
#include <fs.h>
#include <of.h>
#include <linux/list.h>
+#include <linux/err.h>
#include <complete.h>
#include <pinctrl.h>
@@ -286,7 +287,7 @@ struct resource *dev_get_resource_by_name(struct device_d *dev,
return res;
}
- return NULL;
+ return ERR_PTR(-ENOENT);
}
void *dev_get_mem_region_by_name(struct device_d *dev, const char *name)
@@ -294,7 +295,7 @@ void *dev_get_mem_region_by_name(struct device_d *dev, const char *name)
struct resource *res;
res = dev_get_resource_by_name(dev, IORESOURCE_MEM, name);
- if (!res)
+ if (IS_ERR(res))
return NULL;
return (void __force *)res->start;
@@ -306,7 +307,7 @@ void __iomem *dev_request_mem_region_by_name(struct device_d *dev, const char *n
struct resource *res;
res = dev_get_resource_by_name(dev, IORESOURCE_MEM, name);
- if (!res)
+ if (IS_ERR(res))
return NULL;
res = request_iomem_region(dev_name(dev), res->start, res->end);
diff --git a/drivers/gpio/gpio-generic.c b/drivers/gpio/gpio-generic.c
index 5c4628204..eeb4b4277 100644
--- a/drivers/gpio/gpio-generic.c
+++ b/drivers/gpio/gpio-generic.c
@@ -13,6 +13,7 @@
#include <init.h>
#include <malloc.h>
+#include <linux/err.h>
#include <linux/log2.h>
#include <linux/basic_mmio_gpio.h>
@@ -311,7 +312,7 @@ static void __iomem *bgpio_map(struct device_d *dev, const char *name,
*err = 0;
r = dev_get_resource_by_name(dev, IORESOURCE_MEM, name);
- if (!r)
+ if (IS_ERR(r))
return NULL;
if (resource_size(r) != sane_sz) {
@@ -343,8 +344,8 @@ static int bgpio_dev_probe(struct device_d *dev)
struct bgpio_pdata *pdata = dev->platform_data;
r = dev_get_resource_by_name(dev, IORESOURCE_MEM, "dat");
- if (!r)
- return -EINVAL;
+ if (IS_ERR(r))
+ return PTR_ERR(r);
sz = resource_size(r);