From 0e8c506758fe9fea8ee6d9d74708d0df1fd56dff Mon Sep 17 00:00:00 2001 From: Konstantin Makariev Date: Thu, 1 Feb 2018 13:58:29 -0600 Subject: [PATCH] input: ldc2114: fix rmmod DLKM was not properly unloading in response to rmmod command. Change-Id: I23b958727cd245edccdf477adbb43183e927abff Signed-off-by: Konstantin Makariev Reviewed-on: https://gerrit.mot.com/1128638 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Konstantin Makariev Submit-Approved: Jira Key --- drivers/input/misc/ldc2114-cdev.c | 3 ++- drivers/input/misc/ldc2114.c | 23 ++++++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/drivers/input/misc/ldc2114-cdev.c b/drivers/input/misc/ldc2114-cdev.c index 453c97a4196f..346b37f7e0a0 100644 --- a/drivers/input/misc/ldc2114-cdev.c +++ b/drivers/input/misc/ldc2114-cdev.c @@ -314,8 +314,9 @@ void ldc2114_cdev_remove(void) if (!cxt) return; - unregister_chrdev(cxt->major, DRVNAME); + device_destroy(cxt->class, MKDEV(cxt->major, 0)); class_destroy(cxt->class); + unregister_chrdev(cxt->major, DRVNAME); platform_device_unregister(cxt->pdev); kfree(cxt); } diff --git a/drivers/input/misc/ldc2114.c b/drivers/input/misc/ldc2114.c index 07a480738f03..7bda71e02407 100644 --- a/drivers/input/misc/ldc2114.c +++ b/drivers/input/misc/ldc2114.c @@ -963,8 +963,9 @@ static irqreturn_t ldc2114_irq(int irq, void *data) #ifdef CONFIG_OF static const struct of_device_id ldc2114_of_match[] = { { .compatible = "ti,ldc2114", }, - { /* sentinel */ } + {}, }; + MODULE_DEVICE_TABLE(of, ldc2114_of_match); static struct ldc2114_config *read_config_data(struct ldc2114_data *ldc, @@ -1385,25 +1386,41 @@ static int ldc2114_remove(struct i2c_client *client) sysfs_remove_group(&client->dev.kobj, &ldc2114_attr_group); + unregister_reboot_notifier(&ldc->reboot_nb); + return 0; } static const struct i2c_device_id ldc2114_ids[] = { { "ldc2114", 0 }, - { /* sentinel */ } + {}, }; MODULE_DEVICE_TABLE(i2c, ldc2114_ids); static struct i2c_driver ldc2114_i2c_driver = { .driver = { .name = LDC2114_DRIVER_NAME, +#ifdef CONFIG_OF .of_match_table = of_match_ptr(ldc2114_of_match), +#endif }, .probe = ldc2114_probe, .remove = ldc2114_remove, .id_table = ldc2114_ids, }; -module_i2c_driver(ldc2114_i2c_driver); + +static int __init ldc2114_init(void) +{ + return i2c_add_driver(&ldc2114_i2c_driver); +} + +static void __exit ldc2114_exit(void) +{ + i2c_del_driver(&ldc2114_i2c_driver); +} + +module_init(ldc2114_init); +module_exit(ldc2114_exit); MODULE_AUTHOR("Andrew F. Davis "); MODULE_DESCRIPTION("TI LDC2114 Metal Touch Inductance-to-Digital Converter");