Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756247AbaKSQae (ORCPT ); Wed, 19 Nov 2014 11:30:34 -0500 Received: from mail-ig0-f177.google.com ([209.85.213.177]:44789 "EHLO mail-ig0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754641AbaKSQad (ORCPT ); Wed, 19 Nov 2014 11:30:33 -0500 MIME-Version: 1.0 In-Reply-To: References: <1415342031.4925.27.camel@kernel.crashing.org> <3422452.OFUjscQXRB@wuerfel> <11269246.iBzpsM0jDI@wuerfel> From: Grant Likely Date: Wed, 19 Nov 2014 16:30:12 +0000 X-Google-Sender-Auth: 7vvb5zHRZCb3PWa_V9FP3xqmwZ0 Message-ID: Subject: Re: [PATCH] drivers/core/of: Add symlink to device-tree from devices with an OF node To: Rob Herring Cc: Arnd Bergmann , Benjamin Herrenschmidt , Jeremy Kerr , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Olof Johansson , Greg KH Content-Type: text/plain; charset=ISO-8859-1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 19, 2014 at 3:39 PM, Rob Herring wrote: > On Wed, Nov 19, 2014 at 8:49 AM, Arnd Bergmann wrote: >> 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. > > Oh, right. That would definitely be worthwhile to do. Agreed. g. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/