* [PATCH] extcon: Implement OF-based extcon lookup properly
@ 2014-10-16 13:11 Marek Szyprowski
2014-10-16 23:32 ` Chanwoo Choi
0 siblings, 1 reply; 2+ messages in thread
From: Marek Szyprowski @ 2014-10-16 13:11 UTC (permalink / raw)
To: linux-kernel; +Cc: Marek Szyprowski, Chanwoo Choi, MyungJoo Ham, Tomasz Figa
From: Tomasz Figa <tomasz.figa@gmail.com>
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>
---
drivers/extcon/extcon-class.c | 14 +++++++++-----
1 file 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 @@
#include <linux/fs.h>
#include <linux/err.h>
#include <linux/extcon.h>
+#include <linux/of.h>
#include <linux/slab.h>
#include <linux/sysfs.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);
}
- edev = extcon_get_extcon_dev(node->name);
- if (!edev) {
- dev_err(dev, "unable to get extcon device : %s\n", node->name);
- return ERR_PTR(-ENODEV);
+ mutex_lock(&extcon_dev_list_lock);
+ list_for_each_entry(edev, &extcon_dev_list, entry) {
+ if (edev->dev.parent && edev->dev.parent->of_node == node) {
+ mutex_unlock(&extcon_dev_list_lock);
+ return edev;
+ }
}
+ mutex_unlock(&extcon_dev_list_lock);
- return edev;
+ return ERR_PTR(-EPROBE_DEFER);
}
#else
struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index)
--
1.9.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] extcon: Implement OF-based extcon lookup properly
2014-10-16 13:11 [PATCH] extcon: Implement OF-based extcon lookup properly Marek Szyprowski
@ 2014-10-16 23:32 ` Chanwoo Choi
0 siblings, 0 replies; 2+ messages in thread
From: Chanwoo Choi @ 2014-10-16 23:32 UTC (permalink / raw)
To: Marek Szyprowski; +Cc: linux-kernel, MyungJoo Ham, Tomasz Figa
On 10/16/2014 10:11 PM, Marek Szyprowski wrote:
> From: Tomasz Figa <tomasz.figa@gmail.com>
>
> 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>
> ---
> drivers/extcon/extcon-class.c | 14 +++++++++-----
> 1 file changed, 9 insertions(+), 5 deletions(-)
Applied it. Thank you.
Chanwoo Choi
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-10-16 23:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-16 13:11 [PATCH] extcon: Implement OF-based extcon lookup properly Marek Szyprowski
2014-10-16 23:32 ` Chanwoo Choi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox