mirror of
https://github.com/torvalds/linux.git
synced 2024-12-05 02:23:16 +00:00
usb: dwc3: Simplify with dev_err_probe()
Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and the error value gets printed. Acked-by: Felipe Balbi <balbi@kernel.org> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20210111135458.57084-1-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
370e3d5b71
commit
0c0a20f6da
@ -1126,11 +1126,8 @@ static int dwc3_core_get_phy(struct dwc3 *dwc)
|
||||
ret = PTR_ERR(dwc->usb2_phy);
|
||||
if (ret == -ENXIO || ret == -ENODEV) {
|
||||
dwc->usb2_phy = NULL;
|
||||
} else if (ret == -EPROBE_DEFER) {
|
||||
return ret;
|
||||
} else {
|
||||
dev_err(dev, "no usb2 phy configured\n");
|
||||
return ret;
|
||||
return dev_err_probe(dev, ret, "no usb2 phy configured\n");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1138,11 +1135,8 @@ static int dwc3_core_get_phy(struct dwc3 *dwc)
|
||||
ret = PTR_ERR(dwc->usb3_phy);
|
||||
if (ret == -ENXIO || ret == -ENODEV) {
|
||||
dwc->usb3_phy = NULL;
|
||||
} else if (ret == -EPROBE_DEFER) {
|
||||
return ret;
|
||||
} else {
|
||||
dev_err(dev, "no usb3 phy configured\n");
|
||||
return ret;
|
||||
return dev_err_probe(dev, ret, "no usb3 phy configured\n");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1151,11 +1145,8 @@ static int dwc3_core_get_phy(struct dwc3 *dwc)
|
||||
ret = PTR_ERR(dwc->usb2_generic_phy);
|
||||
if (ret == -ENOSYS || ret == -ENODEV) {
|
||||
dwc->usb2_generic_phy = NULL;
|
||||
} else if (ret == -EPROBE_DEFER) {
|
||||
return ret;
|
||||
} else {
|
||||
dev_err(dev, "no usb2 phy configured\n");
|
||||
return ret;
|
||||
return dev_err_probe(dev, ret, "no usb2 phy configured\n");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1164,11 +1155,8 @@ static int dwc3_core_get_phy(struct dwc3 *dwc)
|
||||
ret = PTR_ERR(dwc->usb3_generic_phy);
|
||||
if (ret == -ENOSYS || ret == -ENODEV) {
|
||||
dwc->usb3_generic_phy = NULL;
|
||||
} else if (ret == -EPROBE_DEFER) {
|
||||
return ret;
|
||||
} else {
|
||||
dev_err(dev, "no usb3 phy configured\n");
|
||||
return ret;
|
||||
return dev_err_probe(dev, ret, "no usb3 phy configured\n");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1190,11 +1178,8 @@ static int dwc3_core_init_mode(struct dwc3 *dwc)
|
||||
phy_set_mode(dwc->usb3_generic_phy, PHY_MODE_USB_DEVICE);
|
||||
|
||||
ret = dwc3_gadget_init(dwc);
|
||||
if (ret) {
|
||||
if (ret != -EPROBE_DEFER)
|
||||
dev_err(dev, "failed to initialize gadget\n");
|
||||
return ret;
|
||||
}
|
||||
if (ret)
|
||||
return dev_err_probe(dev, ret, "failed to initialize gadget\n");
|
||||
break;
|
||||
case USB_DR_MODE_HOST:
|
||||
dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_HOST);
|
||||
@ -1205,20 +1190,14 @@ static int dwc3_core_init_mode(struct dwc3 *dwc)
|
||||
phy_set_mode(dwc->usb3_generic_phy, PHY_MODE_USB_HOST);
|
||||
|
||||
ret = dwc3_host_init(dwc);
|
||||
if (ret) {
|
||||
if (ret != -EPROBE_DEFER)
|
||||
dev_err(dev, "failed to initialize host\n");
|
||||
return ret;
|
||||
}
|
||||
if (ret)
|
||||
return dev_err_probe(dev, ret, "failed to initialize host\n");
|
||||
break;
|
||||
case USB_DR_MODE_OTG:
|
||||
INIT_WORK(&dwc->drd_work, __dwc3_set_mode);
|
||||
ret = dwc3_drd_init(dwc);
|
||||
if (ret) {
|
||||
if (ret != -EPROBE_DEFER)
|
||||
dev_err(dev, "failed to initialize dual-role\n");
|
||||
return ret;
|
||||
}
|
||||
if (ret)
|
||||
return dev_err_probe(dev, ret, "failed to initialize dual-role\n");
|
||||
break;
|
||||
default:
|
||||
dev_err(dev, "Unsupported mode of operation %d\n", dwc->dr_mode);
|
||||
@ -1555,8 +1534,7 @@ static int dwc3_probe(struct platform_device *pdev)
|
||||
|
||||
ret = dwc3_core_init(dwc);
|
||||
if (ret) {
|
||||
if (ret != -EPROBE_DEFER)
|
||||
dev_err(dev, "failed to initialize core: %d\n", ret);
|
||||
dev_err_probe(dev, ret, "failed to initialize core\n");
|
||||
goto err4;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user