mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 11:11:45 -04:00
usb: typec: Find the ports by also matching against the device node
When the connections are defined in firmware, struct device_connection will have the fwnode member pointing to the device node (struct fwnode_handle) of the requested device, and the endpoint will not be used at all in that case. Acked-by: Hans de Goede <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Reviewed-by: Jun Li <[email protected]> Signed-off-by: Heikki Krogerus <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
This commit is contained in:
parent
ec69e9533c
commit
6a0bbcf96b
1 changed files with 21 additions and 3 deletions
|
|
@ -9,6 +9,7 @@
|
|||
#include <linux/device.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/property.h>
|
||||
#include <linux/slab.h>
|
||||
|
||||
#include "bus.h"
|
||||
|
|
@ -204,15 +205,32 @@ static void typec_altmode_put_partner(struct altmode *altmode)
|
|||
put_device(&adev->dev);
|
||||
}
|
||||
|
||||
static int __typec_port_match(struct device *dev, const void *name)
|
||||
static int typec_port_fwnode_match(struct device *dev, const void *fwnode)
|
||||
{
|
||||
return dev_fwnode(dev) == fwnode;
|
||||
}
|
||||
|
||||
static int typec_port_name_match(struct device *dev, const void *name)
|
||||
{
|
||||
return !strcmp((const char *)name, dev_name(dev));
|
||||
}
|
||||
|
||||
static void *typec_port_match(struct device_connection *con, int ep, void *data)
|
||||
{
|
||||
return class_find_device(typec_class, NULL, con->endpoint[ep],
|
||||
__typec_port_match);
|
||||
struct device *dev;
|
||||
|
||||
/*
|
||||
* FIXME: Check does the fwnode supports the requested SVID. If it does
|
||||
* 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);
|
||||
|
||||
dev = class_find_device(typec_class, NULL, con->endpoint[ep],
|
||||
typec_port_name_match);
|
||||
|
||||
return dev ? dev : ERR_PTR(-EPROBE_DEFER);
|
||||
}
|
||||
|
||||
struct typec_altmode *
|
||||
|
|
|
|||
Loading…
Reference in a new issue