aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/extcon/extcon.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-02-22 14:38:22 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2017-02-22 14:38:22 -0500
commite30aee9e10bb5168579e047f05c3d13d09e23356 (patch)
tree12371bdcd52d2427cad838201997479e31b6a9c9 /drivers/extcon/extcon.c
parent8ff546b801e5cca0337c0f0a7234795d0a6309a1 (diff)
parent6cf18e6927c0b224f972e3042fb85770d63cb9f8 (diff)
Merge tag 'char-misc-4.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc
Pull char/misc driver updates from Greg KH: "Here is the big char/misc driver patchset for 4.11-rc1. Lots of different driver subsystems updated here: rework for the hyperv subsystem to handle new platforms better, mei and w1 and extcon driver updates, as well as a number of other "minor" driver updates. All of these have been in linux-next for a while with no reported issues" * tag 'char-misc-4.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (169 commits) goldfish: Sanitize the broken interrupt handler x86/platform/goldfish: Prevent unconditional loading vmbus: replace modulus operation with subtraction vmbus: constify parameters where possible vmbus: expose hv_begin/end_read vmbus: remove conditional locking of vmbus_write vmbus: add direct isr callback mode vmbus: change to per channel tasklet vmbus: put related per-cpu variable together vmbus: callback is in softirq not workqueue binder: Add support for file-descriptor arrays binder: Add support for scatter-gather binder: Add extra size to allocator binder: Refactor binder_transact() binder: Support multiple /dev instances binder: Deal with contexts in debugfs binder: Support multiple context managers binder: Split flat_binder_object auxdisplay: ht16k33: remove private workqueue auxdisplay: ht16k33: rework input device initialization ...
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}