Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp267618img; Mon, 18 Mar 2019 02:40:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqytuBgmlBuWBgGah93AmtOVCwpO7ZvYwuMBF3pZUZRpYbzlf/he4TUz8y68bZc9eQtXtQyp X-Received: by 2002:a62:1249:: with SMTP id a70mr11235651pfj.160.1552902029996; Mon, 18 Mar 2019 02:40:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552902029; cv=none; d=google.com; s=arc-20160816; b=vUwiYrGZV3qt1+mXc8BqEbe+n5zECSX6Byat/UNxj2Se56mMUOewv4YHOFP805awdm XS0X87TU53Ip03HvFSE3vmy46IHQf3i2wCUcBf04Xizl6glQ0ywg2tjDfAk2M0aQt2GU nE7op9/Hp+WddUFM+/b2/fChNJN0aF0d/swrXzKyhZ0eS7g7NCP9WZ7cGXuv44ySCe9d FAVjaQSX14gLiz3CjcN/5/59Io8tbomgJNscC06jq+PoZUDiS5JCMql7jxW3bQUEOTtg Q9TlKwz5vEZhbB+Y/qKHT5jKvviXyxeEDhpsxJQzprJIIMKL6tpGPaWd0ftC81TL1HPv eCIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=BgU//jkmWIXn8ZnTJyhR8mkEWVssUeHiKd/vLWERF9c=; b=erR2hhHScpW4kSgjyp6uxA89/+XUeBtChRZJLsqoKC4Ysc/NwypI9RDJlevDtQ7GfN OFGYpxUwAYhfyvzxTVZCiJsqft3ccRuQdJom3mzMDHHPsoz/x4aqQ0OGMxy4dMiw/w+Y BbYKTb5zghnLybt8qAFJnuo6mR0yZhVuK/L/fCU+WkbWE4oFmwQCRQ06SP7T632vwQNx Bpo2jewHsA/V3rpSOhUWGYFEbXShUc7xI+fTOu3gx+dqd8o79zMvae8Oq+Uw0X57I0MY Z9DfOA+0+IBHHmcxnEdZYT5uWPel+vzmM+h2kxltYM6wkUdzDa43LUaE872y7To2IdsF cpqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="hHjbjGu/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cm10si9591468plb.295.2019.03.18.02.40.15; Mon, 18 Mar 2019 02:40:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="hHjbjGu/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387942AbfCRJhr (ORCPT + 99 others); Mon, 18 Mar 2019 05:37:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:46070 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387936AbfCRJho (ORCPT ); Mon, 18 Mar 2019 05:37:44 -0400 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 88F322087C; Mon, 18 Mar 2019 09:37:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1552901864; bh=OZJ5IHnoXbgwtayRjLqWOSDr/fkquP7Z016tsh7le5Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hHjbjGu/WlaQgjRTVgJleAl09IAV1wh4ldNkrzzbwMFh7uk0oZpNLbOGDVlep7yWc qhfsizPTZ6GbwTmKFVnuQPNWrMsLZCDvLEBwHPmoX4y35Mq57nYNXM7deQnp2W+jpN 2wRWMT9IURwxnDhoYksbhBVhuPNnMNYIwfIipTyw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sakari Ailus , Kieran Bingham , Rob Herring , Nathan Chancellor Subject: [PATCH 4.9 30/31] of: Support const and non-const use for to_of_node() Date: Mon, 18 Mar 2019 10:26:05 +0100 Message-Id: <20190318084211.641869720@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190318084210.397476003@linuxfoundation.org> References: <20190318084210.397476003@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sakari Ailus commit d20dc1493db438fbbfb7733adc82f472dd8a0789 upstream. Turn to_of_node() into a macro in order to support both const and non-const use. Additionally make the fwnode argument to is_of_node() const as well. Signed-off-by: Sakari Ailus Reviewed-by: Kieran Bingham Signed-off-by: Rob Herring Cc: Nathan Chancellor Signed-off-by: Greg Kroah-Hartman --- include/linux/of.h | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) --- a/include/linux/of.h +++ b/include/linux/of.h @@ -148,16 +148,20 @@ extern raw_spinlock_t devtree_lock; #ifdef CONFIG_OF void of_core_init(void); -static inline bool is_of_node(struct fwnode_handle *fwnode) +static inline bool is_of_node(const struct fwnode_handle *fwnode) { return !IS_ERR_OR_NULL(fwnode) && fwnode->type == FWNODE_OF; } -static inline struct device_node *to_of_node(struct fwnode_handle *fwnode) -{ - return is_of_node(fwnode) ? - container_of(fwnode, struct device_node, fwnode) : NULL; -} +#define to_of_node(__fwnode) \ + ({ \ + typeof(__fwnode) __to_of_node_fwnode = (__fwnode); \ + \ + is_of_node(__to_of_node_fwnode) ? \ + container_of(__to_of_node_fwnode, \ + struct device_node, fwnode) : \ + NULL; \ + }) static inline bool of_have_populated_dt(void) { @@ -529,12 +533,12 @@ static inline void of_core_init(void) { } -static inline bool is_of_node(struct fwnode_handle *fwnode) +static inline bool is_of_node(const struct fwnode_handle *fwnode) { return false; } -static inline struct device_node *to_of_node(struct fwnode_handle *fwnode) +static inline struct device_node *to_of_node(const struct fwnode_handle *fwnode) { return NULL; }