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

extcon: Split out extcon header file for consumer and provider device

The extcon has two type of extcon devices as following.
- 'extcon provider deivce' adds new extcon device and detect the
state/properties of external connector. Also, it notifies the
state/properties to the extcon consumer device.
- 'extcon consumer device' gets the change state/properties
from extcon provider device.
Prior to that, include/linux/extcon.h contains all exported API for
both provider and consumer device driver. To clarify the meaning of
header file and to remove the wrong use-case on consumer device,
this patch separates into extcon.h and extcon-provider.h.

[Description for include/linux/{extcon.h|extcon-provider.h}]
- extcon.h includes the extcon API and data structure for extcon consumer
device driver. This header file contains the following APIs:
: Register/unregister the notifier to catch the change of extcon device
: Get the extcon device instance
: Get the extcon device name
: Get the state of each external connector
: Get the property value of each external connector
: Get the property capability of each external connector

- extcon-provider.h includes the extcon API and data structure for extcon
provider device driver. This header file contains the following APIs:
: Include 'include/linux/extcon.h'
: Allocate the memory for extcon device instance
: Register/unregister extcon device
: Set the state of each external connector
: Set the property value of each external connector
: Set the property capability of each external connector

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Acked-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Acked-by: Chen-Yu Tsai <wens@csie.org>
Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Acked-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Acked-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Acked-by: Kishon Vijay Abraham I <kishon@ti.com>

