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>
Esse commit está contido em:

commit de
Greg Kroah-Hartman

pai
cfba5de9b9
commit
67843bbaf3
@@ -4499,19 +4499,13 @@ static const struct acpi_device_id hns_roce_acpi_match[] = {
|
||||
};
|
||||
MODULE_DEVICE_TABLE(acpi, hns_roce_acpi_match);
|
||||
|
||||
static int hns_roce_node_match(struct device *dev, const void *fwnode)
|
||||
{
|
||||
return dev->fwnode == fwnode;
|
||||
}
|
||||
|
||||
static struct
|
||||
platform_device *hns_roce_find_pdev(struct fwnode_handle *fwnode)
|
||||
{
|
||||
struct device *dev;
|
||||
|
||||
/* get the 'device' corresponding to the matching 'fwnode' */
|
||||
dev = bus_find_device(&platform_bus_type, NULL,
|
||||
fwnode, hns_roce_node_match);
|
||||
dev = bus_find_device_by_fwnode(&platform_bus_type, fwnode);
|
||||
/* get the platform device */
|
||||
return dev ? to_platform_device(dev) : NULL;
|
||||
}
|
||||
|
Referência em uma nova issue
Block a user