staging: unisys: remove redundant variable
PATCH v5 1/5 staging: unisys: remove redundant variable
remove the variable "registered", which was used in the cleanup() to detect if the driver has successfully initialized. the cleanup() is called from module_exit, so its obvious that the module has successfully initialized. if the initialization had failed, then we will never be in the cleanup().
---
v5: reordered the patch series
v4: messed up the subject in v3
v3: broke the previous patch in series
drivers/staging/unisys/visorchipset/file.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/staging/unisys/visorchipset/file.c +3 -9
@@ -31,7 +31,6 @@static struct cdev file_cdev;static struct visorchannel **file_controlvm_channel;static dev_t majordev =-1 ;/**< indicates major num for device */ -static BOOL registered = FALSE;static int visorchipset_open (struct inode *inode,struct file *file);static int visorchipset_release (struct inode *inode,struct file *file);
@@ -62,12 +61,10 @@ visorchipset_file_init(dev_t major_dev, struct visorchannel **controlvm_channel)/* dynamic major device number registration required */ if (alloc_chrdev_region (&majordev,0 ,1 ,MYDRVNAME ) <0 )return -1 ; - registered = TRUE; }else {/* static major device number registration required */ if (register_chrdev_region (majordev,1 ,MYDRVNAME ) <0 )return -1 ; - registered = TRUE; } rc =cdev_add (&file_cdev,MKDEV (MAJOR (majordev),0 ),1 );if (rc <0 )
@@ -81,12 +78,9 @@ visorchipset_file_cleanup(void)if (file_cdev.ops !=NULL )cdev_del (&file_cdev); file_cdev.ops =NULL ; -if (registered) { -if (MAJOR (majordev) >=0 ) { -unregister_chrdev_region (majordev,1 ); - majordev =MKDEV (0 ,0 ); - } - registered = FALSE; +if (MAJOR (majordev) >=0 ) { +unregister_chrdev_region (majordev,1 ); + majordev =MKDEV (0 ,0 ); } }
Signature · 1 line
1.8.1.2
PATCH v5 2/5 staging: unisys: use local variable
we are getting dev_t as an argument in the function, so use the local variable instead of the global variable "majordev".
this global variable will be removed in one of the next patch of the series.
---
v5: reordered the patch series
v4: messed up the subject in v3
v3: broke the previous patch in series
drivers/staging/unisys/visorchipset/file.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/staging/unisys/visorchipset/file.c +4 -4
@@ -57,16 +57,16 @@ visorchipset_file_init(dev_t major_dev, struct visorchannel **controlvm_channel) majordev = major_dev;cdev_init (&file_cdev, &visorchipset_fops); file_cdev.owner =THIS_MODULE ; -if (MAJOR (majordev) ==0 ) { +if (MAJOR (major_dev) ==0 ) {/* dynamic major device number registration required */ -if (alloc_chrdev_region (&majordev,0 ,1 ,MYDRVNAME ) <0 ) +if (alloc_chrdev_region (&major_dev,0 ,1 ,MYDRVNAME ) <0 )return -1 ; }else {/* static major device number registration required */ -if (register_chrdev_region (majordev,1 ,MYDRVNAME ) <0 ) +if (register_chrdev_region (major_dev,1 ,MYDRVNAME ) <0 )return -1 ; } - rc =cdev_add (&file_cdev,MKDEV (MAJOR (majordev),0 ),1 ); + rc =cdev_add (&file_cdev,MKDEV (MAJOR (major_dev),0 ),1 );if (rc <0 )return -1 ;return 0 ;
Signature · 1 line
1.8.1.2
PATCH v5 3/5 staging: unisys: use local variable in cleanup
In reply to Sudip Mukherjeethe dev_t was being stored in visorchipset_platform_device.dev.devt while initializing the module. so pass that value as an argument to cleanup() so that it can use this local variable instead of the global variable.
---
v5: reordered the patch series
v4: messed up the subject in v3
v3: broke the previous patch in series
drivers/staging/unisys/visorchipset/file.c | 6 +++--- drivers/staging/unisys/visorchipset/file.h | 2 +- drivers/staging/unisys/visorchipset/visorchipset_main.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-)
drivers/staging/unisys/visorchipset/file.c +3 -3
@@ -73,13 +73,13 @@ visorchipset_file_init(dev_t major_dev, struct visorchannel **controlvm_channel) }void -visorchipset_file_cleanup (void ) +visorchipset_file_cleanup (dev_t major_dev) {if (file_cdev.ops !=NULL )cdev_del (&file_cdev); file_cdev.ops =NULL ; -if (MAJOR (majordev) >=0 ) { -unregister_chrdev_region (majordev,1 ); +if (MAJOR (major_dev) >=0 ) { +unregister_chrdev_region (major_dev,1 ); majordev =MKDEV (0 ,0 ); } }
drivers/staging/unisys/visorchipset/file.h +1 -1
@@ -22,6 +22,6 @@int visorchipset_file_init (dev_t majorDev,struct visorchannel **pControlVm_channel); -void visorchipset_file_cleanup (void ); +void visorchipset_file_cleanup (dev_t major_dev);#endif
drivers/staging/unisys/visorchipset/visorchipset_main.c +1 -1
@@ -2278,7 +2278,7 @@ visorchipset_exit(void)visorchannel_destroy (controlvm_channel); -visorchipset_file_cleanup (); +visorchipset_file_cleanup (visorchipset_platform_device.dev.devt);POSTCODE_LINUX_2 (DRIVER_EXIT_PC ,POSTCODE_SEVERITY_INFO ); }
Signature · 1 line
1.8.1.2
PATCH v5 4/5 staging: unisys: remove global dev_t
In reply to Sudip Mukherjeethe global variable majordev is no longer required, as it is not being used anywhere.
---
v5: reordered the patch series
v4: messed up the subject in v3
v3: broke the previous patch in series
drivers/staging/unisys/visorchipset/file.c | 3 --- 1 file changed, 3 deletions(-)
drivers/staging/unisys/visorchipset/file.c +0 -3
@@ -30,7 +30,6 @@static struct cdev file_cdev;static struct visorchannel **file_controlvm_channel; -static dev_t majordev =-1 ;/**< indicates major num for device */ static int visorchipset_open (struct inode *inode,struct file *file);static int visorchipset_release (struct inode *inode,struct file *file);
@@ -54,7 +53,6 @@ visorchipset_file_init(dev_t major_dev, struct visorchannel **controlvm_channel)int rc =0 ; file_controlvm_channel = controlvm_channel; - majordev = major_dev;cdev_init (&file_cdev, &visorchipset_fops); file_cdev.owner =THIS_MODULE ;if (MAJOR (major_dev) ==0 ) {
@@ -80,7 +78,6 @@ visorchipset_file_cleanup(dev_t major_dev) file_cdev.ops =NULL ;if (MAJOR (major_dev) >=0 ) {unregister_chrdev_region (major_dev,1 ); - majordev =MKDEV (0 ,0 ); } }
Signature · 1 line
1.8.1.2
PATCH v5 5/5 staging: unisys: remove comparison
In reply to Sudip Mukherjeethe comparison is always true as the dev_t has been initialized in the init function and we are sending that initialized dev_t to the cleanup().
---
v5: reordered the patch series
v4: messed up the subject in v3
v3: broke the previous patch in series
drivers/staging/unisys/visorchipset/file.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/unisys/visorchipset/file.c +1 -3
@@ -76,9 +76,7 @@ visorchipset_file_cleanup(dev_t major_dev)if (file_cdev.ops !=NULL )cdev_del (&file_cdev); file_cdev.ops =NULL ; -if (MAJOR (major_dev) >=0 ) { -unregister_chrdev_region (major_dev,1 ); - } +unregister_chrdev_region (major_dev,1 ); } static int
Signature · 1 line
1.8.1.2
Greg Kroah-Hartman
maintainerQuoted 6 lines · Sudip Mukherjee
remove the variable "registered", which was used in the
cleanup()to detect if the driver has successfully initialized. thecleanup()is called frommodule_exit, so its obvious that the module has successfully initialized. if the initialization had failed, then we will never be in thecleanup().
Quoted 6 lines
Signed-off-by Sudip Mukherjee <[email protected]>---
v5: reordered the patch series
v4: messed up the subject in v3
v3: broke the previous patch in series
I need an ack from Benjamin and/or David before I can take these, as they are the maintainers of the driver, and have the ability to test these patches.
I'll just wait to apply them until that happens.
Ben/David?
thanks,
greg k-h
Quoted 7 lines · Greg Kroah-Hartman
I need an ack from Benjamin and/or David before I can take these, as they are the maintainers of the driver, and have the ability to test these patches.
I'll just wait to apply them until that happens.
Ben/David?
I'll test them today. :)
-- Ben
Quoted 5 lines · Ben Romer
Quoted 4 lines · Greg Kroah-Hartman
I need an ack from Benjamin and/or David before I can take these, as they are the maintainers of the driver, and have the ability to test these patches.
Quoted 8 lines
Quoted 3 lines
I'll just wait to apply them until that happens.
Ben/David?
I'll test them today. :)
-- Ben
I've tested them and everything appears to function correctly, so please accept this patch series.
Thanks!
-- Ben