diff options
Diffstat (limited to 'drivers/extcon/extcon-sm5502.c')
-rw-r--r-- | drivers/extcon/extcon-sm5502.c | 33 |
1 files changed, 10 insertions, 23 deletions
diff --git a/drivers/extcon/extcon-sm5502.c b/drivers/extcon/extcon-sm5502.c index 2f93cf307852..817dece23b4c 100644 --- a/drivers/extcon/extcon-sm5502.c +++ b/drivers/extcon/extcon-sm5502.c | |||
@@ -92,19 +92,11 @@ static struct reg_data sm5502_reg_data[] = { | |||
92 | }; | 92 | }; |
93 | 93 | ||
94 | /* List of detectable cables */ | 94 | /* List of detectable cables */ |
95 | enum { | 95 | static const unsigned int sm5502_extcon_cable[] = { |
96 | EXTCON_CABLE_USB = 0, | 96 | EXTCON_USB, |
97 | EXTCON_CABLE_USB_HOST, | 97 | EXTCON_USB_HOST, |
98 | EXTCON_CABLE_TA, | 98 | EXTCON_TA, |
99 | 99 | EXTCON_NONE, | |
100 | EXTCON_CABLE_END, | ||
101 | }; | ||
102 | |||
103 | static const char *sm5502_extcon_cable[] = { | ||
104 | [EXTCON_CABLE_USB] = "USB", | ||
105 | [EXTCON_CABLE_USB_HOST] = "USB-Host", | ||
106 | [EXTCON_CABLE_TA] = "TA", | ||
107 | NULL, | ||
108 | }; | 100 | }; |
109 | 101 | ||
110 | /* Define supported accessory type */ | 102 | /* Define supported accessory type */ |
@@ -377,16 +369,12 @@ static int sm5502_muic_cable_handler(struct sm5502_muic_info *info, | |||
377 | bool attached) | 369 | bool attached) |
378 | { | 370 | { |
379 | static unsigned int prev_cable_type = SM5502_MUIC_ADC_GROUND; | 371 | static unsigned int prev_cable_type = SM5502_MUIC_ADC_GROUND; |
380 | const char **cable_names = info->edev->supported_cable; | ||
381 | unsigned int cable_type = SM5502_MUIC_ADC_GROUND; | 372 | unsigned int cable_type = SM5502_MUIC_ADC_GROUND; |
382 | unsigned int con_sw = DM_DP_SWITCH_OPEN; | 373 | unsigned int con_sw = DM_DP_SWITCH_OPEN; |
383 | unsigned int vbus_sw = VBUSIN_SWITCH_OPEN; | 374 | unsigned int vbus_sw = VBUSIN_SWITCH_OPEN; |
384 | unsigned int idx = 0; | 375 | unsigned int id; |
385 | int ret; | 376 | int ret; |
386 | 377 | ||
387 | if (!cable_names) | ||
388 | return 0; | ||
389 | |||
390 | /* Get the type of attached or detached cable */ | 378 | /* Get the type of attached or detached cable */ |
391 | if (attached) | 379 | if (attached) |
392 | cable_type = sm5502_muic_get_cable_type(info); | 380 | cable_type = sm5502_muic_get_cable_type(info); |
@@ -396,17 +384,17 @@ static int sm5502_muic_cable_handler(struct sm5502_muic_info *info, | |||
396 | 384 | ||
397 | switch (cable_type) { | 385 | switch (cable_type) { |
398 | case SM5502_MUIC_ADC_OPEN_USB: | 386 | case SM5502_MUIC_ADC_OPEN_USB: |
399 | idx = EXTCON_CABLE_USB; | 387 | id = EXTCON_USB; |
400 | con_sw = DM_DP_SWITCH_USB; | 388 | con_sw = DM_DP_SWITCH_USB; |
401 | vbus_sw = VBUSIN_SWITCH_VBUSOUT_WITH_USB; | 389 | vbus_sw = VBUSIN_SWITCH_VBUSOUT_WITH_USB; |
402 | break; | 390 | break; |
403 | case SM5502_MUIC_ADC_OPEN_TA: | 391 | case SM5502_MUIC_ADC_OPEN_TA: |
404 | idx = EXTCON_CABLE_TA; | 392 | id = EXTCON_TA; |
405 | con_sw = DM_DP_SWITCH_OPEN; | 393 | con_sw = DM_DP_SWITCH_OPEN; |
406 | vbus_sw = VBUSIN_SWITCH_VBUSOUT; | 394 | vbus_sw = VBUSIN_SWITCH_VBUSOUT; |
407 | break; | 395 | break; |
408 | case SM5502_MUIC_ADC_OPEN_USB_OTG: | 396 | case SM5502_MUIC_ADC_OPEN_USB_OTG: |
409 | idx = EXTCON_CABLE_USB_HOST; | 397 | id = EXTCON_USB_HOST; |
410 | con_sw = DM_DP_SWITCH_USB; | 398 | con_sw = DM_DP_SWITCH_USB; |
411 | vbus_sw = VBUSIN_SWITCH_OPEN; | 399 | vbus_sw = VBUSIN_SWITCH_OPEN; |
412 | break; | 400 | break; |
@@ -422,7 +410,7 @@ static int sm5502_muic_cable_handler(struct sm5502_muic_info *info, | |||
422 | return ret; | 410 | return ret; |
423 | 411 | ||
424 | /* Change the state of external accessory */ | 412 | /* Change the state of external accessory */ |
425 | extcon_set_cable_state(info->edev, cable_names[idx], attached); | 413 | extcon_set_cable_state_(info->edev, id, attached); |
426 | 414 | ||
427 | return 0; | 415 | return 0; |
428 | } | 416 | } |
@@ -623,7 +611,6 @@ static int sm5022_muic_i2c_probe(struct i2c_client *i2c, | |||
623 | dev_err(info->dev, "failed to allocate memory for extcon\n"); | 611 | dev_err(info->dev, "failed to allocate memory for extcon\n"); |
624 | return -ENOMEM; | 612 | return -ENOMEM; |
625 | } | 613 | } |
626 | info->edev->name = np->name; | ||
627 | 614 | ||
628 | /* Register extcon device */ | 615 | /* Register extcon device */ |
629 | ret = devm_extcon_dev_register(info->dev, info->edev); | 616 | ret = devm_extcon_dev_register(info->dev, info->edev); |