Skip to content

Commit

Permalink
char: make misc_deregister a void function
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Greg Kroah-Hartman committed Aug 5, 2015
1 parent 379e4f7 commit f368ed6
Show file tree
Hide file tree
Showing 16 changed files with 27 additions and 59 deletions.
9 changes: 3 additions & 6 deletions drivers/char/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,25 +243,22 @@ 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);
device_destroy(misc_class, MKDEV(MISC_MAJOR, misc->minor));
if (i < DYNAMIC_MINORS && i >= 0)
clear_bit(i, misc_minors);
mutex_unlock(&misc_mtx);
return 0;
}

EXPORT_SYMBOL(misc_register);
Expand Down
4 changes: 1 addition & 3 deletions drivers/md/dm-ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
7 changes: 1 addition & 6 deletions drivers/misc/vmw_vmci/vmci_host.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
5 changes: 2 additions & 3 deletions drivers/rtc/rtc-ds1374.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 1 addition & 6 deletions drivers/staging/android/ashmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
3 changes: 2 additions & 1 deletion drivers/staging/android/ion/ion_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions drivers/staging/lustre/lustre/libcfs/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
4 changes: 2 additions & 2 deletions drivers/vhost/scsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions drivers/watchdog/at91rm9200_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
9 changes: 3 additions & 6 deletions drivers/watchdog/ks8695_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion drivers/watchdog/ts72xx_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
3 changes: 1 addition & 2 deletions fs/btrfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions fs/dlm/plock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

9 changes: 3 additions & 6 deletions fs/dlm/user.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,18 +362,15 @@ static int dlm_device_register(struct dlm_ls *ls, char *name)

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,
Expand Down
9 changes: 1 addition & 8 deletions fs/ocfs2/stack_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion include/linux/miscdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down

0 comments on commit f368ed6

Please sign in to comment.