[PATCH 1/2] s3c-hsudc: reorder error handling in start function

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

 



This removes duplicate code and makes room for more error handling steps.

Signed-off-by: Heiko Stuebner <heiko@xxxxxxxxx>
---
 drivers/usb/gadget/s3c-hsudc.c |   22 ++++++++++------------
 1 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/gadget/s3c-hsudc.c b/drivers/usb/gadget/s3c-hsudc.c
index 787ac5b..74be824 100644
--- a/drivers/usb/gadget/s3c-hsudc.c
+++ b/drivers/usb/gadget/s3c-hsudc.c
@@ -1165,11 +1165,7 @@ static int s3c_hsudc_start(struct usb_gadget_driver *driver,
 	ret = bind(&hsudc->gadget);
 	if (ret) {
 		dev_err(hsudc->dev, "%s: bind failed\n", hsudc->gadget.name);
-		device_del(&hsudc->gadget.dev);
-
-		hsudc->driver = NULL;
-		hsudc->gadget.dev.driver = NULL;
-		return ret;
+		goto err_bind;
 	}
 
 	/* connect to bus through transceiver */
@@ -1178,13 +1174,7 @@ static int s3c_hsudc_start(struct usb_gadget_driver *driver,
 		if (ret) {
 			dev_err(hsudc->dev, "%s: can't bind to transceiver\n",
 					hsudc->gadget.name);
-			driver->unbind(&hsudc->gadget);
-
-			device_del(&hsudc->gadget.dev);
-
-			hsudc->driver = NULL;
-			hsudc->gadget.dev.driver = NULL;
-			return ret;
+			goto err_otg;
 		}
 	}
 
@@ -1197,6 +1187,14 @@ static int s3c_hsudc_start(struct usb_gadget_driver *driver,
 		hsudc->pd->gpio_init();
 
 	return 0;
+err_otg:
+	driver->unbind(&hsudc->gadget);
+err_bind:
+	device_del(&hsudc->gadget.dev);
+
+	hsudc->driver = NULL;
+	hsudc->gadget.dev.driver = NULL;
+	return ret;
 }
 
 static int s3c_hsudc_stop(struct usb_gadget_driver *driver)
-- 
1.7.2.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