Skip to content

Commit

Permalink
device property: check fwnode type in to_of_node()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Andy Shevchenko authored and Rafael J. Wysocki committed Aug 25, 2015
1 parent 7dc59dc commit 4bf0118
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion include/linux/of.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 4bf0118

Please sign in to comment.