From: Arnd Bergmann Subject: Re: [PATCH] drivers/core/of: Add symlink to device-tree from devices with an OF node Date: Wed, 19 Nov 2014 15:49:13 +0100 Message-ID: <11269246.iBzpsM0jDI@wuerfel> References: <1415342031.4925.27.camel@kernel.crashing.org> <3422452.OFUjscQXRB@wuerfel> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit Return-path: In-Reply-To: Sender: devicetree-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Rob Herring Cc: Benjamin Herrenschmidt , Jeremy Kerr , "devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" , "linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" , Olof Johansson , Grant Likely , Greg KH List-Id: devicetree@vger.kernel.org On Wednesday 19 November 2014 08:45:58 Rob Herring wrote: > > static inline struct device_node *dev_of_node(struct device *of_node) > > { > > if (!IS_ENABLED(CONFIG_OF)) > > return NULL; > > > > return dev->of_node; > > } > > > > Adding the IS_ENABLED() in a lot of drivers isn't horrible, but we seem > > to be doing it a lot. > > I think you misread things. of_node is always present now, so it > should always be NULL for !CONFIG_OF. > No, I didn't misread it but I should have been clearer with the intention: The idea is to tell the compiler that we know it will be NULL when CONFIG_OF is unset, so it can optimize out all code that does struct device_node *dn = dev_of_node(dev); if (dn) { ... /* complex code */ ... } and we can avoid using an #ifdef or if(IS_ENABLED()) in the source to compile out the DT-only sections of a driver. Arnd -- 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