Skip to content

Commit 1ad94ff

Browse files
committed
extcon: Move OF helper function to extcon core and change function name
This patch move simply OF helper function to extcon core and change function name as following: - of_extcon_get_extcon_dev() -> extcon_get_edev_by_phandle() Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com> Acked-by: Felipe Balbi <balbi@ti.com>
1 parent ca48824 commit 1ad94ff

7 files changed

Lines changed: 55 additions & 95 deletions

File tree

‎drivers/extcon/Kconfig‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ if EXTCON
1414

1515
comment "Extcon Device Drivers"
1616

17-
config OF_EXTCON
18-
def_tristate y
19-
depends on OF
20-
2117
config EXTCON_GPIO
2218
tristate "GPIO extcon support"
2319
depends on GPIOLIB

‎drivers/extcon/Makefile‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
# Makefile for external connector class (extcon) devices
33
#
44

5-
obj-$(CONFIG_OF_EXTCON) += of_extcon.o
6-
75
obj-$(CONFIG_EXTCON) += extcon-class.o
86
obj-$(CONFIG_EXTCON_GPIO) += extcon-gpio.o
97
obj-$(CONFIG_EXTCON_ADC_JACK) += extcon-adc-jack.o

‎drivers/extcon/extcon-class.c‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <linux/extcon.h>
3232
#include <linux/slab.h>
3333
#include <linux/sysfs.h>
34+
#include <linux/of.h>
3435

3536
/*
3637
* extcon_cable_name suggests the standard cable names for commonly used
@@ -818,6 +819,47 @@ void extcon_dev_unregister(struct extcon_dev *edev)
818819
}
819820
EXPORT_SYMBOL_GPL(extcon_dev_unregister);
820821

822+
#ifdef CONFIG_OF
823+
/*
824+
* extcon_get_edev_by_phandle - Get the extcon device from devicetree
825+
* @dev - instance to the given device
826+
* @index - index into list of extcon_dev
827+
*
828+
* return the instance of extcon device
829+
*/
830+
struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index)
831+
{
832+
struct device_node *node;
833+
struct extcon_dev *edev;
834+
835+
if (!dev->of_node) {
836+
dev_err(dev, "device does not have a device node entry\n");
837+
return ERR_PTR(-EINVAL);
838+
}
839+
840+
node = of_parse_phandle(dev->of_node, "extcon", index);
841+
if (!node) {
842+
dev_err(dev, "failed to get phandle in %s node\n",
843+
dev->of_node->full_name);
844+
return ERR_PTR(-ENODEV);
845+
}
846+
847+
edev = extcon_get_extcon_dev(node->name);
848+
if (!edev) {
849+
dev_err(dev, "unable to get extcon device : %s\n", node->name);
850+
return ERR_PTR(-ENODEV);
851+
}
852+
853+
return edev;
854+
}
855+
#else
856+
struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index)
857+
{
858+
return ERR_PTR(-ENOSYS);
859+
}
860+
#endif /* CONFIG_OF */
861+
EXPORT_SYMBOL_GPL(extcon_get_edev_by_phandle);
862+
821863
static int __init extcon_class_init(void)
822864
{
823865
return create_extcon_class();

‎drivers/extcon/of_extcon.c‎

Lines changed: 0 additions & 56 deletions
This file was deleted.

‎drivers/usb/dwc3/dwc3-omap.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#include <linux/of.h>
3030
#include <linux/of_platform.h>
3131
#include <linux/extcon.h>
32-
#include <linux/extcon/of_extcon.h>
3332
#include <linux/regulator/consumer.h>
3433

3534
#include <linux/usb/otg.h>
@@ -522,7 +521,7 @@ static int dwc3_omap_probe(struct platform_device *pdev)
522521
dwc3_omap_enable_irqs(omap);
523522

524523
if (of_property_read_bool(node, "extcon")) {
525-
edev = of_extcon_get_extcon_dev(dev, 0);
524+
edev = extcon_get_edev_by_phandle(dev, 0);
526525
if (IS_ERR(edev)) {
527526
dev_vdbg(dev, "couldn't get extcon device\n");
528527
ret = -EPROBE_DEFER;

‎include/linux/extcon.h‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,12 @@ extern int extcon_register_notifier(struct extcon_dev *edev,
240240
struct notifier_block *nb);
241241
extern int extcon_unregister_notifier(struct extcon_dev *edev,
242242
struct notifier_block *nb);
243+
244+
/*
245+
* Following API get the extcon device from devicetree.
246+
* This function use phandle of devicetree to get extcon device directly.
247+
*/
248+
extern struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index);
243249
#else /* CONFIG_EXTCON */
244250
static inline int extcon_dev_register(struct extcon_dev *edev)
245251
{
@@ -324,5 +330,11 @@ static inline int extcon_unregister_interest(struct extcon_specific_cable_nb
324330
{
325331
return 0;
326332
}
333+
334+
static inline struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev,
335+
int index)
336+
{
337+
return ERR_PTR(-ENODEV);
338+
}
327339
#endif /* CONFIG_EXTCON */
328340
#endif /* __LINUX_EXTCON_H__ */

‎include/linux/extcon/of_extcon.h‎

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)