[PATCH] char: make misc_deregister a void function

2015-07-30 Thread Greg Kroah-Hartman
From: Greg Kroah-Hartman 

With well over 200+ users of this api, there are a mere 12 users that
actually cheked the return value of this function.  And all of them
really didn't do anything with that information as the system or module
was shutting down no matter what.

So stop pretending like it matters, and just return void from
misc_deregister().  If something goes wrong in the call, you will get a
WARNING splat in the syslog so you know how to fix up your driver.
Other than that, there's nothing that can go wrong.

Cc: Alasdair Kergon 
Cc: Mike Snitzer 
Cc: Neil Brown 
Cc: Alessandro Zummo 
Cc: Alexandre Belloni 
Cc: Oleg Drokin 
Cc: Andreas Dilger 
Cc: "Michael S. Tsirkin" 
Cc: Wim Van Sebroeck 
Cc: Christine Caulfield 
Cc: David Teigland 
Cc: Mark Fasheh 
Cc: Joel Becker 
Signed-off-by: Greg Kroah-Hartman 

---

If the different subsystem maintainers want to give me an ack for this,
I'd appreciate it.  I'd like to just take the single patch in through
the char-misc tree in one piece.


 drivers/char/misc.c   |9 +++--
 drivers/md/dm-ioctl.c |4 +---
 drivers/misc/vmw_vmci/vmci_host.c |5 +
 drivers/rtc/rtc-ds1374.c  |5 ++---
 drivers/staging/android/ashmem.c  |5 +
 drivers/staging/android/ion/ion_test.c|3 ++-
 drivers/staging/lustre/lustre/libcfs/module.c |4 +---
 drivers/vhost/scsi.c  |4 ++--
 drivers/watchdog/at91rm9200_wdt.c |5 ++---
 drivers/watchdog/ks8695_wdt.c |9 +++--
 drivers/watchdog/ts72xx_wdt.c |3 ++-
 fs/dlm/user.c |9 +++--
 fs/ocfs2/stack_user.c |9 +
 include/linux/miscdevice.h|2 +-
 14 files changed, 25 insertions(+), 51 deletions(-)


