All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Luis R. Rodriguez" <mcgrof@do-not-panic.com>
To: johannes@sipsolutions.net
Cc: backports@vger.kernel.org, "Luis R. Rodriguez" <mcgrof@do-not-panic.com>
Subject: [PATCH 09/18] compat: backport devm_ioremap_resource()
Date: Wed, 10 Apr 2013 04:35:19 -0700	[thread overview]
Message-ID: <1365593728-5720-10-git-send-email-mcgrof@do-not-panic.com> (raw)
In-Reply-To: <1365593728-5720-1-git-send-email-mcgrof@do-not-panic.com>

From: "Luis R. Rodriguez" <mcgrof@do-not-panic.com>

The new API gives more information to driver users but
the older kernels do not have any of these mechanisms
in place so just throw out ERR_PTR(-ENOMEM) in case
of failure.

mcgrof@frijol ~/linux-stable (git::master)$ git describe --contains 75096579
v3.9-rc1~128^2~63

commit 75096579c3ac39ddc2f8b0d9a8924eba31f4d920
Author: Thierry Reding <thierry.reding@avionic-design.de>
Date:   Mon Jan 21 11:08:54 2013 +0100

    lib: devres: Introduce devm_ioremap_resource()

    The devm_request_and_ioremap() function is very useful and helps avoid a
    whole lot of boilerplate. However, one issue that keeps popping up is
    its lack of a specific error code to determine which of the steps that
    it performs failed. Furthermore, while the function gives an example and
    suggests what error code to return on failure, a wide variety of error
    codes are used throughout the tree.

    In an attempt to fix these problems, this patch adds a new function that
    drivers can transition to. The devm_ioremap_resource() returns a pointer
    to the remapped I/O memory on success or an ERR_PTR() encoded error code
    on failure. Callers can check for failure using IS_ERR() and determine
    its cause by extracting the error code using PTR_ERR().

    devm_request_and_ioremap() is implemented as a wrapper around the new
    API and return NULL on failure as before. This ensures that backwards
    compatibility is maintained until all users have been converted to the
    new API, at which point the old devm_request_and_ioremap() function
    should be removed.

    A semantic patch is included which can be used to convert from the old
    devm_request_and_ioremap() API to the new devm_ioremap_resource() API.
    Some non-trivial cases may require manual intervention, though.

    Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>
    Cc: Arnd Bergmann <arnd@arndb.de>
    Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
---
 backport/compat/compat-3.9.c        |   12 ++++++++++++
 backport/include/linux/compat-3.9.h |    4 ++++
 2 files changed, 16 insertions(+)

diff --git a/backport/compat/compat-3.9.c b/backport/compat/compat-3.9.c
index 1f24842..61a062a 100644
--- a/backport/compat/compat-3.9.c
+++ b/backport/compat/compat-3.9.c
@@ -10,6 +10,7 @@
 
 #include <linux/module.h>
 #include <linux/scatterlist.h>
+#include <linux/device.h>
 
 #ifdef __sg_page_iter_next
 
@@ -51,4 +52,15 @@ bool __sg_page_iter_next(struct sg_page_iter *piter)
 }
 EXPORT_SYMBOL_GPL(__sg_page_iter_next);
 
+void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res)
+{
+	void __iomem *dest_ptr;
+
+	dest_ptr = devm_ioremap_resource(dev, res);
+	if (!dest_ptr)
+		return ERR_PTR(-ENOMEM);
+	return dest_ptr;
+}
+EXPORT_SYMBOL_GPL(devm_ioremap_resource);
+
 #endif /* __sg_page_iter_next */
diff --git a/backport/include/linux/compat-3.9.h b/backport/include/linux/compat-3.9.h
index aed569c..a4362e2 100644
--- a/backport/include/linux/compat-3.9.h
+++ b/backport/include/linux/compat-3.9.h
@@ -15,6 +15,7 @@
 #include <linux/tty_flip.h>
 #include <linux/printk.h>
 #include <linux/scatterlist.h>
+#include <linux/device.h>
 
 /* include this before changing hlist_for_each_* to use the old versions. */
 #include <net/sch_generic.h>
@@ -207,6 +208,9 @@ static inline struct inode *file_inode(struct file *f)
 	return f->f_path.dentry->d_inode;
 }
 
+#define devm_ioremap_resource LINUX_BACKPORT(devm_ioremap_resource)
+void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res);
+
 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)) */
 
 #endif /* LINUX_3_9_COMPAT_H */
