From: Marek Szyprowski <m.szyprowski@samsung.com>
To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Cc: Marek Szyprowski <m.szyprowski@samsung.com>,
linaro-mm-sig@lists.linaro.org, Arnd Bergmann <arnd@arndb.de>,
Michal Nazarewicz <mina86@mina86.com>,
Andrew Morton <akpm@linux-foundation.org>,
Grant Likely <grant.likely@linaro.org>,
Laura Abbott <lauraa@codeaurora.org>,
Josh Cartwright <joshc@codeaurora.org>,
Joonsoo Kim <iamjoonsoo.kim@lge.com>,
Kyungmin Park <kyungmin.park@samsung.com>,
Russell King <rmk+kernel@arm.linux.org.uk>,
Stephen Rothwell <sfr@canb.auug.org.au>
Subject: [PATCH v4] drivers: of: add return value to of_reserved_mem_device_init
Date: Wed, 15 Oct 2014 13:01:42 +0200 [thread overview]
Message-ID: <1413370902-28187-1-git-send-email-m.szyprowski@samsung.com> (raw)
In-Reply-To: <13963062.ORRNOhrvYD@wuerfel>
Driver calling of_reserved_mem_device_init() might be interested if the
initialization has been successful or not, so add support for returning
error code.
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
This patch fixes build warining caused by commit
7bfa5ab6fa1b18f53fb94f922e107e6fbdc5e485 ("drivers: dma-coherent: add
initialization from device tree"), which has been merged without this
change and without fixing function return value.
---
drivers/base/dma-contiguous.c | 3 ++-
drivers/of/of_reserved_mem.c | 14 +++++++++-----
include/linux/of_reserved_mem.h | 9 ++++++---
3 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/drivers/base/dma-contiguous.c b/drivers/base/dma-contiguous.c
index 473ff4892401..950fff9ce453 100644
--- a/drivers/base/dma-contiguous.c
+++ b/drivers/base/dma-contiguous.c
@@ -223,9 +223,10 @@ bool dma_release_from_contiguous(struct device *dev, struct page *pages,
#undef pr_fmt
#define pr_fmt(fmt) fmt
-static void rmem_cma_device_init(struct reserved_mem *rmem, struct device *dev)
+static int rmem_cma_device_init(struct reserved_mem *rmem, struct device *dev)
{
dev_set_cma_area(dev, rmem->priv);
+ return 0;
}
static void rmem_cma_device_release(struct reserved_mem *rmem,
diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index 59fb12e84e6b..dc566b38645f 100644
--- a/drivers/of/of_reserved_mem.c
+++ b/drivers/of/of_reserved_mem.c
@@ -243,23 +243,27 @@ static inline struct reserved_mem *__find_rmem(struct device_node *node)
* This function assign memory region pointed by "memory-region" device tree
* property to the given device.
*/
-void of_reserved_mem_device_init(struct device *dev)
+int of_reserved_mem_device_init(struct device *dev)
{
struct reserved_mem *rmem;
struct device_node *np;
+ int ret;
np = of_parse_phandle(dev->of_node, "memory-region", 0);
if (!np)
- return;
+ return -ENODEV;
rmem = __find_rmem(np);
of_node_put(np);
if (!rmem || !rmem->ops || !rmem->ops->device_init)
- return;
+ return -EINVAL;
+
+ ret = rmem->ops->device_init(rmem, dev);
+ if (ret == 0)
+ dev_info(dev, "assigned reserved memory node %s\n", rmem->name);
- rmem->ops->device_init(rmem, dev);
- dev_info(dev, "assigned reserved memory node %s\n", rmem->name);
+ return ret;
}
/**
diff --git a/include/linux/of_reserved_mem.h b/include/linux/of_reserved_mem.h
index 5b5efae09135..ad2f67054372 100644
--- a/include/linux/of_reserved_mem.h
+++ b/include/linux/of_reserved_mem.h
@@ -16,7 +16,7 @@ struct reserved_mem {
};
struct reserved_mem_ops {
- void (*device_init)(struct reserved_mem *rmem,
+ int (*device_init)(struct reserved_mem *rmem,
struct device *dev);
void (*device_release)(struct reserved_mem *rmem,
struct device *dev);
@@ -28,14 +28,17 @@ typedef int (*reservedmem_of_init_fn)(struct reserved_mem *rmem);
_OF_DECLARE(reservedmem, name, compat, init, reservedmem_of_init_fn)
#ifdef CONFIG_OF_RESERVED_MEM
-void of_reserved_mem_device_init(struct device *dev);
+int of_reserved_mem_device_init(struct device *dev);
void of_reserved_mem_device_release(struct device *dev);
void fdt_init_reserved_mem(void);
void fdt_reserved_mem_save_node(unsigned long node, const char *uname,
phys_addr_t base, phys_addr_t size);
#else
-static inline void of_reserved_mem_device_init(struct device *dev) { }
+static inline int of_reserved_mem_device_init(struct device *dev)
+{
+ return -ENOSYS;
+}
static inline void of_reserved_mem_device_release(struct device *pdev) { }
static inline void fdt_init_reserved_mem(void) { }
--
1.9.2
next prev parent reply other threads:[~2014-10-15 11:01 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-11 11:22 [PATCH v2 0/3] CMA & device tree, another approach Marek Szyprowski
2014-09-11 11:22 ` [PATCH v2 1/3] drivers: of: add return value to of_reserved_mem_device_init Marek Szyprowski
2014-09-26 6:44 ` [PATCH v2 1/3] drivers: of: add return value to of_reserved_mem_device_init (fixup) Marek Szyprowski
2014-09-27 13:58 ` Fabio Estevam
2014-09-26 20:13 ` [PATCH v2 1/3] drivers: of: add return value to of_reserved_mem_device_init Arnd Bergmann
2014-10-09 12:18 ` [PATCH v3] " Marek Szyprowski
2014-10-13 11:19 ` Arnd Bergmann
2014-10-15 11:01 ` Marek Szyprowski [this message]
2014-10-20 19:04 ` [Linaro-mm-sig] [PATCH v4] " Arnd Bergmann
2014-09-11 11:22 ` [PATCH v2 2/3] drivers: dma-coherent: add initialization from device tree Marek Szyprowski
2014-09-24 22:26 ` Andrew Morton
2014-09-24 22:28 ` Andrew Morton
2014-09-11 11:22 ` [PATCH v2 3/3] drivers: dma-contiguous: " Marek Szyprowski
2014-09-23 8:05 ` [PATCH v2 0/3] CMA & device tree, another approach Marek Szyprowski
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=1413370902-28187-1-git-send-email-m.szyprowski@samsung.com \
--to=m.szyprowski@samsung.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=grant.likely@linaro.org \
--cc=iamjoonsoo.kim@lge.com \
--cc=joshc@codeaurora.org \
--cc=kyungmin.park@samsung.com \
--cc=lauraa@codeaurora.org \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mina86@mina86.com \
--cc=rmk+kernel@arm.linux.org.uk \
--cc=sfr@canb.auug.org.au \
/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;
as well as URLs for NNTP newsgroup(s).