devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] of: silence warnings due to max() usage
@ 2016-05-30 23:38 Stephen Rothwell
  2016-06-03 12:27 ` Rob Herring
  0 siblings, 1 reply; 2+ messages in thread
From: Stephen Rothwell @ 2016-05-30 23:38 UTC (permalink / raw)
  To: Rob Herring, Frank Rowand, Grant Likely
  Cc: devicetree, linux-kernel, Jason Liu

pageblock_order can be (at least) an unsigned int or an unsigned long
depending on the kernel config and architecture, so use max_t(unsigned
long ...) when comparing it.

fixes these warnings:

In file included from include/linux/list.h:8:0,
                 from include/linux/kobject.h:20,
                 from include/linux/of.h:21,
                 from drivers/of/of_reserved_mem.c:17:
drivers/of/of_reserved_mem.c: In function ‘__reserved_mem_alloc_size’:
include/linux/kernel.h:748:17: warning: comparison of distinct pointer types lacks a cast
  (void) (&_max1 == &_max2);  \
                 ^
include/linux/kernel.h:747:9: note: in definition of macro ‘max’
  typeof(y) _max2 = (y);   \
         ^
drivers/of/of_reserved_mem.c:131:48: note: in expansion of macro ‘max’
   align = max(align, (phys_addr_t)PAGE_SIZE << max(MAX_ORDER - 1, pageblock_ord
                                                ^
include/linux/kernel.h:748:17: warning: comparison of distinct pointer types lacks a cast
  (void) (&_max1 == &_max2);  \
                 ^
include/linux/kernel.h:747:21: note: in definition of macro ‘max’
  typeof(y) _max2 = (y);   \
                     ^
drivers/of/of_reserved_mem.c:131:48: note: in expansion of macro ‘max’
   align = max(align, (phys_addr_t)PAGE_SIZE << max(MAX_ORDER - 1, pageblock_ord
                                                ^

Fixes: 1cc8e3458b51 ("drivers: of: of_reserved_mem: fixup the alignment with CMA setup")
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
---
 drivers/of/of_reserved_mem.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Hi guys, this has been irking me for some time now ... I will add this
to my fixes tree in linux-next today.  Please apply and send to Linus.

diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index ed01c0172e4a..07dd81586c52 100644
--- a/drivers/of/of_reserved_mem.c
+++ b/drivers/of/of_reserved_mem.c
@@ -127,8 +127,12 @@ static int __init __reserved_mem_alloc_size(unsigned long node,
 	}
 
 	/* Need adjust the alignment to satisfy the CMA requirement */
-	if (IS_ENABLED(CONFIG_CMA) && of_flat_dt_is_compatible(node, "shared-dma-pool"))
-		align = max(align, (phys_addr_t)PAGE_SIZE << max(MAX_ORDER - 1, pageblock_order));
+	if (IS_ENABLED(CONFIG_CMA) && of_flat_dt_is_compatible(node, "shared-dma-pool")) {
+		unsigned long order =
+			max_t(unsigned long, MAX_ORDER - 1, pageblock_order);
+
+		align = max(align, (phys_addr_t)PAGE_SIZE << order);
+	}
 
 	prop = of_get_flat_dt_prop(node, "alloc-ranges", &len);
 	if (prop) {
-- 
2.8.1

-- 
Cheers,
Stephen Rothwell

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

* Re: [PATCH] of: silence warnings due to max() usage
  2016-05-30 23:38 [PATCH] of: silence warnings due to max() usage Stephen Rothwell
@ 2016-06-03 12:27 ` Rob Herring
  0 siblings, 0 replies; 2+ messages in thread
From: Rob Herring @ 2016-06-03 12:27 UTC (permalink / raw)
  To: Stephen Rothwell
  Cc: Frank Rowand, Grant Likely, devicetree, linux-kernel, Jason Liu

On Tue, May 31, 2016 at 09:38:56AM +1000, Stephen Rothwell wrote:
> pageblock_order can be (at least) an unsigned int or an unsigned long
> depending on the kernel config and architecture, so use max_t(unsigned
> long ...) when comparing it.
> 
> fixes these warnings:
> 
> In file included from include/linux/list.h:8:0,
>                  from include/linux/kobject.h:20,
>                  from include/linux/of.h:21,
>                  from drivers/of/of_reserved_mem.c:17:
> drivers/of/of_reserved_mem.c: In function ‘__reserved_mem_alloc_size’:
> include/linux/kernel.h:748:17: warning: comparison of distinct pointer types lacks a cast
>   (void) (&_max1 == &_max2);  \
>                  ^
> include/linux/kernel.h:747:9: note: in definition of macro ‘max’
>   typeof(y) _max2 = (y);   \
>          ^
> drivers/of/of_reserved_mem.c:131:48: note: in expansion of macro ‘max’
>    align = max(align, (phys_addr_t)PAGE_SIZE << max(MAX_ORDER - 1, pageblock_ord
>                                                 ^
> include/linux/kernel.h:748:17: warning: comparison of distinct pointer types lacks a cast
>   (void) (&_max1 == &_max2);  \
>                  ^
> include/linux/kernel.h:747:21: note: in definition of macro ‘max’
>   typeof(y) _max2 = (y);   \
>                      ^
> drivers/of/of_reserved_mem.c:131:48: note: in expansion of macro ‘max’
>    align = max(align, (phys_addr_t)PAGE_SIZE << max(MAX_ORDER - 1, pageblock_ord
>                                                 ^
> 
> Fixes: 1cc8e3458b51 ("drivers: of: of_reserved_mem: fixup the alignment with CMA setup")
> Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
> ---
>  drivers/of/of_reserved_mem.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> Hi guys, this has been irking me for some time now ... I will add this
> to my fixes tree in linux-next today.  Please apply and send to Linus.

Applied, thanks.

Rob

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

end of thread, other threads:[~2016-06-03 12:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-30 23:38 [PATCH] of: silence warnings due to max() usage Stephen Rothwell
2016-06-03 12:27 ` Rob Herring

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