device property: check fwnode type in to_of_node()
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Mon, 10 Aug 2015 16:56:46 +0000 (19:56 +0300)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 25 Aug 2015 23:46:39 +0000 (01:46 +0200)
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 <andriy.shevchenko@linux.intel.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
include/linux/of.h

index edc068d19c79248564239e3823982a819dad7411..2194b8ca41f92fe4edb7bb32ecd4bc4507f1ddf0 100644 (file)
@@ -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)
This page took 0.025156 seconds and 5 git commands to generate.