mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 05/10] resource: Let request_iomem_region return an error pointer
Date: Fri, 12 Sep 2014 12:13:45 +0200	[thread overview]
Message-ID: <1410516830-9403-6-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1410516830-9403-1-git-send-email-s.hauer@pengutronix.de>

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 common/memory.c                    | 4 ++--
 common/resource.c                  | 8 +-------
 drivers/amba/bus.c                 | 5 +++--
 drivers/ata/intf_platform_ide.c    | 1 +
 drivers/base/driver.c              | 4 ++--
 drivers/gpio/gpio-generic.c        | 5 +++--
 drivers/mfd/syscon.c               | 4 ++--
 drivers/pinctrl/pinctrl-rockchip.c | 4 ++--
 8 files changed, 16 insertions(+), 19 deletions(-)

diff --git a/common/memory.c b/common/memory.c
index c564550..57c73ab 100644
--- a/common/memory.c
+++ b/common/memory.c
@@ -124,8 +124,8 @@ int barebox_add_memory_bank(const char *name, resource_size_t start,
 	struct device_d *dev;
 
 	bank->res = request_iomem_region(name, start, start + size - 1);
-	if (!bank->res)
-		return -EBUSY;
+	if (IS_ERR(bank->res))
+		return PTR_ERR(bank->res);
 
 	dev = add_mem_device(name, start, size, IORESOURCE_MEM_WRITEABLE);
 
diff --git a/common/resource.c b/common/resource.c
index 6e84bd8..fd04f26 100644
--- a/common/resource.c
+++ b/common/resource.c
@@ -125,13 +125,7 @@ struct resource iomem_resource = {
 struct resource *request_iomem_region(const char *name,
 		resource_size_t start, resource_size_t end)
 {
-	struct resource *res;
-
-	res = __request_region(&iomem_resource, name, start, end);
-	if (IS_ERR(res))
-		return NULL;
-
-	return res;
+	return __request_region(&iomem_resource, name, start, end);
 }
 
 /* The root resource for the whole io-mapped io space */
diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
index 6106252..b934e11 100644
--- a/drivers/amba/bus.c
+++ b/drivers/amba/bus.c
@@ -7,6 +7,7 @@
 #include <common.h>
 #include <driver.h>
 #include <linux/clk.h>
+#include <linux/err.h>
 #include <linux/amba/bus.h>
 #include <io.h>
 #include <init.h>
@@ -115,8 +116,8 @@ int amba_device_add(struct amba_device *dev)
 	 */
 	size = resource_size(&dev->res);
 	res = request_iomem_region("amba", dev->res.start, dev->res.end);
-	if (!res)
-		return -ENOMEM;
+	if (IS_ERR(res))
+		return PTR_ERR(res);
 	dev->base = tmp = (void __force __iomem *)res->start;
 	if (!tmp) {
 		ret = -ENOMEM;
diff --git a/drivers/ata/intf_platform_ide.c b/drivers/ata/intf_platform_ide.c
index b3faf47..db4c356 100644
--- a/drivers/ata/intf_platform_ide.c
+++ b/drivers/ata/intf_platform_ide.c
@@ -28,6 +28,7 @@
 #include <errno.h>
 #include <ata_drive.h>
 #include <platform_ide.h>
+#include <linux/err.h>
 
 /**
  * Setup the register specific addresses for an ATA like divice
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index e39a351..d90da42 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -311,7 +311,7 @@ void __iomem *dev_request_mem_region_by_name(struct device_d *dev, const char *n
 		return NULL;
 
 	res = request_iomem_region(dev_name(dev), res->start, res->end);
-	if (!res)
+	if (IS_ERR(res))
 		return NULL;
 
 	return (void __force __iomem *)res->start;
@@ -327,7 +327,7 @@ void __iomem *dev_request_mem_region(struct device_d *dev, int num)
 		return NULL;
 
 	res = request_iomem_region(dev_name(dev), res->start, res->end);
-	if (!res)
+	if (IS_ERR(res))
 		return NULL;
 
 	return (void __force __iomem *)res->start;
diff --git a/drivers/gpio/gpio-generic.c b/drivers/gpio/gpio-generic.c
index 60c8b3a..a8b214c 100644
--- a/drivers/gpio/gpio-generic.c
+++ b/drivers/gpio/gpio-generic.c
@@ -14,6 +14,7 @@
 #include <init.h>
 #include <malloc.h>
 #include <linux/log2.h>
+#include <linux/err.h>
 #include <linux/basic_mmio_gpio.h>
 
 static void bgpio_write8(void __iomem *reg, unsigned int data)
@@ -320,8 +321,8 @@ static void __iomem *bgpio_map(struct device_d *dev, const char *name,
 	}
 
 	ret = request_iomem_region(dev_name(dev), r->start, r->end);
-	if (!ret) {
-		*err = -ENOMEM;
+	if (IS_ERR(ret)) {
+		*err = PTR_ERR(ret);
 		return NULL;
 	}
 
diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
index 55cc34f..231f4fe 100644
--- a/drivers/mfd/syscon.c
+++ b/drivers/mfd/syscon.c
@@ -77,9 +77,9 @@ static int syscon_probe(struct device_d *dev)
 	}
 
 	res = request_iomem_region(dev_name(dev), res->start, res->end);
-	if (!res) {
+	if (IS_ERR(res)) {
 		free(syscon);
-		return -EBUSY;
+		return PTR_ERR(res);
 	}
 
 	syscon->base = (void __iomem *)res->start;
diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
index 56377ea..a5b52a8 100644
--- a/drivers/pinctrl/pinctrl-rockchip.c
+++ b/drivers/pinctrl/pinctrl-rockchip.c
@@ -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);
-	if (!res) {
+	if (IS_ERR(res)) {
 		dev_err(dev, "cannot request iomem region %08x\n",
 			node_res.start);
-		return -ENOENT;
+		return PTR_ERR(res);
 	}
 
 	bank->reg_base = (void __iomem *)res->start;
-- 
2.1.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2014-09-12 10:14 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-12 10:13 Return error pointers from resource handling functions Sascha Hauer
2014-09-12 10:13 ` [PATCH 01/10] ata: platform_ide: cleanup resource requesting Sascha Hauer
2014-09-12 10:13 ` [PATCH 02/10] resource: Let dev_get_resource_by_name return an error pointer Sascha Hauer
2014-09-12 10:13 ` [PATCH 03/10] resource: Let dev_get_mem_region_by_name " Sascha Hauer
2014-09-12 10:13 ` [PATCH 04/10] resource: Let __request_region " Sascha Hauer
2014-09-12 10:13 ` Sascha Hauer [this message]
2014-09-12 10:13 ` [PATCH 06/10] resource: Let dev_get_resource " Sascha Hauer
2014-09-12 10:13 ` [PATCH 07/10] resource: Let dev_get_mem_region " Sascha Hauer
2014-09-12 15:20   ` Sebastian Hesselbarth
2014-09-12 10:13 ` [PATCH 08/10] resource: Let dev_request_mem_region_by_name " Sascha Hauer
2014-09-12 10:13 ` [PATCH 09/10] resource: Let dev_request_mem_region " Sascha Hauer
2014-09-12 11:48   ` Baruch Siach
2014-09-15  5:21     ` Sascha Hauer
2014-09-12 10:13 ` [PATCH 10/10] resource: Let request_ioport_region " Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1410516830-9403-6-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox