char: make misc_deregister a void function
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 30 Jul 2015 22:59:57 +0000 (15:59 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 5 Aug 2015 17:35:49 +0000 (10:35 -0700)
With well over 200+ users of this api, there are a mere 12 users that
actually checked 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 <agk@redhat.com>
Cc: Neil Brown <neilb@suse.com>
Cc: Oleg Drokin <oleg.drokin@intel.com>
Cc: Andreas Dilger <andreas.dilger@intel.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Wim Van Sebroeck <wim@iguana.be>
Cc: Christine Caulfield <ccaulfie@redhat.com>
Cc: David Teigland <teigland@redhat.com>
Cc: Mark Fasheh <mfasheh@suse.com>
Acked-by: Joel Becker <jlbec@evilplan.org>
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Alessandro Zummo <a.zummo@towertech.it>
Acked-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
16 files changed:
drivers/char/misc.c
drivers/md/dm-ioctl.c
drivers/misc/vmw_vmci/vmci_host.c
drivers/rtc/rtc-ds1374.c
drivers/staging/android/ashmem.c
drivers/staging/android/ion/ion_test.c
drivers/staging/lustre/lustre/libcfs/module.c
drivers/vhost/scsi.c
drivers/watchdog/at91rm9200_wdt.c
drivers/watchdog/ks8695_wdt.c
drivers/watchdog/ts72xx_wdt.c
fs/btrfs/super.c
fs/dlm/plock.c
fs/dlm/user.c
fs/ocfs2/stack_user.c
include/linux/miscdevice.h

index c83ef9652bc9c6dd38b6f52f8fc9f08853b995a5..8069b361b8dd1ce2363afff0bf4eb6eef5e5fc1c 100644 (file)
@@ -243,17 +243,15 @@ int misc_register(struct miscdevice * misc)
  *     @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 *misc)
        if (i < DYNAMIC_MINORS && i >= 0)
                clear_bit(i, misc_minors);
        mutex_unlock(&misc_mtx);
-       return 0;
 }
 
 EXPORT_SYMBOL(misc_register);
index 720ceeb7fa9b29118bea02dcb59e82a9f2638ee6..80a43954325966a872cf8ebc95fb23c92c0b8819 100644 (file)
@@ -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();
 }
 
index a721b5d8a9dacdafe85257c64ea7c1f545e6f743..9ec262a526564134a0a61b4fa442549ea0ea2c57 100644 (file)
@@ -1031,14 +1031,9 @@ int __init vmci_host_init(void)
 
 void __exit vmci_host_exit(void)
 {
-       int error;
-
        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();
 
index 167783fa7ac125238e88e4cc1e0ec5b3a114aba9..72c9333752339ce322cc3b47af40865e0a1e1275 100644 (file)
@@ -666,9 +666,8 @@ static int ds1374_remove(struct i2c_client *client)
 #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
 
index c5c037ccf32cc0097f25fe16ddc7848cbd41e547..2c75d90b26c8699ab1117b3e131764ea5a250f25 100644 (file)
@@ -863,14 +863,9 @@ static int __init ashmem_init(void)
 
 static void __exit ashmem_exit(void)
 {
-       int ret;
-
        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);
 
index 7d6e6b6bc894c9336674bbd16455592f1cf396ab..b8dcf5a26cc4ac1250bda0ded24d1ceff3c8cf24 100644 (file)
@@ -269,7 +269,8 @@ static int ion_test_remove(struct platform_device *pdev)
        if (!testdev)
                return -ENODATA;
 
-       return misc_deregister(&testdev->misc);
+       misc_deregister(&testdev->misc);
+       return 0;
 }
 
 static struct platform_device *ion_test_pdev;
index e60b2e9b91944ad1f2d22a7cc4d9d59f872f12f9..e7074006e41bd421bb6c9a05ea26a6d207d9fa23 100644 (file)
@@ -467,9 +467,7 @@ static void exit_libcfs_module(void)
        cfs_crypto_unregister();
        cfs_wi_shutdown();
 
-       rc = misc_deregister(&libcfs_dev);
-       if (rc)
-               CERROR("misc_deregister error %d\n", rc);
+       misc_deregister(&libcfs_dev);
 
        cfs_cpu_fini();
 
index dfcc02c936485199c44d1545bf95b73bfe23ff97..f114a9dbb48f0ea59718da7fe59a02180da07821 100644 (file)
@@ -1573,9 +1573,9 @@ static int __init vhost_scsi_register(void)
        return misc_register(&vhost_scsi_misc);
 }
 
-static int vhost_scsi_deregister(void)
+static void vhost_scsi_deregister(void)
 {
-       return misc_deregister(&vhost_scsi_misc);
+       misc_deregister(&vhost_scsi_misc);
 }
 
 static char *vhost_scsi_dump_proto_id(struct vhost_scsi_tport *tport)
index 41cecb55766c049b600834d6ee021ef45f15332e..9ba1153465ae8a1ef051dca258875940feb77b74 100644 (file)
@@ -269,9 +269,8 @@ static int at91wdt_remove(struct platform_device *pdev)
        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;
 }
index b7ea39b455c86c730f895e1a63ad8d1ee172068f..1e41818a44bc828f88c9fba9829bebcd31819dba 100644 (file)
@@ -254,13 +254,10 @@ static int ks8695wdt_probe(struct platform_device *pdev)
 
 static int ks8695wdt_remove(struct platform_device *pdev)
 {
-       int res;
-
-       res = misc_deregister(&ks8695wdt_miscdev);
-       if (!res)
-               ks8695wdt_miscdev.parent = NULL;
+       misc_deregister(&ks8695wdt_miscdev);
+       ks8695wdt_miscdev.parent = NULL;
 
-       return res;
+       return 0;
 }
 
 static void ks8695wdt_shutdown(struct platform_device *pdev)
index 119beb7f6017ca1cd6e2abd8c18ad701433b36e1..4b541934b6c59e6702345e14ea90360ff67a694e 100644 (file)
@@ -428,7 +428,8 @@ static int ts72xx_wdt_probe(struct platform_device *pdev)
 
 static int ts72xx_wdt_remove(struct platform_device *pdev)
 {
-       return misc_deregister(&ts72xx_wdt_miscdev);
+       misc_deregister(&ts72xx_wdt_miscdev);
+       return 0;
 }
 
 static struct platform_driver ts72xx_wdt_driver = {
index cd7ef34d2dce99987fe87f3040ba20038bb3f041..6bad63379a4ce23dc730605035f098db1d03ef00 100644 (file)
@@ -2163,8 +2163,7 @@ static int btrfs_interface_init(void)
 
 static void btrfs_interface_exit(void)
 {
-       if (misc_deregister(&btrfs_misc) < 0)
-               printk(KERN_INFO "BTRFS: misc_deregister failed for control device\n");
+       misc_deregister(&btrfs_misc);
 }
 
 static void btrfs_print_info(void)
index e0ab3a93eeff01b42ec4ffaeb48160bcd0fc9ad6..5532f097f6dac5fddbfde8030ba981fe417b6877 100644 (file)
@@ -509,7 +509,6 @@ int dlm_plock_init(void)
 
 void dlm_plock_exit(void)
 {
-       if (misc_deregister(&plock_dev_misc) < 0)
-               log_print("dlm_plock_exit: misc_deregister failed");
+       misc_deregister(&plock_dev_misc);
 }
 
index fb85f32e9eca66f238d3cfb97a82781be626d0b2..75ecc0d3bc85ad1bfa7096bff0a498d5de56bb06 100644 (file)
@@ -362,18 +362,15 @@ fail:
 
 int dlm_device_deregister(struct dlm_ls *ls)
 {
-       int error;
-
        /* The device is not registered.  This happens when the lockspace
           was never used from userspace, or when device_create_lockspace()
           calls dlm_release_lockspace() after the register fails. */
        if (!ls->ls_device.name)
                return 0;
 
-       error = misc_deregister(&ls->ls_device);
-       if (!error)
-               kfree(ls->ls_device.name);
-       return error;
+       misc_deregister(&ls->ls_device);
+       kfree(ls->ls_device.name);
+       return 0;
 }
 
 static int device_user_purge(struct dlm_user_proc *proc,
index 2768eb1da2b865f4afba3c35087da7c477c87309..ced70c8139f7391346e7c7eaffc8c8a2fec6303b 100644 (file)
@@ -655,14 +655,7 @@ static int ocfs2_control_init(void)
 
 static void ocfs2_control_exit(void)
 {
-       int rc;
-
-       rc = misc_deregister(&ocfs2_control_device);
-       if (rc)
-               printk(KERN_ERR
-                      "ocfs2: Unable to deregister ocfs2_control device "
-                      "(errno %d)\n",
-                      -rc);
+       misc_deregister(&ocfs2_control_device);
 }
 
 static void fsdlm_lock_ast_wrapper(void *astarg)
index 819077c326901384ec3bdb8d16217a1363ab8e28..81f6e427ba6bbb9b65f52a5d5937c39aee0c0125 100644 (file)
@@ -67,7 +67,7 @@ struct miscdevice  {
 };
 
 extern int misc_register(struct miscdevice *misc);
-extern int misc_deregister(struct miscdevice *misc);
+extern void misc_deregister(struct miscdevice *misc);
 
 #define MODULE_ALIAS_MISCDEV(minor)                            \
        MODULE_ALIAS("char-major-" __stringify(MISC_MAJOR)      \