Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+55 -95
-4
drivers/extcon/Kconfig
··· 14 14 15 15 comment "Extcon Device Drivers" 16 16 17 - config OF_EXTCON 18 - def_tristate y 19 - depends on OF 20 - 21 17 config EXTCON_GPIO 22 18 tristate "GPIO extcon support" 23 19 depends on GPIOLIB
-2
drivers/extcon/Makefile
··· 2 2 # Makefile for external connector class (extcon) devices 3 3 # 4 4 5 - obj-$(CONFIG_OF_EXTCON) += of_extcon.o 6 - 7 5 obj-$(CONFIG_EXTCON) += extcon-class.o 8 6 obj-$(CONFIG_EXTCON_GPIO) += extcon-gpio.o 9 7 obj-$(CONFIG_EXTCON_ADC_JACK) += extcon-adc-jack.o
+42
drivers/extcon/extcon-class.c
··· 31 31 #include <linux/extcon.h> 32 32 #include <linux/slab.h> 33 33 #include <linux/sysfs.h> 34 + #include <linux/of.h> 34 35 35 36 /* 36 37 * extcon_cable_name suggests the standard cable names for commonly used ··· 818 817 put_device(&edev->dev); 819 818 } 820 819 EXPORT_SYMBOL_GPL(extcon_dev_unregister); 820 + 821 + #ifdef CONFIG_OF 822 + /* 823 + * extcon_get_edev_by_phandle - Get the extcon device from devicetree 824 + * @dev - instance to the given device 825 + * @index - index into list of extcon_dev 826 + * 827 + * return the instance of extcon device 828 + */ 829 + struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index) 830 + { 831 + struct device_node *node; 832 + struct extcon_dev *edev; 833 + 834 + if (!dev->of_node) { 835 + dev_err(dev, "device does not have a device node entry\n"); 836 + return ERR_PTR(-EINVAL); 837 + } 838 + 839 + node = of_parse_phandle(dev->of_node, "extcon", index); 840 + if (!node) { 841 + dev_err(dev, "failed to get phandle in %s node\n", 842 + dev->of_node->full_name); 843 + return ERR_PTR(-ENODEV); 844 + } 845 + 846 + edev = extcon_get_extcon_dev(node->name); 847 + if (!edev) { 848 + dev_err(dev, "unable to get extcon device : %s\n", node->name); 849 + return ERR_PTR(-ENODEV); 850 + } 851 + 852 + return edev; 853 + } 854 + #else 855 + struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index) 856 + { 857 + return ERR_PTR(-ENOSYS); 858 + } 859 + #endif /* CONFIG_OF */ 860 + EXPORT_SYMBOL_GPL(extcon_get_edev_by_phandle); 821 861 822 862 static int __init extcon_class_init(void) 823 863 {
-56
drivers/extcon/of_extcon.c
··· 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 - */ 31 - struct 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 - } 56 - EXPORT_SYMBOL_GPL(of_extcon_get_extcon_dev);
+1 -2
drivers/usb/dwc3/dwc3-omap.c
··· 29 29 #include <linux/of.h> 30 30 #include <linux/of_platform.h> 31 31 #include <linux/extcon.h> 32 - #include <linux/extcon/of_extcon.h> 33 32 #include <linux/regulator/consumer.h> 34 33 35 34 #include <linux/usb/otg.h> ··· 521 522 dwc3_omap_enable_irqs(omap); 522 523 523 524 if (of_property_read_bool(node, "extcon")) { 524 - edev = of_extcon_get_extcon_dev(dev, 0); 525 + edev = extcon_get_edev_by_phandle(dev, 0); 525 526 if (IS_ERR(edev)) { 526 527 dev_vdbg(dev, "couldn't get extcon device\n"); 527 528 ret = -EPROBE_DEFER;
+12
include/linux/extcon.h
··· 240 240 struct notifier_block *nb); 241 241 extern int extcon_unregister_notifier(struct extcon_dev *edev, 242 242 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); 243 249 #else /* CONFIG_EXTCON */ 244 250 static inline int extcon_dev_register(struct extcon_dev *edev) 245 251 { ··· 329 323 *obj) 330 324 { 331 325 return 0; 326 + } 327 + 328 + static inline struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, 329 + int index) 330 + { 331 + return ERR_PTR(-ENODEV); 332 332 } 333 333 #endif /* CONFIG_EXTCON */ 334 334 #endif /* __LINUX_EXTCON_H__ */
-31
include/linux/extcon/of_extcon.h
··· 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 - #ifndef __LINUX_OF_EXTCON_H 17 - #define __LINUX_OF_EXTCON_H 18 - 19 - #include <linux/err.h> 20 - 21 - #if IS_ENABLED(CONFIG_OF_EXTCON) 22 - extern struct extcon_dev 23 - *of_extcon_get_extcon_dev(struct device *dev, int index); 24 - #else 25 - static inline struct extcon_dev 26 - *of_extcon_get_extcon_dev(struct device *dev, int index) 27 - { 28 - return ERR_PTR(-ENOSYS); 29 - } 30 - #endif /* CONFIG_OF_EXTCON */ 31 - #endif /* __LINUX_OF_EXTCON_H */