[PATCH 07/11] usb: gadget: udc: pxa27x: 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.

Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@xxxxxxxxx>
---
 drivers/usb/gadget/udc/pxa27x_udc.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/gadget/udc/pxa27x_udc.c b/drivers/usb/gadget/udc/pxa27x_udc.c
index b51226a..27e4047 100644
--- a/drivers/usb/gadget/udc/pxa27x_udc.c
+++ b/drivers/usb/gadget/udc/pxa27x_udc.c
@@ -1558,7 +1558,7 @@ static int should_enable_udc(struct pxa_udc *udc)
 	int put_on;
 
 	put_on = ((udc->pullup_on) && (udc->driver));
-	put_on &= ((udc->vbus_sensed) || (IS_ERR_OR_NULL(udc->transceiver)));
+	put_on &= ((udc->vbus_sensed) || !udc->transceiver);
 	return put_on;
 }
 
@@ -1579,7 +1579,7 @@ static int should_disable_udc(struct pxa_udc *udc)
 	int put_off;
 
 	put_off = ((!udc->pullup_on) || (!udc->driver));
-	put_off |= ((!udc->vbus_sensed) && (!IS_ERR_OR_NULL(udc->transceiver)));
+	put_off |= ((!udc->vbus_sensed) && udc->transceiver);
 	return put_off;
 }
 
@@ -1650,9 +1650,8 @@ static int pxa_udc_vbus_draw(struct usb_gadget *_gadget, unsigned mA)
 	struct pxa_udc *udc;
 
 	udc = to_gadget_udc(_gadget);
-	if (!IS_ERR_OR_NULL(udc->transceiver))
-		return usb_phy_set_power(udc->transceiver, mA);
-	return -EOPNOTSUPP;
+
+	return usb_phy_set_power(udc->transceiver, mA);
 }
 
 static int pxa27x_udc_start(struct usb_gadget *g,
@@ -1798,7 +1797,7 @@ static int pxa27x_udc_start(struct usb_gadget *g,
 	/* first hook up the driver ... */
 	udc->driver = driver;
 
-	if (!IS_ERR_OR_NULL(udc->transceiver)) {
+	if (udc->transceiver) {
 		retval = otg_set_peripheral(udc->transceiver->otg,
 						&udc->gadget);
 		if (retval) {
@@ -1852,7 +1851,7 @@ static int pxa27x_udc_stop(struct usb_gadget *g)
 
 	udc->driver = NULL;
 
-	if (!IS_ERR_OR_NULL(udc->transceiver))
+	if (udc->transceiver)
 		return otg_set_peripheral(udc->transceiver->otg, NULL);
 	return 0;
 }
@@ -2435,6 +2434,8 @@ static int pxa_udc_probe(struct platform_device *pdev)
 
 	udc->dev = &pdev->dev;
 	udc->transceiver = usb_get_phy(USB_PHY_TYPE_USB2);
+	if (IS_ERR(udc->transceiver))
+		udc->transceiver = NULL;
 
 	if (IS_ERR(udc->gpiod)) {
 		dev_err(&pdev->dev, "Couldn't find or request D+ gpio : %ld\n",
-- 
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