Commit 449d04a9 authored by Chao Xie's avatar Chao Xie Committed by Felipe Balbi

usb: gadget: mv_udc: fix the value of tranceiver

usally we will use udc->tranceiver == NULL or
udc->tranceiver != NULL.
So when failed to get the udc->tranceiver by usb_get_phy(), we
directly set udc->tranceiver to be NULL.
Then the source code will not need macro IS_ERR_OR_NULL() for
udc->tranceiver judgement. It can reduce the line size and make
the judgement simple.
Signed-off-by: default avatarChao Xie <chao.xie@marvell.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent ab592a74
...@@ -1394,7 +1394,7 @@ static int mv_udc_start(struct usb_gadget *gadget, ...@@ -1394,7 +1394,7 @@ static int mv_udc_start(struct usb_gadget *gadget,
spin_unlock_irqrestore(&udc->lock, flags); spin_unlock_irqrestore(&udc->lock, flags);
if (!IS_ERR_OR_NULL(udc->transceiver)) { if (udc->transceiver) {
retval = otg_set_peripheral(udc->transceiver->otg, retval = otg_set_peripheral(udc->transceiver->otg,
&udc->gadget); &udc->gadget);
if (retval) { if (retval) {
...@@ -2174,9 +2174,14 @@ static int mv_udc_probe(struct platform_device *pdev) ...@@ -2174,9 +2174,14 @@ static int mv_udc_probe(struct platform_device *pdev)
udc->dev = pdev; udc->dev = pdev;
#ifdef CONFIG_USB_OTG_UTILS #ifdef CONFIG_USB_OTG_UTILS
if (pdata->mode == MV_USB_MODE_OTG) if (pdata->mode == MV_USB_MODE_OTG) {
udc->transceiver = devm_usb_get_phy(&pdev->dev, udc->transceiver = devm_usb_get_phy(&pdev->dev,
USB_PHY_TYPE_USB2); USB_PHY_TYPE_USB2);
if (IS_ERR_OR_NULL(udc->transceiver)) {
udc->transceiver = NULL;
return -ENODEV;
}
}
#endif #endif
udc->clknum = pdata->clknum; udc->clknum = pdata->clknum;
...@@ -2319,7 +2324,7 @@ static int mv_udc_probe(struct platform_device *pdev) ...@@ -2319,7 +2324,7 @@ static int mv_udc_probe(struct platform_device *pdev)
eps_init(udc); eps_init(udc);
/* VBUS detect: we can disable/enable clock on demand.*/ /* VBUS detect: we can disable/enable clock on demand.*/
if (!IS_ERR_OR_NULL(udc->transceiver)) if (udc->transceiver)
udc->clock_gating = 1; udc->clock_gating = 1;
else if (pdata->vbus) { else if (pdata->vbus) {
udc->clock_gating = 1; udc->clock_gating = 1;
...@@ -2386,7 +2391,7 @@ static int mv_udc_suspend(struct device *dev) ...@@ -2386,7 +2391,7 @@ static int mv_udc_suspend(struct device *dev)
udc = dev_get_drvdata(dev); udc = dev_get_drvdata(dev);
/* if OTG is enabled, the following will be done in OTG driver*/ /* if OTG is enabled, the following will be done in OTG driver*/
if (!IS_ERR_OR_NULL(udc->transceiver)) if (udc->transceiver)
return 0; return 0;
if (udc->pdata->vbus && udc->pdata->vbus->poll) if (udc->pdata->vbus && udc->pdata->vbus->poll)
...@@ -2421,7 +2426,7 @@ static int mv_udc_resume(struct device *dev) ...@@ -2421,7 +2426,7 @@ static int mv_udc_resume(struct device *dev)
udc = dev_get_drvdata(dev); udc = dev_get_drvdata(dev);
/* if OTG is enabled, the following will be done in OTG driver*/ /* if OTG is enabled, the following will be done in OTG driver*/
if (!IS_ERR_OR_NULL(udc->transceiver)) if (udc->transceiver)
return 0; return 0;
if (!udc->clock_gating) { if (!udc->clock_gating) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment