From patchwork Thu Nov 2 09:57:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 10038263 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AF5D06032D for ; Thu, 2 Nov 2017 09:58:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9E0D028ED7 for ; Thu, 2 Nov 2017 09:58:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9228228ED9; Thu, 2 Nov 2017 09:58:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 32BD828ED7 for ; Thu, 2 Nov 2017 09:58:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=eXufDuMUtT+t3sFzTv7pgjOB8Tyo2Az7GARThVNtzM4=; b=Wj4r8BjembKO1/orvgI1one5oc OPcxzlFmpkY1RsowTHi4n1iRomO6jfpjDiwz5UT2BgIl3ziMKREsqIIgPpUklvzU5F0f3O7HVHJI9 5k2Wi/qRTtJ8iqP7YrTI48kqG0T6N2TlsnuNw7KkyMMBzgJBfuqTB67hsD1FnLUBQpQh/cfx9GXvs MxUv2Kw4qpCrHLHZIl+fv0mvm3OlMxm0wfJ6NLIanAvTWWWvVF3aGiHPsrdIBshlAgx6mKw7tEMWv 7H2nV/qAiXrciGNvX+Un1uqwqQAc62iHjt9QpJNoGldh68DNQW7IQCPN+/Zzdr4kSf1mGzQ5/ux2t k16Pd8LQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eACFz-0004Xv-UK; Thu, 02 Nov 2017 09:57:51 +0000 Received: from hillosipuli.retiisi.org.uk ([2001:1bc8:1a6:d3d5::81:2]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eACFw-0004WM-QC for linux-arm-kernel@lists.infradead.org; Thu, 02 Nov 2017 09:57:50 +0000 Received: from lanttu.localdomain (unknown [IPv6:2001:1bc8:1a6:d3d5::e1:1002]) by hillosipuli.retiisi.org.uk (Postfix) with ESMTP id BADB7600CA; Thu, 2 Nov 2017 11:57:22 +0200 (EET) From: Sakari Ailus To: devicetree@vger.kernel.org, m.chehab@osg.samsung.com Subject: [PATCH 1/1] of: Make return types of to_of_node and of_fwnode_handle macros consistent Date: Thu, 2 Nov 2017 11:57:22 +0200 Message-Id: <20171102095722.6893-1-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <2117711.dO2rQLXOup@avalon> References: <2117711.dO2rQLXOup@avalon> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171102_025749_066039_94131414 X-CRM114-Status: UNSURE ( 8.50 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: robh@kernel.org, hyun.kwon@xilinx.com, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org, soren.brinkmann@xilinx.com, laurent.pinchart@ideasonboard.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP to_of_node() macro checks whether the fwnode_handle passed to it is not an OF node, and if so, returns NULL in order to be NULL-safe. Otherwise it returns the pointer to the OF node which the fwnode_handle contains. The problem with returning NULL is that its type was void *, which sometimes matters. Explicitly return struct device_node * instead. Make a similar change to of_fwnode_handle() as well. Fixes: d20dc1493db4 ("of: Support const and non-const use for to_of_node()") Fixes: debd3a3b27c7 ("of: Make of_fwnode_handle() safer") Signed-off-by: Sakari Ailus --- Hi Mauro, Could you check whether this addresses the smatch issue with the xilinx driver? Thanks. include/linux/of.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/linux/of.h b/include/linux/of.h index b240ed69dc96..0651231c115e 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -161,7 +161,7 @@ static inline bool is_of_node(const struct fwnode_handle *fwnode) is_of_node(__to_of_node_fwnode) ? \ container_of(__to_of_node_fwnode, \ struct device_node, fwnode) : \ - NULL; \ + (struct device_node *)NULL; \ }) #define of_fwnode_handle(node) \ @@ -169,7 +169,8 @@ static inline bool is_of_node(const struct fwnode_handle *fwnode) typeof(node) __of_fwnode_handle_node = (node); \ \ __of_fwnode_handle_node ? \ - &__of_fwnode_handle_node->fwnode : NULL; \ + &__of_fwnode_handle_node->fwnode : \ + (struct fwnode_handle *)NULL; \ }) static inline bool of_have_populated_dt(void)