diff options
author | Chanwoo Choi <cw00.choi@samsung.com> | 2013-02-13 04:35:08 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-02-13 11:35:44 -0500 |
commit | 19d3243e797c2abc02a214d3cec9fefa5dc048ff (patch) | |
tree | d1e7ae85afda78d261268c40e6c5cc0c18b2b0ba /drivers/extcon | |
parent | eff7d74f5b88ef31ac47c6d96b1494db199705f5 (diff) |
extcon: max77693: Remove unnecessary goto statement to improve readability
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/extcon')
-rw-r--r-- | drivers/extcon/extcon-max77693.c | 77 |
1 files changed, 43 insertions, 34 deletions
diff --git a/drivers/extcon/extcon-max77693.c b/drivers/extcon/extcon-max77693.c index 597f33c1f868..ad6e9a466855 100644 --- a/drivers/extcon/extcon-max77693.c +++ b/drivers/extcon/extcon-max77693.c | |||
@@ -224,16 +224,17 @@ static int max77693_muic_set_debounce_time(struct max77693_muic_info *info, | |||
224 | MAX77693_MUIC_REG_CTRL3, | 224 | MAX77693_MUIC_REG_CTRL3, |
225 | time << CONTROL3_ADCDBSET_SHIFT, | 225 | time << CONTROL3_ADCDBSET_SHIFT, |
226 | CONTROL3_ADCDBSET_MASK); | 226 | CONTROL3_ADCDBSET_MASK); |
227 | if (ret) | 227 | if (ret) { |
228 | dev_err(info->dev, "failed to set ADC debounce time\n"); | 228 | dev_err(info->dev, "failed to set ADC debounce time\n"); |
229 | return -EAGAIN; | ||
230 | } | ||
229 | break; | 231 | break; |
230 | default: | 232 | default: |
231 | dev_err(info->dev, "invalid ADC debounce time\n"); | 233 | dev_err(info->dev, "invalid ADC debounce time\n"); |
232 | ret = -EINVAL; | 234 | return -EINVAL; |
233 | break; | ||
234 | } | 235 | } |
235 | 236 | ||
236 | return ret; | 237 | return 0; |
237 | }; | 238 | }; |
238 | 239 | ||
239 | /* | 240 | /* |
@@ -261,7 +262,7 @@ static int max77693_muic_set_path(struct max77693_muic_info *info, | |||
261 | MAX77693_MUIC_REG_CTRL1, ctrl1, COMP_SW_MASK); | 262 | MAX77693_MUIC_REG_CTRL1, ctrl1, COMP_SW_MASK); |
262 | if (ret < 0) { | 263 | if (ret < 0) { |
263 | dev_err(info->dev, "failed to update MUIC register\n"); | 264 | dev_err(info->dev, "failed to update MUIC register\n"); |
264 | goto out; | 265 | return -EAGAIN; |
265 | } | 266 | } |
266 | 267 | ||
267 | if (attached) | 268 | if (attached) |
@@ -274,14 +275,14 @@ static int max77693_muic_set_path(struct max77693_muic_info *info, | |||
274 | CONTROL2_LOWPWR_MASK | CONTROL2_CPEN_MASK); | 275 | CONTROL2_LOWPWR_MASK | CONTROL2_CPEN_MASK); |
275 | if (ret < 0) { | 276 | if (ret < 0) { |
276 | dev_err(info->dev, "failed to update MUIC register\n"); | 277 | dev_err(info->dev, "failed to update MUIC register\n"); |
277 | goto out; | 278 | return -EAGAIN; |
278 | } | 279 | } |
279 | 280 | ||
280 | dev_info(info->dev, | 281 | dev_info(info->dev, |
281 | "CONTROL1 : 0x%02x, CONTROL2 : 0x%02x, state : %s\n", | 282 | "CONTROL1 : 0x%02x, CONTROL2 : 0x%02x, state : %s\n", |
282 | ctrl1, ctrl2, attached ? "attached" : "detached"); | 283 | ctrl1, ctrl2, attached ? "attached" : "detached"); |
283 | out: | 284 | |
284 | return ret; | 285 | return 0; |
285 | } | 286 | } |
286 | 287 | ||
287 | /* | 288 | /* |
@@ -503,6 +504,10 @@ static int max77693_muic_dock_handler(struct max77693_muic_info *info, | |||
503 | if (!attached) | 504 | if (!attached) |
504 | extcon_set_cable_state(info->edev, "USB", false); | 505 | extcon_set_cable_state(info->edev, "USB", false); |
505 | break; | 506 | break; |
507 | default: | ||
508 | dev_err(info->dev, "failed to detect %s dock device\n", | ||
509 | attached ? "attached" : "detached"); | ||
510 | return -EINVAL; | ||
506 | } | 511 | } |
507 | 512 | ||
508 | /* Dock-Car/Desk/Audio, PATH:AUDIO */ | 513 | /* Dock-Car/Desk/Audio, PATH:AUDIO */ |
@@ -520,7 +525,6 @@ static int max77693_muic_dock_button_handler(struct max77693_muic_info *info, | |||
520 | { | 525 | { |
521 | struct input_dev *dock = info->dock; | 526 | struct input_dev *dock = info->dock; |
522 | unsigned int code; | 527 | unsigned int code; |
523 | int ret = 0; | ||
524 | 528 | ||
525 | switch (button_type) { | 529 | switch (button_type) { |
526 | case MAX77693_MUIC_ADC_REMOTE_S3_BUTTON-1 | 530 | case MAX77693_MUIC_ADC_REMOTE_S3_BUTTON-1 |
@@ -550,14 +554,12 @@ static int max77693_muic_dock_button_handler(struct max77693_muic_info *info, | |||
550 | dev_err(info->dev, | 554 | dev_err(info->dev, |
551 | "failed to detect %s key (adc:0x%x)\n", | 555 | "failed to detect %s key (adc:0x%x)\n", |
552 | attached ? "pressed" : "released", button_type); | 556 | attached ? "pressed" : "released", button_type); |
553 | ret = -EINVAL; | 557 | return -EINVAL; |
554 | goto out; | ||
555 | } | 558 | } |
556 | 559 | ||
557 | input_event(dock, EV_KEY, code, attached); | 560 | input_event(dock, EV_KEY, code, attached); |
558 | input_sync(dock); | 561 | input_sync(dock); |
559 | 562 | ||
560 | out: | ||
561 | return 0; | 563 | return 0; |
562 | } | 564 | } |
563 | 565 | ||
@@ -576,14 +578,14 @@ static int max77693_muic_adc_ground_handler(struct max77693_muic_info *info) | |||
576 | /* USB_OTG, PATH: AP_USB */ | 578 | /* USB_OTG, PATH: AP_USB */ |
577 | ret = max77693_muic_set_path(info, CONTROL1_SW_USB, attached); | 579 | ret = max77693_muic_set_path(info, CONTROL1_SW_USB, attached); |
578 | if (ret < 0) | 580 | if (ret < 0) |
579 | goto out; | 581 | return ret; |
580 | extcon_set_cable_state(info->edev, "USB-Host", attached); | 582 | extcon_set_cable_state(info->edev, "USB-Host", attached); |
581 | break; | 583 | break; |
582 | case MAX77693_MUIC_GND_AV_CABLE_LOAD: | 584 | case MAX77693_MUIC_GND_AV_CABLE_LOAD: |
583 | /* Audio Video Cable with load, PATH:AUDIO */ | 585 | /* Audio Video Cable with load, PATH:AUDIO */ |
584 | ret = max77693_muic_set_path(info, CONTROL1_SW_AUDIO, attached); | 586 | ret = max77693_muic_set_path(info, CONTROL1_SW_AUDIO, attached); |
585 | if (ret < 0) | 587 | if (ret < 0) |
586 | goto out; | 588 | return ret; |
587 | extcon_set_cable_state(info->edev, | 589 | extcon_set_cable_state(info->edev, |
588 | "Audio-video-load", attached); | 590 | "Audio-video-load", attached); |
589 | break; | 591 | break; |
@@ -593,14 +595,12 @@ static int max77693_muic_adc_ground_handler(struct max77693_muic_info *info) | |||
593 | extcon_set_cable_state(info->edev, "MHL", attached); | 595 | extcon_set_cable_state(info->edev, "MHL", attached); |
594 | break; | 596 | break; |
595 | default: | 597 | default: |
596 | dev_err(info->dev, "failed to detect %s accessory\n", | 598 | dev_err(info->dev, "failed to detect %s cable of gnd type\n", |
597 | attached ? "attached" : "detached"); | 599 | attached ? "attached" : "detached"); |
598 | ret = -EINVAL; | 600 | return -EINVAL; |
599 | break; | ||
600 | } | 601 | } |
601 | 602 | ||
602 | out: | 603 | return 0; |
603 | return ret; | ||
604 | } | 604 | } |
605 | 605 | ||
606 | static int max77693_muic_jig_handler(struct max77693_muic_info *info, | 606 | static int max77693_muic_jig_handler(struct max77693_muic_info *info, |
@@ -630,15 +630,19 @@ static int max77693_muic_jig_handler(struct max77693_muic_info *info, | |||
630 | strcpy(cable_name, "JIG-UART-OFF"); | 630 | strcpy(cable_name, "JIG-UART-OFF"); |
631 | path = CONTROL1_SW_UART; | 631 | path = CONTROL1_SW_UART; |
632 | break; | 632 | break; |
633 | default: | ||
634 | dev_err(info->dev, "failed to detect %s jig cable\n", | ||
635 | attached ? "attached" : "detached"); | ||
636 | return -EINVAL; | ||
633 | } | 637 | } |
634 | 638 | ||
635 | ret = max77693_muic_set_path(info, path, attached); | 639 | ret = max77693_muic_set_path(info, path, attached); |
636 | if (ret < 0) | 640 | if (ret < 0) |
637 | goto out; | 641 | return ret; |
638 | 642 | ||
639 | extcon_set_cable_state(info->edev, cable_name, attached); | 643 | extcon_set_cable_state(info->edev, cable_name, attached); |
640 | out: | 644 | |
641 | return ret; | 645 | return 0; |
642 | } | 646 | } |
643 | 647 | ||
644 | static int max77693_muic_adc_handler(struct max77693_muic_info *info) | 648 | static int max77693_muic_adc_handler(struct max77693_muic_info *info) |
@@ -668,7 +672,7 @@ static int max77693_muic_adc_handler(struct max77693_muic_info *info) | |||
668 | /* JIG */ | 672 | /* JIG */ |
669 | ret = max77693_muic_jig_handler(info, cable_type, attached); | 673 | ret = max77693_muic_jig_handler(info, cable_type, attached); |
670 | if (ret < 0) | 674 | if (ret < 0) |
671 | goto out; | 675 | return ret; |
672 | break; | 676 | break; |
673 | case MAX77693_MUIC_ADC_RESERVED_ACC_3: /* Dock-Smart */ | 677 | case MAX77693_MUIC_ADC_RESERVED_ACC_3: /* Dock-Smart */ |
674 | case MAX77693_MUIC_ADC_FACTORY_MODE_UART_ON: /* Dock-Car */ | 678 | case MAX77693_MUIC_ADC_FACTORY_MODE_UART_ON: /* Dock-Car */ |
@@ -685,7 +689,7 @@ static int max77693_muic_adc_handler(struct max77693_muic_info *info) | |||
685 | */ | 689 | */ |
686 | ret = max77693_muic_dock_handler(info, cable_type, attached); | 690 | ret = max77693_muic_dock_handler(info, cable_type, attached); |
687 | if (ret < 0) | 691 | if (ret < 0) |
688 | goto out; | 692 | return ret; |
689 | break; | 693 | break; |
690 | case MAX77693_MUIC_ADC_REMOTE_S3_BUTTON: /* DOCK_KEY_PREV */ | 694 | case MAX77693_MUIC_ADC_REMOTE_S3_BUTTON: /* DOCK_KEY_PREV */ |
691 | case MAX77693_MUIC_ADC_REMOTE_S7_BUTTON: /* DOCK_KEY_NEXT */ | 695 | case MAX77693_MUIC_ADC_REMOTE_S7_BUTTON: /* DOCK_KEY_NEXT */ |
@@ -710,7 +714,7 @@ static int max77693_muic_adc_handler(struct max77693_muic_info *info) | |||
710 | ret = max77693_muic_dock_button_handler(info, button_type, | 714 | ret = max77693_muic_dock_button_handler(info, button_type, |
711 | attached); | 715 | attached); |
712 | if (ret < 0) | 716 | if (ret < 0) |
713 | goto out; | 717 | return ret; |
714 | break; | 718 | break; |
715 | case MAX77693_MUIC_ADC_SEND_END_BUTTON: | 719 | case MAX77693_MUIC_ADC_SEND_END_BUTTON: |
716 | case MAX77693_MUIC_ADC_REMOTE_S1_BUTTON: | 720 | case MAX77693_MUIC_ADC_REMOTE_S1_BUTTON: |
@@ -738,17 +742,15 @@ static int max77693_muic_adc_handler(struct max77693_muic_info *info) | |||
738 | dev_info(info->dev, | 742 | dev_info(info->dev, |
739 | "accessory is %s but it isn't used (adc:0x%x)\n", | 743 | "accessory is %s but it isn't used (adc:0x%x)\n", |
740 | attached ? "attached" : "detached", cable_type); | 744 | attached ? "attached" : "detached", cable_type); |
741 | goto out; | 745 | return -EAGAIN; |
742 | default: | 746 | default: |
743 | dev_err(info->dev, | 747 | dev_err(info->dev, |
744 | "failed to detect %s accessory (adc:0x%x)\n", | 748 | "failed to detect %s accessory (adc:0x%x)\n", |
745 | attached ? "attached" : "detached", cable_type); | 749 | attached ? "attached" : "detached", cable_type); |
746 | ret = -EINVAL; | 750 | return -EINVAL; |
747 | goto out; | ||
748 | } | 751 | } |
749 | 752 | ||
750 | out: | 753 | return 0; |
751 | return ret; | ||
752 | } | 754 | } |
753 | 755 | ||
754 | static int max77693_muic_chg_handler(struct max77693_muic_info *info) | 756 | static int max77693_muic_chg_handler(struct max77693_muic_info *info) |
@@ -959,7 +961,8 @@ static void max77693_muic_irq_work(struct work_struct *work) | |||
959 | default: | 961 | default: |
960 | dev_err(info->dev, "muic interrupt: irq %d occurred\n", | 962 | dev_err(info->dev, "muic interrupt: irq %d occurred\n", |
961 | irq_type); | 963 | irq_type); |
962 | break; | 964 | mutex_unlock(&info->mutex); |
965 | return; | ||
963 | } | 966 | } |
964 | 967 | ||
965 | if (ret < 0) | 968 | if (ret < 0) |
@@ -1007,21 +1010,27 @@ static int max77693_muic_detect_accessory(struct max77693_muic_info *info) | |||
1007 | &attached); | 1010 | &attached); |
1008 | if (attached && adc != MAX77693_MUIC_ADC_OPEN) { | 1011 | if (attached && adc != MAX77693_MUIC_ADC_OPEN) { |
1009 | ret = max77693_muic_adc_handler(info); | 1012 | ret = max77693_muic_adc_handler(info); |
1010 | if (ret < 0) | 1013 | if (ret < 0) { |
1011 | dev_err(info->dev, "Cannot detect accessory\n"); | 1014 | dev_err(info->dev, "Cannot detect accessory\n"); |
1015 | mutex_unlock(&info->mutex); | ||
1016 | return ret; | ||
1017 | } | ||
1012 | } | 1018 | } |
1013 | 1019 | ||
1014 | chg_type = max77693_muic_get_cable_type(info, MAX77693_CABLE_GROUP_CHG, | 1020 | chg_type = max77693_muic_get_cable_type(info, MAX77693_CABLE_GROUP_CHG, |
1015 | &attached); | 1021 | &attached); |
1016 | if (attached && chg_type != MAX77693_CHARGER_TYPE_NONE) { | 1022 | if (attached && chg_type != MAX77693_CHARGER_TYPE_NONE) { |
1017 | ret = max77693_muic_chg_handler(info); | 1023 | ret = max77693_muic_chg_handler(info); |
1018 | if (ret < 0) | 1024 | if (ret < 0) { |
1019 | dev_err(info->dev, "Cannot detect charger accessory\n"); | 1025 | dev_err(info->dev, "Cannot detect charger accessory\n"); |
1026 | mutex_unlock(&info->mutex); | ||
1027 | return ret; | ||
1028 | } | ||
1020 | } | 1029 | } |
1021 | 1030 | ||
1022 | mutex_unlock(&info->mutex); | 1031 | mutex_unlock(&info->mutex); |
1023 | 1032 | ||
1024 | return ret; | 1033 | return 0; |
1025 | } | 1034 | } |
1026 | 1035 | ||
1027 | static void max77693_muic_detect_cable_wq(struct work_struct *work) | 1036 | static void max77693_muic_detect_cable_wq(struct work_struct *work) |