[PATCHv2,2/2] Staging: dgnc: dgnc_driver.c: Add end tag to dgnc_init_module()

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

 



The work flow of dgnc_init_module() is base on if statment. Here is a
nest "if" in the function.

To avoid the nest if statment, make the code easier to understand and
make the codingstyle to be identical with others, add "end" label to
dgnc_init_module() and use goto to control the work flow.

Signed-off-by: Navy Cheng <navych@xxxxxxx>
---
 drivers/staging/dgnc/dgnc_driver.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c b/drivers/staging/dgnc/dgnc_driver.c
index 805dc61..2ef5e12 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -179,7 +179,7 @@ static int __init dgnc_init_module(void)
 	rc = dgnc_start();
 
 	if (rc < 0)
-		return rc;
+		goto end;
 
 	/*
 	 * Find and configure all the cards
@@ -187,20 +187,21 @@ static int __init dgnc_init_module(void)
 	rc = pci_register_driver(&dgnc_driver);
 
 	/*
-	 * If something went wrong in the scan, bail out of driver.
+	 * Dirver regist successfully
 	 */
-	if (rc < 0) {
-		/* Only unregister if it was actually registered. */
-		if (dgnc_NumBoards)
-			pci_unregister_driver(&dgnc_driver);
-		else
-			pr_warn("WARNING: dgnc driver load failed.  No Digi Neo or Classic boards found.\n");
-
-		dgnc_cleanup_module();
-	} else {
+	if (rc == 0) {
 		dgnc_create_driver_sysfiles(&dgnc_driver);
+		goto end;
 	}
 
+	/* Only unregister if it was actually registered. */
+	if (dgnc_NumBoards)
+		pci_unregister_driver(&dgnc_driver);
+	else
+		pr_warn("WARNING: dgnc driver load failed.  No Digi Neo or Classic boards found.\n");
+
+	dgnc_cleanup_module();
+end:
 	return rc;
 }
 
-- 
2.1.4


_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux