Commit f5514c91 authored by Heikki Krogerus's avatar Heikki Krogerus Committed by Greg Kroah-Hartman

device connection: Remove struct device_connection

Since the connection descriptors can't be stored into the
list anymore, there is no need for the data structure.
Signed-off-by: default avatarHeikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20200904125123.83725-4-heikki.krogerus@linux.intel.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 87ea5926
...@@ -13,17 +13,17 @@ static void * ...@@ -13,17 +13,17 @@ static void *
fwnode_graph_devcon_match(struct fwnode_handle *fwnode, const char *con_id, fwnode_graph_devcon_match(struct fwnode_handle *fwnode, const char *con_id,
void *data, devcon_match_fn_t match) void *data, devcon_match_fn_t match)
{ {
struct device_connection con = { .id = con_id }; struct fwnode_handle *node;
struct fwnode_handle *ep; struct fwnode_handle *ep;
void *ret; void *ret;
fwnode_graph_for_each_endpoint(fwnode, ep) { fwnode_graph_for_each_endpoint(fwnode, ep) {
con.fwnode = fwnode_graph_get_remote_port_parent(ep); node = fwnode_graph_get_remote_port_parent(ep);
if (!fwnode_device_is_available(con.fwnode)) if (!fwnode_device_is_available(node))
continue; continue;
ret = match(&con, -1, data); ret = match(node, con_id, data);
fwnode_handle_put(con.fwnode); fwnode_handle_put(node);
if (ret) { if (ret) {
fwnode_handle_put(ep); fwnode_handle_put(ep);
return ret; return ret;
...@@ -36,17 +36,17 @@ static void * ...@@ -36,17 +36,17 @@ static void *
fwnode_devcon_match(struct fwnode_handle *fwnode, const char *con_id, fwnode_devcon_match(struct fwnode_handle *fwnode, const char *con_id,
void *data, devcon_match_fn_t match) void *data, devcon_match_fn_t match)
{ {
struct device_connection con = { }; struct fwnode_handle *node;
void *ret; void *ret;
int i; int i;
for (i = 0; ; i++) { for (i = 0; ; i++) {
con.fwnode = fwnode_find_reference(fwnode, con_id, i); node = fwnode_find_reference(fwnode, con_id, i);
if (IS_ERR(con.fwnode)) if (IS_ERR(node))
break; break;
ret = match(&con, -1, data); ret = match(node, NULL, data);
fwnode_handle_put(con.fwnode); fwnode_handle_put(node);
if (ret) if (ret)
return ret; return ret;
} }
......
...@@ -87,19 +87,15 @@ enum usb_role usb_role_switch_get_role(struct usb_role_switch *sw) ...@@ -87,19 +87,15 @@ enum usb_role usb_role_switch_get_role(struct usb_role_switch *sw)
} }
EXPORT_SYMBOL_GPL(usb_role_switch_get_role); EXPORT_SYMBOL_GPL(usb_role_switch_get_role);
static void *usb_role_switch_match(struct device_connection *con, int ep, static void *usb_role_switch_match(struct fwnode_handle *fwnode, const char *id,
void *data) void *data)
{ {
struct device *dev; struct device *dev;
if (con->fwnode) { if (id && !fwnode_property_present(fwnode, id))
if (con->id && !fwnode_property_present(con->fwnode, con->id))
return NULL; return NULL;
dev = class_find_device_by_fwnode(role_class, con->fwnode); dev = class_find_device_by_fwnode(role_class, fwnode);
} else {
dev = class_find_device_by_name(role_class, con->endpoint[ep]);
}
return dev ? to_role_switch(dev) : ERR_PTR(-EPROBE_DEFER); return dev ? to_role_switch(dev) : ERR_PTR(-EPROBE_DEFER);
} }
......
...@@ -34,15 +34,15 @@ static int switch_fwnode_match(struct device *dev, const void *fwnode) ...@@ -34,15 +34,15 @@ static int switch_fwnode_match(struct device *dev, const void *fwnode)
return dev_fwnode(dev) == fwnode && dev_name_ends_with(dev, "-switch"); return dev_fwnode(dev) == fwnode && dev_name_ends_with(dev, "-switch");
} }
static void *typec_switch_match(struct device_connection *con, int ep, static void *typec_switch_match(struct fwnode_handle *fwnode, const char *id,
void *data) void *data)
{ {
struct device *dev; struct device *dev;
if (con->id && !fwnode_property_present(con->fwnode, con->id)) if (id && !fwnode_property_present(fwnode, id))
return NULL; return NULL;
dev = class_find_device(&typec_mux_class, NULL, con->fwnode, dev = class_find_device(&typec_mux_class, NULL, fwnode,
switch_fwnode_match); switch_fwnode_match);
return dev ? to_typec_switch(dev) : ERR_PTR(-EPROBE_DEFER); return dev ? to_typec_switch(dev) : ERR_PTR(-EPROBE_DEFER);
...@@ -183,7 +183,8 @@ static int mux_fwnode_match(struct device *dev, const void *fwnode) ...@@ -183,7 +183,8 @@ static int mux_fwnode_match(struct device *dev, const void *fwnode)
return dev_fwnode(dev) == fwnode && dev_name_ends_with(dev, "-mux"); return dev_fwnode(dev) == fwnode && dev_name_ends_with(dev, "-mux");
} }
static void *typec_mux_match(struct device_connection *con, int ep, void *data) static void *typec_mux_match(struct fwnode_handle *fwnode, const char *id,
void *data)
{ {
const struct typec_altmode_desc *desc = data; const struct typec_altmode_desc *desc = data;
struct device *dev; struct device *dev;
...@@ -196,20 +197,20 @@ static void *typec_mux_match(struct device_connection *con, int ep, void *data) ...@@ -196,20 +197,20 @@ static void *typec_mux_match(struct device_connection *con, int ep, void *data)
* Check has the identifier already been "consumed". If it * Check has the identifier already been "consumed". If it
* has, no need to do any extra connection identification. * has, no need to do any extra connection identification.
*/ */
match = !con->id; match = !id;
if (match) if (match)
goto find_mux; goto find_mux;
/* Accessory Mode muxes */ /* Accessory Mode muxes */
if (!desc) { if (!desc) {
match = fwnode_property_present(con->fwnode, "accessory"); match = fwnode_property_present(fwnode, "accessory");
if (match) if (match)
goto find_mux; goto find_mux;
return NULL; return NULL;
} }
/* Alternate Mode muxes */ /* Alternate Mode muxes */
nval = fwnode_property_count_u16(con->fwnode, "svid"); nval = fwnode_property_count_u16(fwnode, "svid");
if (nval <= 0) if (nval <= 0)
return NULL; return NULL;
...@@ -217,7 +218,7 @@ static void *typec_mux_match(struct device_connection *con, int ep, void *data) ...@@ -217,7 +218,7 @@ static void *typec_mux_match(struct device_connection *con, int ep, void *data)
if (!val) if (!val)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
nval = fwnode_property_read_u16_array(con->fwnode, "svid", val, nval); nval = fwnode_property_read_u16_array(fwnode, "svid", val, nval);
if (nval < 0) { if (nval < 0) {
kfree(val); kfree(val);
return ERR_PTR(nval); return ERR_PTR(nval);
...@@ -234,7 +235,7 @@ static void *typec_mux_match(struct device_connection *con, int ep, void *data) ...@@ -234,7 +235,7 @@ static void *typec_mux_match(struct device_connection *con, int ep, void *data)
return NULL; return NULL;
find_mux: find_mux:
dev = class_find_device(&typec_mux_class, NULL, con->fwnode, dev = class_find_device(&typec_mux_class, NULL, fwnode,
mux_fwnode_match); mux_fwnode_match);
return dev ? to_typec_switch(dev) : ERR_PTR(-EPROBE_DEFER); return dev ? to_typec_switch(dev) : ERR_PTR(-EPROBE_DEFER);
......
...@@ -292,23 +292,7 @@ struct device_dma_parameters { ...@@ -292,23 +292,7 @@ struct device_dma_parameters {
unsigned long segment_boundary_mask; unsigned long segment_boundary_mask;
}; };
/** typedef void *(*devcon_match_fn_t)(struct fwnode_handle *fwnode, const char *id,
* struct device_connection - Device Connection Descriptor
* @fwnode: The device node of the connected device
* @endpoint: The names of the two devices connected together
* @id: Unique identifier for the connection
*
* NOTE: @fwnode is not used together with @endpoint. @fwnode is used when
* platform firmware defines the connection. When the connection is registered
* with device_connection_add() @endpoint is used instead.
*/
struct device_connection {
struct fwnode_handle *fwnode;
const char *endpoint[2];
const char *id;
};
typedef void *(*devcon_match_fn_t)(struct device_connection *con, int ep,
void *data); void *data);
void *fwnode_connection_find_match(struct fwnode_handle *fwnode, void *fwnode_connection_find_match(struct fwnode_handle *fwnode,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment