summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2014-07-31 09:02:47 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2014-09-16 08:32:10 +0200
commit29b7f95f3bd244a4b4d036e1b3a94a7bfbe3581c (patch)
tree282c0036b7127af4ecb76e6fb214de8a2077bcfb
parent9d518ba397712add7fa06ff3ab056a26a3c46de6 (diff)
downloadbarebox-29b7f95f3bd244a4b4d036e1b3a94a7bfbe3581c.tar.gz
barebox-29b7f95f3bd244a4b4d036e1b3a94a7bfbe3581c.tar.xz
resource: Let dev_get_mem_region return an error pointer
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Acked-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
-rw-r--r--drivers/base/driver.c7
-rw-r--r--drivers/bus/omap-gpmc.c5
-rw-r--r--drivers/net/gianfar.c11
-rw-r--r--drivers/net/orion-gbe.c5
-rw-r--r--drivers/net/phy/mdio-mvebu.c5
-rw-r--r--drivers/pinctrl/imx-iomux-v1.c3
-rw-r--r--drivers/serial/serial_clps711x.c2
7 files changed, 29 insertions, 9 deletions
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 524ed1c98..23f31ce77 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -265,7 +265,7 @@ void *dev_get_mem_region(struct device_d *dev, int num)
res = dev_get_resource(dev, IORESOURCE_MEM, num);
if (IS_ERR(res))
- return NULL;
+ return ERR_CAST(res);
return (void __force *)res->start;
}
@@ -348,6 +348,8 @@ int generic_memmap_ro(struct cdev *cdev, void **map, int flags)
if (flags & PROT_WRITE)
return -EACCES;
*map = dev_get_mem_region(cdev->dev, 0);
+ if (IS_ERR(*map))
+ return PTR_ERR(*map);
return 0;
}
@@ -357,6 +359,9 @@ int generic_memmap_rw(struct cdev *cdev, void **map, int flags)
return -EINVAL;
*map = dev_get_mem_region(cdev->dev, 0);
+ if (IS_ERR(*map))
+ return PTR_ERR(*map);
+
return 0;
}
diff --git a/drivers/bus/omap-gpmc.c b/drivers/bus/omap-gpmc.c
index d7b02cf6e..6cc326999 100644
--- a/drivers/bus/omap-gpmc.c
+++ b/drivers/bus/omap-gpmc.c
@@ -17,6 +17,7 @@
#include <of_address.h>
#include <of_mtd.h>
#include <linux/clk.h>
+#include <linux/err.h>
#include <mach/gpmc_nand.h>
#include <mach/gpmc.h>
@@ -404,8 +405,8 @@ static int gpmc_probe_nand_child(struct device_d *dev,
}
gpmc_base = dev_get_mem_region(dev, 0);
- if (!gpmc_base)
- return -ENODEV;
+ if (IS_ERR(gpmc_base))
+ return PTR_ERR(gpmc_base);
gpmc_nand_data.cs = val;
gpmc_nand_data.of_node = child;
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index a308035ff..5e47c64e0 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -21,6 +21,7 @@
#include <errno.h>
#include <asm/io.h>
#include <linux/phy.h>
+#include <linux/err.h>
#include "gianfar.h"
/* 2 seems to be the minimum number of TX descriptors to make it work. */
@@ -489,6 +490,8 @@ static int gfar_probe(struct device_d *dev)
priv->mdiobus_tbi = gfar_info->mdiobus_tbi;
priv->regs = dev_get_mem_region(dev, 0);
+ if (IS_ERR(priv->regs))
+ return PTR_ERR(priv->regs);
priv->phyaddr = gfar_info->phyaddr;
priv->tbicr = gfar_info->tbicr;
priv->tbiana = gfar_info->tbiana;
@@ -553,8 +556,8 @@ static int gfar_phy_probe(struct device_d *dev)
phy = xzalloc(sizeof(*phy));
phy->dev = dev;
phy->regs = dev_get_mem_region(dev, 0);
- if (!phy->regs)
- return -ENOMEM;
+ if (IS_ERR(phy->regs))
+ return PTR_ERR(phy->regs);
phy->miibus.read = gfar_miiphy_read;
phy->miibus.write = gfar_miiphy_write;
@@ -584,8 +587,8 @@ static int gfar_tbiphy_probe(struct device_d *dev)
phy = xzalloc(sizeof(*phy));
phy->dev = dev;
phy->regs = dev_get_mem_region(dev, 0);
- if (!phy->regs)
- return -ENOMEM;
+ if (IS_ERR(phy->regs))
+ return PTR_ERR(phy->regs);
phy->miibus.read = gfar_miiphy_read;
phy->miibus.write = gfar_miiphy_write;
diff --git a/drivers/net/orion-gbe.c b/drivers/net/orion-gbe.c
index 991c8a80d..ab761ad2e 100644
--- a/drivers/net/orion-gbe.c
+++ b/drivers/net/orion-gbe.c
@@ -415,6 +415,8 @@ static int port_probe(struct device_d *parent, struct port_priv *port)
port->intf = PHY_INTERFACE_MODE_RGMII;
port->regs = dev_get_mem_region(parent, 0) + PORTn_REGS(port->portno);
+ if (IS_ERR(port->regs))
+ return PTR_ERR(port->regs);
/* allocate rx/tx descriptors and buffers */
port->txdesc = dma_alloc_coherent(ALIGN(sizeof(*port->txdesc), 16));
@@ -490,6 +492,9 @@ static int orion_gbe_probe(struct device_d *dev)
dev->priv = gbe;
gbe->regs = dev_get_mem_region(dev, 0);
+ if (IS_ERR(gbe->regs))
+ return PTR_ERR(gbe->regs);
+
gbe->clk = clk_get(dev, 0);
if (!IS_ERR(gbe->clk))
clk_enable(gbe->clk);
diff --git a/drivers/net/phy/mdio-mvebu.c b/drivers/net/phy/mdio-mvebu.c
index b90e28102..460e2b413 100644
--- a/drivers/net/phy/mdio-mvebu.c
+++ b/drivers/net/phy/mdio-mvebu.c
@@ -28,6 +28,7 @@
#include <io.h>
#include <of.h>
#include <linux/clk.h>
+#include <linux/err.h>
#include <linux/phy.h>
#define SMI_DATA_SHIFT 0
@@ -113,8 +114,8 @@ static int mvebu_mdio_probe(struct device_d *dev)
dev->priv = priv;
priv->regs = dev_get_mem_region(dev, 0);
- if (!priv->regs)
- return -ENOMEM;
+ if (IS_ERR(priv->regs))
+ return PTR_ERR(priv->regs);
priv->clk = clk_get(dev, NULL);
if (IS_ERR(priv->clk))
diff --git a/drivers/pinctrl/imx-iomux-v1.c b/drivers/pinctrl/imx-iomux-v1.c
index 16415c2de..a3f04802a 100644
--- a/drivers/pinctrl/imx-iomux-v1.c
+++ b/drivers/pinctrl/imx-iomux-v1.c
@@ -4,6 +4,7 @@
#include <malloc.h>
#include <pinctrl.h>
#include <mach/iomux-v1.h>
+#include <linux/err.h>
/*
* GPIO Module and I/O Multiplexer
@@ -284,6 +285,8 @@ static int imx_iomux_v1_probe(struct device_d *dev)
return -EBUSY;
iomuxv1_base = dev_get_mem_region(dev, 0);
+ if (IS_ERR(iomuxv1_base))
+ return PTR_ERR(iomuxv1_base);
ret = of_platform_populate(dev->device_node, NULL, NULL);
diff --git a/drivers/serial/serial_clps711x.c b/drivers/serial/serial_clps711x.c
index a75547ce8..ad14373ac 100644
--- a/drivers/serial/serial_clps711x.c
+++ b/drivers/serial/serial_clps711x.c
@@ -147,6 +147,8 @@ static int clps711x_probe(struct device_d *dev)
}
s->base = dev_get_mem_region(dev, 0);
+ if (IS_ERR(s->base))
+ return PTR_ERR(s->base);
if (!dev->device_node) {
sprintf(syscon_dev, "syscon%i", id + 1);