aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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
-rw-r--r--include/linux/extcon.h50
5 files changed, 56 insertions, 61 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
diff --git a/include/linux/extcon.h b/include/linux/extcon.h
index 2c26c14cd710..fcb51c88319f 100644
--- a/include/linux/extcon.h
+++ b/include/linux/extcon.h
@@ -23,7 +23,9 @@
23#ifndef __LINUX_EXTCON_H__ 23#ifndef __LINUX_EXTCON_H__
24#define __LINUX_EXTCON_H__ 24#define __LINUX_EXTCON_H__
25 25
26#include <linux/device.h>
26#include <linux/notifier.h> 27#include <linux/notifier.h>
28#include <linux/sysfs.h>
27 29
28#define SUPPORTED_CABLE_MAX 32 30#define SUPPORTED_CABLE_MAX 32
29#define CABLE_NAME_MAX 30 31#define CABLE_NAME_MAX 30
@@ -74,12 +76,12 @@ struct extcon_cable;
74 76
75/** 77/**
76 * struct extcon_dev - An extcon device represents one external connector. 78 * struct extcon_dev - An extcon device represents one external connector.
77 * @name The name of this extcon device. Parent device name is used 79 * @name: The name of this extcon device. Parent device name is used
78 * if NULL. 80 * if NULL.
79 * @supported_cable Array of supported cable names ending with NULL. 81 * @supported_cable: Array of supported cable names ending with NULL.
80 * If supported_cable is NULL, cable name related APIs 82 * If supported_cable is NULL, cable name related APIs
81 * are disabled. 83 * are disabled.
82 * @mutually_exclusive Array of mutually exclusive set of cables that cannot 84 * @mutually_exclusive: Array of mutually exclusive set of cables that cannot
83 * be attached simultaneously. The array should be 85 * be attached simultaneously. The array should be
84 * ending with NULL or be NULL (no mutually exclusive 86 * ending with NULL or be NULL (no mutually exclusive
85 * cables). For example, if it is { 0x7, 0x30, 0}, then, 87 * cables). For example, if it is { 0x7, 0x30, 0}, then,
@@ -87,21 +89,21 @@ struct extcon_cable;
87 * be attached simulataneously. {0x7, 0} is equivalent to 89 * be attached simulataneously. {0x7, 0} is equivalent to
88 * {0x3, 0x6, 0x5, 0}. If it is {0xFFFFFFFF, 0}, there 90 * {0x3, 0x6, 0x5, 0}. If it is {0xFFFFFFFF, 0}, there
89 * can be no simultaneous connections. 91 * can be no simultaneous connections.
90 * @print_name An optional callback to override the method to print the 92 * @print_name: An optional callback to override the method to print the
91 * name of the extcon device. 93 * name of the extcon device.
92 * @print_state An optional callback to override the method to print the 94 * @print_state: An optional callback to override the method to print the
93 * status of the extcon device. 95 * status of the extcon device.
94 * @dev Device of this extcon. Do not provide at register-time. 96 * @dev: Device of this extcon. Do not provide at register-time.
95 * @state Attach/detach state of this extcon. Do not provide at 97 * @state: Attach/detach state of this extcon. Do not provide at
96 * register-time 98 * register-time
97 * @nh Notifier for the state change events from this extcon 99 * @nh: Notifier for the state change events from this extcon
98 * @entry To support list of extcon devices so that users can search 100 * @entry: To support list of extcon devices so that users can search
99 * for extcon devices based on the extcon name. 101 * for extcon devices based on the extcon name.
100 * @lock 102 * @lock:
101 * @max_supported Internal value to store the number of cables. 103 * @max_supported: Internal value to store the number of cables.
102 * @extcon_dev_type Device_type struct to provide attribute_groups 104 * @extcon_dev_type: Device_type struct to provide attribute_groups
103 * customized for each extcon device. 105 * customized for each extcon device.
104 * @cables Sysfs subdirectories. Each represents one cable. 106 * @cables: Sysfs subdirectories. Each represents one cable.
105 * 107 *
106 * In most cases, users only need to provide "User initializing data" of 108 * In most cases, users only need to provide "User initializing data" of
107 * this struct when registering an extcon. In some exceptional cases, 109 * this struct when registering an extcon. In some exceptional cases,
@@ -137,12 +139,12 @@ struct extcon_dev {
137 139
138/** 140/**
139 * struct extcon_cable - An internal data for each cable of extcon device. 141 * struct extcon_cable - An internal data for each cable of extcon device.
140 * @edev The extcon device 142 * @edev: The extcon device
141 * @cable_index Index of this cable in the edev 143 * @cable_index: Index of this cable in the edev
142 * @attr_g Attribute group for the cable 144 * @attr_g: Attribute group for the cable
143 * @attr_name "name" sysfs entry 145 * @attr_name: "name" sysfs entry
144 * @attr_state "state" sysfs entry 146 * @attr_state: "state" sysfs entry
145 * @attrs Array pointing to attr_name and attr_state for attr_g 147 * @attrs: Array pointing to attr_name and attr_state for attr_g
146 */ 148 */
147struct extcon_cable { 149struct extcon_cable {
148 struct extcon_dev *edev; 150 struct extcon_dev *edev;
@@ -158,11 +160,11 @@ struct extcon_cable {
158/** 160/**
159 * struct extcon_specific_cable_nb - An internal data for 161 * struct extcon_specific_cable_nb - An internal data for
160 * extcon_register_interest(). 162 * extcon_register_interest().
161 * @internal_nb a notifier block bridging extcon notifier and cable notifier. 163 * @internal_nb: a notifier block bridging extcon notifier and cable notifier.
162 * @user_nb user provided notifier block for events from a specific cable. 164 * @user_nb: user provided notifier block for events from a specific cable.
163 * @cable_index the target cable. 165 * @cable_index: the target cable.
164 * @edev the target extcon device. 166 * @edev: the target extcon device.
165 * @previous_value the saved previous event value. 167 * @previous_value: the saved previous event value.
166 */ 168 */
167struct extcon_specific_cable_nb { 169struct extcon_specific_cable_nb {
168 struct notifier_block internal_nb; 170 struct notifier_block internal_nb;