extcon: Implement OF-based extcon lookup properly
Platform bus is not the only way to have extcon devices, so current implementation of of_extcon_get_extcon_dev() is broken. Also using parent device node only to get device name is quite ugly. This patch reimplements of_extcon_get_extcon_dev() to do exactly the same as extcon_get_extcon_dev() but instead of comparing names, compare node pointers. Signed-off-by: Tomasz Figa <tomasz.figa@gmail.com> [mszyprow: simplified the code] Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
This commit is contained in:
parent
0df1f2487d
commit
f841afb174
|
@ -29,6 +29,7 @@
|
||||||
#include <linux/fs.h>
|
#include <linux/fs.h>
|
||||||
#include <linux/err.h>
|
#include <linux/err.h>
|
||||||
#include <linux/extcon.h>
|
#include <linux/extcon.h>
|
||||||
|
#include <linux/of.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
#include <linux/sysfs.h>
|
#include <linux/sysfs.h>
|
||||||
#include <linux/of.h>
|
#include <linux/of.h>
|
||||||
|
@ -997,13 +998,16 @@ struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index)
|
||||||
return ERR_PTR(-ENODEV);
|
return ERR_PTR(-ENODEV);
|
||||||
}
|
}
|
||||||
|
|
||||||
edev = extcon_get_extcon_dev(node->name);
|
mutex_lock(&extcon_dev_list_lock);
|
||||||
if (!edev) {
|
list_for_each_entry(edev, &extcon_dev_list, entry) {
|
||||||
dev_err(dev, "unable to get extcon device : %s\n", node->name);
|
if (edev->dev.parent && edev->dev.parent->of_node == node) {
|
||||||
return ERR_PTR(-ENODEV);
|
mutex_unlock(&extcon_dev_list_lock);
|
||||||
|
return edev;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
mutex_unlock(&extcon_dev_list_lock);
|
||||||
|
|
||||||
return edev;
|
return ERR_PTR(-EPROBE_DEFER);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index)
|
struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index)
|
||||||
|
|
Loading…
Reference in New Issue