[PATCH 4/4] staging: dgnc: Remove unnecessary dgnc_Major_Control_Registered variable

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

 



The dgnc_Major_Control_Registered variable purpose was to act as a flag
to indicate if the character device has been successfully registered
into the kernel. This flag was later checked in the module cleanup
function to know if the character device needs to be deregistered.

However the {device,class}_destroy and unregister_chrdev functions may
be called with 'invalid' data perfectly fine. This means that this
variable is not needed and can safely be removed which is what this
commit does.

Signed-off-by: Konrad Zapalowicz <bergo.torino@xxxxxxxxx>
---
 drivers/staging/dgnc/dgnc_driver.c | 38 +++++++++++++++-----------------------
 1 file changed, 15 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c b/drivers/staging/dgnc/dgnc_driver.c
index 726b5dd..a9f1a8c 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -96,8 +96,6 @@ int			dgnc_poll_tick = 20;	/* Poll interval - 20 ms */
 /*
  * Static vars.
  */
-static uint		dgnc_Major_Control_Registered = FALSE;
-
 static struct class *dgnc_class;
 
 /*
@@ -197,11 +195,9 @@ static void dgnc_cleanup_module(void)
 
 	dgnc_remove_driver_sysfiles(&dgnc_driver);
 
-	if (dgnc_Major_Control_Registered) {
-		device_destroy(dgnc_class, MKDEV(dgnc_Major, 0));
-		class_destroy(dgnc_class);
-		unregister_chrdev(dgnc_Major, "dgnc");
-	}
+	device_destroy(dgnc_class, MKDEV(dgnc_Major, 0));
+	class_destroy(dgnc_class);
+	unregister_chrdev(dgnc_Major, "dgnc");
 
 	for (i = 0; i < dgnc_NumBoards; ++i) {
 		dgnc_remove_ports_sysfiles(dgnc_Board[i]);
@@ -278,24 +274,20 @@ static int dgnc_start(void)
 	 * Register our base character device into the kernel.
 	 * This allows the download daemon to connect to the downld device
 	 * before any of the boards are init'ed.
+	 *
+	 * Register management/dpa devices
 	 */
-	if (!dgnc_Major_Control_Registered) {
-		/*
-		 * Register management/dpa devices
-		 */
-		rc = register_chrdev(0, "dgnc", &dgnc_BoardFops);
-		if (rc <= 0) {
-			APR(("Can't register dgnc driver device (%d)\n", rc));
-			return -ENXIO;
-		}
-		dgnc_Major = rc;
-
-		dgnc_class = class_create(THIS_MODULE, "dgnc_mgmt");
-		device_create(dgnc_class, NULL,
-			MKDEV(dgnc_Major, 0),
-			NULL, "dgnc_mgmt");
-		dgnc_Major_Control_Registered = TRUE;
+	rc = register_chrdev(0, "dgnc", &dgnc_BoardFops);
+	if (rc <= 0) {
+		APR(("Can't register dgnc driver device (%d)\n", rc));
+		return -ENXIO;
 	}
+	dgnc_Major = rc;
+
+	dgnc_class = class_create(THIS_MODULE, "dgnc_mgmt");
+	device_create(dgnc_class, NULL,
+		MKDEV(dgnc_Major, 0),
+		NULL, "dgnc_mgmt");
 
 	/*
 	 * Init any global tty stuff.
-- 
1.8.1.2

_______________________________________________
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