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
@@ -85,11 +85,6 @@ enum usb_role usb_role_switch_get_role(struct usb_role_switch *sw)
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(usb_role_switch_get_role);
|
||||
|
||||
static int switch_fwnode_match(struct device *dev, const void *fwnode)
|
||||
{
|
||||
return dev_fwnode(dev) == fwnode;
|
||||
}
|
||||
|
||||
static void *usb_role_switch_match(struct device_connection *con, int ep,
|
||||
void *data)
|
||||
{
|
||||
@@ -99,8 +94,7 @@ static void *usb_role_switch_match(struct device_connection *con, int ep,
|
||||
if (con->id && !fwnode_property_present(con->fwnode, con->id))
|
||||
return NULL;
|
||||
|
||||
dev = class_find_device(role_class, NULL, con->fwnode,
|
||||
switch_fwnode_match);
|
||||
dev = class_find_device_by_fwnode(role_class, con->fwnode);
|
||||
} else {
|
||||
dev = class_find_device_by_name(role_class, con->endpoint[ep]);
|
||||
}
|
||||
|
@@ -205,11 +205,6 @@ static void typec_altmode_put_partner(struct altmode *altmode)
|
||||
put_device(&adev->dev);
|
||||
}
|
||||
|
||||
static int typec_port_fwnode_match(struct device *dev, const void *fwnode)
|
||||
{
|
||||
return dev_fwnode(dev) == fwnode;
|
||||
}
|
||||
|
||||
static void *typec_port_match(struct device_connection *con, int ep, void *data)
|
||||
{
|
||||
struct device *dev;
|
||||
@@ -219,8 +214,7 @@ static void *typec_port_match(struct device_connection *con, int ep, void *data)
|
||||
* we need to return ERR_PTR(-PROBE_DEFER) when there is no device.
|
||||
*/
|
||||
if (con->fwnode)
|
||||
return class_find_device(typec_class, NULL, con->fwnode,
|
||||
typec_port_fwnode_match);
|
||||
return class_find_device_by_fwnode(typec_class, con->fwnode);
|
||||
|
||||
dev = class_find_device_by_name(typec_class, con->endpoint[ep]);
|
||||
|
||||
|
Reference in New Issue
Block a user