[PATCH 05/11] usb: gadget: udc: fsl: 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: Peter Chen <peter.chen@xxxxxxxxxxxxx>
Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@xxxxxxxxx>
---
 drivers/usb/gadget/udc/fsl_udc_core.c | 26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)

diff --git a/drivers/usb/gadget/udc/fsl_udc_core.c b/drivers/usb/gadget/udc/fsl_udc_core.c
index 55fcb93..c08b977 100644
--- a/drivers/usb/gadget/udc/fsl_udc_core.c
+++ b/drivers/usb/gadget/udc/fsl_udc_core.c
@@ -1206,9 +1206,8 @@ static int fsl_vbus_draw(struct usb_gadget *gadget, unsigned mA)
 	struct fsl_udc *udc;
 
 	udc = container_of(gadget, struct fsl_udc, gadget);
-	if (!IS_ERR_OR_NULL(udc->transceiver))
-		return usb_phy_set_power(udc->transceiver, mA);
-	return -ENOTSUPP;
+
+	return usb_phy_set_power(udc->transceiver, mA);
 }
 
 /* Change Data+ pullup status
@@ -1950,21 +1949,18 @@ static int fsl_udc_start(struct usb_gadget *g,
 	spin_unlock_irqrestore(&udc_controller->lock, flags);
 	g->is_selfpowered = 1;
 
-	if (!IS_ERR_OR_NULL(udc_controller->transceiver)) {
+	if (udc_controller->transceiver) {
 		/* Suspend the controller until OTG enable it */
 		udc_controller->stopped = 1;
 		printk(KERN_INFO "Suspend udc for OTG auto detect\n");
 
 		/* connect to bus through transceiver */
-		if (!IS_ERR_OR_NULL(udc_controller->transceiver)) {
-			retval = otg_set_peripheral(
-					udc_controller->transceiver->otg,
+		retval = otg_set_peripheral(udc_controller->transceiver->otg,
 						    &udc_controller->gadget);
-			if (retval < 0) {
-				ERR("can't bind to transceiver\n");
-				udc_controller->driver = NULL;
-				return retval;
-			}
+		if (retval < 0) {
+			ERR("can't bind to transceiver\n");
+			udc_controller->driver = NULL;
+			return retval;
 		}
 	} else {
 		/* Enable DR IRQ reg and set USBCMD reg Run bit */
@@ -1983,7 +1979,7 @@ static int fsl_udc_stop(struct usb_gadget *g)
 	struct fsl_ep *loop_ep;
 	unsigned long flags;
 
-	if (!IS_ERR_OR_NULL(udc_controller->transceiver))
+	if (udc_controller->transceiver)
 		otg_set_peripheral(udc_controller->transceiver->otg, NULL);
 
 	/* stop DR, disable intr */
@@ -2438,7 +2434,7 @@ static int fsl_udc_probe(struct platform_device *pdev)
 		goto err_free_irq;
 	}
 
-	if (IS_ERR_OR_NULL(udc_controller->transceiver)) {
+	if (udc_controller->transceiver) {
 		/* initialize usb hw reg except for regs for EP,
 		 * leave usbintr reg untouched */
 		dr_controller_setup(udc_controller);
@@ -2460,7 +2456,7 @@ static int fsl_udc_probe(struct platform_device *pdev)
 	dev_set_name(&udc_controller->gadget.dev, "gadget");
 	udc_controller->gadget.dev.of_node = pdev->dev.of_node;
 
-	if (!IS_ERR_OR_NULL(udc_controller->transceiver))
+	if (udc_controller->transceiver)
 		udc_controller->gadget.is_otg = 1;
 
 	/* setup QH and epctrl for ep0 */
-- 
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