aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/extcon
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/extcon')
-rw-r--r--drivers/extcon/extcon-class.c75
1 files changed, 35 insertions, 40 deletions
diff --git a/drivers/extcon/extcon-class.c b/drivers/extcon/extcon-class.c
index c27d58d6bbd..39d3e4d4847 100644
--- a/drivers/extcon/extcon-class.c
+++ b/drivers/extcon/extcon-class.c
@@ -545,47 +545,9 @@ static int create_extcon_class(void)
545 return 0; 545 return 0;
546} 546}
547 547
548static void extcon_cleanup(struct extcon_dev *edev, bool skip)
549{
550 mutex_lock(&extcon_dev_list_lock);
551 list_del(&edev->entry);
552 mutex_unlock(&extcon_dev_list_lock);
553
554 if (!skip && get_device(edev->dev)) {
555 int index;
556
557 if (edev->mutually_exclusive && edev->max_supported) {
558 for (index = 0; edev->mutually_exclusive[index];
559 index++)
560 kfree(edev->d_attrs_muex[index].attr.name);
561 kfree(edev->d_attrs_muex);
562 kfree(edev->attrs_muex);
563 }
564
565 for (index = 0; index < edev->max_supported; index++)
566 kfree(edev->cables[index].attr_g.name);
567
568 if (edev->max_supported) {
569 kfree(edev->extcon_dev_type.groups);
570 kfree(edev->cables);
571 }
572
573#if defined(CONFIG_ANDROID)
574 if (switch_class)
575 class_compat_remove_link(switch_class, edev->dev, NULL);
576#endif
577 device_unregister(edev->dev);
578 put_device(edev->dev);
579 }
580
581 kfree(edev->dev);
582}
583
584static void extcon_dev_release(struct device *dev) 548static void extcon_dev_release(struct device *dev)
585{ 549{
586 struct extcon_dev *edev = (struct extcon_dev *) dev_get_drvdata(dev); 550 kfree(dev);
587
588 extcon_cleanup(edev, true);
589} 551}
590 552
591static const char *muex_name = "mutually_exclusive"; 553static const char *muex_name = "mutually_exclusive";
@@ -811,7 +773,40 @@ EXPORT_SYMBOL_GPL(extcon_dev_register);
811 */ 773 */
812void extcon_dev_unregister(struct extcon_dev *edev) 774void extcon_dev_unregister(struct extcon_dev *edev)
813{ 775{
814 extcon_cleanup(edev, false); 776 int index;
777
778 mutex_lock(&extcon_dev_list_lock);
779 list_del(&edev->entry);
780 mutex_unlock(&extcon_dev_list_lock);
781
782 if (IS_ERR_OR_NULL(get_device(edev->dev))) {
783 dev_err(edev->dev, "Failed to unregister extcon_dev (%s)\n",
784 dev_name(edev->dev));
785 return;
786 }
787
788 if (edev->mutually_exclusive && edev->max_supported) {
789 for (index = 0; edev->mutually_exclusive[index];
790 index++)
791 kfree(edev->d_attrs_muex[index].attr.name);
792 kfree(edev->d_attrs_muex);
793 kfree(edev->attrs_muex);
794 }
795
796 for (index = 0; index < edev->max_supported; index++)
797 kfree(edev->cables[index].attr_g.name);
798
799 if (edev->max_supported) {
800 kfree(edev->extcon_dev_type.groups);
801 kfree(edev->cables);
802 }
803
804#if defined(CONFIG_ANDROID)
805 if (switch_class)
806 class_compat_remove_link(switch_class, edev->dev, NULL);
807#endif
808 device_unregister(edev->dev);
809 put_device(edev->dev);
815} 810}
816EXPORT_SYMBOL_GPL(extcon_dev_unregister); 811EXPORT_SYMBOL_GPL(extcon_dev_unregister);
817 812