aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/extcon.h
diff options
context:
space:
mode:
authorMyungJoo Ham <myungjoo.ham@samsung.com>2012-04-20 01:16:22 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-04-20 12:21:11 -0400
commitde55d8716ac50a356cea736c29bb7db5ac3d0190 (patch)
treed63f799c7859c97ee7089609bd183d28ca63e2bf /include/linux/extcon.h
parent7cd9c9bb57476167e83b7780dbc06d1dd601789d (diff)
Extcon (external connector): import Android's switch class and modify.
External connector class (extcon) is based on and an extension of Android kernel's switch class located at linux/drivers/switch/. This patch provides the before-extension switch class moved to the location where the extcon will be located (linux/drivers/extcon/) and updates to handle class properly. The before-extension class, switch class of Android kernel, commits imported are: switch: switch class and GPIO drivers. (splitted) Author: Mike Lockwood <lockwood@android.com> switch: Use device_create instead of device_create_drvdata. Author: Arve Hjønnevåg <arve@android.com> In this patch, upon the commits of Android kernel, we have added: - Relocated and renamed for extcon. - Comments, module name, and author information are updated - Code clean for successing patches - Bugfix: enabling write access without write functions - Class/device/sysfs create/remove handling - Added comments about uevents - Format changes for extcon_dev_register() to have a parent dev. Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Reviewed-by: Mark Brown <broonie@opensource.wolfsonmicro.com> -- Changes from v7 - Compiler error fixed when it is compiled as a module. - Removed out-of-date Kconfig entry Changes from v6 - Updated comment/strings - Revised "Android-compatible" mode. * Automatically activated if CONFIG_ANDROID && !CONFIG_ANDROID_SWITCH * Creates /sys/class/switch/*, which is a copy of /sys/class/extcon/* Changes from v5 - Split the patch - Style fixes - "Android-compatible" mode is enabled by Kconfig option. Changes from v2 - Updated name_show - Sysfs entries are handled by class itself. - Updated the method to add/remove devices for the class - Comments on uevent send - Able to become a module - Compatible with Android platform Changes from RFC - Renamed to extcon (external connector) from multistate switch - Added a seperated directory (drivers/extcon) - Added kerneldoc comments - Removed unused variables from extcon_gpio.c - Added ABI Documentation. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/extcon.h')
-rw-r--r--include/linux/extcon.h82
1 files changed, 82 insertions, 0 deletions
diff --git a/include/linux/extcon.h b/include/linux/extcon.h
new file mode 100644
index 000000000000..9cb3aaaf67f5
--- /dev/null
+++ b/include/linux/extcon.h
@@ -0,0 +1,82 @@
1/*
2 * External connector (extcon) class driver
3 *
4 * Copyright (C) 2012 Samsung Electronics
5 * Author: Donggeun Kim <dg77.kim@samsung.com>
6 * Author: MyungJoo Ham <myungjoo.ham@samsung.com>
7 *
8 * based on switch class driver
9 * Copyright (C) 2008 Google, Inc.
10 * Author: Mike Lockwood <lockwood@android.com>
11 *
12 * This software is licensed under the terms of the GNU General Public
13 * License version 2, as published by the Free Software Foundation, and
14 * may be copied, distributed, and modified under those terms.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21*/
22
23#ifndef __LINUX_EXTCON_H__
24#define __LINUX_EXTCON_H__
25
26/**
27 * struct extcon_dev - An extcon device represents one external connector.
28 * @name The name of this extcon device. Parent device name is used
29 * if NULL.
30 * @print_name An optional callback to override the method to print the
31 * name of the extcon device.
32 * @print_state An optional callback to override the method to print the
33 * status of the extcon device.
34 * @dev Device of this extcon. Do not provide at register-time.
35 * @state Attach/detach state of this extcon. Do not provide at
36 * register-time
37 *
38 * In most cases, users only need to provide "User initializing data" of
39 * this struct when registering an extcon. In some exceptional cases,
40 * optional callbacks may be needed. However, the values in "internal data"
41 * are overwritten by register function.
42 */
43struct extcon_dev {
44 /* --- Optional user initializing data --- */
45 const char *name;
46
47 /* --- Optional callbacks to override class functions --- */
48 ssize_t (*print_name)(struct extcon_dev *edev, char *buf);
49 ssize_t (*print_state)(struct extcon_dev *edev, char *buf);
50
51 /* --- Internal data. Please do not set. --- */
52 struct device *dev;
53 u32 state;
54};
55
56#if IS_ENABLED(CONFIG_EXTCON)
57extern int extcon_dev_register(struct extcon_dev *edev, struct device *dev);
58extern void extcon_dev_unregister(struct extcon_dev *edev);
59
60static inline u32 extcon_get_state(struct extcon_dev *edev)
61{
62 return edev->state;
63}
64
65extern void extcon_set_state(struct extcon_dev *edev, u32 state);
66#else /* CONFIG_EXTCON */
67static inline int extcon_dev_register(struct extcon_dev *edev,
68 struct device *dev)
69{
70 return 0;
71}
72
73static inline void extcon_dev_unregister(struct extcon_dev *edev) { }
74
75static inline u32 extcon_get_state(struct extcon_dev *edev)
76{
77 return 0;
78}
79
80static inline void extcon_set_state(struct extcon_dev *edev, u32 state) { }
81#endif /* CONFIG_EXTCON */
82#endif /* __LINUX_EXTCON_H__ */