9
0
Fork 0

resource: Let request_iomem_region return an error pointer

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Sascha Hauer 2014-07-31 08:38:08 +02:00
parent 82ed205466
commit dde56d42ad
8 changed files with 16 additions and 19 deletions

View File

@ -124,8 +124,8 @@ int barebox_add_memory_bank(const char *name, resource_size_t start,
struct device_d *dev; struct device_d *dev;
bank->res = request_iomem_region(name, start, start + size - 1); bank->res = request_iomem_region(name, start, start + size - 1);
if (!bank->res) if (IS_ERR(bank->res))
return -EBUSY; return PTR_ERR(bank->res);
dev = add_mem_device(name, start, size, IORESOURCE_MEM_WRITEABLE); dev = add_mem_device(name, start, size, IORESOURCE_MEM_WRITEABLE);

View File

@ -125,13 +125,7 @@ struct resource iomem_resource = {
struct resource *request_iomem_region(const char *name, struct resource *request_iomem_region(const char *name,
resource_size_t start, resource_size_t end) resource_size_t start, resource_size_t end)
{ {
struct resource *res; return __request_region(&iomem_resource, name, start, end);
res = __request_region(&iomem_resource, name, start, end);
if (IS_ERR(res))
return NULL;
return res;
} }
/* The root resource for the whole io-mapped io space */ /* The root resource for the whole io-mapped io space */

View File

@ -7,6 +7,7 @@
#include <common.h> #include <common.h>
#include <driver.h> #include <driver.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/err.h>
#include <linux/amba/bus.h> #include <linux/amba/bus.h>
#include <io.h> #include <io.h>
#include <init.h> #include <init.h>
@ -115,8 +116,8 @@ int amba_device_add(struct amba_device *dev)
*/ */
size = resource_size(&dev->res); size = resource_size(&dev->res);
res = request_iomem_region("amba", dev->res.start, dev->res.end); res = request_iomem_region("amba", dev->res.start, dev->res.end);
if (!res) if (IS_ERR(res))
return -ENOMEM; return PTR_ERR(res);
dev->base = tmp = (void __force __iomem *)res->start; dev->base = tmp = (void __force __iomem *)res->start;
if (!tmp) { if (!tmp) {
ret = -ENOMEM; ret = -ENOMEM;

View File

@ -28,6 +28,7 @@
#include <errno.h> #include <errno.h>
#include <ata_drive.h> #include <ata_drive.h>
#include <platform_ide.h> #include <platform_ide.h>
#include <linux/err.h>
/** /**
* Setup the register specific addresses for an ATA like divice * Setup the register specific addresses for an ATA like divice

View File

@ -311,7 +311,7 @@ void __iomem *dev_request_mem_region_by_name(struct device_d *dev, const char *n
return NULL; return NULL;
res = request_iomem_region(dev_name(dev), res->start, res->end); res = request_iomem_region(dev_name(dev), res->start, res->end);
if (!res) if (IS_ERR(res))
return NULL; return NULL;
return (void __force __iomem *)res->start; return (void __force __iomem *)res->start;
@ -327,7 +327,7 @@ void __iomem *dev_request_mem_region(struct device_d *dev, int num)
return NULL; return NULL;
res = request_iomem_region(dev_name(dev), res->start, res->end); res = request_iomem_region(dev_name(dev), res->start, res->end);
if (!res) if (IS_ERR(res))
return NULL; return NULL;
return (void __force __iomem *)res->start; return (void __force __iomem *)res->start;

View File

@ -15,6 +15,7 @@
#include <malloc.h> #include <malloc.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/log2.h> #include <linux/log2.h>
#include <linux/err.h>
#include <linux/basic_mmio_gpio.h> #include <linux/basic_mmio_gpio.h>
static void bgpio_write8(void __iomem *reg, unsigned int data) static void bgpio_write8(void __iomem *reg, unsigned int data)
@ -321,8 +322,8 @@ static void __iomem *bgpio_map(struct device_d *dev, const char *name,
} }
ret = request_iomem_region(dev_name(dev), r->start, r->end); ret = request_iomem_region(dev_name(dev), r->start, r->end);
if (!ret) { if (IS_ERR(ret)) {
*err = -ENOMEM; *err = PTR_ERR(ret);
return NULL; return NULL;
} }

View File

@ -77,9 +77,9 @@ static int syscon_probe(struct device_d *dev)
} }
res = request_iomem_region(dev_name(dev), res->start, res->end); res = request_iomem_region(dev_name(dev), res->start, res->end);
if (!res) { if (IS_ERR(res)) {
free(syscon); free(syscon);
return -EBUSY; return PTR_ERR(res);
} }
syscon->base = (void __iomem *)res->start; syscon->base = (void __iomem *)res->start;

View File

@ -341,10 +341,10 @@ static int rockchip_get_bank_data(struct rockchip_pin_bank *bank,
} }
res = request_iomem_region(dev_name(dev), node_res.start, node_res.end); res = request_iomem_region(dev_name(dev), node_res.start, node_res.end);
if (!res) { if (IS_ERR(res)) {
dev_err(dev, "cannot request iomem region %08x\n", dev_err(dev, "cannot request iomem region %08x\n",
node_res.start); node_res.start);
return -ENOENT; return PTR_ERR(res);
} }
bank->reg_base = (void __iomem *)res->start; bank->reg_base = (void __iomem *)res->start;