From 1111244ff4493448c0ee66e814e20c6e81d3b93d Mon Sep 17 00:00:00 2001 From: Sangjung Woo Date: Mon, 21 Apr 2014 19:10:08 +0900 Subject: extcon: Add resource-managed extcon register function Add resource-managed extcon device register function for convenience. For example, if a extcon device is attached with new devm_extcon_dev_register(), that extcon device is automatically unregistered on driver detach. Signed-off-by: Sangjung Woo [Fix bug about devm_extcon_dev_match/release() and code clean by Chanwoo Choi] Signed-off-by: Chanwoo Choi --- include/linux/extcon.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'include/linux/extcon.h') diff --git a/include/linux/extcon.h b/include/linux/extcon.h index f488145bb2d4..548447be2d8f 100644 --- a/include/linux/extcon.h +++ b/include/linux/extcon.h @@ -185,6 +185,10 @@ struct extcon_specific_cable_nb { */ extern int extcon_dev_register(struct extcon_dev *edev); extern void extcon_dev_unregister(struct extcon_dev *edev); +extern int devm_extcon_dev_register(struct device *dev, + struct extcon_dev *edev); +extern void devm_extcon_dev_unregister(struct device *dev, + struct extcon_dev *edev); extern struct extcon_dev *extcon_get_extcon_dev(const char *extcon_name); /* @@ -254,6 +258,15 @@ static inline int extcon_dev_register(struct extcon_dev *edev) static inline void extcon_dev_unregister(struct extcon_dev *edev) { } +static inline int devm_extcon_dev_register(struct device *dev, + struct extcon_dev *edev) +{ + return -EINVAL; +} + +static inline void devm_extcon_dev_unregister(struct device *dev, + struct extcon_dev *edev) { } + static inline u32 extcon_get_state(struct extcon_dev *edev) { return 0; -- cgit