aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/extcon/extcon.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/extcon/extcon.c')
-rw-r--r--drivers/extcon/extcon.c43
1 files changed, 15 insertions, 28 deletions
diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c
index 7c1e3a7b14e0..09ac5e70c2f3 100644
--- a/drivers/extcon/extcon.c
+++ b/drivers/extcon/extcon.c
@@ -30,11 +30,12 @@
30#include <linux/device.h> 30#include <linux/device.h>
31#include <linux/fs.h> 31#include <linux/fs.h>
32#include <linux/err.h> 32#include <linux/err.h>
33#include <linux/extcon.h>
34#include <linux/of.h> 33#include <linux/of.h>
35#include <linux/slab.h> 34#include <linux/slab.h>
36#include <linux/sysfs.h> 35#include <linux/sysfs.h>
37 36
37#include "extcon.h"
38
38#define SUPPORTED_CABLE_MAX 32 39#define SUPPORTED_CABLE_MAX 32
39#define CABLE_NAME_MAX 30 40#define CABLE_NAME_MAX 30
40 41
@@ -59,7 +60,7 @@ struct __extcon_info {
59 [EXTCON_USB_HOST] = { 60 [EXTCON_USB_HOST] = {
60 .type = EXTCON_TYPE_USB, 61 .type = EXTCON_TYPE_USB,
61 .id = EXTCON_USB_HOST, 62 .id = EXTCON_USB_HOST,
62 .name = "USB_HOST", 63 .name = "USB-HOST",
63 }, 64 },
64 65
65 /* Charging external connector */ 66 /* Charging external connector */
@@ -98,6 +99,11 @@ struct __extcon_info {
98 .id = EXTCON_CHG_WPT, 99 .id = EXTCON_CHG_WPT,
99 .name = "WPT", 100 .name = "WPT",
100 }, 101 },
102 [EXTCON_CHG_USB_PD] = {
103 .type = EXTCON_TYPE_CHG | EXTCON_TYPE_USB,
104 .id = EXTCON_CHG_USB_PD,
105 .name = "PD",
106 },
101 107
102 /* Jack external connector */ 108 /* Jack external connector */
103 [EXTCON_JACK_MICROPHONE] = { 109 [EXTCON_JACK_MICROPHONE] = {
@@ -906,35 +912,16 @@ int extcon_register_notifier(struct extcon_dev *edev, unsigned int id,
906 unsigned long flags; 912 unsigned long flags;
907 int ret, idx = -EINVAL; 913 int ret, idx = -EINVAL;
908 914
909 if (!nb) 915 if (!edev || !nb)
910 return -EINVAL; 916 return -EINVAL;
911 917
912 if (edev) { 918 idx = find_cable_index_by_id(edev, id);
913 idx = find_cable_index_by_id(edev, id); 919 if (idx < 0)
914 if (idx < 0) 920 return idx;
915 return idx;
916
917 spin_lock_irqsave(&edev->lock, flags);
918 ret = raw_notifier_chain_register(&edev->nh[idx], nb);
919 spin_unlock_irqrestore(&edev->lock, flags);
920 } else {
921 struct extcon_dev *extd;
922
923 mutex_lock(&extcon_dev_list_lock);
924 list_for_each_entry(extd, &extcon_dev_list, entry) {
925 idx = find_cable_index_by_id(extd, id);
926 if (idx >= 0)
927 break;
928 }
929 mutex_unlock(&extcon_dev_list_lock);
930 921
931 if (idx >= 0) { 922 spin_lock_irqsave(&edev->lock, flags);
932 edev = extd; 923 ret = raw_notifier_chain_register(&edev->nh[idx], nb);
933 return extcon_register_notifier(extd, id, nb); 924 spin_unlock_irqrestore(&edev->lock, flags);
934 } else {
935 ret = -ENODEV;
936 }
937 }
938 925
939 return ret; 926 return ret;
940} 927}