usb: chipidea i.MX: Do not return unnecessary error
We only allow to setup the host/peripheral role once, when it's already set then we return -EBUSY. Return 0 instead when we set the same role again and only return -EBUSY when we actually try to change the role. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
4bbfe971bb
commit
b82ae64e47
|
@ -150,7 +150,7 @@ static int imx_chipidea_probe_dt(struct imx_chipidea *ci)
|
|||
|
||||
static int ci_register_role(struct imx_chipidea *ci)
|
||||
{
|
||||
if (ci->role_registered)
|
||||
if (ci->role_registered != IMX_USB_MODE_OTG)
|
||||
return -EBUSY;
|
||||
|
||||
if (ci->mode == IMX_USB_MODE_HOST) {
|
||||
|
@ -180,8 +180,12 @@ static int ci_set_mode(struct param_d *param, void *priv)
|
|||
{
|
||||
struct imx_chipidea *ci = priv;
|
||||
|
||||
if (ci->role_registered)
|
||||
return -EBUSY;
|
||||
if (ci->role_registered != IMX_USB_MODE_OTG) {
|
||||
if (ci->role_registered == ci->mode)
|
||||
return 0;
|
||||
else
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
return ci_register_role(ci);
|
||||
}
|
||||
|
@ -225,6 +229,7 @@ static int imx_chipidea_probe(struct device_d *dev)
|
|||
|
||||
ci = xzalloc(sizeof(*ci));
|
||||
ci->dev = dev;
|
||||
ci->role_registered = IMX_USB_MODE_OTG;
|
||||
|
||||
if (IS_ENABLED(CONFIG_OFDEVICE) && dev->device_node) {
|
||||
ret = imx_chipidea_probe_dt(ci);
|
||||
|
|
Loading…
Reference in New Issue