usb: roles: Provide the switch drivers handle to the switch in the API
The USB role callback functions had a parameter pointing to the parent device (struct device) of the switch. The assumption was that the switch parent is always the controller. Firstly, that may not be true in every case, and secondly, it prevents us from supporting devices that supply multiple muxes. Changing the first parameter of usb_role_switch_set_t and usb_role_switch_get_t from struct device to struct usb_role_switch. Cc: Peter Chen <Peter.Chen@nxp.com> Cc: Felipe Balbi <balbi@kernel.org> Cc: Chunfeng Yun <chunfeng.yun@mediatek.com> Cc: Bin Liu <b-liu@ti.com> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Link: https://lore.kernel.org/r/20200302135353.56659-6-heikki.krogerus@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
69af044a77
commit
bce3052f0c
@@ -600,9 +600,9 @@ static int ci_cable_notifier(struct notifier_block *nb, unsigned long event,
|
||||
return NOTIFY_DONE;
|
||||
}
|
||||
|
||||
static enum usb_role ci_usb_role_switch_get(struct device *dev)
|
||||
static enum usb_role ci_usb_role_switch_get(struct usb_role_switch *sw)
|
||||
{
|
||||
struct ci_hdrc *ci = dev_get_drvdata(dev);
|
||||
struct ci_hdrc *ci = usb_role_switch_get_drvdata(sw);
|
||||
enum usb_role role;
|
||||
unsigned long flags;
|
||||
|
||||
@@ -613,9 +613,10 @@ static enum usb_role ci_usb_role_switch_get(struct device *dev)
|
||||
return role;
|
||||
}
|
||||
|
||||
static int ci_usb_role_switch_set(struct device *dev, enum usb_role role)
|
||||
static int ci_usb_role_switch_set(struct usb_role_switch *sw,
|
||||
enum usb_role role)
|
||||
{
|
||||
struct ci_hdrc *ci = dev_get_drvdata(dev);
|
||||
struct ci_hdrc *ci = usb_role_switch_get_drvdata(sw);
|
||||
struct ci_hdrc_cable *cable = NULL;
|
||||
enum usb_role current_role = ci_role_to_usb_role(ci);
|
||||
enum ci_role ci_role = usb_role_to_ci_role(role);
|
||||
@@ -1118,6 +1119,7 @@ static int ci_hdrc_probe(struct platform_device *pdev)
|
||||
}
|
||||
|
||||
if (ci_role_switch.fwnode) {
|
||||
ci_role_switch.driver_data = ci;
|
||||
ci->role_switch = usb_role_switch_register(dev,
|
||||
&ci_role_switch);
|
||||
if (IS_ERR(ci->role_switch)) {
|
||||
|
Reference in New Issue
Block a user