+172 -129
+1 -1
drivers/extcon/extcon-adc-jack.c
··· 26 26 #include <linux/workqueue.h> 27 27 #include <linux/iio/consumer.h> 28 28 #include <linux/extcon/extcon-adc-jack.h> 29 - #include <linux/extcon.h> 29 + #include <linux/extcon-provider.h> 30 30 31 31 /** 32 32 * struct adc_jack_data - internal data for adc_jack device driver
+1 -1
drivers/extcon/extcon-arizona.c
··· 27 27 #include <linux/pm_runtime.h> 28 28 #include <linux/property.h> 29 29 #include <linux/regulator/consumer.h> 30 - #include <linux/extcon.h> 30 + #include <linux/extcon-provider.h> 31 31 32 32 #include <sound/soc.h> 33 33
+1 -1
drivers/extcon/extcon-axp288.c
··· 22 22 #include <linux/platform_device.h> 23 23 #include <linux/property.h> 24 24 #include <linux/notifier.h> 25 - #include <linux/extcon.h> 25 + #include <linux/extcon-provider.h> 26 26 #include <linux/regmap.h> 27 27 #include <linux/gpio.h> 28 28 #include <linux/gpio/consumer.h>
+1 -1
drivers/extcon/extcon-gpio.c
··· 17 17 * GNU General Public License for more details. 18 18 */ 19 19 20 - #include <linux/extcon.h> 20 + #include <linux/extcon-provider.h> 21 21 #include <linux/extcon/extcon-gpio.h> 22 22 #include <linux/gpio.h> 23 23 #include <linux/gpio/consumer.h>
+1 -1
drivers/extcon/extcon-intel-cht-wc.c
··· 15 15 * more details. 16 16 */ 17 17 18 - #include <linux/extcon.h> 18 + #include <linux/extcon-provider.h> 19 19 #include <linux/interrupt.h> 20 20 #include <linux/kernel.h> 21 21 #include <linux/mfd/intel_soc_pmic.h>
+1 -1
drivers/extcon/extcon-intel-int3496.c
··· 19 19 */ 20 20 21 21 #include <linux/acpi.h> 22 - #include <linux/extcon.h> 22 + #include <linux/extcon-provider.h> 23 23 #include <linux/gpio.h> 24 24 #include <linux/interrupt.h> 25 25 #include <linux/module.h>
+1 -1
drivers/extcon/extcon-max14577.c
··· 23 23 #include <linux/platform_device.h> 24 24 #include <linux/mfd/max14577.h> 25 25 #include <linux/mfd/max14577-private.h> 26 - #include <linux/extcon.h> 26 + #include <linux/extcon-provider.h> 27 27 28 28 #define DELAY_MS_DEFAULT 17000 /* unit: millisecond */ 29 29
+1 -1
drivers/extcon/extcon-max3355.c
··· 9 9 * may be copied, distributed, and modified under those terms. 10 10 */ 11 11 12 - #include <linux/extcon.h> 12 + #include <linux/extcon-provider.h> 13 13 #include <linux/gpio.h> 14 14 #include <linux/gpio/consumer.h> 15 15 #include <linux/interrupt.h>
+1 -1
drivers/extcon/extcon-max77693.c
··· 26 26 #include <linux/mfd/max77693.h> 27 27 #include <linux/mfd/max77693-common.h> 28 28 #include <linux/mfd/max77693-private.h> 29 - #include <linux/extcon.h> 29 + #include <linux/extcon-provider.h> 30 30 #include <linux/regmap.h> 31 31 #include <linux/irqdomain.h> 32 32
+1 -1
drivers/extcon/extcon-max77843.c
··· 11 11 * (at your option) any later version. 12 12 */ 13 13 14 - #include <linux/extcon.h> 14 + #include <linux/extcon-provider.h> 15 15 #include <linux/i2c.h> 16 16 #include <linux/interrupt.h> 17 17 #include <linux/kernel.h>
+1 -1
drivers/extcon/extcon-max8997.c
··· 25 25 #include <linux/kobject.h> 26 26 #include <linux/mfd/max8997.h> 27 27 #include <linux/mfd/max8997-private.h> 28 - #include <linux/extcon.h> 28 + #include <linux/extcon-provider.h> 29 29 #include <linux/irqdomain.h> 30 30 31 31 #define DEV_NAME "max8997-muic"
+1 -1
drivers/extcon/extcon-qcom-spmi-misc.c
··· 15 15 * GNU General Public License for more details. 16 16 */ 17 17 18 - #include <linux/extcon.h> 18 + #include <linux/extcon-provider.h> 19 19 #include <linux/init.h> 20 20 #include <linux/interrupt.h> 21 21 #include <linux/kernel.h>
+1 -1
drivers/extcon/extcon-rt8973a.c
··· 20 20 #include <linux/platform_device.h> 21 21 #include <linux/regmap.h> 22 22 #include <linux/slab.h> 23 - #include <linux/extcon.h> 23 + #include <linux/extcon-provider.h> 24 24 25 25 #include "extcon-rt8973a.h" 26 26
+1 -1
drivers/extcon/extcon-sm5502.c
··· 19 19 #include <linux/platform_device.h> 20 20 #include <linux/regmap.h> 21 21 #include <linux/slab.h> 22 - #include <linux/extcon.h> 22 + #include <linux/extcon-provider.h> 23 23 24 24 #include "extcon-sm5502.h" 25 25
+1 -1
drivers/extcon/extcon-usb-gpio.c
··· 14 14 * GNU General Public License for more details. 15 15 */ 16 16 17 - #include <linux/extcon.h> 17 + #include <linux/extcon-provider.h> 18 18 #include <linux/gpio.h> 19 19 #include <linux/gpio/consumer.h> 20 20 #include <linux/init.h>
+1 -1
drivers/extcon/extcon-usbc-cros-ec.c
··· 14 14 * GNU General Public License for more details. 15 15 */ 16 16 17 - #include <linux/extcon.h> 17 + #include <linux/extcon-provider.h> 18 18 #include <linux/kernel.h> 19 19 #include <linux/mfd/cros_ec.h> 20 20 #include <linux/module.h>
+1 -1
drivers/extcon/extcon.h
··· 1 1 #ifndef __LINUX_EXTCON_INTERNAL_H__ 2 2 #define __LINUX_EXTCON_INTERNAL_H__ 3 3 4 - #include <linux/extcon.h> 4 + #include <linux/extcon-provider.h> 5 5 6 6 /** 7 7 * struct extcon_dev - An extcon device represents one external connector.
+1 -1
drivers/phy/allwinner/phy-sun4i-usb.c
··· 24 24 #include <linux/clk.h> 25 25 #include <linux/delay.h> 26 26 #include <linux/err.h> 27 - #include <linux/extcon.h> 27 + #include <linux/extcon-provider.h> 28 28 #include <linux/io.h> 29 29 #include <linux/interrupt.h> 30 30 #include <linux/kernel.h>
+1 -1
drivers/phy/broadcom/phy-bcm-ns2-usbdrd.c
··· 12 12 */ 13 13 14 14 #include <linux/delay.h> 15 - #include <linux/extcon.h> 15 + #include <linux/extcon-provider.h> 16 16 #include <linux/gpio.h> 17 17 #include <linux/gpio/consumer.h> 18 18 #include <linux/init.h>
+1 -1
drivers/phy/renesas/phy-rcar-gen3-usb2.c
··· 12 12 * published by the Free Software Foundation. 13 13 */ 14 14 15 - #include <linux/extcon.h> 15 + #include <linux/extcon-provider.h> 16 16 #include <linux/interrupt.h> 17 17 #include <linux/io.h> 18 18 #include <linux/module.h>
+1 -1
drivers/phy/rockchip/phy-rockchip-inno-usb2.c
··· 17 17 #include <linux/clk.h> 18 18 #include <linux/clk-provider.h> 19 19 #include <linux/delay.h> 20 - #include <linux/extcon.h> 20 + #include <linux/extcon-provider.h> 21 21 #include <linux/interrupt.h> 22 22 #include <linux/io.h> 23 23 #include <linux/gpio/consumer.h>
+1 -1
drivers/power/supply/qcom_smbb.c
··· 34 34 #include <linux/power_supply.h> 35 35 #include <linux/regmap.h> 36 36 #include <linux/slab.h> 37 - #include <linux/extcon.h> 37 + #include <linux/extcon-provider.h> 38 38 #include <linux/regulator/driver.h> 39 39 40 40 #define SMBB_CHG_VMAX 0x040
+1 -1
drivers/usb/gadget/udc/renesas_usb3.c
··· 12 12 #include <linux/delay.h> 13 13 #include <linux/dma-mapping.h> 14 14 #include <linux/err.h> 15 - #include <linux/extcon.h> 15 + #include <linux/extcon-provider.h> 16 16 #include <linux/interrupt.h> 17 17 #include <linux/io.h> 18 18 #include <linux/module.h>
+1 -1
drivers/usb/phy/phy-tahvo.c
··· 23 23 #include <linux/io.h> 24 24 #include <linux/clk.h> 25 25 #include <linux/usb.h> 26 - #include <linux/extcon.h> 26 + #include <linux/extcon-provider.h> 27 27 #include <linux/kernel.h> 28 28 #include <linux/module.h> 29 29 #include <linux/usb/otg.h>
+142
include/linux/extcon-provider.h
··· 1 + /* 2 + * External Connector (extcon) framework 3 + * - linux/include/linux/extcon-provider.h for extcon provider device driver. 4 + * 5 + * Copyright (C) 2017 Samsung Electronics 6 + * Author: Chanwoo Choi <cw00.choi@samsung.com> 7 + * 8 + * This software is licensed under the terms of the GNU General Public 9 + * License version 2, as published by the Free Software Foundation, and 10 + * may be copied, distributed, and modified under those terms. 11 + * 12 + * This program is distributed in the hope that it will be useful, 13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 + * GNU General Public License for more details. 16 + */ 17 + 18 + #ifndef __LINUX_EXTCON_PROVIDER_H__ 19 + #define __LINUX_EXTCON_PROVIDER_H__ 20 + 21 + #include <linux/extcon.h> 22 + 23 + struct extcon_dev; 24 + 25 + #if IS_ENABLED(CONFIG_EXTCON) 26 + 27 + /* Following APIs register/unregister the extcon device. */ 28 + extern int extcon_dev_register(struct extcon_dev *edev); 29 + extern void extcon_dev_unregister(struct extcon_dev *edev); 30 + extern int devm_extcon_dev_register(struct device *dev, 31 + struct extcon_dev *edev); 32 + extern void devm_extcon_dev_unregister(struct device *dev, 33 + struct extcon_dev *edev); 34 + 35 + /* Following APIs allocate/free the memory of the extcon device. */ 36 + extern struct extcon_dev *extcon_dev_allocate(const unsigned int *cable); 37 + extern void extcon_dev_free(struct extcon_dev *edev); 38 + extern struct extcon_dev *devm_extcon_dev_allocate(struct device *dev, 39 + const unsigned int *cable); 40 + extern void devm_extcon_dev_free(struct device *dev, struct extcon_dev *edev); 41 + 42 + /* Synchronize the state and property value for each external connector. */ 43 + extern int extcon_sync(struct extcon_dev *edev, unsigned int id); 44 + 45 + /* 46 + * Following APIs set the connected state of each external connector. 47 + * The 'id' argument indicates the defined external connector. 48 + */ 49 + extern int extcon_set_state(struct extcon_dev *edev, unsigned int id, 50 + bool state); 51 + extern int extcon_set_state_sync(struct extcon_dev *edev, unsigned int id, 52 + bool state); 53 + 54 + /* 55 + * Following APIs set the property of each external connector. 56 + * The 'id' argument indicates the defined external connector 57 + * and the 'prop' indicates the extcon property. 58 + * 59 + * And extcon_set_property_capability() set the capability of the property 60 + * for each external connector. They are used to set the capability of the 61 + * property of each external connector based on the id and property. 62 + */ 63 + extern int extcon_set_property(struct extcon_dev *edev, unsigned int id, 64 + unsigned int prop, 65 + union extcon_property_value prop_val); 66 + extern int extcon_set_property_sync(struct extcon_dev *edev, unsigned int id, 67 + unsigned int prop, 68 + union extcon_property_value prop_val); 69 + extern int extcon_set_property_capability(struct extcon_dev *edev, 70 + unsigned int id, unsigned int prop); 71 + 72 + #else /* CONFIG_EXTCON */ 73 + static inline int extcon_dev_register(struct extcon_dev *edev) 74 + { 75 + return 0; 76 + } 77 + 78 + static inline void extcon_dev_unregister(struct extcon_dev *edev) { } 79 + 80 + static inline int devm_extcon_dev_register(struct device *dev, 81 + struct extcon_dev *edev) 82 + { 83 + return -EINVAL; 84 + } 85 + 86 + static inline void devm_extcon_dev_unregister(struct device *dev, 87 + struct extcon_dev *edev) { } 88 + 89 + static inline struct extcon_dev *extcon_dev_allocate(const unsigned int *cable) 90 + { 91 + return ERR_PTR(-ENOSYS); 92 + } 93 + 94 + static inline void extcon_dev_free(struct extcon_dev *edev) { } 95 + 96 + static inline struct extcon_dev *devm_extcon_dev_allocate(struct device *dev, 97 + const unsigned int *cable) 98 + { 99 + return ERR_PTR(-ENOSYS); 100 + } 101 + 102 + static inline void devm_extcon_dev_free(struct extcon_dev *edev) { } 103 + 104 + 105 + static inline int extcon_set_state(struct extcon_dev *edev, unsigned int id, 106 + bool state) 107 + { 108 + return 0; 109 + } 110 + 111 + static inline int extcon_set_state_sync(struct extcon_dev *edev, unsigned int id, 112 + bool state) 113 + { 114 + return 0; 115 + } 116 + 117 + static inline int extcon_sync(struct extcon_dev *edev, unsigned int id) 118 + { 119 + return 0; 120 + } 121 + 122 + static inline int extcon_set_property(struct extcon_dev *edev, unsigned int id, 123 + unsigned int prop, 124 + union extcon_property_value prop_val) 125 + { 126 + return 0; 127 + } 128 + 129 + static inline int extcon_set_property_sync(struct extcon_dev *edev, 130 + unsigned int id, unsigned int prop, 131 + union extcon_property_value prop_val) 132 + { 133 + return 0; 134 + } 135 + 136 + static inline int extcon_set_property_capability(struct extcon_dev *edev, 137 + unsigned int id, unsigned int prop) 138 + { 139 + return 0; 140 + } 141 + #endif /* CONFIG_EXTCON */ 142 + #endif /* __LINUX_EXTCON_PROVIDER_H__ */
+5 -104
include/linux/extcon.h
··· 1 1 /* 2 2 * External Connector (extcon) framework 3 + * - linux/include/linux/extcon.h for extcon consumer device driver. 3 4 * 4 5 * Copyright (C) 2015 Samsung Electronics 5 6 * Author: Chanwoo Choi <cw00.choi@samsung.com> ··· 171 170 int intval; /* type : integer (intval) */ 172 171 }; 173 172 174 - struct extcon_cable; 175 173 struct extcon_dev; 176 174 177 175 #if IS_ENABLED(CONFIG_EXTCON) 178 - 179 - /* Following APIs register/unregister the extcon device. */ 180 - extern int extcon_dev_register(struct extcon_dev *edev); 181 - extern void extcon_dev_unregister(struct extcon_dev *edev); 182 - extern int devm_extcon_dev_register(struct device *dev, 183 - struct extcon_dev *edev); 184 - extern void devm_extcon_dev_unregister(struct device *dev, 185 - struct extcon_dev *edev); 186 - 187 - /* Following APIs allocate/free the memory of the extcon device. */ 188 - extern struct extcon_dev *extcon_dev_allocate(const unsigned int *cable); 189 - extern void extcon_dev_free(struct extcon_dev *edev); 190 - extern struct extcon_dev *devm_extcon_dev_allocate(struct device *dev, 191 - const unsigned int *cable); 192 - extern void devm_extcon_dev_free(struct device *dev, struct extcon_dev *edev); 193 - 194 - /* Synchronize the state and property value for each external connector. */ 195 - extern int extcon_sync(struct extcon_dev *edev, unsigned int id); 196 - 197 176 /* 198 - * Following APIs get/set the connected state of each external connector. 177 + * Following APIs get the connected state of each external connector. 199 178 * The 'id' argument indicates the defined external connector. 200 179 */ 201 180 extern int extcon_get_state(struct extcon_dev *edev, unsigned int id); 202 - extern int extcon_set_state(struct extcon_dev *edev, unsigned int id, 203 - bool state); 204 - extern int extcon_set_state_sync(struct extcon_dev *edev, unsigned int id, 205 - bool state); 206 181 207 182 /* 208 - * Following APIs get/set the property of each external connector. 183 + * Following APIs get the property of each external connector. 209 184 * The 'id' argument indicates the defined external connector 210 185 * and the 'prop' indicates the extcon property. 211 186 * 212 - * And extcon_get/set_property_capability() set the capability of the property 213 - * for each external connector. They are used to set the capability of the 187 + * And extcon_get_property_capability() get the capability of the property 188 + * for each external connector. They are used to get the capability of the 214 189 * property of each external connector based on the id and property. 215 190 */ 216 191 extern int extcon_get_property(struct extcon_dev *edev, unsigned int id, 217 192 unsigned int prop, 218 193 union extcon_property_value *prop_val); 219 - extern int extcon_set_property(struct extcon_dev *edev, unsigned int id, 220 - unsigned int prop, 221 - union extcon_property_value prop_val); 222 - extern int extcon_set_property_sync(struct extcon_dev *edev, unsigned int id, 223 - unsigned int prop, 224 - union extcon_property_value prop_val); 225 194 extern int extcon_get_property_capability(struct extcon_dev *edev, 226 - unsigned int id, unsigned int prop); 227 - extern int extcon_set_property_capability(struct extcon_dev *edev, 228 195 unsigned int id, unsigned int prop); 229 196 230 197 /* ··· 237 268 extern const char *extcon_get_edev_name(struct extcon_dev *edev); 238 269 239 270 #else /* CONFIG_EXTCON */ 240 - static inline int extcon_dev_register(struct extcon_dev *edev) 241 - { 242 - return 0; 243 - } 244 - 245 - static inline void extcon_dev_unregister(struct extcon_dev *edev) { } 246 - 247 - static inline int devm_extcon_dev_register(struct device *dev, 248 - struct extcon_dev *edev) 249 - { 250 - return -EINVAL; 251 - } 252 - 253 - static inline void devm_extcon_dev_unregister(struct device *dev, 254 - struct extcon_dev *edev) { } 255 - 256 - static inline struct extcon_dev *extcon_dev_allocate(const unsigned int *cable) 257 - { 258 - return ERR_PTR(-ENOSYS); 259 - } 260 - 261 - static inline void extcon_dev_free(struct extcon_dev *edev) { } 262 - 263 - static inline struct extcon_dev *devm_extcon_dev_allocate(struct device *dev, 264 - const unsigned int *cable) 265 - { 266 - return ERR_PTR(-ENOSYS); 267 - } 268 - 269 - static inline void devm_extcon_dev_free(struct extcon_dev *edev) { } 270 - 271 - 272 271 static inline int extcon_get_state(struct extcon_dev *edev, unsigned int id) 273 - { 274 - return 0; 275 - } 276 - 277 - static inline int extcon_set_state(struct extcon_dev *edev, unsigned int id, 278 - bool state) 279 - { 280 - return 0; 281 - } 282 - 283 - static inline int extcon_set_state_sync(struct extcon_dev *edev, unsigned int id, 284 - bool state) 285 - { 286 - return 0; 287 - } 288 - 289 - static inline int extcon_sync(struct extcon_dev *edev, unsigned int id) 290 272 { 291 273 return 0; 292 274 } ··· 248 328 { 249 329 return 0; 250 330 } 251 - static inline int extcon_set_property(struct extcon_dev *edev, unsigned int id, 252 - unsigned int prop, 253 - union extcon_property_value prop_val) 254 - { 255 - return 0; 256 - } 257 - 258 - static inline int extcon_set_property_sync(struct extcon_dev *edev, 259 - unsigned int id, unsigned int prop, 260 - union extcon_property_value prop_val) 261 - { 262 - return 0; 263 - } 264 331 265 332 static inline int extcon_get_property_capability(struct extcon_dev *edev, 266 - unsigned int id, unsigned int prop) 267 - { 268 - return 0; 269 - } 270 - 271 - static inline int extcon_set_property_capability(struct extcon_dev *edev, 272 333 unsigned int id, unsigned int prop) 273 334 { 274 335 return 0;
+1 -1
include/linux/mfd/palmas.h
··· 20 20 #include <linux/leds.h> 21 21 #include <linux/regmap.h> 22 22 #include <linux/regulator/driver.h> 23 - #include <linux/extcon.h> 23 + #include <linux/extcon-provider.h> 24 24 #include <linux/of_gpio.h> 25 25 #include <linux/usb/phy_companion.h> 26 26