[PATCH 03/11] usb: gadget: udc: s3c-hs: simplify phy checks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



transceiver is either NULL or a valid pointer. It is never
left containing -ve error value. Simplify error checks based on this.

Moreover, its OK to call phy APIs with NULL phy pointer.

Cc: Thomas Abraham <thomas.ab@xxxxxxxxxxx>
Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@xxxxxxxxx>
---
 drivers/usb/gadget/udc/s3c-hsudc.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/gadget/udc/s3c-hsudc.c b/drivers/usb/gadget/udc/s3c-hsudc.c
index 85a712a..35e08ba 100644
--- a/drivers/usb/gadget/udc/s3c-hsudc.c
+++ b/drivers/usb/gadget/udc/s3c-hsudc.c
@@ -1161,7 +1161,7 @@ static int s3c_hsudc_start(struct usb_gadget *gadget,
 	}
 
 	/* connect to bus through transceiver */
-	if (!IS_ERR_OR_NULL(hsudc->transceiver)) {
+	if (hsudc->transceiver) {
 		ret = otg_set_peripheral(hsudc->transceiver->otg,
 					&hsudc->gadget);
 		if (ret) {
@@ -1207,7 +1207,7 @@ static int s3c_hsudc_stop(struct usb_gadget *gadget)
 	s3c_hsudc_stop_activity(hsudc);
 	spin_unlock_irqrestore(&hsudc->lock, flags);
 
-	if (!IS_ERR_OR_NULL(hsudc->transceiver))
+	if (hsudc->transceiver)
 		(void) otg_set_peripheral(hsudc->transceiver->otg, NULL);
 
 	disable_irq(hsudc->irq);
@@ -1235,10 +1235,7 @@ static int s3c_hsudc_vbus_draw(struct usb_gadget *gadget, unsigned mA)
 	if (!hsudc)
 		return -ENODEV;
 
-	if (!IS_ERR_OR_NULL(hsudc->transceiver))
-		return usb_phy_set_power(hsudc->transceiver, mA);
-
-	return -EOPNOTSUPP;
+	return usb_phy_set_power(hsudc->transceiver, mA);
 }
 
 static const struct usb_gadget_ops s3c_hsudc_gadget_ops = {
@@ -1267,6 +1264,8 @@ static int s3c_hsudc_probe(struct platform_device *pdev)
 	hsudc->pd = dev_get_platdata(&pdev->dev);
 
 	hsudc->transceiver = usb_get_phy(USB_PHY_TYPE_USB2);
+	if (IS_ERR(hsudc->transceiver))
+		hsudc->transceiver = NULL;
 
 	for (i = 0; i < ARRAY_SIZE(hsudc->supplies); i++)
 		hsudc->supplies[i].supply = s3c_hsudc_supply_names[i];
@@ -1335,7 +1334,7 @@ static int s3c_hsudc_probe(struct platform_device *pdev)
 err_add_udc:
 	clk_disable(hsudc->uclk);
 err_res:
-	if (!IS_ERR_OR_NULL(hsudc->transceiver))
+	if (hsudc->transceiver)
 		usb_put_phy(hsudc->transceiver);
 
 err_supplies:
-- 
2.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux