summaryrefslogtreecommitdiff
path: root/include/linux/extcon.h
diff options
context:
space:
mode:
authorDonggeun Kim <dg77.kim@samsung.com>2012-04-20 14:16:24 +0900
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-04-20 09:23:09 -0700
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 @@
#ifndef __LINUX_EXTCON_H__
#define __LINUX_EXTCON_H__
+#include <linux/notifier.h>
/**
* struct extcon_dev - An extcon device represents one external connector.
* @name The name of this extcon device. Parent device name is used
@@ -34,6 +35,9 @@
* @dev Device of this extcon. Do not provide at register-time.
* @state Attach/detach state of this extcon. Do not provide at
* register-time
+ * @nh Notifier for the state change events from this extcon
+ * @entry To support list of extcon devices so that uses can search
+ * for extcon devices based on the extcon name.
*
* In most cases, users only need to provide "User initializing data" of
* this struct when registering an extcon. In some exceptional cases,
@@ -51,11 +55,19 @@ struct extcon_dev {
/* --- Internal data. Please do not set. --- */
struct device *dev;
u32 state;
+ struct raw_notifier_head nh;
+ struct list_head entry;
};
#if IS_ENABLED(CONFIG_EXTCON)
+
+/*
+ * Following APIs are for notifiers or configurations.
+ * Notifiers are the external port and connection devices.
+ */
extern int extcon_dev_register(struct extcon_dev *edev, struct device *dev);
extern void extcon_dev_unregister(struct extcon_dev *edev);
+extern struct extcon_dev *extcon_get_extcon_dev(const char *extcon_name);
static inline u32 extcon_get_state(struct extcon_dev *edev)
{
@@ -63,6 +75,15 @@ static inline u32 extcon_get_state(struct extcon_dev *edev)
}
extern void extcon_set_state(struct extcon_dev *edev, u32 state);
+
+/*
+ * Following APIs are to monitor every action of a notifier.
+ * Registerer gets notified for every external port of a connection device.
+ */
+extern int extcon_register_notifier(struct extcon_dev *edev,
+ struct notifier_block *nb);
+extern int extcon_unregister_notifier(struct extcon_dev *edev,
+ struct notifier_block *nb);
#else /* CONFIG_EXTCON */
static inline int extcon_dev_register(struct extcon_dev *edev,
struct device *dev)
@@ -78,5 +99,22 @@ static inline u32 extcon_get_state(struct extcon_dev *edev)
}
static inline void extcon_set_state(struct extcon_dev *edev, u32 state) { }
+static inline struct extcon_dev *extcon_get_extcon_dev(const char *extcon_name)
+{
+ return NULL;
+}
+
+static inline int extcon_register_notifier(struct extcon_dev *edev,
+ struct notifier_block *nb)
+{
+ return 0;
+}
+
+static inline int extcon_unregister_notifier(struct extcon_dev *edev,
+ struct notifier_block *nb)
+{
+ return 0;
+}
+
#endif /* CONFIG_EXTCON */
#endif /* __LINUX_EXTCON_H__ */