From ea6eb0f3e56e36037861fc803c67236cde37ad88 Mon Sep 17 00:00:00 2001 From: Mayank Rana Date: Thu, 6 Jul 2017 16:42:06 -0700 Subject: [PATCH] ANDROID: GKI: extcon: Add extcon_register_blocking_notifier API. This change adds the extcon_register_blocking_notifier API to register blocking notifier calls for blocking functionality using extcon framework. Bug: 150893404 Test: make Signed-off-by: Mayank Rana Signed-off-by: Jack Pham Change-Id: I28d56bd898beea1da1f8c315602cc404e8bc326f (cherry picked from commit 9dce266c7ad8f075f3b7b13cbbb99e058e57d30b) [hridya: commit modified to only include ABI diff]. Signed-off-by: Hridya Valsaraju --- drivers/extcon/extcon.c | 16 ++++++++++++++++ drivers/extcon/extcon.h | 1 + include/linux/extcon.h | 9 +++++++++ 3 files changed, 26 insertions(+) diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c index b9d27c8fe57e..8cbb2ca8340f 100644 --- a/drivers/extcon/extcon.c +++ b/drivers/extcon/extcon.c @@ -925,6 +925,22 @@ 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); + /** * extcon_unregister_notifier() - Unregister a notifier block from the extcon. * @edev: the extcon device diff --git a/drivers/extcon/extcon.h b/drivers/extcon/extcon.h index 93b5e0306966..5b200dd37e43 100644 --- a/drivers/extcon/extcon.h +++ b/drivers/extcon/extcon.h @@ -48,6 +48,7 @@ struct extcon_dev { struct device dev; struct raw_notifier_head nh_all; 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 */ diff --git a/include/linux/extcon.h b/include/linux/extcon.h index 7f033b1ea568..d91dd704a729 100644 --- a/include/linux/extcon.h +++ b/include/linux/extcon.h @@ -208,6 +208,8 @@ 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 devm_extcon_register_notifier(struct device *dev, struct extcon_dev *edev, unsigned int id, struct notifier_block *nb); @@ -268,6 +270,13 @@ 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 devm_extcon_register_notifier(struct device *dev, struct extcon_dev *edev, unsigned int id, struct notifier_block *nb)