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

extcon: Redefine the unique id of supported external connectors without 'enum extcon' type

This patch just redefine the unique id of supported external connectors without
'enum extcon' type. Because unique id would be used on devictree file(*.dts) to
indicate the specific external connectors like key number of input framework.
So, I have the plan to move this definitions to following header file which
includes the unique id of supported external connectors.
- include/dt-bindings/extcon/extcon.h

Fixes: 2a9de9c0f08d ("extcon: Use the unique id for external connector instead of string")
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Chanwoo Choi and committed by
Greg Kroah-Hartman
73b6ecdb 03cb0503

+67 -73
+1 -1
drivers/extcon/extcon-adc-jack.c
··· 40 40 struct adc_jack_data { 41 41 struct extcon_dev *edev; 42 42 43 - const char **cable_names; 43 + const unsigned int **cable_names; 44 44 struct adc_jack_cond *adc_conditions; 45 45 int num_conditions; 46 46
+2 -2
drivers/extcon/extcon-arizona.c
··· 118 118 1257, 119 119 }; 120 120 121 - static const enum extcon arizona_cable[] = { 121 + static const unsigned int arizona_cable[] = { 122 122 EXTCON_MECHANICAL, 123 123 EXTCON_MICROPHONE, 124 124 EXTCON_HEADPHONE, ··· 552 552 struct arizona_extcon_info *info = data; 553 553 struct arizona *arizona = info->arizona; 554 554 int id_gpio = arizona->pdata.hpdet_id_gpio; 555 - enum extcon report = EXTCON_HEADPHONE; 555 + unsigned int report = EXTCON_HEADPHONE; 556 556 int ret, reading; 557 557 bool mic = false; 558 558
+2 -2
drivers/extcon/extcon-axp288.c
··· 101 101 EXTCON_IRQ_END, 102 102 }; 103 103 104 - static const enum extcon axp288_extcon_cables[] = { 104 + static const unsigned int axp288_extcon_cables[] = { 105 105 EXTCON_SLOW_CHARGER, 106 106 EXTCON_CHARGE_DOWNSTREAM, 107 107 EXTCON_FAST_CHARGER, ··· 157 157 static int axp288_handle_chrg_det_event(struct axp288_extcon_info *info) 158 158 { 159 159 static bool notify_otg, notify_charger; 160 - static enum extcon cable; 160 + static unsigned int cable; 161 161 int ret, stat, cfg, pwr_stat; 162 162 u8 chrg_type; 163 163 bool vbus_attach = false;
+1 -1
drivers/extcon/extcon-max14577.c
··· 148 148 MAX14577_MUIC_ADC_OPEN, 149 149 }; 150 150 151 - static const enum extcon max14577_extcon_cable[] = { 151 + static const unsigned int max14577_extcon_cable[] = { 152 152 EXTCON_USB, 153 153 EXTCON_TA, 154 154 EXTCON_FAST_CHARGER,
+2 -2
drivers/extcon/extcon-max77693.c
··· 200 200 /* 201 201 * MAX77693 MUIC device support below list of accessories(external connector) 202 202 */ 203 - static const enum extcon max77693_extcon_cable[] = { 203 + static const unsigned int max77693_extcon_cable[] = { 204 204 EXTCON_USB, 205 205 EXTCON_USB_HOST, 206 206 EXTCON_TA, ··· 457 457 int ret = 0; 458 458 int vbvolt; 459 459 bool cable_attached; 460 - enum extcon dock_id; 460 + unsigned int dock_id; 461 461 462 462 dev_info(info->dev, 463 463 "external connector is %s (adc:0x%02x)\n",
+1 -1
drivers/extcon/extcon-max77843.c
··· 118 118 MAX77843_MUIC_CHG_GND, 119 119 }; 120 120 121 - static const enum extcon max77843_extcon_cable[] = { 121 + static const unsigned int max77843_extcon_cable[] = { 122 122 EXTCON_USB, 123 123 EXTCON_USB_HOST, 124 124 EXTCON_TA,
+1 -1
drivers/extcon/extcon-max8997.c
··· 145 145 int path_uart; 146 146 }; 147 147 148 - static const enum extcon max8997_extcon_cable[] = { 148 + static const unsigned int max8997_extcon_cable[] = { 149 149 EXTCON_USB, 150 150 EXTCON_USB_HOST, 151 151 EXTCON_TA,
+1 -1
drivers/extcon/extcon-palmas.c
··· 29 29 #include <linux/of.h> 30 30 #include <linux/of_platform.h> 31 31 32 - static const enum extcon palmas_extcon_cable[] = { 32 + static const unsigned int palmas_extcon_cable[] = { 33 33 EXTCON_USB, 34 34 EXTCON_USB_HOST, 35 35 EXTCON_NONE,
+2 -2
drivers/extcon/extcon-rt8973a.c
··· 90 90 }; 91 91 92 92 /* List of detectable cables */ 93 - static const enum extcon rt8973a_extcon_cable[] = { 93 + static const unsigned int rt8973a_extcon_cable[] = { 94 94 EXTCON_USB, 95 95 EXTCON_USB_HOST, 96 96 EXTCON_TA, ··· 300 300 static unsigned int prev_cable_type; 301 301 unsigned int con_sw = DM_DP_SWITCH_UART; 302 302 int ret, cable_type; 303 - enum extcon id; 303 + unsigned int id; 304 304 bool attached = false; 305 305 306 306 switch (event) {
+2 -2
drivers/extcon/extcon-sm5502.c
··· 92 92 }; 93 93 94 94 /* List of detectable cables */ 95 - static const enum extcon sm5502_extcon_cable[] = { 95 + static const unsigned int sm5502_extcon_cable[] = { 96 96 EXTCON_USB, 97 97 EXTCON_USB_HOST, 98 98 EXTCON_TA, ··· 372 372 unsigned int cable_type = SM5502_MUIC_ADC_GROUND; 373 373 unsigned int con_sw = DM_DP_SWITCH_OPEN; 374 374 unsigned int vbus_sw = VBUSIN_SWITCH_OPEN; 375 - enum extcon id; 375 + unsigned int id; 376 376 int ret; 377 377 378 378 /* Get the type of attached or detached cable */
+1 -1
drivers/extcon/extcon-usb-gpio.c
··· 39 39 struct delayed_work wq_detcable; 40 40 }; 41 41 42 - static const enum extcon usb_extcon_cable[] = { 42 + static const unsigned int usb_extcon_cable[] = { 43 43 EXTCON_USB, 44 44 EXTCON_USB_HOST, 45 45 EXTCON_NONE,
+12 -12
drivers/extcon/extcon.c
··· 39 39 #define CABLE_NAME_MAX 30 40 40 41 41 static const char *extcon_name[] = { 42 + [EXTCON_NONE] = "NONE", 43 + 42 44 /* USB external connector */ 43 45 [EXTCON_USB] = "USB", 44 46 [EXTCON_USB_HOST] = "USB-HOST", ··· 111 109 return 0; 112 110 } 113 111 114 - static int find_cable_index_by_id(struct extcon_dev *edev, const enum extcon id) 112 + static int find_cable_index_by_id(struct extcon_dev *edev, const unsigned int id) 115 113 { 116 114 int i; 117 115 ··· 126 124 127 125 static int find_cable_index_by_name(struct extcon_dev *edev, const char *name) 128 126 { 129 - enum extcon id = EXTCON_NONE; 130 - int i; 127 + unsigned int id = EXTCON_NONE; 128 + int i = 0; 131 129 132 130 if (edev->max_supported == 0) 133 131 return -EINVAL; 134 132 135 133 /* Find the the number of extcon cable */ 136 - for (i = 0; i < EXTCON_END; i++) { 137 - if (!extcon_name[i]) 138 - continue; 134 + while (extcon_name[i]) { 139 135 if (!strncmp(extcon_name[i], name, CABLE_NAME_MAX)) { 140 136 id = i; 141 137 break; ··· 337 337 * @edev: the extcon device that has the cable. 338 338 * @id: the unique id of each external connector in extcon enumeration. 339 339 */ 340 - int extcon_get_cable_state_(struct extcon_dev *edev, const enum extcon id) 340 + int extcon_get_cable_state_(struct extcon_dev *edev, const unsigned int id) 341 341 { 342 342 int index; 343 343 ··· 374 374 * @state: the new cable status. The default semantics is 375 375 * true: attached / false: detached. 376 376 */ 377 - int extcon_set_cable_state_(struct extcon_dev *edev, enum extcon id, 377 + int extcon_set_cable_state_(struct extcon_dev *edev, unsigned int id, 378 378 bool cable_state) 379 379 { 380 380 u32 state; ··· 539 539 * "old_state", not the current state. The current state can be retrieved 540 540 * by looking at the third pameter (edev pointer)'s state value. 541 541 */ 542 - int extcon_register_notifier(struct extcon_dev *edev, enum extcon id, 542 + int extcon_register_notifier(struct extcon_dev *edev, unsigned int id, 543 543 struct notifier_block *nb) 544 544 { 545 545 unsigned long flags; ··· 561 561 * @id: the unique id of each external connector in extcon enumeration. 562 562 * @nb: a notifier block to be registered. 563 563 */ 564 - int extcon_unregister_notifier(struct extcon_dev *edev, enum extcon id, 564 + int extcon_unregister_notifier(struct extcon_dev *edev, unsigned int id, 565 565 struct notifier_block *nb) 566 566 { 567 567 unsigned long flags; ··· 623 623 * 624 624 * Return the pointer of extcon device if success or ERR_PTR(err) if fail 625 625 */ 626 - struct extcon_dev *extcon_dev_allocate(const enum extcon *supported_cable) 626 + struct extcon_dev *extcon_dev_allocate(const unsigned int *supported_cable) 627 627 { 628 628 struct extcon_dev *edev; 629 629 ··· 677 677 * or ERR_PTR(err) if fail 678 678 */ 679 679 struct extcon_dev *devm_extcon_dev_allocate(struct device *dev, 680 - const enum extcon *supported_cable) 680 + const unsigned int *supported_cable) 681 681 { 682 682 struct extcon_dev **ptr, *edev; 683 683
+1 -1
drivers/usb/phy/phy-tahvo.c
··· 60 60 struct extcon_dev extcon; 61 61 }; 62 62 63 - static const enum extcon tahvo_cable[] = { 63 + static const unsigned int tahvo_cable[] = { 64 64 EXTCON_USB, 65 65 EXTCON_USB_HOST, 66 66
+38 -44
include/linux/extcon.h
··· 30 30 #include <linux/notifier.h> 31 31 #include <linux/sysfs.h> 32 32 33 - enum extcon { 34 - EXTCON_NONE = 0x0, 33 + /* 34 + * Define the unique id of supported external connectors 35 + */ 36 + #define EXTCON_NONE 0 35 37 36 - /* USB external connector */ 37 - EXTCON_USB = 0x1, 38 - EXTCON_USB_HOST = 0x2, 38 + #define EXTCON_USB 1 /* USB connector */ 39 + #define EXTCON_USB_HOST 2 39 40 40 - /* Charger external connector */ 41 - EXTCON_TA = 0x10, 42 - EXTCON_FAST_CHARGER = 0x11, 43 - EXTCON_SLOW_CHARGER = 0x12, 44 - EXTCON_CHARGE_DOWNSTREAM = 0x13, 41 + #define EXTCON_TA 3 /* Charger connector */ 42 + #define EXTCON_FAST_CHARGER 4 43 + #define EXTCON_SLOW_CHARGER 5 44 + #define EXTCON_CHARGE_DOWNSTREAM 6 45 45 46 - /* Audio/Video external connector */ 47 - EXTCON_LINE_IN = 0x20, 48 - EXTCON_LINE_OUT = 0x21, 49 - EXTCON_MICROPHONE = 0x22, 50 - EXTCON_HEADPHONE = 0x23, 46 + #define EXTCON_LINE_IN 7 /* Audio/Video connector */ 47 + #define EXTCON_LINE_OUT 8 48 + #define EXTCON_MICROPHONE 9 49 + #define EXTCON_HEADPHONE 10 50 + #define EXTCON_HDMI 11 51 + #define EXTCON_MHL 12 52 + #define EXTCON_DVI 13 53 + #define EXTCON_VGA 14 54 + #define EXTCON_SPDIF_IN 15 55 + #define EXTCON_SPDIF_OUT 16 56 + #define EXTCON_VIDEO_IN 17 57 + #define EXTCON_VIDEO_OUT 18 51 58 52 - EXTCON_HDMI = 0x30, 53 - EXTCON_MHL = 0x31, 54 - EXTCON_DVI = 0x32, 55 - EXTCON_VGA = 0x33, 56 - EXTCON_SPDIF_IN = 0x34, 57 - EXTCON_SPDIF_OUT = 0x35, 58 - EXTCON_VIDEO_IN = 0x36, 59 - EXTCON_VIDEO_OUT = 0x37, 60 - 61 - /* Etc external connector */ 62 - EXTCON_DOCK = 0x50, 63 - EXTCON_JIG = 0x51, 64 - EXTCON_MECHANICAL = 0x52, 65 - 66 - EXTCON_END, 67 - }; 59 + #define EXTCON_DOCK 19 /* Misc connector */ 60 + #define EXTCON_JIG 20 61 + #define EXTCON_MECHANICAL 21 68 62 69 63 struct extcon_cable; 70 64 ··· 99 105 struct extcon_dev { 100 106 /* Optional user initializing data */ 101 107 const char *name; 102 - const enum extcon *supported_cable; 108 + const unsigned int *supported_cable; 103 109 const u32 *mutually_exclusive; 104 110 105 111 /* Optional callbacks to override class functions */ ··· 176 182 /* 177 183 * Following APIs control the memory of extcon device. 178 184 */ 179 - extern struct extcon_dev *extcon_dev_allocate(const enum extcon *cable); 185 + extern struct extcon_dev *extcon_dev_allocate(const unsigned int *cable); 180 186 extern void extcon_dev_free(struct extcon_dev *edev); 181 187 extern struct extcon_dev *devm_extcon_dev_allocate(struct device *dev, 182 - const enum extcon *cable); 188 + const unsigned int *cable); 183 189 extern void devm_extcon_dev_free(struct device *dev, struct extcon_dev *edev); 184 190 185 191 /* ··· 200 206 * get/set_cable_state access each bit of the 32b encoded state value. 201 207 * They are used to access the status of each cable based on the cable_name. 202 208 */ 203 - extern int extcon_get_cable_state_(struct extcon_dev *edev, enum extcon id); 204 - extern int extcon_set_cable_state_(struct extcon_dev *edev, enum extcon id, 209 + extern int extcon_get_cable_state_(struct extcon_dev *edev, unsigned int id); 210 + extern int extcon_set_cable_state_(struct extcon_dev *edev, unsigned int id, 205 211 bool cable_state); 206 212 207 213 extern int extcon_get_cable_state(struct extcon_dev *edev, ··· 228 234 * we do not recommend to use this for normal 'notifiee' device drivers who 229 235 * want to be notified by a specific external port of the notifier. 230 236 */ 231 - extern int extcon_register_notifier(struct extcon_dev *edev, enum extcon id, 237 + extern int extcon_register_notifier(struct extcon_dev *edev, unsigned int id, 232 238 struct notifier_block *nb); 233 - extern int extcon_unregister_notifier(struct extcon_dev *edev, enum extcon id, 239 + extern int extcon_unregister_notifier(struct extcon_dev *edev, unsigned int id, 234 240 struct notifier_block *nb); 235 241 236 242 /* ··· 260 266 static inline void devm_extcon_dev_unregister(struct device *dev, 261 267 struct extcon_dev *edev) { } 262 268 263 - static inline struct extcon_dev *extcon_dev_allocate(const enum extcon *cable) 269 + static inline struct extcon_dev *extcon_dev_allocate(const unsigned int *cable) 264 270 { 265 271 return ERR_PTR(-ENOSYS); 266 272 } ··· 268 274 static inline void extcon_dev_free(struct extcon_dev *edev) { } 269 275 270 276 static inline struct extcon_dev *devm_extcon_dev_allocate(struct device *dev, 271 - const enum extcon *cable) 277 + const unsigned int *cable) 272 278 { 273 279 return ERR_PTR(-ENOSYS); 274 280 } ··· 292 298 } 293 299 294 300 static inline int extcon_get_cable_state_(struct extcon_dev *edev, 295 - enum extcon id) 301 + unsigned int id) 296 302 { 297 303 return 0; 298 304 } 299 305 300 306 static inline int extcon_set_cable_state_(struct extcon_dev *edev, 301 - enum extcon id, bool cable_state) 307 + unsigned int id, bool cable_state) 302 308 { 303 309 return 0; 304 310 } ··· 321 327 } 322 328 323 329 static inline int extcon_register_notifier(struct extcon_dev *edev, 324 - enum extcon id, 330 + unsigned int id, 325 331 struct notifier_block *nb) 326 332 { 327 333 return 0; 328 334 } 329 335 330 336 static inline int extcon_unregister_notifier(struct extcon_dev *edev, 331 - enum extcon id, 337 + unsigned int id, 332 338 struct notifier_block *nb) 333 339 { 334 340 return 0;