summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2014-07-31 08:47:48 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2014-09-16 08:32:09 +0200
commit9d518ba397712add7fa06ff3ab056a26a3c46de6 (patch)
treeda8fbe4537c39f433b6868b7733bbc2e34250378
parentdde56d42ad1763dd81a3de65b74d7387d12f6fa9 (diff)
downloadbarebox-9d518ba397712add7fa06ff3ab056a26a3c46de6.tar.gz
barebox-9d518ba397712add7fa06ff3ab056a26a3c46de6.tar.xz
resource: Let dev_get_resource return an error pointer
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--drivers/ata/intf_platform_ide.c6
-rw-r--r--drivers/base/driver.c6
-rw-r--r--drivers/mfd/syscon.c4
-rw-r--r--drivers/misc/sram.c2
-rw-r--r--drivers/serial/serial_ns16550.c8
5 files changed, 14 insertions, 12 deletions
diff --git a/drivers/ata/intf_platform_ide.c b/drivers/ata/intf_platform_ide.c
index db4c35611..851f8f5c5 100644
--- a/drivers/ata/intf_platform_ide.c
+++ b/drivers/ata/intf_platform_ide.c
@@ -97,8 +97,8 @@ static int platform_ide_probe(struct device_d *dev)
alt_base = dev_request_mem_region(dev, 1);
} else {
reg = dev_get_resource(dev, IORESOURCE_IO, 0);
- if (!reg)
- return -ENODEV;
+ if (IS_ERR(reg))
+ return PTR_ERR(reg);
reg = request_ioport_region(dev_name(dev), reg->start,
reg->end);
@@ -108,7 +108,7 @@ static int platform_ide_probe(struct device_d *dev)
reg_base = (void __force __iomem *) reg->start;
alt = dev_get_resource(dev, IORESOURCE_IO, 1);
- if (alt) {
+ if (!IS_ERR(alt)) {
alt = request_ioport_region(dev_name(dev),
alt->start,
alt->end);
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index d90da4227..524ed1c98 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -256,7 +256,7 @@ struct resource *dev_get_resource(struct device_d *dev, unsigned long type,
}
}
- return NULL;
+ return ERR_PTR(-ENOENT);
}
void *dev_get_mem_region(struct device_d *dev, int num)
@@ -264,7 +264,7 @@ void *dev_get_mem_region(struct device_d *dev, int num)
struct resource *res;
res = dev_get_resource(dev, IORESOURCE_MEM, num);
- if (!res)
+ if (IS_ERR(res))
return NULL;
return (void __force *)res->start;
@@ -323,7 +323,7 @@ void __iomem *dev_request_mem_region(struct device_d *dev, int num)
struct resource *res;
res = dev_get_resource(dev, IORESOURCE_MEM, num);
- if (!res)
+ if (IS_ERR(res))
return NULL;
res = request_iomem_region(dev_name(dev), res->start, res->end);
diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
index 231f4fef9..9589a03f1 100644
--- a/drivers/mfd/syscon.c
+++ b/drivers/mfd/syscon.c
@@ -71,9 +71,9 @@ static int syscon_probe(struct device_d *dev)
return -ENOMEM;
res = dev_get_resource(dev, IORESOURCE_MEM, 0);
- if (!res) {
+ if (IS_ERR(res)) {
free(syscon);
- return -ENOENT;
+ return PTR_ERR(res);
}
res = request_iomem_region(dev_name(dev), res->start, res->end);
diff --git a/drivers/misc/sram.c b/drivers/misc/sram.c
index 0466a1528..c89fe87ea 100644
--- a/drivers/misc/sram.c
+++ b/drivers/misc/sram.c
@@ -48,6 +48,8 @@ static int sram_probe(struct device_d *dev)
cdev_find_free_index("sram"));
res = dev_get_resource(dev, IORESOURCE_MEM, 0);
+ if (IS_ERR(res))
+ return PTR_ERR(res);
sram->cdev.size = (unsigned long)resource_size(res);
sram->cdev.ops = &memops;
diff --git a/drivers/serial/serial_ns16550.c b/drivers/serial/serial_ns16550.c
index 09e6a6aba..dd0986c32 100644
--- a/drivers/serial/serial_ns16550.c
+++ b/drivers/serial/serial_ns16550.c
@@ -317,8 +317,8 @@ static int ns16550_init_iomem(struct device_d *dev, struct ns16550_priv *priv)
int width;
res = dev_get_resource(dev, IORESOURCE_MEM, 0);
- if (!res)
- return -ENODEV;
+ if (IS_ERR(res))
+ return PTR_ERR(res);
priv->mmiobase = dev_request_mem_region(dev, 0);
@@ -347,8 +347,8 @@ static int ns16550_init_ioport(struct device_d *dev, struct ns16550_priv *priv)
int width;
res = dev_get_resource(dev, IORESOURCE_IO, 0);
- if (!res)
- return -ENODEV;
+ if (IS_ERR(res))
+ return PTR_ERR(res);
res = request_ioport_region(dev_name(dev), res->start, res->end);
if (!res)