mirror of
https://github.com/followmsi/android_kernel_google_msm.git
synced 2024-11-06 23:17:41 +00:00
extcon : register for cable interest by cable name
There are some scnearios where a driver/framework needs to register interest for a particular cable without specifying the extcon device name. One such scenario is charger notifications. The platform will have charger cabel which will be bound to any extcon device. It's not mandatory for the charger driver to know which extcon device it should use. This patch enables the support for registering interest for a cable just by cable name wihtout specifying the extcon device name Signed-off-by: Jenny TC <jenny.tc@intel.com> Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com> Tested-by: Chanwoo Choi <cw00.choi@samsung.com> -- Kernel-doc comment added by MyungJoo Ham
This commit is contained in:
parent
44b7bccf7c
commit
4f2de3bf17
1 changed files with 37 additions and 13 deletions
|
@ -441,6 +441,8 @@ static int _call_per_cable(struct notifier_block *nb, unsigned long val,
|
||||||
* extcon device.
|
* extcon device.
|
||||||
* @obj: an empty extcon_specific_cable_nb object to be returned.
|
* @obj: an empty extcon_specific_cable_nb object to be returned.
|
||||||
* @extcon_name: the name of extcon device.
|
* @extcon_name: the name of extcon device.
|
||||||
|
* if NULL, extcon_register_interest will register
|
||||||
|
* every cable with the target cable_name given.
|
||||||
* @cable_name: the target cable name.
|
* @cable_name: the target cable name.
|
||||||
* @nb: the notifier block to get notified.
|
* @nb: the notifier block to get notified.
|
||||||
*
|
*
|
||||||
|
@ -460,22 +462,44 @@ int extcon_register_interest(struct extcon_specific_cable_nb *obj,
|
||||||
const char *extcon_name, const char *cable_name,
|
const char *extcon_name, const char *cable_name,
|
||||||
struct notifier_block *nb)
|
struct notifier_block *nb)
|
||||||
{
|
{
|
||||||
if (!obj || !extcon_name || !cable_name || !nb)
|
if (!obj || !cable_name || !nb)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
obj->edev = extcon_get_extcon_dev(extcon_name);
|
if (extcon_name) {
|
||||||
if (!obj->edev)
|
obj->edev = extcon_get_extcon_dev(extcon_name);
|
||||||
|
if (!obj->edev)
|
||||||
|
return -ENODEV;
|
||||||
|
|
||||||
|
obj->cable_index = extcon_find_cable_index(obj->edev, cable_name);
|
||||||
|
if (obj->cable_index < 0)
|
||||||
|
return -ENODEV;
|
||||||
|
|
||||||
|
obj->user_nb = nb;
|
||||||
|
|
||||||
|
obj->internal_nb.notifier_call = _call_per_cable;
|
||||||
|
|
||||||
|
return raw_notifier_chain_register(&obj->edev->nh, &obj->internal_nb);
|
||||||
|
} else {
|
||||||
|
struct class_dev_iter iter;
|
||||||
|
struct extcon_dev *extd;
|
||||||
|
struct device *dev;
|
||||||
|
|
||||||
|
if (!extcon_class)
|
||||||
|
return -ENODEV;
|
||||||
|
class_dev_iter_init(&iter, extcon_class, NULL, NULL);
|
||||||
|
while ((dev = class_dev_iter_next(&iter))) {
|
||||||
|
extd = (struct extcon_dev *)dev_get_drvdata(dev);
|
||||||
|
|
||||||
|
if (extcon_find_cable_index(extd, cable_name) < 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
class_dev_iter_exit(&iter);
|
||||||
|
return extcon_register_interest(obj, extd->name,
|
||||||
|
cable_name, nb);
|
||||||
|
}
|
||||||
|
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
}
|
||||||
obj->cable_index = extcon_find_cable_index(obj->edev, cable_name);
|
|
||||||
if (obj->cable_index < 0)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
obj->user_nb = nb;
|
|
||||||
|
|
||||||
obj->internal_nb.notifier_call = _call_per_cable;
|
|
||||||
|
|
||||||
return raw_notifier_chain_register(&obj->edev->nh, &obj->internal_nb);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue