FROMGIT: driver core: Add fwnode_to_dev() to look up device from fwnode

It's often useful to look up a device that corresponds to a fwnode. So
add an API to do that irrespective of the bus on which the device has
been added to.

Signed-off-by: Saravana Kannan <saravanak@google.com>
Link: https://lore.kernel.org/r/20190904211126.47518-2-saravanak@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

(cherry-picked from commit 372a67c0c5
 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git driver-core-next)

Bug: 141703324
Change-Id: I68c36177da083bfb04e73c1b754e740f40faf284
This commit is contained in:
Saravana Kannan
2019-09-04 14:11:20 -07:00
parent 8e9e0abf99
commit 58acf67e41
2 changed files with 9 additions and 0 deletions

View File

@@ -17,6 +17,7 @@ struct device;
struct fwnode_handle {
struct fwnode_handle *secondary;
const struct fwnode_operations *ops;
struct device *dev;
};
/**
@@ -123,5 +124,6 @@ struct fwnode_operations {
if (fwnode_has_op(fwnode, op)) \
(fwnode)->ops->op(fwnode, ## __VA_ARGS__); \
} while (false)
#define get_dev_from_fwnode(fwnode) get_device((fwnode)->dev)
#endif