Loading drivers/extcon/extcon.c +54 −0 Original line number Diff line number Diff line Loading @@ -482,6 +482,21 @@ int extcon_sync(struct extcon_dev *edev, unsigned int id) } EXPORT_SYMBOL_GPL(extcon_sync); int extcon_blocking_sync(struct extcon_dev *edev, unsigned int id, bool val) { int index; if (!edev) return -EINVAL; index = find_cable_index_by_id(edev, id); if (index < 0) return index; return blocking_notifier_call_chain(&edev->bnh[index], val, edev); } EXPORT_SYMBOL(extcon_blocking_sync); /** * extcon_get_state() - Get the state of a external connector. * @edev: the extcon device that has the cable. Loading Loading @@ -940,6 +955,38 @@ int extcon_register_notifier(struct extcon_dev *edev, unsigned int id, } EXPORT_SYMBOL_GPL(extcon_register_notifier); int extcon_register_blocking_notifier(struct extcon_dev *edev, unsigned int id, struct notifier_block *nb) { int idx = -EINVAL; if (!edev || !nb) return -EINVAL; idx = find_cable_index_by_id(edev, id); if (idx < 0) return idx; return blocking_notifier_chain_register(&edev->bnh[idx], nb); } EXPORT_SYMBOL(extcon_register_blocking_notifier); int extcon_unregister_blocking_notifier(struct extcon_dev *edev, unsigned int id, struct notifier_block *nb) { int idx; if (!edev || !nb) return -EINVAL; idx = find_cable_index_by_id(edev, id); if (idx < 0) return idx; return blocking_notifier_chain_unregister(&edev->bnh[idx], nb); } EXPORT_SYMBOL(extcon_unregister_blocking_notifier); /** * extcon_unregister_notifier() - Unregister a notifiee from the extcon device. * @edev: the extcon device that has the external connecotr. Loading Loading @@ -1222,6 +1269,13 @@ int extcon_dev_register(struct extcon_dev *edev) goto err_dev; } edev->bnh = devm_kzalloc(&edev->dev, sizeof(*edev->bnh) * edev->max_supported, GFP_KERNEL); if (!edev->bnh) { ret = -ENOMEM; goto err_dev; } for (index = 0; index < edev->max_supported; index++) RAW_INIT_NOTIFIER_HEAD(&edev->nh[index]); Loading include/linux/extcon.h +21 −1 Original line number Diff line number Diff line Loading @@ -202,6 +202,7 @@ struct extcon_dev { /* Internal data. Please do not set. */ struct device dev; struct raw_notifier_head *nh; struct blocking_notifier_head *bnh; struct list_head entry; int max_supported; spinlock_t lock; /* could be called by irq handler */ Loading Loading @@ -289,6 +290,10 @@ extern int extcon_register_notifier(struct extcon_dev *edev, unsigned int id, struct notifier_block *nb); extern int extcon_unregister_notifier(struct extcon_dev *edev, unsigned int id, struct notifier_block *nb); extern int extcon_register_blocking_notifier(struct extcon_dev *edev, unsigned int id, struct notifier_block *nb); extern int extcon_unregister_blocking_notifier(struct extcon_dev *edev, unsigned int id, struct notifier_block *nb); extern int devm_extcon_register_notifier(struct device *dev, struct extcon_dev *edev, unsigned int id, struct notifier_block *nb); Loading @@ -306,7 +311,8 @@ extern struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, /* Following API to get information of extcon device */ extern const char *extcon_get_edev_name(struct extcon_dev *edev); extern int extcon_blocking_sync(struct extcon_dev *edev, unsigned int id, bool val); #else /* CONFIG_EXTCON */ static inline int extcon_dev_register(struct extcon_dev *edev) { Loading Loading @@ -413,6 +419,20 @@ static inline int extcon_unregister_notifier(struct extcon_dev *edev, return 0; } static inline int extcon_register_blocking_notifier(struct extcon_dev *edev, unsigned int id, struct notifier_block *nb) { return 0; } static inline int extcon_unregister_blocking_notifier(struct extcon_dev *edev, unsigned int id, struct notifier_block *nb) { return 0; } static inline int devm_extcon_register_notifier(struct device *dev, struct extcon_dev *edev, unsigned int id, struct notifier_block *nb) Loading Loading
drivers/extcon/extcon.c +54 −0 Original line number Diff line number Diff line Loading @@ -482,6 +482,21 @@ int extcon_sync(struct extcon_dev *edev, unsigned int id) } EXPORT_SYMBOL_GPL(extcon_sync); int extcon_blocking_sync(struct extcon_dev *edev, unsigned int id, bool val) { int index; if (!edev) return -EINVAL; index = find_cable_index_by_id(edev, id); if (index < 0) return index; return blocking_notifier_call_chain(&edev->bnh[index], val, edev); } EXPORT_SYMBOL(extcon_blocking_sync); /** * extcon_get_state() - Get the state of a external connector. * @edev: the extcon device that has the cable. Loading Loading @@ -940,6 +955,38 @@ int extcon_register_notifier(struct extcon_dev *edev, unsigned int id, } EXPORT_SYMBOL_GPL(extcon_register_notifier); int extcon_register_blocking_notifier(struct extcon_dev *edev, unsigned int id, struct notifier_block *nb) { int idx = -EINVAL; if (!edev || !nb) return -EINVAL; idx = find_cable_index_by_id(edev, id); if (idx < 0) return idx; return blocking_notifier_chain_register(&edev->bnh[idx], nb); } EXPORT_SYMBOL(extcon_register_blocking_notifier); int extcon_unregister_blocking_notifier(struct extcon_dev *edev, unsigned int id, struct notifier_block *nb) { int idx; if (!edev || !nb) return -EINVAL; idx = find_cable_index_by_id(edev, id); if (idx < 0) return idx; return blocking_notifier_chain_unregister(&edev->bnh[idx], nb); } EXPORT_SYMBOL(extcon_unregister_blocking_notifier); /** * extcon_unregister_notifier() - Unregister a notifiee from the extcon device. * @edev: the extcon device that has the external connecotr. Loading Loading @@ -1222,6 +1269,13 @@ int extcon_dev_register(struct extcon_dev *edev) goto err_dev; } edev->bnh = devm_kzalloc(&edev->dev, sizeof(*edev->bnh) * edev->max_supported, GFP_KERNEL); if (!edev->bnh) { ret = -ENOMEM; goto err_dev; } for (index = 0; index < edev->max_supported; index++) RAW_INIT_NOTIFIER_HEAD(&edev->nh[index]); Loading
include/linux/extcon.h +21 −1 Original line number Diff line number Diff line Loading @@ -202,6 +202,7 @@ struct extcon_dev { /* Internal data. Please do not set. */ struct device dev; struct raw_notifier_head *nh; struct blocking_notifier_head *bnh; struct list_head entry; int max_supported; spinlock_t lock; /* could be called by irq handler */ Loading Loading @@ -289,6 +290,10 @@ extern int extcon_register_notifier(struct extcon_dev *edev, unsigned int id, struct notifier_block *nb); extern int extcon_unregister_notifier(struct extcon_dev *edev, unsigned int id, struct notifier_block *nb); extern int extcon_register_blocking_notifier(struct extcon_dev *edev, unsigned int id, struct notifier_block *nb); extern int extcon_unregister_blocking_notifier(struct extcon_dev *edev, unsigned int id, struct notifier_block *nb); extern int devm_extcon_register_notifier(struct device *dev, struct extcon_dev *edev, unsigned int id, struct notifier_block *nb); Loading @@ -306,7 +311,8 @@ extern struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, /* Following API to get information of extcon device */ extern const char *extcon_get_edev_name(struct extcon_dev *edev); extern int extcon_blocking_sync(struct extcon_dev *edev, unsigned int id, bool val); #else /* CONFIG_EXTCON */ static inline int extcon_dev_register(struct extcon_dev *edev) { Loading Loading @@ -413,6 +419,20 @@ static inline int extcon_unregister_notifier(struct extcon_dev *edev, return 0; } static inline int extcon_register_blocking_notifier(struct extcon_dev *edev, unsigned int id, struct notifier_block *nb) { return 0; } static inline int extcon_unregister_blocking_notifier(struct extcon_dev *edev, unsigned int id, struct notifier_block *nb) { return 0; } static inline int devm_extcon_register_notifier(struct device *dev, struct extcon_dev *edev, unsigned int id, struct notifier_block *nb) Loading