ANDROID: GKI: extcon: Fix Add usage of blocking notifier chain
The previous partial cherry-pick commitea6eb0f3e5
missed out some code that's needed for functionality. So, pick that up too. Change-Id: I0e8e3b29d169ca833f85e42d2df98dd8380cbf46 Signed-off-by: Mayank Rana <mrana@codeaurora.org> Signed-off-by: Jack Pham <jackp@codeaurora.org> Bug: 150893404 (cherry picked from commit9dce266c7a
) Signed-off-by: Saravana Kannan <saravanak@google.com>
This commit is contained in:
parent
77379e5ac1
commit
b1605321a5
2 changed files with 49 additions and 0 deletions
|
@ -487,6 +487,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 an external connector.
|
||||
* @edev: the extcon device
|
||||
|
@ -941,6 +956,22 @@ int extcon_register_blocking_notifier(struct extcon_dev *edev, unsigned int id,
|
|||
}
|
||||
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 notifier block from the extcon.
|
||||
* @edev: the extcon device
|
||||
|
@ -1275,6 +1306,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]);
|
||||
|
||||
|
|
|
@ -215,6 +215,8 @@ 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);
|
||||
|
@ -244,6 +246,8 @@ extern struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev,
|
|||
/* Following API get the name 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_get_state(struct extcon_dev *edev, unsigned int id)
|
||||
{
|
||||
|
@ -282,6 +286,13 @@ static inline int extcon_register_blocking_notifier(struct extcon_dev *edev,
|
|||
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…
Reference in a new issue