Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 67843bba authored by Suzuki K Poulose's avatar Suzuki K Poulose Committed by Greg Kroah-Hartman
Browse files

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: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
Acked-by: default avatarRobin Murphy <robin.murphy@arm.com>
Reviewed-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: default avatarHeikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20190723221838.12024-4-suzuki.poulose@arm.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent cfba5de9
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -3368,3 +3368,9 @@ int device_match_of_node(struct device *dev, const void *np)
	return dev->of_node == np;
}
EXPORT_SYMBOL_GPL(device_match_of_node);

int device_match_fwnode(struct device *dev, const void *fwnode)
{
	return dev_fwnode(dev) == fwnode;
}
EXPORT_SYMBOL_GPL(device_match_fwnode);
+1 −7
Original line number Diff line number Diff line
@@ -133,19 +133,13 @@ static struct bus_type *generic_match_buses[] = {
	NULL,
};

static int device_fwnode_match(struct device *dev, const void *fwnode)
{
	return dev_fwnode(dev) == fwnode;
}

static void *device_connection_fwnode_match(struct device_connection *con)
{
	struct bus_type *bus;
	struct device *dev;

	for (bus = generic_match_buses[0]; bus; bus++) {
		dev = bus_find_device(bus, NULL, (void *)con->fwnode,
				      device_fwnode_match);
		dev = bus_find_device_by_fwnode(bus, con->fwnode);
		if (dev && !strncmp(dev_name(dev), con->id, strlen(con->id)))
			return dev;

+2 −9
Original line number Diff line number Diff line
@@ -37,11 +37,6 @@ static int coresight_alloc_conns(struct device *dev,
	return 0;
}

int coresight_device_fwnode_match(struct device *dev, const void *fwnode)
{
	return dev_fwnode(dev) == fwnode;
}

static struct device *
coresight_find_device_by_fwnode(struct fwnode_handle *fwnode)
{
@@ -51,8 +46,7 @@ coresight_find_device_by_fwnode(struct fwnode_handle *fwnode)
	 * If we have a non-configurable replicator, it will be found on the
	 * platform bus.
	 */
	dev = bus_find_device(&platform_bus_type, NULL,
			      fwnode, coresight_device_fwnode_match);
	dev = bus_find_device_by_fwnode(&platform_bus_type, fwnode);
	if (dev)
		return dev;

@@ -60,8 +54,7 @@ coresight_find_device_by_fwnode(struct fwnode_handle *fwnode)
	 * We have a configurable component - circle through the AMBA bus
	 * looking for the device that matches the endpoint node.
	 */
	return bus_find_device(&amba_bustype, NULL,
			       fwnode, coresight_device_fwnode_match);
	return bus_find_device_by_fwnode(&amba_bustype, fwnode);
}

#ifdef CONFIG_OF
+0 −2
Original line number Diff line number Diff line
@@ -202,6 +202,4 @@ static inline void *coresight_get_uci_data(const struct amba_id *id)

void coresight_release_platform_data(struct coresight_platform_data *pdata);

int coresight_device_fwnode_match(struct device *dev, const void *fwnode);

#endif
+1 −3
Original line number Diff line number Diff line
@@ -1046,9 +1046,7 @@ static void coresight_fixup_device_conns(struct coresight_device *csdev)
		struct coresight_connection *conn = &csdev->pdata->conns[i];
		struct device *dev = NULL;

		dev = bus_find_device(&coresight_bustype, NULL,
				      (void *)conn->child_fwnode,
				      coresight_device_fwnode_match);
		dev = bus_find_device_by_fwnode(&coresight_bustype, conn->child_fwnode);
		if (dev) {
			conn->child_dev = to_coresight_device(dev);
			/* and put reference from 'bus_find_device()' */
Loading