aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/extcon
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/extcon')
-rw-r--r--drivers/extcon/extcon-arizona.c1
-rw-r--r--drivers/extcon/extcon-class.c2
-rw-r--r--drivers/extcon/extcon-max77693.c36
-rw-r--r--drivers/extcon/extcon-max8997.c28
4 files changed, 30 insertions, 37 deletions
diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
index f10f05d4ee9c..414aed50b1bc 100644
--- a/drivers/extcon/extcon-arizona.c
+++ b/drivers/extcon/extcon-arizona.c
@@ -166,6 +166,7 @@ static irqreturn_t arizona_micdet(int irq, void *data)
166 ret = regmap_read(arizona->regmap, ARIZONA_MIC_DETECT_3, &val); 166 ret = regmap_read(arizona->regmap, ARIZONA_MIC_DETECT_3, &val);
167 if (ret != 0) { 167 if (ret != 0) {
168 dev_err(arizona->dev, "Failed to read MICDET: %d\n", ret); 168 dev_err(arizona->dev, "Failed to read MICDET: %d\n", ret);
169 mutex_unlock(&info->lock);
169 return IRQ_NONE; 170 return IRQ_NONE;
170 } 171 }
171 172
diff --git a/drivers/extcon/extcon-class.c b/drivers/extcon/extcon-class.c
index d398821097f3..60adc04b0561 100644
--- a/drivers/extcon/extcon-class.c
+++ b/drivers/extcon/extcon-class.c
@@ -472,7 +472,7 @@ int extcon_register_interest(struct extcon_specific_cable_nb *obj,
472 472
473 obj->cable_index = extcon_find_cable_index(obj->edev, cable_name); 473 obj->cable_index = extcon_find_cable_index(obj->edev, cable_name);
474 if (obj->cable_index < 0) 474 if (obj->cable_index < 0)
475 return -ENODEV; 475 return obj->cable_index;
476 476
477 obj->user_nb = nb; 477 obj->user_nb = nb;
478 478
diff --git a/drivers/extcon/extcon-max77693.c b/drivers/extcon/extcon-max77693.c
index b656dfa401a6..8c17b65eb74d 100644
--- a/drivers/extcon/extcon-max77693.c
+++ b/drivers/extcon/extcon-max77693.c
@@ -657,17 +657,17 @@ static int max77693_muic_probe(struct platform_device *pdev)
657 int ret, i; 657 int ret, i;
658 u8 id; 658 u8 id;
659 659
660 info = kzalloc(sizeof(struct max77693_muic_info), GFP_KERNEL); 660 info = devm_kzalloc(&pdev->dev, sizeof(struct max77693_muic_info),
661 GFP_KERNEL);
661 if (!info) { 662 if (!info) {
662 dev_err(&pdev->dev, "failed to allocate memory\n"); 663 dev_err(&pdev->dev, "failed to allocate memory\n");
663 ret = -ENOMEM; 664 return -ENOMEM;
664 goto err_kfree;
665 } 665 }
666 info->dev = &pdev->dev; 666 info->dev = &pdev->dev;
667 info->max77693 = max77693; 667 info->max77693 = max77693;
668 if (info->max77693->regmap_muic) 668 if (info->max77693->regmap_muic) {
669 dev_dbg(&pdev->dev, "allocate register map\n"); 669 dev_dbg(&pdev->dev, "allocate register map\n");
670 else { 670 } else {
671 info->max77693->regmap_muic = devm_regmap_init_i2c( 671 info->max77693->regmap_muic = devm_regmap_init_i2c(
672 info->max77693->muic, 672 info->max77693->muic,
673 &max77693_muic_regmap_config); 673 &max77693_muic_regmap_config);
@@ -675,7 +675,7 @@ static int max77693_muic_probe(struct platform_device *pdev)
675 ret = PTR_ERR(info->max77693->regmap_muic); 675 ret = PTR_ERR(info->max77693->regmap_muic);
676 dev_err(max77693->dev, 676 dev_err(max77693->dev,
677 "failed to allocate register map: %d\n", ret); 677 "failed to allocate register map: %d\n", ret);
678 goto err_regmap; 678 return ret;
679 } 679 }
680 } 680 }
681 platform_set_drvdata(pdev, info); 681 platform_set_drvdata(pdev, info);
@@ -686,11 +686,13 @@ static int max77693_muic_probe(struct platform_device *pdev)
686 /* Support irq domain for MAX77693 MUIC device */ 686 /* Support irq domain for MAX77693 MUIC device */
687 for (i = 0; i < ARRAY_SIZE(muic_irqs); i++) { 687 for (i = 0; i < ARRAY_SIZE(muic_irqs); i++) {
688 struct max77693_muic_irq *muic_irq = &muic_irqs[i]; 688 struct max77693_muic_irq *muic_irq = &muic_irqs[i];
689 int virq = 0; 689 unsigned int virq = 0;
690 690
691 virq = irq_create_mapping(max77693->irq_domain, muic_irq->irq); 691 virq = irq_create_mapping(max77693->irq_domain, muic_irq->irq);
692 if (!virq) 692 if (!virq) {
693 ret = -EINVAL;
693 goto err_irq; 694 goto err_irq;
695 }
694 muic_irq->virq = virq; 696 muic_irq->virq = virq;
695 697
696 ret = request_threaded_irq(virq, NULL, 698 ret = request_threaded_irq(virq, NULL,
@@ -702,14 +704,13 @@ static int max77693_muic_probe(struct platform_device *pdev)
702 " error :%d)\n", 704 " error :%d)\n",
703 muic_irq->irq, ret); 705 muic_irq->irq, ret);
704 706
705 for (i = i - 1; i >= 0; i--)
706 free_irq(muic_irq->virq, info);
707 goto err_irq; 707 goto err_irq;
708 } 708 }
709 } 709 }
710 710
711 /* Initialize extcon device */ 711 /* Initialize extcon device */
712 info->edev = kzalloc(sizeof(struct extcon_dev), GFP_KERNEL); 712 info->edev = devm_kzalloc(&pdev->dev, sizeof(struct extcon_dev),
713 GFP_KERNEL);
713 if (!info->edev) { 714 if (!info->edev) {
714 dev_err(&pdev->dev, "failed to allocate memory for extcon\n"); 715 dev_err(&pdev->dev, "failed to allocate memory for extcon\n");
715 ret = -ENOMEM; 716 ret = -ENOMEM;
@@ -720,7 +721,7 @@ static int max77693_muic_probe(struct platform_device *pdev)
720 ret = extcon_dev_register(info->edev, NULL); 721 ret = extcon_dev_register(info->edev, NULL);
721 if (ret) { 722 if (ret) {
722 dev_err(&pdev->dev, "failed to register extcon device\n"); 723 dev_err(&pdev->dev, "failed to register extcon device\n");
723 goto err_extcon; 724 goto err_irq;
724 } 725 }
725 726
726 /* Initialize MUIC register by using platform data */ 727 /* Initialize MUIC register by using platform data */
@@ -753,7 +754,7 @@ static int max77693_muic_probe(struct platform_device *pdev)
753 MAX77693_MUIC_REG_ID, &id); 754 MAX77693_MUIC_REG_ID, &id);
754 if (ret < 0) { 755 if (ret < 0) {
755 dev_err(&pdev->dev, "failed to read revision number\n"); 756 dev_err(&pdev->dev, "failed to read revision number\n");
756 goto err_extcon; 757 goto err_irq;
757 } 758 }
758 dev_info(info->dev, "device ID : 0x%x\n", id); 759 dev_info(info->dev, "device ID : 0x%x\n", id);
759 760
@@ -765,12 +766,9 @@ static int max77693_muic_probe(struct platform_device *pdev)
765 766
766 return ret; 767 return ret;
767 768
768err_extcon:
769 kfree(info->edev);
770err_irq: 769err_irq:
771err_regmap: 770 while (--i >= 0)
772 kfree(info); 771 free_irq(muic_irqs[i].virq, info);
773err_kfree:
774 return ret; 772 return ret;
775} 773}
776 774
@@ -783,8 +781,6 @@ static int max77693_muic_remove(struct platform_device *pdev)
783 free_irq(muic_irqs[i].virq, info); 781 free_irq(muic_irqs[i].virq, info);
784 cancel_work_sync(&info->irq_work); 782 cancel_work_sync(&info->irq_work);
785 extcon_dev_unregister(info->edev); 783 extcon_dev_unregister(info->edev);
786 kfree(info->edev);
787 kfree(info);
788 784
789 return 0; 785 return 0;
790} 786}
diff --git a/drivers/extcon/extcon-max8997.c b/drivers/extcon/extcon-max8997.c
index bad76f51161b..93009fe6ef05 100644
--- a/drivers/extcon/extcon-max8997.c
+++ b/drivers/extcon/extcon-max8997.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * extcon-max8997.c - MAX8997 extcon driver to support MAX8997 MUIC 2 * extcon-max8997.c - MAX8997 extcon driver to support MAX8997 MUIC
3 * 3 *
4 * Copyright (C) 2012 Samsung Electrnoics 4 * Copyright (C) 2012 Samsung Electronics
5 * Donggeun Kim <dg77.kim@samsung.com> 5 * Donggeun Kim <dg77.kim@samsung.com>
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
@@ -433,11 +433,11 @@ static int max8997_muic_probe(struct platform_device *pdev)
433 struct max8997_muic_info *info; 433 struct max8997_muic_info *info;
434 int ret, i; 434 int ret, i;
435 435
436 info = kzalloc(sizeof(struct max8997_muic_info), GFP_KERNEL); 436 info = devm_kzalloc(&pdev->dev, sizeof(struct max8997_muic_info),
437 GFP_KERNEL);
437 if (!info) { 438 if (!info) {
438 dev_err(&pdev->dev, "failed to allocate memory\n"); 439 dev_err(&pdev->dev, "failed to allocate memory\n");
439 ret = -ENOMEM; 440 return -ENOMEM;
440 goto err_kfree;
441 } 441 }
442 442
443 info->dev = &pdev->dev; 443 info->dev = &pdev->dev;
@@ -450,14 +450,16 @@ static int max8997_muic_probe(struct platform_device *pdev)
450 450
451 for (i = 0; i < ARRAY_SIZE(muic_irqs); i++) { 451 for (i = 0; i < ARRAY_SIZE(muic_irqs); i++) {
452 struct max8997_muic_irq *muic_irq = &muic_irqs[i]; 452 struct max8997_muic_irq *muic_irq = &muic_irqs[i];
453 int virq = 0; 453 unsigned int virq = 0;
454 454
455 virq = irq_create_mapping(max8997->irq_domain, muic_irq->irq); 455 virq = irq_create_mapping(max8997->irq_domain, muic_irq->irq);
456 if (!virq) 456 if (!virq) {
457 ret = -EINVAL;
457 goto err_irq; 458 goto err_irq;
459 }
458 muic_irq->virq = virq; 460 muic_irq->virq = virq;
459 461
460 ret = request_threaded_irq(virq, NULL,max8997_muic_irq_handler, 462 ret = request_threaded_irq(virq, NULL, max8997_muic_irq_handler,
461 0, muic_irq->name, info); 463 0, muic_irq->name, info);
462 if (ret) { 464 if (ret) {
463 dev_err(&pdev->dev, 465 dev_err(&pdev->dev,
@@ -469,7 +471,8 @@ static int max8997_muic_probe(struct platform_device *pdev)
469 } 471 }
470 472
471 /* External connector */ 473 /* External connector */
472 info->edev = kzalloc(sizeof(struct extcon_dev), GFP_KERNEL); 474 info->edev = devm_kzalloc(&pdev->dev, sizeof(struct extcon_dev),
475 GFP_KERNEL);
473 if (!info->edev) { 476 if (!info->edev) {
474 dev_err(&pdev->dev, "failed to allocate memory for extcon\n"); 477 dev_err(&pdev->dev, "failed to allocate memory for extcon\n");
475 ret = -ENOMEM; 478 ret = -ENOMEM;
@@ -480,7 +483,7 @@ static int max8997_muic_probe(struct platform_device *pdev)
480 ret = extcon_dev_register(info->edev, NULL); 483 ret = extcon_dev_register(info->edev, NULL);
481 if (ret) { 484 if (ret) {
482 dev_err(&pdev->dev, "failed to register extcon device\n"); 485 dev_err(&pdev->dev, "failed to register extcon device\n");
483 goto err_extcon; 486 goto err_irq;
484 } 487 }
485 488
486 /* Initialize registers according to platform data */ 489 /* Initialize registers according to platform data */
@@ -498,13 +501,9 @@ static int max8997_muic_probe(struct platform_device *pdev)
498 501
499 return ret; 502 return ret;
500 503
501err_extcon:
502 kfree(info->edev);
503err_irq: 504err_irq:
504 while (--i >= 0) 505 while (--i >= 0)
505 free_irq(muic_irqs[i].virq, info); 506 free_irq(muic_irqs[i].virq, info);
506 kfree(info);
507err_kfree:
508 return ret; 507 return ret;
509} 508}
510 509
@@ -519,9 +518,6 @@ static int max8997_muic_remove(struct platform_device *pdev)
519 518
520 extcon_dev_unregister(info->edev); 519 extcon_dev_unregister(info->edev);
521 520
522 kfree(info->edev);
523 kfree(info);
524
525 return 0; 521 return 0;
526} 522}
527 523