mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 2/3] driver: Introduce dev_request_mem_resource
Date: Thu, 18 Feb 2016 11:50:16 +0100	[thread overview]
Message-ID: <1455792617-13671-3-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1455792617-13671-1-git-send-email-s.hauer@pengutronix.de>

dev_request_mem_region returns a void * which shall be checked with
IS_ERR(), but in some cases the valid pointer returned clashes with
error values. This is especially the case on some Atmel SoCs.

This introduces dev_request_mem_resource which returns a struct resource
instead which in any case can be checked with IS_ERR(). It's the drivers
responsibility then to get the IOMEM pointer from the resource.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/base/driver.c | 11 +++++++++--
 include/driver.h      |  6 ++++++
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index c529296..5867fe4 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -404,7 +404,7 @@ void __iomem *dev_request_mem_region_err_null(struct device_d *dev, int num)
 }
 EXPORT_SYMBOL(dev_request_mem_region_err_null);
 
-void __iomem *dev_request_mem_region(struct device_d *dev, int num)
+struct resource *dev_request_mem_resource(struct device_d *dev, int num)
 {
 	struct resource *res;
 
@@ -412,7 +412,14 @@ void __iomem *dev_request_mem_region(struct device_d *dev, int num)
 	if (IS_ERR(res))
 		return ERR_CAST(res);
 
-	res = request_iomem_region(dev_name(dev), res->start, res->end);
+	return request_iomem_region(dev_name(dev), res->start, res->end);
+}
+
+void __iomem *dev_request_mem_region(struct device_d *dev, int num)
+{
+	struct resource *res;
+
+	res = dev_request_mem_resource(dev, num);
 	if (IS_ERR(res))
 		return ERR_CAST(res);
 
diff --git a/include/driver.h b/include/driver.h
index 31c6734..5e2b88f 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -203,10 +203,16 @@ void *dev_get_mem_region(struct device_d *dev, int num);
 
 /*
  * exlusively request register base 'num' for a device
+ * deprecated, use dev_request_mem_resource instead
  */
 void __iomem *dev_request_mem_region(struct device_d *dev, int num);
 
 /*
+ * exlusively request resource 'num' for a device
+ */
+struct resource *dev_request_mem_resource(struct device_d *dev, int num);
+
+/*
  * exlusively request register base 'num' for a device
  * will return NULL on error
  * only used on platform like at91 where the Ressource address collision with
-- 
2.7.0


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

  parent reply	other threads:[~2016-02-18 10:50 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-18 10:50 [PATCH] dev_request_mem_region -> dev_request_mem_resource conversion Sascha Hauer
2016-02-18 10:50 ` [PATCH 1/3] Fix return check of dev_request_mem_region Sascha Hauer
2016-02-19  0:58   ` Andrey Smirnov
2016-02-19  8:29     ` Sascha Hauer
2016-02-19 19:12       ` Andrey Smirnov
2016-02-23  7:15         ` Sascha Hauer
2016-02-18 10:50 ` Sascha Hauer [this message]
2016-02-18 10:50 ` [PATCH 3/3] driver: replace dev_request_mem_region with dev_request_mem_resource Sascha Hauer
2016-02-26  8:37   ` Teresa Remmet
2016-02-29  6:41     ` 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=1455792617-13671-3-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