drivers: Introduce device lookup variants by fwnode
Add a helper to match the firmware node handle of a device and provide wrappers for {bus/class/driver}_find_device() APIs to avoid proliferation of duplicate custom match functions. Cc: "David S. Miller" <davem@davemloft.net> Cc: Doug Ledford <dledford@redhat.com> Cc: Jason Gunthorpe <jgg@ziepe.ca> Cc: linux-usb@vger.kernel.org Cc: "Rafael J. Wysocki" <rafael@kernel.org> Cc: Ulf Hansson <ulf.hansson@linaro.org> Cc: Joe Perches <joe@perches.com> Cc: Will Deacon <will.deacon@arm.com> Cc: Joerg Roedel <joro@8bytes.org> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> Acked-by: Robin Murphy <robin.murphy@arm.com> Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Link: https://lore.kernel.org/r/20190723221838.12024-4-suzuki.poulose@arm.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
cfba5de9b9
commit
67843bbaf3
@@ -166,6 +166,7 @@ void subsys_dev_iter_exit(struct subsys_dev_iter *iter);
|
||||
|
||||
int device_match_name(struct device *dev, const void *name);
|
||||
int device_match_of_node(struct device *dev, const void *np);
|
||||
int device_match_fwnode(struct device *dev, const void *fwnode);
|
||||
|
||||
int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data,
|
||||
int (*fn)(struct device *dev, void *data));
|
||||
@@ -198,6 +199,18 @@ bus_find_device_by_of_node(struct bus_type *bus, const struct device_node *np)
|
||||
return bus_find_device(bus, NULL, np, device_match_of_node);
|
||||
}
|
||||
|
||||
/**
|
||||
* bus_find_device_by_fwnode : device iterator for locating a particular device
|
||||
* matching the fwnode.
|
||||
* @bus: bus type
|
||||
* @fwnode: fwnode of the device to match.
|
||||
*/
|
||||
static inline struct device *
|
||||
bus_find_device_by_fwnode(struct bus_type *bus, const struct fwnode_handle *fwnode)
|
||||
{
|
||||
return bus_find_device(bus, NULL, fwnode, device_match_fwnode);
|
||||
}
|
||||
|
||||
struct device *subsys_find_device_by_id(struct bus_type *bus, unsigned int id,
|
||||
struct device *hint);
|
||||
int bus_for_each_drv(struct bus_type *bus, struct device_driver *start,
|
||||
@@ -391,6 +404,19 @@ driver_find_device_by_of_node(struct device_driver *drv,
|
||||
return driver_find_device(drv, NULL, np, device_match_of_node);
|
||||
}
|
||||
|
||||
/**
|
||||
* driver_find_device_by_fwnode- device iterator for locating a particular device
|
||||
* by fwnode pointer.
|
||||
* @driver: the driver we're iterating
|
||||
* @fwnode: fwnode pointer to match.
|
||||
*/
|
||||
static inline struct device *
|
||||
driver_find_device_by_fwnode(struct device_driver *drv,
|
||||
const struct fwnode_handle *fwnode)
|
||||
{
|
||||
return driver_find_device(drv, NULL, fwnode, device_match_fwnode);
|
||||
}
|
||||
|
||||
void driver_deferred_probe_add(struct device *dev);
|
||||
int driver_deferred_probe_check_state(struct device *dev);
|
||||
int driver_deferred_probe_check_state_continue(struct device *dev);
|
||||
@@ -544,6 +570,19 @@ class_find_device_by_of_node(struct class *class, const struct device_node *np)
|
||||
return class_find_device(class, NULL, np, device_match_of_node);
|
||||
}
|
||||
|
||||
/**
|
||||
* class_find_device_by_fwnode : device iterator for locating a particular device
|
||||
* matching the fwnode.
|
||||
* @class: class type
|
||||
* @fwnode: fwnode of the device to match.
|
||||
*/
|
||||
static inline struct device *
|
||||
class_find_device_by_fwnode(struct class *class,
|
||||
const struct fwnode_handle *fwnode)
|
||||
{
|
||||
return class_find_device(class, NULL, fwnode, device_match_fwnode);
|
||||
}
|
||||
|
||||
struct class_attribute {
|
||||
struct attribute attr;
|
||||
ssize_t (*show)(struct class *class, struct class_attribute *attr,
|
||||
|
Reference in New Issue
Block a user