summaryrefslogtreecommitdiff
path: root/drivers/usb/cdns3/core.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/cdns3/core.c')
-rw-r--r--drivers/usb/cdns3/core.c47
1 files changed, 17 insertions, 30 deletions
diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c
index 19bbb5b7e6b6..72885c5edb09 100644
--- a/drivers/usb/cdns3/core.c
+++ b/drivers/usb/cdns3/core.c
@@ -27,13 +27,6 @@
static int cdns3_idle_init(struct cdns3 *cdns);
-static inline
-struct cdns3_role_driver *cdns3_get_current_role_driver(struct cdns3 *cdns)
-{
- WARN_ON(!cdns->roles[cdns->role]);
- return cdns->roles[cdns->role];
-}
-
static int cdns3_role_start(struct cdns3 *cdns, enum usb_role role)
{
int ret;
@@ -93,7 +86,7 @@ static int cdns3_core_init_role(struct cdns3 *cdns)
struct device *dev = cdns->dev;
enum usb_dr_mode best_dr_mode;
enum usb_dr_mode dr_mode;
- int ret = 0;
+ int ret;
dr_mode = usb_get_dr_mode(dev);
cdns->role = USB_ROLE_NONE;
@@ -184,7 +177,7 @@ static int cdns3_core_init_role(struct cdns3 *cdns)
goto err;
}
- return ret;
+ return 0;
err:
cdns3_exit_roles(cdns);
return ret;
@@ -198,11 +191,17 @@ err:
*/
static enum usb_role cdns3_hw_role_state_machine(struct cdns3 *cdns)
{
- enum usb_role role;
+ enum usb_role role = USB_ROLE_NONE;
int id, vbus;
- if (cdns->dr_mode != USB_DR_MODE_OTG)
- goto not_otg;
+ if (cdns->dr_mode != USB_DR_MODE_OTG) {
+ if (cdns3_is_host(cdns))
+ role = USB_ROLE_HOST;
+ if (cdns3_is_device(cdns))
+ role = USB_ROLE_DEVICE;
+
+ return role;
+ }
id = cdns3_get_id(cdns);
vbus = cdns3_get_vbus(cdns);
@@ -239,14 +238,6 @@ static enum usb_role cdns3_hw_role_state_machine(struct cdns3 *cdns)
dev_dbg(cdns->dev, "role %d -> %d\n", cdns->role, role);
return role;
-
-not_otg:
- if (cdns3_is_host(cdns))
- role = USB_ROLE_HOST;
- if (cdns3_is_device(cdns))
- role = USB_ROLE_DEVICE;
-
- return role;
}
static int cdns3_idle_role_start(struct cdns3 *cdns)
@@ -282,7 +273,7 @@ static int cdns3_idle_init(struct cdns3 *cdns)
/**
* cdns3_hw_role_switch - switch roles based on HW state
- * @cdns3: controller
+ * @cdns: controller
*/
int cdns3_hw_role_switch(struct cdns3 *cdns)
{
@@ -320,7 +311,7 @@ exit:
/**
* cdsn3_role_get - get current role of controller.
*
- * @dev: Pointer to device structure
+ * @sw: pointer to USB role switch structure
*
* Returns role
*/
@@ -334,8 +325,8 @@ static enum usb_role cdns3_role_get(struct usb_role_switch *sw)
/**
* cdns3_role_set - set current role of controller.
*
- * @dev: pointer to device object
- * @role - the previous role
+ * @sw: pointer to USB role switch structure
+ * @role: the previous role
* Handles below events:
* - Role switch for dual-role devices
* - USB_ROLE_GADGET <--> USB_ROLE_NONE for peripheral-only devices
@@ -356,7 +347,6 @@ static int cdns3_role_set(struct usb_role_switch *sw, enum usb_role role)
case USB_ROLE_HOST:
break;
default:
- ret = -EPERM;
goto pm_put;
}
}
@@ -367,17 +357,14 @@ static int cdns3_role_set(struct usb_role_switch *sw, enum usb_role role)
case USB_ROLE_DEVICE:
break;
default:
- ret = -EPERM;
goto pm_put;
}
}
cdns3_role_stop(cdns);
ret = cdns3_role_start(cdns, role);
- if (ret) {
+ if (ret)
dev_err(cdns->dev, "set role %d has failed\n", role);
- ret = -EPERM;
- }
pm_put:
pm_runtime_put_sync(cdns->dev);
@@ -402,7 +389,7 @@ static int cdns3_probe(struct platform_device *pdev)
ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
if (ret) {
dev_err(dev, "error setting dma mask: %d\n", ret);
- return -ENODEV;
+ return ret;
}
cdns = devm_kzalloc(dev, sizeof(*cdns), GFP_KERNEL);