diff options
author | Tomasz Figa <tomasz.figa@gmail.com> | 2014-10-16 09:11:44 -0400 |
---|---|---|
committer | Chanwoo Choi <cw00.choi@samsung.com> | 2014-11-24 06:51:15 -0500 |
commit | f841afb17476f485900bb6213cf93a64a7dc303f (patch) | |
tree | b8da8088c72a4a0ee587e1a8e9c575625da4e369 | |
parent | 0df1f2487d2f0d04703f142813d53615d62a1da4 (diff) |
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>
-rw-r--r-- | drivers/extcon/extcon-class.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/drivers/extcon/extcon-class.c b/drivers/extcon/extcon-class.c index 4c2f2c543bb7..043dcd9946c9 100644 --- a/drivers/extcon/extcon-class.c +++ b/drivers/extcon/extcon-class.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include <linux/fs.h> | 29 | #include <linux/fs.h> |
30 | #include <linux/err.h> | 30 | #include <linux/err.h> |
31 | #include <linux/extcon.h> | 31 | #include <linux/extcon.h> |
32 | #include <linux/of.h> | ||
32 | #include <linux/slab.h> | 33 | #include <linux/slab.h> |
33 | #include <linux/sysfs.h> | 34 | #include <linux/sysfs.h> |
34 | #include <linux/of.h> | 35 | #include <linux/of.h> |
@@ -997,13 +998,16 @@ struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index) | |||
997 | return ERR_PTR(-ENODEV); | 998 | return ERR_PTR(-ENODEV); |
998 | } | 999 | } |
999 | 1000 | ||
1000 | edev = extcon_get_extcon_dev(node->name); | 1001 | mutex_lock(&extcon_dev_list_lock); |
1001 | if (!edev) { | 1002 | list_for_each_entry(edev, &extcon_dev_list, entry) { |
1002 | dev_err(dev, "unable to get extcon device : %s\n", node->name); | 1003 | if (edev->dev.parent && edev->dev.parent->of_node == node) { |
1003 | return ERR_PTR(-ENODEV); | 1004 | mutex_unlock(&extcon_dev_list_lock); |
1005 | return edev; | ||
1006 | } | ||
1004 | } | 1007 | } |
1008 | mutex_unlock(&extcon_dev_list_lock); | ||
1005 | 1009 | ||
1006 | return edev; | 1010 | return ERR_PTR(-EPROBE_DEFER); |
1007 | } | 1011 | } |
1008 | #else | 1012 | #else |
1009 | struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index) | 1013 | struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index) |