* [PATCH 1/7] Make for_each_child_of_node() reference its args when CONFIG_OF=n
@ 2014-01-03 16:07 David Howells
[not found] ` <20140103160723.8153.14334.stgit-S6HVgzuS8uM4Awkfq6JHfwNdhmdF6hFW@public.gmane.org>
0 siblings, 1 reply; 2+ messages in thread
From: David Howells @ 2014-01-03 16:07 UTC (permalink / raw)
To: akpm; +Cc: Grant Likely, devicetree, dhowells, Rob Herring, linux-kernel
Make for_each_child_of_node() reference its args when CONFIG_OF=n to avoid
warnings like:
drivers/leds/leds-pwm.c:88:22: warning: unused variable 'node' [-Wunused-variable]
struct device_node *node = pdev->dev.of_node;
^
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Grant Likely <grant.likely@linaro.org>
cc: Rob Herring <robh+dt@kernel.org>
cc: devicetree@vger.kernel.org
---
include/linux/of.h | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/include/linux/of.h b/include/linux/of.h
index 276c546980d8..70c64ba17fa5 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -377,8 +377,13 @@ static inline bool of_have_populated_dt(void)
return false;
}
+/* Kill an unused variable warning on a device_node pointer */
+static inline void __of_use_dn(const struct device_node *np)
+{
+}
+
#define for_each_child_of_node(parent, child) \
- while (0)
+ while (__of_use_dn(parent), __of_use_dn(child), 0)
#define for_each_available_child_of_node(parent, child) \
while (0)
^ permalink raw reply related [flat|nested] 2+ messages in thread[parent not found: <20140103160723.8153.14334.stgit-S6HVgzuS8uM4Awkfq6JHfwNdhmdF6hFW@public.gmane.org>]
* Re: [PATCH 1/7] Make for_each_child_of_node() reference its args when CONFIG_OF=n [not found] ` <20140103160723.8153.14334.stgit-S6HVgzuS8uM4Awkfq6JHfwNdhmdF6hFW@public.gmane.org> @ 2014-01-03 22:30 ` Andrew Morton 0 siblings, 0 replies; 2+ messages in thread From: Andrew Morton @ 2014-01-03 22:30 UTC (permalink / raw) To: David Howells Cc: Grant Likely, devicetree-u79uwXL29TY76Z2rM5mHXA, Rob Herring, linux-kernel-u79uwXL29TY76Z2rM5mHXA > Subject: [PATCH 1/7] Make for_each_child_of_node() reference its args when CONFIG_OF=n Nit: Documentation/SubmittingPatches, section 15. "subsystem: " is missing from all patche titles. On Fri, 03 Jan 2014 16:07:23 +0000 David Howells <dhowells-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote: > Make for_each_child_of_node() reference its args when CONFIG_OF=n to avoid > warnings like: > > drivers/leds/leds-pwm.c:88:22: warning: unused variable 'node' [-Wunused-variable] > struct device_node *node = pdev->dev.of_node; > ^ > ... > > --- a/include/linux/of.h > +++ b/include/linux/of.h > @@ -377,8 +377,13 @@ static inline bool of_have_populated_dt(void) > return false; > } > > +/* Kill an unused variable warning on a device_node pointer */ > +static inline void __of_use_dn(const struct device_node *np) > +{ > +} > + > #define for_each_child_of_node(parent, child) \ > - while (0) > + while (__of_use_dn(parent), __of_use_dn(child), 0) > > #define for_each_available_child_of_node(parent, child) \ > while (0) That's a bit ugly. __maybe_unused fixes it appropriately but can't be placed into the macro. I wonder if we should instead generalise it to static inline void reference_var_to_squish_gcc_warning(const void *p) { } I guess not, until/unless we find other macros which need the same treatment. Yes, passing a var to an empty function suppresses the warning. But is this intentional or a happy accident? Future gcc's could quite legitimately be enhanced to detect that the arg is still unused and then we'd need to find a new way of suppressing the warning, if such exists. -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-01-03 22:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-03 16:07 [PATCH 1/7] Make for_each_child_of_node() reference its args when CONFIG_OF=n David Howells
[not found] ` <20140103160723.8153.14334.stgit-S6HVgzuS8uM4Awkfq6JHfwNdhmdF6hFW@public.gmane.org>
2014-01-03 22:30 ` Andrew Morton
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).