--- a/drivers/char/misc.c
+++ b/drivers/char/misc.c
@@ -243,17 +243,15 @@ int misc_register(struct miscdevice * mi
  * @misc: device to unregister
  *
  * Unregister a miscellaneous device that was previously
- * successfully registered with misc_register(). Success
- * is indicated by a zero return, a negative errno code
- * indicates an error.
+ * successfully registered with misc_register().
  */
 
-int misc_deregister(struct miscdevice *misc)
+void misc_deregister(struct miscdevice *misc)
 {
int i = DYNAMIC_MINORS - misc->minor - 1;
 
if (WARN_ON(list_empty(&misc->list)))
-   return -EINVAL;
+   return;
 
mutex_lock(&misc_mtx);
list_del(&misc->list);
@@ -261,7 +259,6 @@ int misc_deregister(struct miscdevice *m
if (i < DYNAMIC_MINORS && i >= 0)
clear_bit(i, misc_minors);
mutex_unlock(&misc_mtx);
-   return 0;
 }
 
 EXPORT_SYMBOL(misc_register);
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -1919,9 +1919,7 @@ int __init dm_interface_init(void)
 
 void dm_interface_exit(void)
 {
-   if (misc_deregister(&_dm_misc) < 0)
-   DMERR("misc_deregister failed for control device");
-
+   misc_deregister(&_dm_misc);
dm_hash_exit();
 }
 
--- a/drivers/misc/vmw_vmci/vmci_host.c
+++ b/drivers/misc/vmw_vmci/vmci_host.c
@@ -1035,10 +1035,7 @@ void __exit vmci_host_exit(void)
 
vmci_host_device_initialized = false;
 
-   error = misc_deregister(&vmci_host_miscdev);
-   if (error)
-   pr_warn("Error unregistering character device: %d\n", error);
-
+   misc_deregister(&vmci_host_miscdev);
vmci_ctx_destroy(host_context);
vmci_qp_broker_exit();
 
--- a/drivers/rtc/rtc-ds1374.c
+++ b/drivers/rtc/rtc-ds1374.c
@@ -666,9 +666,8 @@ static int ds1374_remove(struct i2c_clie
 #ifdef CONFIG_RTC_DRV_DS1374_WDT
int res;
 
-   res = misc_deregister(&ds1374_miscdev);
-   if (!res)
-   ds1374_miscdev.parent = NULL;
+   misc_deregister(&ds1374_miscdev);
+   ds1374_miscdev.parent = NULL;
unregister_reboot_notifier(&ds1374_wdt_notifier);
 #endif
 
--- a/drivers/staging/android/ashmem.c
+++ b/drivers/staging/android/ashmem.c
@@ -867,10 +867,7 @@ static void __exit ashmem_exit(void)
 
unregister_shrinker(&ashmem_shrinker);
 
-   ret = misc_deregister(&ashmem_misc);
-   if (unlikely(ret))
-   pr_err("failed to unregister misc device!\n");
-
+   misc_deregister(&ashmem_misc);
kmem_cache_destroy(ashmem_range_cachep);
kmem_cache_destroy(ashmem_area_cachep);
 
--- a/drivers/staging/android/ion/ion_test.c
+++ b/drivers/staging/android/ion/ion_test.c
@@ -269,7 +269,8 @@ static int ion_test_remove(struct platfo
if (!testdev)
return -ENODATA;
 
-   return misc_deregister(&testdev->misc);
+   misc_deregister(&testdev->misc);
+   return 0;
 }
 
 static struct platform_device *ion_test_pdev;
--- a/drivers/staging/lustre/lustre/libcfs/module.c
+++ b/drivers/

Re: [PATCH] char: make misc_deregister a void function

2015-07-31 Thread Alessandro Zummo
On Thu, 30 Jul 2015 15:59:57 -0700
Greg Kroah-Hartman  wrote:

> If the different subsystem maintainers want to give me an ack for this,
> I'd appreciate it.  I'd like to just take the single patch in through
> the char-misc tree in one piece.

 RTC

 Acked-by: Alessandro Zummo 

-- 

 Best regards,

 Alessandro Zummo - CEO,
  Tower Technologies - Torino, Italy

  http://www.towertech.it

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] char: make misc_deregister a void function

2015-07-31 Thread Alexandre Belloni
Hi,

On 30/07/2015 at 15:59:57 -0700, Greg Kroah-Hartman wrote :
> From: Greg Kroah-Hartman 
> 
> With well over 200+ users of this api, there are a mere 12 users that
> actually cheked the return value of this function.  And all of them
 ^
small typo here

> really didn't do anything with that information as the system or module
> was shutting down no matter what.
> 
> So stop pretending like it matters, and just return void from
> misc_deregister().  If something goes wrong in the call, you will get a
> WARNING splat in the syslog so you know how to fix up your driver.
> Other than that, there's nothing that can go wrong.
> 
> Cc: Alasdair Kergon 
> Cc: Mike Snitzer 
> Cc: Neil Brown 
> Cc: Alessandro Zummo 
> Cc: Alexandre Belloni 
> Cc: Oleg Drokin 
> Cc: Andreas Dilger 
> Cc: "Michael S. Tsirkin" 
> Cc: Wim Van Sebroeck 
> Cc: Christine Caulfield 
> Cc: David Teigland 
> Cc: Mark Fasheh 
> Cc: Joel Becker 
> Signed-off-by: Greg Kroah-Hartman 

For rtc and at91rm9200_wdt.c:
Acked-by: Alexandre Belloni 

[...]

> --- a/drivers/watchdog/at91rm9200_wdt.c
> +++ b/drivers/watchdog/at91rm9200_wdt.c
> @@ -269,9 +269,8 @@ static int at91wdt_remove(struct platfor
>   if (res)
>   dev_warn(dev, "failed to unregister restart handler\n");
>  
> - res = misc_deregister(&at91wdt_miscdev);
> - if (!res)
> - at91wdt_miscdev.parent = NULL;
> + misc_deregister(&at91wdt_miscdev);
> + at91wdt_miscdev.parent = NULL;
>  
>   return res;

That one was actually doing something with the return value ;)


-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] char: make misc_deregister a void function

2015-07-31 Thread Joel Becker
Acked-by: Joel Becker 

On Thu, Jul 30, 2015 at 03:59:57PM -0700, Greg Kroah-Hartman wrote:
> From: Greg Kroah-Hartman 
> 
> With well over 200+ users of this api, there are a mere 12 users that
> actually cheked the return value of this function.  And all of them
> really didn't do anything with that information as the system or module
> was shutting down no matter what.
> 
> So stop pretending like it matters, and just return void from
> misc_deregister().  If something goes wrong in the call, you will get a
> WARNING splat in the syslog so you know how to fix up your driver.
> Other than that, there's nothing that can go wrong.
> 
> Cc: Alasdair Kergon 
> Cc: Mike Snitzer 
> Cc: Neil Brown 
> Cc: Alessandro Zummo 
> Cc: Alexandre Belloni 
> Cc: Oleg Drokin 
> Cc: Andreas Dilger 
> Cc: "Michael S. Tsirkin" 
> Cc: Wim Van Sebroeck 
> Cc: Christine Caulfield 
> Cc: David Teigland 
> Cc: Mark Fasheh 
> Cc: Joel Becker 
> Signed-off-by: Greg Kroah-Hartman 
> 
> ---
> 
> If the different subsystem maintainers want to give me an ack for this,
> I'd appreciate it.  I'd like to just take the single patch in through
> the char-misc tree in one piece.
> 
> 
>  drivers/char/misc.c   |9 +++--
>  drivers/md/dm-ioctl.c |4 +---
>  drivers/misc/vmw_vmci/vmci_host.c |5 +
>  drivers/rtc/rtc-ds1374.c  |5 ++---
>  drivers/staging/android/ashmem.c  |5 +
>  drivers/staging/android/ion/ion_test.c|3 ++-
>  drivers/staging/lustre/lustre/libcfs/module.c |4 +---
>  drivers/vhost/scsi.c  |4 ++--
>  drivers/watchdog/at91rm9200_wdt.c |5 ++---
>  drivers/watchdog/ks8695_wdt.c |9 +++--
>  drivers/watchdog/ts72xx_wdt.c |3 ++-
>  fs/dlm/user.c |9 +++--
>  fs/ocfs2/stack_user.c |9 +
>  include/linux/miscdevice.h|2 +-
>  14 files changed, 25 insertions(+), 51 deletions(-)
> 
> 
> --- a/drivers/char/misc.c
> +++ b/drivers/char/misc.c
> @@ -243,17 +243,15 @@ int misc_register(struct miscdevice * mi
>   *   @misc: device to unregister
>   *
>   *   Unregister a miscellaneous device that was previously
> - *   successfully registered with misc_register(). Success
> - *   is indicated by a zero return, a negative errno code
> - *   indicates an error.
> + *   successfully registered with misc_register().
>   */
>  
> -int misc_deregister(struct miscdevice *misc)
> +void misc_deregister(struct miscdevice *misc)
>  {
>   int i = DYNAMIC_MINORS - misc->minor - 1;
>  
>   if (WARN_ON(list_empty(&misc->list)))
> - return -EINVAL;
> + return;
>  
>   mutex_lock(&misc_mtx);
>   list_del(&misc->list);
> @@ -261,7 +259,6 @@ int misc_deregister(struct miscdevice *m
>   if (i < DYNAMIC_MINORS && i >= 0)
>   clear_bit(i, misc_minors);
>   mutex_unlock(&misc_mtx);
> - return 0;
>  }
>  
>  EXPORT_SYMBOL(misc_register);
> --- a/drivers/md/dm-ioctl.c
> +++ b/drivers/md/dm-ioctl.c
> @@ -1919,9 +1919,7 @@ int __init dm_interface_init(void)
>  
>  void dm_interface_exit(void)
>  {
> - if (misc_deregister(&_dm_misc) < 0)
> - DMERR("misc_deregister failed for control device");
> -
> + misc_deregister(&_dm_misc);
>   dm_hash_exit();
>  }
>  
> --- a/drivers/misc/vmw_vmci/vmci_host.c
> +++ b/drivers/misc/vmw_vmci/vmci_host.c
> @@ -1035,10 +1035,7 @@ void __exit vmci_host_exit(void)
>  
>   vmci_host_device_initialized = false;
>  
> - error = misc_deregister(&vmci_host_miscdev);
> - if (error)
> - pr_warn("Error unregistering character device: %d\n", error);
> -
> + misc_deregister(&vmci_host_miscdev);
>   vmci_ctx_destroy(host_context);
>   vmci_qp_broker_exit();
>  
> --- a/drivers/rtc/rtc-ds1374.c
> +++ b/drivers/rtc/rtc-ds1374.c
> @@ -666,9 +666,8 @@ static int ds1374_remove(struct i2c_clie
>  #ifdef CONFIG_RTC_DRV_DS1374_WDT
>   int res;
>  
> - res = misc_deregister(&ds1374_miscdev);
> - if (!res)
> - ds1374_miscdev.parent = NULL;
> + misc_deregister(&ds1374_miscdev);
> + ds1374_miscdev.parent = NULL;
>   unregister_reboot_notifier(&ds1374_wdt_notifier);
>  #endif
>  
> --- a/drivers/staging/android/ashmem.c
> +++ b/drivers/staging/android/ashmem.c
> @@ -867,10 +867,7 @@ static void __exit ashmem_exit(void)
>  
>   unregister_shrinker(&ashmem_shrinker);
>  
> - ret = misc_deregister(&ashmem_misc);
> - if (unlikely(ret))
> - pr_err("failed to unregister misc device!\n");
> -
> + misc_deregister(&ashmem_misc);
>   kmem_cache_destroy(ashmem_range_cachep);
>   kmem_cache_destroy(ashmem_area_cachep);
>  
> --- a/drivers/staging/android/ion/ion_test.c
> +++ b/drivers/staging/android/ion/ion_test.c
> @@ -269,7 +269,8 @@ static int ion_test_remove(struct