
All the users of that API have now been converted to use software fwnodes instead. Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Link: https://lore.kernel.org/r/20200904125123.83725-3-heikki.krogerus@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
102 lines
2.7 KiB
C
102 lines
2.7 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/**
|
|
* Device connections
|
|
*
|
|
* Copyright (C) 2018 Intel Corporation
|
|
* Author: Heikki Krogerus <heikki.krogerus@linux.intel.com>
|
|
*/
|
|
|
|
#include <linux/device.h>
|
|
#include <linux/property.h>
|
|
|
|
static void *
|
|
fwnode_graph_devcon_match(struct fwnode_handle *fwnode, const char *con_id,
|
|
void *data, devcon_match_fn_t match)
|
|
{
|
|
struct device_connection con = { .id = con_id };
|
|
struct fwnode_handle *ep;
|
|
void *ret;
|
|
|
|
fwnode_graph_for_each_endpoint(fwnode, ep) {
|
|
con.fwnode = fwnode_graph_get_remote_port_parent(ep);
|
|
if (!fwnode_device_is_available(con.fwnode))
|
|
continue;
|
|
|
|
ret = match(&con, -1, data);
|
|
fwnode_handle_put(con.fwnode);
|
|
if (ret) {
|
|
fwnode_handle_put(ep);
|
|
return ret;
|
|
}
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
static void *
|
|
fwnode_devcon_match(struct fwnode_handle *fwnode, const char *con_id,
|
|
void *data, devcon_match_fn_t match)
|
|
{
|
|
struct device_connection con = { };
|
|
void *ret;
|
|
int i;
|
|
|
|
for (i = 0; ; i++) {
|
|
con.fwnode = fwnode_find_reference(fwnode, con_id, i);
|
|
if (IS_ERR(con.fwnode))
|
|
break;
|
|
|
|
ret = match(&con, -1, data);
|
|
fwnode_handle_put(con.fwnode);
|
|
if (ret)
|
|
return ret;
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
/**
|
|
* fwnode_connection_find_match - Find connection from a device node
|
|
* @fwnode: Device node with the connection
|
|
* @con_id: Identifier for the connection
|
|
* @data: Data for the match function
|
|
* @match: Function to check and convert the connection description
|
|
*
|
|
* Find a connection with unique identifier @con_id between @fwnode and another
|
|
* device node. @match will be used to convert the connection description to
|
|
* data the caller is expecting to be returned.
|
|
*/
|
|
void *fwnode_connection_find_match(struct fwnode_handle *fwnode,
|
|
const char *con_id, void *data,
|
|
devcon_match_fn_t match)
|
|
{
|
|
void *ret;
|
|
|
|
if (!fwnode || !match)
|
|
return NULL;
|
|
|
|
ret = fwnode_graph_devcon_match(fwnode, con_id, data, match);
|
|
if (ret)
|
|
return ret;
|
|
|
|
return fwnode_devcon_match(fwnode, con_id, data, match);
|
|
}
|
|
EXPORT_SYMBOL_GPL(fwnode_connection_find_match);
|
|
|
|
/**
|
|
* device_connection_find_match - Find physical connection to a device
|
|
* @dev: Device with the connection
|
|
* @con_id: Identifier for the connection
|
|
* @data: Data for the match function
|
|
* @match: Function to check and convert the connection description
|
|
*
|
|
* Find a connection with unique identifier @con_id between @dev and another
|
|
* device. @match will be used to convert the connection description to data the
|
|
* caller is expecting to be returned.
|
|
*/
|
|
void *device_connection_find_match(struct device *dev, const char *con_id,
|
|
void *data, devcon_match_fn_t match)
|
|
{
|
|
return fwnode_connection_find_match(dev_fwnode(dev), con_id, data, match);
|
|
}
|
|
EXPORT_SYMBOL_GPL(device_connection_find_match);
|