linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] base: dma-coherent: fix device_init initialization
@ 2014-10-15 20:32 Felipe Balbi
  2014-10-15 20:39 ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Felipe Balbi @ 2014-10-15 20:32 UTC (permalink / raw)
  To: Greg KH
  Cc: Linux Kernel Mailing List, Felipe Balbi, Marek Szyprowski,
	Arnd Bergmann, Michal Nazarewicz, Grant Likely, Laura Abbott,
	Josh Cartwright, Joonsoo Kim, Kyungmin Park, Andrew Morton

commit 7bfa5ab (drivers: dma-coherent: add initialization
from device tree) added support for dma coherent pool for
DeviceTree. Unfortunately that commit introduced a new
build warning because of a wrong type on the definition
of ->device_init(). This patch fixes it.

Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Michal Nazarewicz <mina86@mina86.com>
Cc: Grant Likely <grant.likely@linaro.org>
Cc: Laura Abbott <lauraa@codeaurora.org>
Cc: Josh Cartwright <joshc@codeaurora.org>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Fixes: 7bfa5ab6 (drivers: dma-coherent: add initialization
	from device tree)
Signed-off-by: Felipe Balbi <balbi@ti.com>
---
 drivers/base/dma-coherent.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/base/dma-coherent.c b/drivers/base/dma-coherent.c
index 55b8398..d3695a8 100644
--- a/drivers/base/dma-coherent.c
+++ b/drivers/base/dma-coherent.c
@@ -276,7 +276,7 @@ EXPORT_SYMBOL(dma_mmap_from_coherent);
 #include <linux/of_fdt.h>
 #include <linux/of_reserved_mem.h>
 
-static int rmem_dma_device_init(struct reserved_mem *rmem, struct device *dev)
+static void rmem_dma_device_init(struct reserved_mem *rmem, struct device *dev)
 {
 	struct dma_coherent_mem *mem = rmem->priv;
 
@@ -286,11 +286,10 @@ static int rmem_dma_device_init(struct reserved_mem *rmem, struct device *dev)
 				     &mem) != DMA_MEMORY_MAP) {
 		pr_err("Reserved memory: failed to init DMA memory pool at %pa, size %ld MiB\n",
 			&rmem->base, (unsigned long)rmem->size / SZ_1M);
-		return -ENODEV;
+		return;
 	}
 	rmem->priv = mem;
 	dma_assign_coherent_memory(dev, mem);
-	return 0;
 }
 
 static void rmem_dma_device_release(struct reserved_mem *rmem,
-- 
2.1.0.GIT


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] base: dma-coherent: fix device_init initialization
  2014-10-15 20:32 [PATCH] base: dma-coherent: fix device_init initialization Felipe Balbi
@ 2014-10-15 20:39 ` Andrew Morton
  2014-10-15 20:42   ` Felipe Balbi
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2014-10-15 20:39 UTC (permalink / raw)
  To: Felipe Balbi
  Cc: Greg KH, Linux Kernel Mailing List, Marek Szyprowski,
	Arnd Bergmann, Michal Nazarewicz, Grant Likely, Laura Abbott,
	Josh Cartwright, Joonsoo Kim, Kyungmin Park

On Wed, 15 Oct 2014 15:32:20 -0500 Felipe Balbi <balbi@ti.com> wrote:

> commit 7bfa5ab (drivers: dma-coherent: add initialization
> from device tree) added support for dma coherent pool for
> DeviceTree. Unfortunately that commit introduced a new
> build warning because of a wrong type on the definition
> of ->device_init(). This patch fixes it.

Guys, when fixing a warning please always always always quote that
warning in the changelog.

Presumably your patch addresses the same mystery warning as did Marek's.


From: Marek Szyprowski <m.szyprowski@samsung.com>
Subject: drivers: of: add return value to of_reserved_mem_device_init()

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.

This fixes a build warining caused by 7bfa5ab6fa1b ("drivers:
dma-coherent: add initialization from device tree"), which has been merged
without this change and without fixing function return value.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Michal Nazarewicz <mina86@mina86.com>
Cc: Grant Likely <grant.likely@linaro.org>
Cc: Laura Abbott <lauraa@codeaurora.org>
Cc: Josh Cartwright <joshc@codeaurora.org>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Russell King <rmk+kernel@arm.linux.org.uk>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 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 -puN drivers/base/dma-contiguous.c~drivers-of-add-return-value-to-of_reserved_mem_device_init drivers/base/dma-contiguous.c
--- a/drivers/base/dma-contiguous.c~drivers-of-add-return-value-to-of_reserved_mem_device_init
+++ a/drivers/base/dma-contiguous.c
@@ -223,9 +223,10 @@ bool dma_release_from_contiguous(struct
 #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 -puN drivers/of/of_reserved_mem.c~drivers-of-add-return-value-to-of_reserved_mem_device_init drivers/of/of_reserved_mem.c
--- a/drivers/of/of_reserved_mem.c~drivers-of-add-return-value-to-of_reserved_mem_device_init
+++ a/drivers/of/of_reserved_mem.c
@@ -243,23 +243,27 @@ static inline struct reserved_mem *__fin
  * 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;
 
-	rmem->ops->device_init(rmem, dev);
-	dev_info(dev, "assigned reserved memory node %s\n", rmem->name);
+	ret = rmem->ops->device_init(rmem, dev);
+	if (ret == 0)
+		dev_info(dev, "assigned reserved memory node %s\n", rmem->name);
+
+	return ret;
 }
 
 /**
diff -puN include/linux/of_reserved_mem.h~drivers-of-add-return-value-to-of_reserved_mem_device_init include/linux/of_reserved_mem.h
--- a/include/linux/of_reserved_mem.h~drivers-of-add-return-value-to-of_reserved_mem_device_init
+++ a/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)(st
 	_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) { }
_



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] base: dma-coherent: fix device_init initialization
  2014-10-15 20:39 ` Andrew Morton
@ 2014-10-15 20:42   ` Felipe Balbi
  0 siblings, 0 replies; 3+ messages in thread
From: Felipe Balbi @ 2014-10-15 20:42 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Felipe Balbi, Greg KH, Linux Kernel Mailing List,
	Marek Szyprowski, Arnd Bergmann, Michal Nazarewicz, Grant Likely,
	Laura Abbott, Josh Cartwright, Joonsoo Kim, Kyungmin Park

[-- Attachment #1: Type: text/plain, Size: 666 bytes --]

Hi,

On Wed, Oct 15, 2014 at 01:39:59PM -0700, Andrew Morton wrote:
> On Wed, 15 Oct 2014 15:32:20 -0500 Felipe Balbi <balbi@ti.com> wrote:
> 
> > commit 7bfa5ab (drivers: dma-coherent: add initialization
> > from device tree) added support for dma coherent pool for
> > DeviceTree. Unfortunately that commit introduced a new
> > build warning because of a wrong type on the definition
> > of ->device_init(). This patch fixes it.
> 
> Guys, when fixing a warning please always always always quote that
> warning in the changelog.

will do.

> Presumably your patch addresses the same mystery warning as did Marek's.

seems like so.

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-10-15 20:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-15 20:32 [PATCH] base: dma-coherent: fix device_init initialization Felipe Balbi
2014-10-15 20:39 ` Andrew Morton
2014-10-15 20:42   ` Felipe Balbi

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).