blob: 9a266e5c7e105dc533bf51d8ed5b5538ee8727aa [file] [log] [blame]
MyungJoo Hamde55d872012-04-20 14:16:22 +09001/*
Chanwoo Choib9ec23c2015-04-24 14:48:52 +09002 * drivers/extcon/extcon.c - External Connector (extcon) framework.
MyungJoo Hamde55d872012-04-20 14:16:22 +09003 *
4 * External connector (extcon) class driver
5 *
Chanwoo Choi2a9de9c2015-04-24 19:16:05 +09006 * Copyright (C) 2015 Samsung Electronics
7 * Author: Chanwoo Choi <cw00.choi@samsung.com>
8 *
MyungJoo Hamde55d872012-04-20 14:16:22 +09009 * Copyright (C) 2012 Samsung Electronics
10 * Author: Donggeun Kim <dg77.kim@samsung.com>
11 * Author: MyungJoo Ham <myungjoo.ham@samsung.com>
12 *
13 * based on android/drivers/switch/switch_class.c
14 * Copyright (C) 2008 Google, Inc.
15 * Author: Mike Lockwood <lockwood@android.com>
16 *
17 * This software is licensed under the terms of the GNU General Public
18 * License version 2, as published by the Free Software Foundation, and
19 * may be copied, distributed, and modified under those terms.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
Chanwoo Choib9ec23c2015-04-24 14:48:52 +090025 */
MyungJoo Hamde55d872012-04-20 14:16:22 +090026
27#include <linux/module.h>
28#include <linux/types.h>
29#include <linux/init.h>
30#include <linux/device.h>
31#include <linux/fs.h>
32#include <linux/err.h>
33#include <linux/extcon.h>
Tomasz Figaf841afb2014-10-16 15:11:44 +020034#include <linux/of.h>
MyungJoo Hamde55d872012-04-20 14:16:22 +090035#include <linux/slab.h>
Mark Brown9baf3222012-08-16 20:03:21 +010036#include <linux/sysfs.h>
MyungJoo Hamde55d872012-04-20 14:16:22 +090037
Chanwoo Choi2a9de9c2015-04-24 19:16:05 +090038#define SUPPORTED_CABLE_MAX 32
39#define CABLE_NAME_MAX 30
40
41static const char *extcon_name[] = {
Chanwoo Choi11eecf92015-10-03 14:15:13 +090042 [EXTCON_NONE] = "NONE",
Chanwoo Choi73b6ecd2015-06-12 11:10:06 +090043
Chanwoo Choi8e9bc362015-05-19 19:58:49 +090044 /* USB external connector */
Chanwoo Choi11eecf92015-10-03 14:15:13 +090045 [EXTCON_USB] = "USB",
46 [EXTCON_USB_HOST] = "USB-HOST",
Chanwoo Choi8e9bc362015-05-19 19:58:49 +090047
Chanwoo Choi11eecf92015-10-03 14:15:13 +090048 /* Charging external connector */
49 [EXTCON_CHG_USB_SDP] = "SDP",
50 [EXTCON_CHG_USB_DCP] = "DCP",
51 [EXTCON_CHG_USB_CDP] = "CDP",
52 [EXTCON_CHG_USB_ACA] = "ACA",
53 [EXTCON_CHG_USB_FAST] = "FAST-CHARGER",
54 [EXTCON_CHG_USB_SLOW] = "SLOW-CHARGER",
Chanwoo Choi8e9bc362015-05-19 19:58:49 +090055
Chanwoo Choi11eecf92015-10-03 14:15:13 +090056 /* Jack external connector */
57 [EXTCON_JACK_MICROPHONE] = "MICROPHONE",
58 [EXTCON_JACK_HEADPHONE] = "HEADPHONE",
59 [EXTCON_JACK_LINE_IN] = "LINE-IN",
60 [EXTCON_JACK_LINE_OUT] = "LINE-OUT",
61 [EXTCON_JACK_VIDEO_IN] = "VIDEO-IN",
62 [EXTCON_JACK_VIDEO_OUT] = "VIDEO-OUT",
63 [EXTCON_JACK_SPDIF_IN] = "SPDIF-IN",
64 [EXTCON_JACK_SPDIF_OUT] = "SPDIF-OUT",
Chanwoo Choi8e9bc362015-05-19 19:58:49 +090065
Chanwoo Choi11eecf92015-10-03 14:15:13 +090066 /* Display external connector */
67 [EXTCON_DISP_HDMI] = "HDMI",
68 [EXTCON_DISP_MHL] = "MHL",
69 [EXTCON_DISP_DVI] = "DVI",
70 [EXTCON_DISP_VGA] = "VGA",
Chanwoo Choi8e9bc362015-05-19 19:58:49 +090071
Chanwoo Choi11eecf92015-10-03 14:15:13 +090072 /* Miscellaneous external connector */
73 [EXTCON_DOCK] = "DOCK",
74 [EXTCON_JIG] = "JIG",
75 [EXTCON_MECHANICAL] = "MECHANICAL",
Chanwoo Choi8e9bc362015-05-19 19:58:49 +090076
Chanwoo Choi2a9de9c2015-04-24 19:16:05 +090077 NULL,
MyungJoo Ham806d9dd2012-04-20 14:16:25 +090078};
79
Chanwoo Choi20f7b532016-06-27 19:17:06 +090080/**
81 * struct extcon_cable - An internal data for each cable of extcon device.
82 * @edev: The extcon device
83 * @cable_index: Index of this cable in the edev
84 * @attr_g: Attribute group for the cable
85 * @attr_name: "name" sysfs entry
86 * @attr_state: "state" sysfs entry
87 * @attrs: Array pointing to attr_name and attr_state for attr_g
88 */
89struct extcon_cable {
90 struct extcon_dev *edev;
91 int cable_index;
92
93 struct attribute_group attr_g;
94 struct device_attribute attr_name;
95 struct device_attribute attr_state;
96
97 struct attribute *attrs[3]; /* to be fed to attr_g.attrs */
98};
99
Mark Brownbe3a07f2012-06-05 16:14:38 +0100100static struct class *extcon_class;
MyungJoo Ham449a2bf2012-04-23 20:19:57 +0900101#if defined(CONFIG_ANDROID)
MyungJoo Hamde55d872012-04-20 14:16:22 +0900102static struct class_compat *switch_class;
MyungJoo Ham449a2bf2012-04-23 20:19:57 +0900103#endif /* CONFIG_ANDROID */
MyungJoo Hamde55d872012-04-20 14:16:22 +0900104
Donggeun Kim74c5d092012-04-20 14:16:24 +0900105static LIST_HEAD(extcon_dev_list);
106static DEFINE_MUTEX(extcon_dev_list_lock);
107
MyungJoo Hambde68e62012-04-20 14:16:26 +0900108/**
109 * check_mutually_exclusive - Check if new_state violates mutually_exclusive
Chanwoo Choia75e1c72013-08-31 13:16:49 +0900110 * condition.
MyungJoo Hambde68e62012-04-20 14:16:26 +0900111 * @edev: the extcon device
112 * @new_state: new cable attach status for @edev
113 *
114 * Returns 0 if nothing violates. Returns the index + 1 for the first
115 * violated condition.
116 */
117static int check_mutually_exclusive(struct extcon_dev *edev, u32 new_state)
118{
119 int i = 0;
120
121 if (!edev->mutually_exclusive)
122 return 0;
123
124 for (i = 0; edev->mutually_exclusive[i]; i++) {
anish kumar28c0ada2012-08-30 00:35:10 +0530125 int weight;
MyungJoo Hambde68e62012-04-20 14:16:26 +0900126 u32 correspondants = new_state & edev->mutually_exclusive[i];
MyungJoo Hambde68e62012-04-20 14:16:26 +0900127
anish kumar28c0ada2012-08-30 00:35:10 +0530128 /* calculate the total number of bits set */
129 weight = hweight32(correspondants);
130 if (weight > 1)
131 return i + 1;
MyungJoo Hambde68e62012-04-20 14:16:26 +0900132 }
133
134 return 0;
135}
136
Chanwoo Choi73b6ecd2015-06-12 11:10:06 +0900137static int find_cable_index_by_id(struct extcon_dev *edev, const unsigned int id)
Chanwoo Choi2a9de9c2015-04-24 19:16:05 +0900138{
139 int i;
140
141 /* Find the the index of extcon cable in edev->supported_cable */
142 for (i = 0; i < edev->max_supported; i++) {
143 if (edev->supported_cable[i] == id)
144 return i;
145 }
146
147 return -EINVAL;
148}
149
Chanwoo Choi046050f2015-05-19 20:01:12 +0900150static bool is_extcon_changed(u32 prev, u32 new, int idx, bool *attached)
151{
152 if (((prev >> idx) & 0x1) != ((new >> idx) & 0x1)) {
Hans de Goedef4513b02015-08-24 00:35:36 +0200153 *attached = ((new >> idx) & 0x1) ? true : false;
Chanwoo Choi046050f2015-05-19 20:01:12 +0900154 return true;
155 }
156
157 return false;
158}
159
MyungJoo Hamde55d872012-04-20 14:16:22 +0900160static ssize_t state_show(struct device *dev, struct device_attribute *attr,
161 char *buf)
162{
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900163 int i, count = 0;
Jingoo Hancb8bb3a2013-09-09 14:33:32 +0900164 struct extcon_dev *edev = dev_get_drvdata(dev);
MyungJoo Hamde55d872012-04-20 14:16:22 +0900165
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900166 if (edev->max_supported == 0)
167 return sprintf(buf, "%u\n", edev->state);
168
Chanwoo Choi2a9de9c2015-04-24 19:16:05 +0900169 for (i = 0; i < edev->max_supported; i++) {
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900170 count += sprintf(buf + count, "%s=%d\n",
Chanwoo Choi2a9de9c2015-04-24 19:16:05 +0900171 extcon_name[edev->supported_cable[i]],
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900172 !!(edev->state & (1 << i)));
173 }
174
175 return count;
176}
Chanwoo Choi5d5321e2016-07-18 15:39:28 +0900177static DEVICE_ATTR_RO(state);
MyungJoo Hamde55d872012-04-20 14:16:22 +0900178
179static ssize_t name_show(struct device *dev, struct device_attribute *attr,
180 char *buf)
181{
Jingoo Hancb8bb3a2013-09-09 14:33:32 +0900182 struct extcon_dev *edev = dev_get_drvdata(dev);
MyungJoo Hamde55d872012-04-20 14:16:22 +0900183
Chanwoo Choi71c3ffa2015-04-15 15:02:01 +0900184 return sprintf(buf, "%s\n", edev->name);
MyungJoo Hamde55d872012-04-20 14:16:22 +0900185}
Greg Kroah-Hartmanaf01da02013-07-24 15:05:10 -0700186static DEVICE_ATTR_RO(name);
MyungJoo Hamde55d872012-04-20 14:16:22 +0900187
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900188static ssize_t cable_name_show(struct device *dev,
189 struct device_attribute *attr, char *buf)
190{
191 struct extcon_cable *cable = container_of(attr, struct extcon_cable,
192 attr_name);
Chanwoo Choi2a9de9c2015-04-24 19:16:05 +0900193 int i = cable->cable_index;
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900194
195 return sprintf(buf, "%s\n",
Chanwoo Choi2a9de9c2015-04-24 19:16:05 +0900196 extcon_name[cable->edev->supported_cable[i]]);
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900197}
198
199static ssize_t cable_state_show(struct device *dev,
200 struct device_attribute *attr, char *buf)
201{
202 struct extcon_cable *cable = container_of(attr, struct extcon_cable,
203 attr_state);
204
Roger Quadrosbe052cc2015-07-07 16:06:15 +0300205 int i = cable->cable_index;
206
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900207 return sprintf(buf, "%d\n",
208 extcon_get_cable_state_(cable->edev,
Roger Quadrosbe052cc2015-07-07 16:06:15 +0300209 cable->edev->supported_cable[i]));
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900210}
211
MyungJoo Hamde55d872012-04-20 14:16:22 +0900212/**
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900213 * extcon_update_state() - Update the cable attach states of the extcon device
Chanwoo Choia75e1c72013-08-31 13:16:49 +0900214 * only for the masked bits.
MyungJoo Hamde55d872012-04-20 14:16:22 +0900215 * @edev: the extcon device
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900216 * @mask: the bit mask to designate updated bits.
MyungJoo Hamde55d872012-04-20 14:16:22 +0900217 * @state: new cable attach status for @edev
218 *
219 * Changing the state sends uevent with environment variable containing
220 * the name of extcon device (envp[0]) and the state output (envp[1]).
221 * Tizen uses this format for extcon device to get events from ports.
222 * Android uses this format as well.
Donggeun Kim74c5d092012-04-20 14:16:24 +0900223 *
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900224 * Note that the notifier provides which bits are changed in the state
225 * variable with the val parameter (second) to the callback.
MyungJoo Hamde55d872012-04-20 14:16:22 +0900226 */
Chanwoo Choi912465b2016-07-01 02:41:18 +0900227static int extcon_update_state(struct extcon_dev *edev, u32 mask, u32 state)
MyungJoo Hamde55d872012-04-20 14:16:22 +0900228{
229 char name_buf[120];
230 char state_buf[120];
231 char *prop_buf;
232 char *envp[3];
233 int env_offset = 0;
234 int length;
Chanwoo Choi046050f2015-05-19 20:01:12 +0900235 int index;
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900236 unsigned long flags;
Chanwoo Choi046050f2015-05-19 20:01:12 +0900237 bool attached;
MyungJoo Hamde55d872012-04-20 14:16:22 +0900238
Chanwoo Choi7eae43a2015-06-21 23:48:36 +0900239 if (!edev)
240 return -EINVAL;
241
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900242 spin_lock_irqsave(&edev->lock, flags);
MyungJoo Hamde55d872012-04-20 14:16:22 +0900243
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900244 if (edev->state != ((edev->state & ~mask) | (state & mask))) {
Roger Quadrosf7a89812015-07-06 17:46:58 +0300245 u32 old_state;
246
MyungJoo Hambde68e62012-04-20 14:16:26 +0900247 if (check_mutually_exclusive(edev, (edev->state & ~mask) |
248 (state & mask))) {
249 spin_unlock_irqrestore(&edev->lock, flags);
250 return -EPERM;
251 }
252
Roger Quadrosf7a89812015-07-06 17:46:58 +0300253 old_state = edev->state;
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900254 edev->state &= ~mask;
255 edev->state |= state & mask;
256
Roger Quadrosf7a89812015-07-06 17:46:58 +0300257 for (index = 0; index < edev->max_supported; index++) {
258 if (is_extcon_changed(old_state, edev->state, index,
259 &attached))
260 raw_notifier_call_chain(&edev->nh[index],
261 attached, edev);
262 }
263
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900264 /* This could be in interrupt handler */
265 prop_buf = (char *)get_zeroed_page(GFP_ATOMIC);
MyungJoo Hamde55d872012-04-20 14:16:22 +0900266 if (prop_buf) {
Chanwoo Choidae61652013-09-27 09:19:40 +0900267 length = name_show(&edev->dev, NULL, prop_buf);
MyungJoo Hamde55d872012-04-20 14:16:22 +0900268 if (length > 0) {
269 if (prop_buf[length - 1] == '\n')
270 prop_buf[length - 1] = 0;
271 snprintf(name_buf, sizeof(name_buf),
272 "NAME=%s", prop_buf);
273 envp[env_offset++] = name_buf;
274 }
Chanwoo Choidae61652013-09-27 09:19:40 +0900275 length = state_show(&edev->dev, NULL, prop_buf);
MyungJoo Hamde55d872012-04-20 14:16:22 +0900276 if (length > 0) {
277 if (prop_buf[length - 1] == '\n')
278 prop_buf[length - 1] = 0;
279 snprintf(state_buf, sizeof(state_buf),
280 "STATE=%s", prop_buf);
281 envp[env_offset++] = state_buf;
282 }
283 envp[env_offset] = NULL;
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900284 /* Unlock early before uevent */
285 spin_unlock_irqrestore(&edev->lock, flags);
286
Chanwoo Choidae61652013-09-27 09:19:40 +0900287 kobject_uevent_env(&edev->dev.kobj, KOBJ_CHANGE, envp);
MyungJoo Hamde55d872012-04-20 14:16:22 +0900288 free_page((unsigned long)prop_buf);
289 } else {
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900290 /* Unlock early before uevent */
291 spin_unlock_irqrestore(&edev->lock, flags);
292
Chanwoo Choidae61652013-09-27 09:19:40 +0900293 dev_err(&edev->dev, "out of memory in extcon_set_state\n");
294 kobject_uevent(&edev->dev.kobj, KOBJ_CHANGE);
MyungJoo Hamde55d872012-04-20 14:16:22 +0900295 }
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900296 } else {
297 /* No changes */
298 spin_unlock_irqrestore(&edev->lock, flags);
MyungJoo Hamde55d872012-04-20 14:16:22 +0900299 }
MyungJoo Hambde68e62012-04-20 14:16:26 +0900300
301 return 0;
MyungJoo Hamde55d872012-04-20 14:16:22 +0900302}
MyungJoo Hamde55d872012-04-20 14:16:22 +0900303
Donggeun Kim74c5d092012-04-20 14:16:24 +0900304/**
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900305 * extcon_get_cable_state_() - Get the status of a specific cable.
306 * @edev: the extcon device that has the cable.
Chanwoo Choi2a9de9c2015-04-24 19:16:05 +0900307 * @id: the unique id of each external connector in extcon enumeration.
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900308 */
Chanwoo Choi73b6ecd2015-06-12 11:10:06 +0900309int extcon_get_cable_state_(struct extcon_dev *edev, const unsigned int id)
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900310{
Chanwoo Choi2a9de9c2015-04-24 19:16:05 +0900311 int index;
312
Chanwoo Choi7eae43a2015-06-21 23:48:36 +0900313 if (!edev)
314 return -EINVAL;
315
Chanwoo Choi2a9de9c2015-04-24 19:16:05 +0900316 index = find_cable_index_by_id(edev, id);
317 if (index < 0)
318 return index;
319
320 if (edev->max_supported && edev->max_supported <= index)
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900321 return -EINVAL;
322
323 return !!(edev->state & (1 << index));
324}
325EXPORT_SYMBOL_GPL(extcon_get_cable_state_);
326
327/**
Axel Lin909f9ec2012-10-04 09:53:45 +0900328 * extcon_set_cable_state_() - Set the status of a specific cable.
Chanwoo Choia75e1c72013-08-31 13:16:49 +0900329 * @edev: the extcon device that has the cable.
Chanwoo Choi2a9de9c2015-04-24 19:16:05 +0900330 * @id: the unique id of each external connector
331 * in extcon enumeration.
332 * @state: the new cable status. The default semantics is
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900333 * true: attached / false: detached.
334 */
Chanwoo Choi73b6ecd2015-06-12 11:10:06 +0900335int extcon_set_cable_state_(struct extcon_dev *edev, unsigned int id,
Chanwoo Choi2a9de9c2015-04-24 19:16:05 +0900336 bool cable_state)
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900337{
338 u32 state;
Chanwoo Choi2a9de9c2015-04-24 19:16:05 +0900339 int index;
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900340
Chanwoo Choi7eae43a2015-06-21 23:48:36 +0900341 if (!edev)
342 return -EINVAL;
343
Chanwoo Choi2a9de9c2015-04-24 19:16:05 +0900344 index = find_cable_index_by_id(edev, id);
345 if (index < 0)
346 return index;
347
348 if (edev->max_supported && edev->max_supported <= index)
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900349 return -EINVAL;
350
351 state = cable_state ? (1 << index) : 0;
MyungJoo Hambde68e62012-04-20 14:16:26 +0900352 return extcon_update_state(edev, 1 << index, state);
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900353}
354EXPORT_SYMBOL_GPL(extcon_set_cable_state_);
355
356/**
Donggeun Kim74c5d092012-04-20 14:16:24 +0900357 * extcon_get_extcon_dev() - Get the extcon device instance from the name
358 * @extcon_name: The extcon name provided with extcon_dev_register()
359 */
360struct extcon_dev *extcon_get_extcon_dev(const char *extcon_name)
361{
362 struct extcon_dev *sd;
363
Chanwoo Choi7eae43a2015-06-21 23:48:36 +0900364 if (!extcon_name)
365 return ERR_PTR(-EINVAL);
366
Donggeun Kim74c5d092012-04-20 14:16:24 +0900367 mutex_lock(&extcon_dev_list_lock);
368 list_for_each_entry(sd, &extcon_dev_list, entry) {
369 if (!strcmp(sd->name, extcon_name))
370 goto out;
371 }
372 sd = NULL;
373out:
374 mutex_unlock(&extcon_dev_list_lock);
375 return sd;
376}
377EXPORT_SYMBOL_GPL(extcon_get_extcon_dev);
378
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900379/**
Peter Meerwaldc338bb02012-08-23 09:11:54 +0900380 * extcon_register_notifier() - Register a notifiee to get notified by
Chanwoo Choia75e1c72013-08-31 13:16:49 +0900381 * any attach status changes from the extcon.
Chanwoo Choi046050f2015-05-19 20:01:12 +0900382 * @edev: the extcon device that has the external connecotr.
383 * @id: the unique id of each external connector in extcon enumeration.
Donggeun Kim74c5d092012-04-20 14:16:24 +0900384 * @nb: a notifier block to be registered.
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900385 *
386 * Note that the second parameter given to the callback of nb (val) is
387 * "old_state", not the current state. The current state can be retrieved
388 * by looking at the third pameter (edev pointer)'s state value.
Donggeun Kim74c5d092012-04-20 14:16:24 +0900389 */
Chanwoo Choi73b6ecd2015-06-12 11:10:06 +0900390int extcon_register_notifier(struct extcon_dev *edev, unsigned int id,
Chanwoo Choi046050f2015-05-19 20:01:12 +0900391 struct notifier_block *nb)
Donggeun Kim74c5d092012-04-20 14:16:24 +0900392{
Hans de Goede66bee352015-03-21 17:26:24 +0100393 unsigned long flags;
Maninder Singh2c8116a2016-08-01 14:51:30 +0530394 int ret, idx = -EINVAL;
Chanwoo Choi046050f2015-05-19 20:01:12 +0900395
Chanwoo Choi830ae442016-05-31 17:32:30 +0900396 if (!nb)
Chanwoo Choi7eae43a2015-06-21 23:48:36 +0900397 return -EINVAL;
398
Chanwoo Choi830ae442016-05-31 17:32:30 +0900399 if (edev) {
400 idx = find_cable_index_by_id(edev, id);
Stephen Boyda05f44c2016-06-23 19:34:30 +0900401 if (idx < 0)
402 return idx;
Hans de Goede66bee352015-03-21 17:26:24 +0100403
Chanwoo Choi830ae442016-05-31 17:32:30 +0900404 spin_lock_irqsave(&edev->lock, flags);
405 ret = raw_notifier_chain_register(&edev->nh[idx], nb);
406 spin_unlock_irqrestore(&edev->lock, flags);
407 } else {
408 struct extcon_dev *extd;
409
410 mutex_lock(&extcon_dev_list_lock);
411 list_for_each_entry(extd, &extcon_dev_list, entry) {
412 idx = find_cable_index_by_id(extd, id);
413 if (idx >= 0)
414 break;
415 }
416 mutex_unlock(&extcon_dev_list_lock);
417
418 if (idx >= 0) {
419 edev = extd;
420 return extcon_register_notifier(extd, id, nb);
421 } else {
422 ret = -ENODEV;
423 }
424 }
Hans de Goede66bee352015-03-21 17:26:24 +0100425
426 return ret;
Donggeun Kim74c5d092012-04-20 14:16:24 +0900427}
428EXPORT_SYMBOL_GPL(extcon_register_notifier);
429
430/**
Peter Meerwaldc338bb02012-08-23 09:11:54 +0900431 * extcon_unregister_notifier() - Unregister a notifiee from the extcon device.
Chanwoo Choi046050f2015-05-19 20:01:12 +0900432 * @edev: the extcon device that has the external connecotr.
433 * @id: the unique id of each external connector in extcon enumeration.
434 * @nb: a notifier block to be registered.
Donggeun Kim74c5d092012-04-20 14:16:24 +0900435 */
Chanwoo Choi73b6ecd2015-06-12 11:10:06 +0900436int extcon_unregister_notifier(struct extcon_dev *edev, unsigned int id,
Chanwoo Choi046050f2015-05-19 20:01:12 +0900437 struct notifier_block *nb)
Donggeun Kim74c5d092012-04-20 14:16:24 +0900438{
Hans de Goede66bee352015-03-21 17:26:24 +0100439 unsigned long flags;
Chanwoo Choi046050f2015-05-19 20:01:12 +0900440 int ret, idx;
441
Chanwoo Choi7eae43a2015-06-21 23:48:36 +0900442 if (!edev || !nb)
443 return -EINVAL;
444
Chanwoo Choi046050f2015-05-19 20:01:12 +0900445 idx = find_cable_index_by_id(edev, id);
Stephen Boyda05f44c2016-06-23 19:34:30 +0900446 if (idx < 0)
447 return idx;
Hans de Goede66bee352015-03-21 17:26:24 +0100448
449 spin_lock_irqsave(&edev->lock, flags);
Chanwoo Choi046050f2015-05-19 20:01:12 +0900450 ret = raw_notifier_chain_unregister(&edev->nh[idx], nb);
Hans de Goede66bee352015-03-21 17:26:24 +0100451 spin_unlock_irqrestore(&edev->lock, flags);
452
453 return ret;
Donggeun Kim74c5d092012-04-20 14:16:24 +0900454}
455EXPORT_SYMBOL_GPL(extcon_unregister_notifier);
456
Greg Kroah-Hartmanaf01da02013-07-24 15:05:10 -0700457static struct attribute *extcon_attrs[] = {
458 &dev_attr_state.attr,
459 &dev_attr_name.attr,
460 NULL,
MyungJoo Hamde55d872012-04-20 14:16:22 +0900461};
Greg Kroah-Hartmanaf01da02013-07-24 15:05:10 -0700462ATTRIBUTE_GROUPS(extcon);
MyungJoo Hamde55d872012-04-20 14:16:22 +0900463
464static int create_extcon_class(void)
465{
466 if (!extcon_class) {
467 extcon_class = class_create(THIS_MODULE, "extcon");
468 if (IS_ERR(extcon_class))
469 return PTR_ERR(extcon_class);
Greg Kroah-Hartmanaf01da02013-07-24 15:05:10 -0700470 extcon_class->dev_groups = extcon_groups;
MyungJoo Hamde55d872012-04-20 14:16:22 +0900471
MyungJoo Ham449a2bf2012-04-23 20:19:57 +0900472#if defined(CONFIG_ANDROID)
MyungJoo Hamde55d872012-04-20 14:16:22 +0900473 switch_class = class_compat_register("switch");
474 if (WARN(!switch_class, "cannot allocate"))
475 return -ENOMEM;
MyungJoo Ham449a2bf2012-04-23 20:19:57 +0900476#endif /* CONFIG_ANDROID */
MyungJoo Hamde55d872012-04-20 14:16:22 +0900477 }
478
479 return 0;
480}
481
MyungJoo Hamde55d872012-04-20 14:16:22 +0900482static void extcon_dev_release(struct device *dev)
483{
MyungJoo Hamde55d872012-04-20 14:16:22 +0900484}
485
MyungJoo Hambde68e62012-04-20 14:16:26 +0900486static const char *muex_name = "mutually_exclusive";
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900487static void dummy_sysfs_dev_release(struct device *dev)
488{
489}
490
Chanwoo Choia9af6522014-04-24 19:46:49 +0900491/*
492 * extcon_dev_allocate() - Allocate the memory of extcon device.
Chanwoo Choi2a9de9c2015-04-24 19:16:05 +0900493 * @supported_cable: Array of supported extcon ending with EXTCON_NONE.
Chanwoo Choia9af6522014-04-24 19:46:49 +0900494 * If supported_cable is NULL, cable name related APIs
495 * are disabled.
496 *
497 * This function allocates the memory for extcon device without allocating
498 * memory in each extcon provider driver and initialize default setting for
499 * extcon device.
500 *
501 * Return the pointer of extcon device if success or ERR_PTR(err) if fail
502 */
Chanwoo Choi73b6ecd2015-06-12 11:10:06 +0900503struct extcon_dev *extcon_dev_allocate(const unsigned int *supported_cable)
Chanwoo Choia9af6522014-04-24 19:46:49 +0900504{
505 struct extcon_dev *edev;
506
Chanwoo Choi7eae43a2015-06-21 23:48:36 +0900507 if (!supported_cable)
508 return ERR_PTR(-EINVAL);
509
Chanwoo Choia9af6522014-04-24 19:46:49 +0900510 edev = kzalloc(sizeof(*edev), GFP_KERNEL);
511 if (!edev)
512 return ERR_PTR(-ENOMEM);
513
514 edev->max_supported = 0;
515 edev->supported_cable = supported_cable;
516
517 return edev;
518}
519
520/*
521 * extcon_dev_free() - Free the memory of extcon device.
522 * @edev: the extcon device to free
523 */
524void extcon_dev_free(struct extcon_dev *edev)
525{
526 kfree(edev);
527}
528EXPORT_SYMBOL_GPL(extcon_dev_free);
529
MyungJoo Hamde55d872012-04-20 14:16:22 +0900530/**
531 * extcon_dev_register() - Register a new extcon device
532 * @edev : the new extcon device (should be allocated before calling)
MyungJoo Hamde55d872012-04-20 14:16:22 +0900533 *
534 * Among the members of edev struct, please set the "user initializing data"
535 * in any case and set the "optional callbacks" if required. However, please
536 * do not set the values of "internal data", which are initialized by
537 * this function.
538 */
Chanwoo Choi42d7d752013-09-27 09:20:26 +0900539int extcon_dev_register(struct extcon_dev *edev)
MyungJoo Hamde55d872012-04-20 14:16:22 +0900540{
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900541 int ret, index = 0;
Chanwoo Choi71c3ffa2015-04-15 15:02:01 +0900542 static atomic_t edev_no = ATOMIC_INIT(-1);
MyungJoo Hamde55d872012-04-20 14:16:22 +0900543
544 if (!extcon_class) {
545 ret = create_extcon_class();
546 if (ret < 0)
547 return ret;
548 }
549
Chanwoo Choi7eae43a2015-06-21 23:48:36 +0900550 if (!edev || !edev->supported_cable)
Chanwoo Choi2a9de9c2015-04-24 19:16:05 +0900551 return -EINVAL;
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900552
Chanwoo Choi2a9de9c2015-04-24 19:16:05 +0900553 for (; edev->supported_cable[index] != EXTCON_NONE; index++);
554
555 edev->max_supported = index;
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900556 if (index > SUPPORTED_CABLE_MAX) {
Chanwoo Choi2a9de9c2015-04-24 19:16:05 +0900557 dev_err(&edev->dev,
558 "exceed the maximum number of supported cables\n");
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900559 return -EINVAL;
560 }
561
Chanwoo Choidae61652013-09-27 09:19:40 +0900562 edev->dev.class = extcon_class;
563 edev->dev.release = extcon_dev_release;
MyungJoo Hamde55d872012-04-20 14:16:22 +0900564
Chanwoo Choi71c3ffa2015-04-15 15:02:01 +0900565 edev->name = dev_name(edev->dev.parent);
Chanwoo Choi42d7d752013-09-27 09:20:26 +0900566 if (IS_ERR_OR_NULL(edev->name)) {
567 dev_err(&edev->dev,
568 "extcon device name is null\n");
569 return -EINVAL;
570 }
Chanwoo Choi71c3ffa2015-04-15 15:02:01 +0900571 dev_set_name(&edev->dev, "extcon%lu",
572 (unsigned long)atomic_inc_return(&edev_no));
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900573
574 if (edev->max_supported) {
575 char buf[10];
576 char *str;
577 struct extcon_cable *cable;
578
579 edev->cables = kzalloc(sizeof(struct extcon_cable) *
580 edev->max_supported, GFP_KERNEL);
581 if (!edev->cables) {
582 ret = -ENOMEM;
583 goto err_sysfs_alloc;
584 }
585 for (index = 0; index < edev->max_supported; index++) {
586 cable = &edev->cables[index];
587
588 snprintf(buf, 10, "cable.%d", index);
589 str = kzalloc(sizeof(char) * (strlen(buf) + 1),
590 GFP_KERNEL);
591 if (!str) {
592 for (index--; index >= 0; index--) {
593 cable = &edev->cables[index];
594 kfree(cable->attr_g.name);
595 }
596 ret = -ENOMEM;
597
598 goto err_alloc_cables;
599 }
600 strcpy(str, buf);
601
602 cable->edev = edev;
603 cable->cable_index = index;
604 cable->attrs[0] = &cable->attr_name.attr;
605 cable->attrs[1] = &cable->attr_state.attr;
606 cable->attrs[2] = NULL;
607 cable->attr_g.name = str;
608 cable->attr_g.attrs = cable->attrs;
609
Mark Brown9baf3222012-08-16 20:03:21 +0100610 sysfs_attr_init(&cable->attr_name.attr);
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900611 cable->attr_name.attr.name = "name";
612 cable->attr_name.attr.mode = 0444;
613 cable->attr_name.show = cable_name_show;
614
Mark Brown9baf3222012-08-16 20:03:21 +0100615 sysfs_attr_init(&cable->attr_state.attr);
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900616 cable->attr_state.attr.name = "state";
Chanwoo Choiea9dd9d2013-05-22 19:31:59 +0900617 cable->attr_state.attr.mode = 0444;
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900618 cable->attr_state.show = cable_state_show;
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900619 }
620 }
621
MyungJoo Hambde68e62012-04-20 14:16:26 +0900622 if (edev->max_supported && edev->mutually_exclusive) {
623 char buf[80];
624 char *name;
625
626 /* Count the size of mutually_exclusive array */
627 for (index = 0; edev->mutually_exclusive[index]; index++)
628 ;
629
630 edev->attrs_muex = kzalloc(sizeof(struct attribute *) *
631 (index + 1), GFP_KERNEL);
632 if (!edev->attrs_muex) {
633 ret = -ENOMEM;
634 goto err_muex;
635 }
636
637 edev->d_attrs_muex = kzalloc(sizeof(struct device_attribute) *
638 index, GFP_KERNEL);
639 if (!edev->d_attrs_muex) {
640 ret = -ENOMEM;
641 kfree(edev->attrs_muex);
642 goto err_muex;
643 }
644
645 for (index = 0; edev->mutually_exclusive[index]; index++) {
646 sprintf(buf, "0x%x", edev->mutually_exclusive[index]);
647 name = kzalloc(sizeof(char) * (strlen(buf) + 1),
648 GFP_KERNEL);
649 if (!name) {
650 for (index--; index >= 0; index--) {
651 kfree(edev->d_attrs_muex[index].attr.
652 name);
653 }
654 kfree(edev->d_attrs_muex);
655 kfree(edev->attrs_muex);
656 ret = -ENOMEM;
657 goto err_muex;
658 }
659 strcpy(name, buf);
Mark Brown9baf3222012-08-16 20:03:21 +0100660 sysfs_attr_init(&edev->d_attrs_muex[index].attr);
MyungJoo Hambde68e62012-04-20 14:16:26 +0900661 edev->d_attrs_muex[index].attr.name = name;
662 edev->d_attrs_muex[index].attr.mode = 0000;
663 edev->attrs_muex[index] = &edev->d_attrs_muex[index]
664 .attr;
665 }
666 edev->attr_g_muex.name = muex_name;
667 edev->attr_g_muex.attrs = edev->attrs_muex;
668
669 }
670
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900671 if (edev->max_supported) {
672 edev->extcon_dev_type.groups =
673 kzalloc(sizeof(struct attribute_group *) *
MyungJoo Hambde68e62012-04-20 14:16:26 +0900674 (edev->max_supported + 2), GFP_KERNEL);
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900675 if (!edev->extcon_dev_type.groups) {
676 ret = -ENOMEM;
677 goto err_alloc_groups;
678 }
679
Chanwoo Choidae61652013-09-27 09:19:40 +0900680 edev->extcon_dev_type.name = dev_name(&edev->dev);
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900681 edev->extcon_dev_type.release = dummy_sysfs_dev_release;
682
683 for (index = 0; index < edev->max_supported; index++)
684 edev->extcon_dev_type.groups[index] =
685 &edev->cables[index].attr_g;
MyungJoo Hambde68e62012-04-20 14:16:26 +0900686 if (edev->mutually_exclusive)
687 edev->extcon_dev_type.groups[index] =
688 &edev->attr_g_muex;
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900689
Chanwoo Choidae61652013-09-27 09:19:40 +0900690 edev->dev.type = &edev->extcon_dev_type;
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900691 }
692
Chanwoo Choidae61652013-09-27 09:19:40 +0900693 ret = device_register(&edev->dev);
MyungJoo Hamde55d872012-04-20 14:16:22 +0900694 if (ret) {
Chanwoo Choidae61652013-09-27 09:19:40 +0900695 put_device(&edev->dev);
MyungJoo Hamde55d872012-04-20 14:16:22 +0900696 goto err_dev;
697 }
MyungJoo Ham449a2bf2012-04-23 20:19:57 +0900698#if defined(CONFIG_ANDROID)
MyungJoo Hamde55d872012-04-20 14:16:22 +0900699 if (switch_class)
Chanwoo Choidae61652013-09-27 09:19:40 +0900700 ret = class_compat_create_link(switch_class, &edev->dev, NULL);
MyungJoo Ham449a2bf2012-04-23 20:19:57 +0900701#endif /* CONFIG_ANDROID */
MyungJoo Hamde55d872012-04-20 14:16:22 +0900702
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900703 spin_lock_init(&edev->lock);
704
Chanwoo Choi046050f2015-05-19 20:01:12 +0900705 edev->nh = devm_kzalloc(&edev->dev,
706 sizeof(*edev->nh) * edev->max_supported, GFP_KERNEL);
707 if (!edev->nh) {
708 ret = -ENOMEM;
709 goto err_dev;
710 }
711
712 for (index = 0; index < edev->max_supported; index++)
713 RAW_INIT_NOTIFIER_HEAD(&edev->nh[index]);
Donggeun Kim74c5d092012-04-20 14:16:24 +0900714
Chanwoo Choidae61652013-09-27 09:19:40 +0900715 dev_set_drvdata(&edev->dev, edev);
MyungJoo Hamde55d872012-04-20 14:16:22 +0900716 edev->state = 0;
Donggeun Kim74c5d092012-04-20 14:16:24 +0900717
718 mutex_lock(&extcon_dev_list_lock);
719 list_add(&edev->entry, &extcon_dev_list);
720 mutex_unlock(&extcon_dev_list_lock);
721
MyungJoo Hamde55d872012-04-20 14:16:22 +0900722 return 0;
723
724err_dev:
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900725 if (edev->max_supported)
726 kfree(edev->extcon_dev_type.groups);
727err_alloc_groups:
MyungJoo Hambde68e62012-04-20 14:16:26 +0900728 if (edev->max_supported && edev->mutually_exclusive) {
729 for (index = 0; edev->mutually_exclusive[index]; index++)
730 kfree(edev->d_attrs_muex[index].attr.name);
731 kfree(edev->d_attrs_muex);
732 kfree(edev->attrs_muex);
733 }
734err_muex:
MyungJoo Ham806d9dd2012-04-20 14:16:25 +0900735 for (index = 0; index < edev->max_supported; index++)
736 kfree(edev->cables[index].attr_g.name);
737err_alloc_cables:
738 if (edev->max_supported)
739 kfree(edev->cables);
740err_sysfs_alloc:
MyungJoo Hamde55d872012-04-20 14:16:22 +0900741 return ret;
742}
743EXPORT_SYMBOL_GPL(extcon_dev_register);
744
745/**
746 * extcon_dev_unregister() - Unregister the extcon device.
Peter Meerwaldc338bb02012-08-23 09:11:54 +0900747 * @edev: the extcon device instance to be unregistered.
MyungJoo Hamde55d872012-04-20 14:16:22 +0900748 *
749 * Note that this does not call kfree(edev) because edev was not allocated
750 * by this class.
751 */
752void extcon_dev_unregister(struct extcon_dev *edev)
753{
anish kumar57e7cd32012-10-22 09:43:33 +0900754 int index;
755
Chanwoo Choi7eae43a2015-06-21 23:48:36 +0900756 if (!edev)
757 return;
758
anish kumar57e7cd32012-10-22 09:43:33 +0900759 mutex_lock(&extcon_dev_list_lock);
760 list_del(&edev->entry);
761 mutex_unlock(&extcon_dev_list_lock);
762
Chanwoo Choidae61652013-09-27 09:19:40 +0900763 if (IS_ERR_OR_NULL(get_device(&edev->dev))) {
764 dev_err(&edev->dev, "Failed to unregister extcon_dev (%s)\n",
765 dev_name(&edev->dev));
anish kumar57e7cd32012-10-22 09:43:33 +0900766 return;
767 }
768
Wang, Xiaoming7585ca02013-11-01 18:48:14 -0400769 device_unregister(&edev->dev);
770
anish kumar57e7cd32012-10-22 09:43:33 +0900771 if (edev->mutually_exclusive && edev->max_supported) {
772 for (index = 0; edev->mutually_exclusive[index];
773 index++)
774 kfree(edev->d_attrs_muex[index].attr.name);
775 kfree(edev->d_attrs_muex);
776 kfree(edev->attrs_muex);
777 }
778
779 for (index = 0; index < edev->max_supported; index++)
780 kfree(edev->cables[index].attr_g.name);
781
782 if (edev->max_supported) {
783 kfree(edev->extcon_dev_type.groups);
784 kfree(edev->cables);
785 }
786
787#if defined(CONFIG_ANDROID)
788 if (switch_class)
Chanwoo Choidae61652013-09-27 09:19:40 +0900789 class_compat_remove_link(switch_class, &edev->dev, NULL);
anish kumar57e7cd32012-10-22 09:43:33 +0900790#endif
Chanwoo Choidae61652013-09-27 09:19:40 +0900791 put_device(&edev->dev);
MyungJoo Hamde55d872012-04-20 14:16:22 +0900792}
793EXPORT_SYMBOL_GPL(extcon_dev_unregister);
794
Chanwoo Choi1ad94ff2014-03-18 19:55:46 +0900795#ifdef CONFIG_OF
796/*
797 * extcon_get_edev_by_phandle - Get the extcon device from devicetree
798 * @dev - instance to the given device
799 * @index - index into list of extcon_dev
800 *
801 * return the instance of extcon device
802 */
803struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index)
804{
805 struct device_node *node;
806 struct extcon_dev *edev;
807
Chanwoo Choi7eae43a2015-06-21 23:48:36 +0900808 if (!dev)
809 return ERR_PTR(-EINVAL);
810
Chanwoo Choi1ad94ff2014-03-18 19:55:46 +0900811 if (!dev->of_node) {
Stephen Boyde8752b72016-07-05 11:57:05 -0700812 dev_dbg(dev, "device does not have a device node entry\n");
Chanwoo Choi1ad94ff2014-03-18 19:55:46 +0900813 return ERR_PTR(-EINVAL);
814 }
815
816 node = of_parse_phandle(dev->of_node, "extcon", index);
817 if (!node) {
Stephen Boyde8752b72016-07-05 11:57:05 -0700818 dev_dbg(dev, "failed to get phandle in %s node\n",
Chanwoo Choi1ad94ff2014-03-18 19:55:46 +0900819 dev->of_node->full_name);
820 return ERR_PTR(-ENODEV);
821 }
822
Tomasz Figaf841afb2014-10-16 15:11:44 +0200823 mutex_lock(&extcon_dev_list_lock);
824 list_for_each_entry(edev, &extcon_dev_list, entry) {
825 if (edev->dev.parent && edev->dev.parent->of_node == node) {
826 mutex_unlock(&extcon_dev_list_lock);
Peter Chen5d5c4c12016-07-01 18:41:55 +0900827 of_node_put(node);
Tomasz Figaf841afb2014-10-16 15:11:44 +0200828 return edev;
829 }
Chanwoo Choi1ad94ff2014-03-18 19:55:46 +0900830 }
Tomasz Figaf841afb2014-10-16 15:11:44 +0200831 mutex_unlock(&extcon_dev_list_lock);
Peter Chen5d5c4c12016-07-01 18:41:55 +0900832 of_node_put(node);
Chanwoo Choi1ad94ff2014-03-18 19:55:46 +0900833
Tomasz Figaf841afb2014-10-16 15:11:44 +0200834 return ERR_PTR(-EPROBE_DEFER);
Chanwoo Choi1ad94ff2014-03-18 19:55:46 +0900835}
836#else
837struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index)
838{
839 return ERR_PTR(-ENOSYS);
840}
841#endif /* CONFIG_OF */
842EXPORT_SYMBOL_GPL(extcon_get_edev_by_phandle);
843
Chanwoo Choi707d7552015-04-15 13:57:51 +0900844/**
845 * extcon_get_edev_name() - Get the name of the extcon device.
846 * @edev: the extcon device
847 */
848const char *extcon_get_edev_name(struct extcon_dev *edev)
849{
850 return !edev ? NULL : edev->name;
851}
852
MyungJoo Hamde55d872012-04-20 14:16:22 +0900853static int __init extcon_class_init(void)
854{
855 return create_extcon_class();
856}
857module_init(extcon_class_init);
858
859static void __exit extcon_class_exit(void)
860{
Peter Huewe0dc77b62012-09-24 15:32:31 +0900861#if defined(CONFIG_ANDROID)
862 class_compat_unregister(switch_class);
863#endif
MyungJoo Hamde55d872012-04-20 14:16:22 +0900864 class_destroy(extcon_class);
865}
866module_exit(extcon_class_exit);
867
Chanwoo Choi2a9de9c2015-04-24 19:16:05 +0900868MODULE_AUTHOR("Chanwoo Choi <cw00.choi@samsung.com>");
MyungJoo Hamde55d872012-04-20 14:16:22 +0900869MODULE_AUTHOR("Mike Lockwood <lockwood@android.com>");
870MODULE_AUTHOR("Donggeun Kim <dg77.kim@samsung.com>");
871MODULE_AUTHOR("MyungJoo Ham <myungjoo.ham@samsung.com>");
872MODULE_DESCRIPTION("External connector (extcon) class driver");
873MODULE_LICENSE("GPL");