From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754890AbbHJQ4z (ORCPT ); Mon, 10 Aug 2015 12:56:55 -0400 Received: from mga11.intel.com ([192.55.52.93]:48794 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753245AbbHJQ4w (ORCPT ); Mon, 10 Aug 2015 12:56:52 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,646,1432623600"; d="scan'208";a="745780002" From: Andy Shevchenko To: "Rafael J . Wysocki" , Greg Kroah-Hartman , linux-kernel@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1 1/3] device property: check fwnode type in to_of_node() Date: Mon, 10 Aug 2015 19:56:46 +0300 Message-Id: <1439225808-132916-1-git-send-email-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.5.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Potentially one of platform can support both ACPI and OF. In that case when we call to_of_node() for non-OF fwnode types we will get non-NULL result, which is wrong. Check for the type and return a correspondent result. Signed-off-by: Andy Shevchenko --- include/linux/of.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/linux/of.h b/include/linux/of.h index edc068d..2194b8c 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -136,7 +136,8 @@ static inline bool is_of_node(struct fwnode_handle *fwnode) static inline struct device_node *to_of_node(struct fwnode_handle *fwnode) { - return fwnode ? container_of(fwnode, struct device_node, fwnode) : NULL; + return is_of_node(fwnode) ? + container_of(fwnode, struct device_node, fwnode) : NULL; } static inline bool of_have_populated_dt(void) -- 2.5.0