diff options
author | MyungJoo Ham <myungjoo.ham@samsung.com> | 2012-04-20 01:16:26 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-04-20 12:24:03 -0400 |
commit | bde68e60b18208978c50c6fb9bdf29826d2887f3 (patch) | |
tree | 62b48807d48c2454c374bede680c9e9c6cf71a0d /include/linux/extcon.h | |
parent | 806d9dd71ff52ef09764585baaeec23afbb98560 (diff) |
Extcon: support mutually exclusive relation between cables.
There could be cables that t recannot be attaches simulatenously. Extcon
device drivers may express such information via mutually_exclusive in
struct extcon_dev.
For example, for an extcon device with 16 cables (bits 0 to 15 are
available), if mutually_exclusive = { 0x7, 0xC0, 0x81, 0 }, then, the
following attachments are prohibitted.
{0, 1}
{0, 2}
{1, 2}
{6, 7}
{0, 7}
and every attachment set that are superset of one of the above.
For the detail, please refer to linux/include/linux/extcon.h.
The concept is suggested by NeilBrown <neilb@suse.de>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
--
Changes from V5:
- Updated sysfs format
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/extcon.h')
-rw-r--r-- | include/linux/extcon.h | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/include/linux/extcon.h b/include/linux/extcon.h index 20e24b32a17d..6495f7731400 100644 --- a/include/linux/extcon.h +++ b/include/linux/extcon.h | |||
@@ -78,6 +78,14 @@ struct extcon_cable; | |||
78 | * @supported_cable Array of supported cable name ending with NULL. | 78 | * @supported_cable Array of supported cable name ending with NULL. |
79 | * If supported_cable is NULL, cable name related APIs | 79 | * If supported_cable is NULL, cable name related APIs |
80 | * are disabled. | 80 | * are disabled. |
81 | * @mutually_exclusive Array of mutually exclusive set of cables that cannot | ||
82 | * be attached simultaneously. The array should be | ||
83 | * ending with NULL or be NULL (no mutually exclusive | ||
84 | * cables). For example, if it is { 0x7, 0x30, 0}, then, | ||
85 | * {0, 1}, {0, 1, 2}, {0, 2}, {1, 2}, or {4, 5} cannot | ||
86 | * be attached simulataneously. {0x7, 0} is equivalent to | ||
87 | * {0x3, 0x6, 0x5, 0}. If it is {0xFFFFFFFF, 0}, there | ||
88 | * can be no simultaneous connections. | ||
81 | * @print_name An optional callback to override the method to print the | 89 | * @print_name An optional callback to override the method to print the |
82 | * name of the extcon device. | 90 | * name of the extcon device. |
83 | * @print_state An optional callback to override the method to print the | 91 | * @print_state An optional callback to override the method to print the |
@@ -103,6 +111,7 @@ struct extcon_dev { | |||
103 | /* --- Optional user initializing data --- */ | 111 | /* --- Optional user initializing data --- */ |
104 | const char *name; | 112 | const char *name; |
105 | const char **supported_cable; | 113 | const char **supported_cable; |
114 | const u32 *mutually_exclusive; | ||
106 | 115 | ||
107 | /* --- Optional callbacks to override class functions --- */ | 116 | /* --- Optional callbacks to override class functions --- */ |
108 | ssize_t (*print_name)(struct extcon_dev *edev, char *buf); | 117 | ssize_t (*print_name)(struct extcon_dev *edev, char *buf); |
@@ -119,6 +128,10 @@ struct extcon_dev { | |||
119 | /* /sys/class/extcon/.../cable.n/... */ | 128 | /* /sys/class/extcon/.../cable.n/... */ |
120 | struct device_type extcon_dev_type; | 129 | struct device_type extcon_dev_type; |
121 | struct extcon_cable *cables; | 130 | struct extcon_cable *cables; |
131 | /* /sys/class/extcon/.../mutually_exclusive/... */ | ||
132 | struct attribute_group attr_g_muex; | ||
133 | struct attribute **attrs_muex; | ||
134 | struct device_attribute *d_attrs_muex; | ||
122 | }; | 135 | }; |
123 | 136 | ||
124 | /** | 137 | /** |
@@ -179,8 +192,8 @@ static inline u32 extcon_get_state(struct extcon_dev *edev) | |||
179 | return edev->state; | 192 | return edev->state; |
180 | } | 193 | } |
181 | 194 | ||
182 | extern void extcon_set_state(struct extcon_dev *edev, u32 state); | 195 | extern int extcon_set_state(struct extcon_dev *edev, u32 state); |
183 | extern void extcon_update_state(struct extcon_dev *edev, u32 mask, u32 state); | 196 | extern int extcon_update_state(struct extcon_dev *edev, u32 mask, u32 state); |
184 | 197 | ||
185 | /* | 198 | /* |
186 | * get/set_cable_state access each bit of the 32b encoded state value. | 199 | * get/set_cable_state access each bit of the 32b encoded state value. |
@@ -235,11 +248,16 @@ static inline u32 extcon_get_state(struct extcon_dev *edev) | |||
235 | return 0; | 248 | return 0; |
236 | } | 249 | } |
237 | 250 | ||
238 | static inline void extcon_set_state(struct extcon_dev *edev, u32 state) { } | 251 | static inline int extcon_set_state(struct extcon_dev *edev, u32 state) |
252 | { | ||
253 | return 0; | ||
254 | } | ||
239 | 255 | ||
240 | static inline void extcon_update_state(struct extcon_dev *edev, u32 mask, | 256 | static inline int extcon_update_state(struct extcon_dev *edev, u32 mask, |
241 | u32 state) | 257 | u32 state) |
242 | { } | 258 | { |
259 | return 0; | ||
260 | } | ||
243 | 261 | ||
244 | static inline int extcon_find_cable_index(struct extcon_dev *edev, | 262 | static inline int extcon_find_cable_index(struct extcon_dev *edev, |
245 | const char *cable_name) | 263 | const char *cable_name) |