-- 
1.7.10.4


  parent reply	other threads:[~2013-04-10 11:36 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-10 11:35 [PATCH 00/18] backports: pending patches for Luis Luis R. Rodriguez
2013-04-10 11:35 ` [PATCH 01/18] backports: enable DRM_NOUVEAU for 3.2 Luis R. Rodriguez
2013-04-10 13:15   ` Johannes Berg
2013-04-10 11:35 ` [PATCH 02/18] compat: backport dev_level_ratelimited() Luis R. Rodriguez
2013-04-10 13:16   ` Johannes Berg
2013-04-10 17:07     ` Luis R. Rodriguez
2013-04-10 17:15       ` Johannes Berg
2013-04-11 14:44         ` taking backports out of compat-*.h (was: [PATCH 02/18] compat: backport dev_level_ratelimited()) Johannes Berg
2013-04-11 14:56           ` taking backports out of compat-*.h Hauke Mehrtens
2013-04-10 11:35 ` [PATCH 03/18] compat: backport __i2c_transfer() Luis R. Rodriguez
2013-04-10 13:20   ` Johannes Berg
2013-04-10 11:35 ` [PATCH 04/18] compat: backport devm_regmap_init() Luis R. Rodriguez
2013-04-10 13:19   ` Johannes Berg
2013-04-10 11:35 ` [PATCH 05/18] compat: backport GPIOF_OPEN_DRAIN definition Luis R. Rodriguez
2013-04-10 13:18   ` Johannes Berg
2013-04-10 17:10     ` Luis R. Rodriguez
2013-04-10 11:35 ` [PATCH 06/18] compat: backport ASYNC_DOMAIN_EXCLUSIVE() Luis R. Rodriguez
2013-04-10 13:22   ` Johannes Berg
2013-04-10 17:13     ` Luis R. Rodriguez
2013-04-10 17:20       ` Johannes Berg
2013-04-10 17:26         ` Luis R. Rodriguez
2013-04-10 18:20           ` Johannes Berg
2013-04-10 19:19             ` Luis R. Rodriguez
2013-04-10 19:27               ` Johannes Berg
2013-04-10 19:32                 ` Luis R. Rodriguez
2013-04-10 19:39                   ` Johannes Berg
2013-04-10 19:40                     ` Luis R. Rodriguez
2013-04-10 11:35 ` [PATCH 07/18] compat: backport devres_release() Luis R. Rodriguez
2013-04-10 11:35 ` [PATCH 08/18] compat: backport dev_get_regmap() Luis R. Rodriguez
2013-04-10 11:35 ` Luis R. Rodriguez [this message]
2013-04-10 11:35 ` [PATCH 10/18] compat: backport module_platform_driver_probe() Luis R. Rodriguez
2013-04-10 11:35 ` [PATCH 11/18] compat: add helpers to aid backport of generic DMA changes for v4l Luis R. Rodriguez
2013-04-10 11:35 ` [PATCH 12/18] compat: backport dma_get_sgtable() Luis R. Rodriguez
2013-04-10 13:26   ` Johannes Berg
2013-04-10 11:35 ` [PATCH 13/18] backports: add blacklist module support Luis R. Rodriguez
2013-04-10 13:35   ` Johannes Berg
2013-04-10 19:57     ` Luis R. Rodriguez
2013-04-10 20:00       ` Johannes Berg
2013-04-10 11:35 ` [PATCH 14/18] backports: add support for module compression Luis R. Rodriguez
2013-04-10 13:40   ` Johannes Berg
2013-04-10 11:35 ` [PATCH 15/18] backports: add check_depmod to look for module search path Luis R. Rodriguez
2013-04-10 13:43   ` Johannes Berg
2013-04-10 11:35 ` [PATCH 16/18] backports: add udev rules if required for backported firmware_class Luis R. Rodriguez
2013-04-10 13:45   ` Johannes Berg
2013-04-10 13:47   ` Johannes Berg
2013-04-10 20:12     ` Luis R. Rodriguez
2013-04-10 11:35 ` [PATCH 17/18] backports: use depmod -a Luis R. Rodriguez
2013-04-10 13:46   ` Johannes Berg
2013-04-10 11:35 ` [PATCH 18/18] backports: add update-initramfs support Luis R. Rodriguez
2013-04-10 13:48   ` Johannes Berg
2013-04-10 20:12     ` Luis R. Rodriguez

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=1365593728-5720-10-git-send-email-mcgrof@do-not-panic.com \
    --to=mcgrof@do-not-panic.com \
    --cc=backports@vger.kernel.org \
    --cc=johannes@sipsolutions.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.