Staging: sep: statically initialize the fops like other drivers

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Wednesday, September 16, 2009 - 9:11 am

Gitweb:     http://git.kernel.org/linus/2f82614ca597ef0aa4ddc26de5f9a176f1a91ee6
Commit:     2f82614ca597ef0aa4ddc26de5f9a176f1a91ee6
Parent:     a2171b6807b01bb942de9524b01df29cf71b46c6
Author:     Alan Cox <alan@linux.intel.com>
AuthorDate: Fri Aug 7 19:23:04 2009 +0100
Committer:  Greg Kroah-Hartman <gregkh@suse.de>
CommitDate: Tue Sep 15 12:02:13 2009 -0700

    Staging: sep: statically initialize the fops like other drivers
    
    This doesn't need to be done at runtime so do it at compile time
    
    Signed-off-by: Alan Cox <alan@linux.intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
 drivers/staging/sep/sep_main_mod.c |   47 ++++++++++++++++++-----------------
 1 files changed, 24 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/sep/sep_main_mod.c b/drivers/staging/sep/sep_main_mod.c
index 0324fdf..197768d 100644
--- a/drivers/staging/sep/sep_main_mod.c
+++ b/drivers/staging/sep/sep_main_mod.c
@@ -71,14 +71,6 @@
 INT_MODULE_PARM(sepDebug, 0x0);
 MODULE_PARM_DESC(sepDebug, "Flag to enable SEP debug messages");
 
-/* major and minor device numbers */
-static dev_t g_sep_device_number;
-
-/* the files operations structure of the driver */
-static struct file_operations g_sep_fops;
-
-/* cdev struct of the driver */
-static struct cdev g_sep_cdev;
 
 /*
   mutex for the access to the internals of the sep driver
@@ -2456,31 +2448,40 @@ static void sep_configure_dma_burst(void)
 
 }
 
+/* major and minor device numbers */
+static dev_t sep_devno;
+
+/* the files operations structure of the driver */
+static struct file_operations sep_file_operations = {
+	.owner = THIS_MODULE,
+	.ioctl = sep_ioctl,
+	.poll = sep_poll,
+	.open = sep_open,
+	.release = sep_release,
+	.mmap = sep_mmap,
+};
+
+
+/* cdev struct of the driver */
+static struct cdev sep_cdev;
+
 /*
   this function registers the driver to the file system
 */
 static int sep_register_driver_to_fs(void)
 {
-	int ret_val = alloc_chrdev_region(&g_sep_device_number, 0, 1, "sep_sec_driver");
+	int ret_val = alloc_chrdev_region(&sep_devno, 0, 1, "sep_sec_driver");
 	if (ret_val) {
 		edbg("sep_driver:major number allocation failed, retval is %d\n", ret_val);
 		goto end_function;
 	}
 
-	/* set the files operations structure */
-	g_sep_fops.owner = THIS_MODULE;
-	g_sep_fops.ioctl = sep_ioctl;
-	g_sep_fops.poll = sep_poll;
-	g_sep_fops.open = sep_open;
-	g_sep_fops.release = sep_release;
-	g_sep_fops.mmap = sep_mmap;
-
 	/* init cdev */
-	cdev_init(&g_sep_cdev, &g_sep_fops);
-	g_sep_cdev.owner = THIS_MODULE;
+	cdev_init(&sep_cdev, &sep_file_operations);
+	sep_cdev.owner = THIS_MODULE;
 
 	/* register the driver with the kernel */
-	ret_val = cdev_add(&g_sep_cdev, g_sep_device_number, 1);
+	ret_val = cdev_add(&sep_cdev, sep_devno, 1);
 
 	if (ret_val) {
 		edbg("sep_driver:cdev_add failed, retval is %d\n", ret_val);
@@ -2492,7 +2493,7 @@ static int sep_register_driver_to_fs(void)
 end_function_unregister_devnum:
 
 	/* unregister dev numbers */
-	unregister_chrdev_region(g_sep_device_number, 1);
+	unregister_chrdev_region(sep_devno, 1);
 
 end_function:
       return ret_val;
@@ -2503,9 +2504,9 @@ end_function:
 */
 static void sep_unregister_driver_from_fs(void)
 {
-	cdev_del(&g_sep_cdev);
+	cdev_del(&sep_cdev);
 	/* unregister dev numbers */
-	unregister_chrdev_region(g_sep_device_number, 1);
+	unregister_chrdev_region(sep_devno, 1);
 }
 
 
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Staging: sep: statically initialize the fops like other dr ..., Linux Kernel Mailing ..., (Wed Sep 16, 9:11 am)