aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/extcon.h
diff options
context:
space:
mode:
authorDonggeun Kim <dg77.kim@samsung.com>2012-04-20 01:16:24 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-04-20 12:23:09 -0400
commit74c5d09bd562edc220d6e076b8f1e118819c178f (patch)
tree65f35b6066fe135405797acc419b4bb6f346e4af /include/linux/extcon.h
parentbe48308a24c7651bf968b561dbd590edb8166d62 (diff)
Extcon: support notification based on the state changes.
State changes of extcon devices have been notified via kobjet_uevent. This patch adds notifier interfaces in order to allow device drivers to get notified easily. Along with notifier interface, extcon_get_extcon_dev() function is added so that device drivers may discover a extcon_dev easily. Signed-off-by: Donggeun Kim <dg77.kim@samsung.com> 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 RFC - Renamed switch to extcon - Bugfix: extcon_dev_unregister() - Bugfix: "edev->dev" is "internal" data. - Added kerneldoc comments. - Reworded comments. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/extcon.h')
-rw-r--r--include/linux/extcon.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/include/linux/extcon.h b/include/linux/extcon.h
index 9cb3aaaf67f5..c9c9afe12b47 100644
--- a/include/linux/extcon.h
+++ b/include/linux/extcon.h
@@ -23,6 +23,7 @@
23#ifndef __LINUX_EXTCON_H__ 23#ifndef __LINUX_EXTCON_H__
24#define __LINUX_EXTCON_H__ 24#define __LINUX_EXTCON_H__
25 25
26#include <linux/notifier.h>
26/** 27/**
27 * struct extcon_dev - An extcon device represents one external connector. 28 * struct extcon_dev - An extcon device represents one external connector.
28 * @name The name of this extcon device. Parent device name is used 29 * @name The name of this extcon device. Parent device name is used
@@ -34,6 +35,9 @@
34 * @dev Device of this extcon. Do not provide at register-time. 35 * @dev Device of this extcon. Do not provide at register-time.
35 * @state Attach/detach state of this extcon. Do not provide at 36 * @state Attach/detach state of this extcon. Do not provide at
36 * register-time 37 * register-time
38 * @nh Notifier for the state change events from this extcon
39 * @entry To support list of extcon devices so that uses can search
40 * for extcon devices based on the extcon name.
37 * 41 *
38 * In most cases, users only need to provide "User initializing data" of 42 * In most cases, users only need to provide "User initializing data" of
39 * this struct when registering an extcon. In some exceptional cases, 43 * this struct when registering an extcon. In some exceptional cases,
@@ -51,11 +55,19 @@ struct extcon_dev {
51 /* --- Internal data. Please do not set. --- */ 55 /* --- Internal data. Please do not set. --- */
52 struct device *dev; 56 struct device *dev;
53 u32 state; 57 u32 state;
58 struct raw_notifier_head nh;
59 struct list_head entry;
54}; 60};
55 61
56#if IS_ENABLED(CONFIG_EXTCON) 62#if IS_ENABLED(CONFIG_EXTCON)
63
64/*
65 * Following APIs are for notifiers or configurations.
66 * Notifiers are the external port and connection devices.
67 */
57extern int extcon_dev_register(struct extcon_dev *edev, struct device *dev); 68extern int extcon_dev_register(struct extcon_dev *edev, struct device *dev);
58extern void extcon_dev_unregister(struct extcon_dev *edev); 69extern void extcon_dev_unregister(struct extcon_dev *edev);
70extern struct extcon_dev *extcon_get_extcon_dev(const char *extcon_name);
59 71
60static inline u32 extcon_get_state(struct extcon_dev *edev) 72static inline u32 extcon_get_state(struct extcon_dev *edev)
61{ 73{
@@ -63,6 +75,15 @@ static inline u32 extcon_get_state(struct extcon_dev *edev)
63} 75}
64 76
65extern void extcon_set_state(struct extcon_dev *edev, u32 state); 77extern void extcon_set_state(struct extcon_dev *edev, u32 state);
78
79/*
80 * Following APIs are to monitor every action of a notifier.
81 * Registerer gets notified for every external port of a connection device.
82 */
83extern int extcon_register_notifier(struct extcon_dev *edev,
84 struct notifier_block *nb);
85extern int extcon_unregister_notifier(struct extcon_dev *edev,
86 struct notifier_block *nb);
66#else /* CONFIG_EXTCON */ 87#else /* CONFIG_EXTCON */
67static inline int extcon_dev_register(struct extcon_dev *edev, 88static inline int extcon_dev_register(struct extcon_dev *edev,
68 struct device *dev) 89 struct device *dev)
@@ -78,5 +99,22 @@ static inline u32 extcon_get_state(struct extcon_dev *edev)
78} 99}
79 100
80static inline void extcon_set_state(struct extcon_dev *edev, u32 state) { } 101static inline void extcon_set_state(struct extcon_dev *edev, u32 state) { }
102static inline struct extcon_dev *extcon_get_extcon_dev(const char *extcon_name)
103{
104 return NULL;
105}
106
107static inline int extcon_register_notifier(struct extcon_dev *edev,
108 struct notifier_block *nb)
109{
110 return 0;
111}
112
113static inline int extcon_unregister_notifier(struct extcon_dev *edev,
114 struct notifier_block *nb)
115{
116 return 0;
117}
118
81#endif /* CONFIG_EXTCON */ 119#endif /* CONFIG_EXTCON */
82#endif /* __LINUX_EXTCON_H__ */ 120#endif /* __LINUX_EXTCON_H__ */