aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/extcon
diff options
context:
space:
mode:
authorChanwoo Choi <cw00.choi@samsung.com>2014-03-18 06:55:46 -0400
committerChanwoo Choi <cw00.choi@samsung.com>2014-03-19 01:41:58 -0400
commit1ad94ffef22c0a6e2ee6ba90a800c32fd29ffa1f (patch)
tree1cacdc1749c8ca3d47e3ef8fc19fa5228db4354e /drivers/extcon
parentca48824117b3ceaa4e35a7c5d651b95c288308e6 (diff)
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>
Diffstat (limited to 'drivers/extcon')
-rw-r--r--drivers/extcon/Kconfig4
-rw-r--r--drivers/extcon/Makefile2
-rw-r--r--drivers/extcon/extcon-class.c42
-rw-r--r--drivers/extcon/of_extcon.c56
4 files changed, 42 insertions, 62 deletions
diff --git a/drivers/extcon/Kconfig b/drivers/extcon/Kconfig
index bdb5a00f1dfa..be56e8ac95e6 100644
--- a/drivers/extcon/Kconfig
+++ b/drivers/extcon/Kconfig
@@ -14,10 +14,6 @@ if EXTCON
14 14
15comment "Extcon Device Drivers" 15comment "Extcon Device Drivers"
16 16
17config OF_EXTCON
18 def_tristate y
19 depends on OF
20
21config EXTCON_GPIO 17config EXTCON_GPIO
22 tristate "GPIO extcon support" 18 tristate "GPIO extcon support"
23 depends on GPIOLIB 19 depends on GPIOLIB
diff --git a/drivers/extcon/Makefile b/drivers/extcon/Makefile
index 43eccc0e3448..bf7861ec0906 100644
--- a/drivers/extcon/Makefile
+++ b/drivers/extcon/Makefile
@@ -2,8 +2,6 @@
2# Makefile for external connector class (extcon) devices 2# Makefile for external connector class (extcon) devices
3# 3#
4 4
5obj-$(CONFIG_OF_EXTCON) += of_extcon.o
6
7obj-$(CONFIG_EXTCON) += extcon-class.o 5obj-$(CONFIG_EXTCON) += extcon-class.o
8obj-$(CONFIG_EXTCON_GPIO) += extcon-gpio.o 6obj-$(CONFIG_EXTCON_GPIO) += extcon-gpio.o
9obj-$(CONFIG_EXTCON_ADC_JACK) += extcon-adc-jack.o 7obj-$(CONFIG_EXTCON_ADC_JACK) += extcon-adc-jack.o
diff --git a/drivers/extcon/extcon-class.c b/drivers/extcon/extcon-class.c
index 76322330cbd7..7ab21aa6eaa1 100644
--- a/drivers/extcon/extcon-class.c
+++ b/drivers/extcon/extcon-class.c
@@ -31,6 +31,7 @@
31#include <linux/extcon.h> 31#include <linux/extcon.h>
32#include <linux/slab.h> 32#include <linux/slab.h>
33#include <linux/sysfs.h> 33#include <linux/sysfs.h>
34#include <linux/of.h>
34 35
35/* 36/*
36 * extcon_cable_name suggests the standard cable names for commonly used 37 * extcon_cable_name suggests the standard cable names for commonly used
@@ -818,6 +819,47 @@ void extcon_dev_unregister(struct extcon_dev *edev)
818} 819}
819EXPORT_SYMBOL_GPL(extcon_dev_unregister); 820EXPORT_SYMBOL_GPL(extcon_dev_unregister);
820 821
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 */
830struct 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
856struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index)
857{
858 return ERR_PTR(-ENOSYS);
859}
860#endif /* CONFIG_OF */
861EXPORT_SYMBOL_GPL(extcon_get_edev_by_phandle);
862
821static int __init extcon_class_init(void) 863static int __init extcon_class_init(void)
822{ 864{
823 return create_extcon_class(); 865 return create_extcon_class();
diff --git a/drivers/extcon/of_extcon.c b/drivers/extcon/of_extcon.c
deleted file mode 100644
index 0a29f822cf77..000000000000
--- a/drivers/extcon/of_extcon.c
+++ /dev/null
@@ -1,56 +0,0 @@
1/*
2 * OF helpers for External connector (extcon) framework
3 *
4 * Copyright (C) 2013 Texas Instruments, Inc.
5 * Kishon Vijay Abraham I <kishon@ti.com>
6 *
7 * Copyright (C) 2013 Samsung Electronics
8 * Chanwoo Choi <cw00.choi@samsung.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 */
15
16#include <linux/module.h>
17#include <linux/slab.h>
18#include <linux/err.h>
19#include <linux/extcon.h>
20#include <linux/of.h>
21#include <linux/of_platform.h>
22#include <linux/extcon/of_extcon.h>
23
24/*
25 * of_extcon_get_extcon_dev - Get the name of extcon device from devicetree
26 * @dev - instance to the given device
27 * @index - index into list of extcon_dev
28 *
29 * return the instance of extcon device
30 */
31struct extcon_dev *of_extcon_get_extcon_dev(struct device *dev, int index)
32{
33 struct device_node *node;
34 struct extcon_dev *edev;
35
36 if (!dev->of_node) {
37 dev_dbg(dev, "device does not have a device node entry\n");
38 return ERR_PTR(-EINVAL);
39 }
40
41 node = of_parse_phandle(dev->of_node, "extcon", index);
42 if (!node) {
43 dev_dbg(dev, "failed to get phandle in %s node\n",
44 dev->of_node->full_name);
45 return ERR_PTR(-ENODEV);
46 }
47
48 edev = extcon_get_extcon_dev(node->name);
49 if (!edev) {
50 dev_dbg(dev, "unable to get extcon device : %s\n", node->name);
51 return ERR_PTR(-ENODEV);
52 }
53
54 return edev;
55}
56EXPORT_SYMBOL_GPL(of_extcon_get_extcon_dev);