Commit 19d3243e authored by Chanwoo Choi's avatar Chanwoo Choi Committed by Greg Kroah-Hartman

extcon: max77693: Remove unnecessary goto statement to improve readability

Signed-off-by: default avatarChanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: default avatarMyungjoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent eff7d74f
...@@ -224,16 +224,17 @@ static int max77693_muic_set_debounce_time(struct max77693_muic_info *info, ...@@ -224,16 +224,17 @@ static int max77693_muic_set_debounce_time(struct max77693_muic_info *info,
MAX77693_MUIC_REG_CTRL3, MAX77693_MUIC_REG_CTRL3,
time << CONTROL3_ADCDBSET_SHIFT, time << CONTROL3_ADCDBSET_SHIFT,
CONTROL3_ADCDBSET_MASK); CONTROL3_ADCDBSET_MASK);
if (ret) if (ret) {
dev_err(info->dev, "failed to set ADC debounce time\n"); dev_err(info->dev, "failed to set ADC debounce time\n");
return -EAGAIN;
}
break; break;
default: default:
dev_err(info->dev, "invalid ADC debounce time\n"); dev_err(info->dev, "invalid ADC debounce time\n");
ret = -EINVAL; return -EINVAL;
break;
} }
return ret; return 0;
}; };
/* /*
...@@ -261,7 +262,7 @@ static int max77693_muic_set_path(struct max77693_muic_info *info, ...@@ -261,7 +262,7 @@ static int max77693_muic_set_path(struct max77693_muic_info *info,
MAX77693_MUIC_REG_CTRL1, ctrl1, COMP_SW_MASK); MAX77693_MUIC_REG_CTRL1, ctrl1, COMP_SW_MASK);
if (ret < 0) { if (ret < 0) {
dev_err(info->dev, "failed to update MUIC register\n"); dev_err(info->dev, "failed to update MUIC register\n");
goto out; return -EAGAIN;
} }
if (attached) if (attached)
...@@ -274,14 +275,14 @@ static int max77693_muic_set_path(struct max77693_muic_info *info, ...@@ -274,14 +275,14 @@ static int max77693_muic_set_path(struct max77693_muic_info *info,
CONTROL2_LOWPWR_MASK | CONTROL2_CPEN_MASK); CONTROL2_LOWPWR_MASK | CONTROL2_CPEN_MASK);
if (ret < 0) { if (ret < 0) {
dev_err(info->dev, "failed to update MUIC register\n"); dev_err(info->dev, "failed to update MUIC register\n");
goto out; return -EAGAIN;
} }
dev_info(info->dev, dev_info(info->dev,
"CONTROL1 : 0x%02x, CONTROL2 : 0x%02x, state : %s\n", "CONTROL1 : 0x%02x, CONTROL2 : 0x%02x, state : %s\n",
ctrl1, ctrl2, attached ? "attached" : "detached"); ctrl1, ctrl2, attached ? "attached" : "detached");
out:
return ret; return 0;
} }
/* /*
...@@ -503,6 +504,10 @@ static int max77693_muic_dock_handler(struct max77693_muic_info *info, ...@@ -503,6 +504,10 @@ static int max77693_muic_dock_handler(struct max77693_muic_info *info,
if (!attached) if (!attached)
extcon_set_cable_state(info->edev, "USB", false); extcon_set_cable_state(info->edev, "USB", false);
break; break;
default:
dev_err(info->dev, "failed to detect %s dock device\n",
attached ? "attached" : "detached");
return -EINVAL;
} }
/* Dock-Car/Desk/Audio, PATH:AUDIO */ /* Dock-Car/Desk/Audio, PATH:AUDIO */
...@@ -520,7 +525,6 @@ static int max77693_muic_dock_button_handler(struct max77693_muic_info *info, ...@@ -520,7 +525,6 @@ static int max77693_muic_dock_button_handler(struct max77693_muic_info *info,
{ {
struct input_dev *dock = info->dock; struct input_dev *dock = info->dock;
unsigned int code; unsigned int code;
int ret = 0;
switch (button_type) { switch (button_type) {
case MAX77693_MUIC_ADC_REMOTE_S3_BUTTON-1 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,14 +554,12 @@ static int max77693_muic_dock_button_handler(struct max77693_muic_info *info,
dev_err(info->dev, dev_err(info->dev,
"failed to detect %s key (adc:0x%x)\n", "failed to detect %s key (adc:0x%x)\n",
attached ? "pressed" : "released", button_type); attached ? "pressed" : "released", button_type);
ret = -EINVAL; return -EINVAL;
goto out;
} }
input_event(dock, EV_KEY, code, attached); input_event(dock, EV_KEY, code, attached);
input_sync(dock); input_sync(dock);
out:
return 0; return 0;
} }
...@@ -576,14 +578,14 @@ static int max77693_muic_adc_ground_handler(struct max77693_muic_info *info) ...@@ -576,14 +578,14 @@ static int max77693_muic_adc_ground_handler(struct max77693_muic_info *info)
/* USB_OTG, PATH: AP_USB */ /* USB_OTG, PATH: AP_USB */
ret = max77693_muic_set_path(info, CONTROL1_SW_USB, attached); ret = max77693_muic_set_path(info, CONTROL1_SW_USB, attached);
if (ret < 0) if (ret < 0)
goto out; return ret;
extcon_set_cable_state(info->edev, "USB-Host", attached); extcon_set_cable_state(info->edev, "USB-Host", attached);
break; break;
case MAX77693_MUIC_GND_AV_CABLE_LOAD: case MAX77693_MUIC_GND_AV_CABLE_LOAD:
/* Audio Video Cable with load, PATH:AUDIO */ /* Audio Video Cable with load, PATH:AUDIO */
ret = max77693_muic_set_path(info, CONTROL1_SW_AUDIO, attached); ret = max77693_muic_set_path(info, CONTROL1_SW_AUDIO, attached);
if (ret < 0) if (ret < 0)
goto out; return ret;
extcon_set_cable_state(info->edev, extcon_set_cable_state(info->edev,
"Audio-video-load", attached); "Audio-video-load", attached);
break; break;
...@@ -593,14 +595,12 @@ static int max77693_muic_adc_ground_handler(struct max77693_muic_info *info) ...@@ -593,14 +595,12 @@ static int max77693_muic_adc_ground_handler(struct max77693_muic_info *info)
extcon_set_cable_state(info->edev, "MHL", attached); extcon_set_cable_state(info->edev, "MHL", attached);
break; break;
default: default:
dev_err(info->dev, "failed to detect %s accessory\n", dev_err(info->dev, "failed to detect %s cable of gnd type\n",
attached ? "attached" : "detached"); attached ? "attached" : "detached");
ret = -EINVAL; return -EINVAL;
break;
} }
out: return 0;
return ret;
} }
static int max77693_muic_jig_handler(struct max77693_muic_info *info, 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,15 +630,19 @@ static int max77693_muic_jig_handler(struct max77693_muic_info *info,
strcpy(cable_name, "JIG-UART-OFF"); strcpy(cable_name, "JIG-UART-OFF");
path = CONTROL1_SW_UART; path = CONTROL1_SW_UART;
break; break;
default:
dev_err(info->dev, "failed to detect %s jig cable\n",
attached ? "attached" : "detached");
return -EINVAL;
} }
ret = max77693_muic_set_path(info, path, attached); ret = max77693_muic_set_path(info, path, attached);
if (ret < 0) if (ret < 0)
goto out; return ret;
extcon_set_cable_state(info->edev, cable_name, attached); extcon_set_cable_state(info->edev, cable_name, attached);
out:
return ret; return 0;
} }
static int max77693_muic_adc_handler(struct max77693_muic_info *info) 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,7 +672,7 @@ static int max77693_muic_adc_handler(struct max77693_muic_info *info)
/* JIG */ /* JIG */
ret = max77693_muic_jig_handler(info, cable_type, attached); ret = max77693_muic_jig_handler(info, cable_type, attached);
if (ret < 0) if (ret < 0)
goto out; return ret;
break; break;
case MAX77693_MUIC_ADC_RESERVED_ACC_3: /* Dock-Smart */ case MAX77693_MUIC_ADC_RESERVED_ACC_3: /* Dock-Smart */
case MAX77693_MUIC_ADC_FACTORY_MODE_UART_ON: /* Dock-Car */ 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,7 +689,7 @@ static int max77693_muic_adc_handler(struct max77693_muic_info *info)
*/ */
ret = max77693_muic_dock_handler(info, cable_type, attached); ret = max77693_muic_dock_handler(info, cable_type, attached);
if (ret < 0) if (ret < 0)
goto out; return ret;
break; break;
case MAX77693_MUIC_ADC_REMOTE_S3_BUTTON: /* DOCK_KEY_PREV */ case MAX77693_MUIC_ADC_REMOTE_S3_BUTTON: /* DOCK_KEY_PREV */
case MAX77693_MUIC_ADC_REMOTE_S7_BUTTON: /* DOCK_KEY_NEXT */ 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,7 +714,7 @@ static int max77693_muic_adc_handler(struct max77693_muic_info *info)
ret = max77693_muic_dock_button_handler(info, button_type, ret = max77693_muic_dock_button_handler(info, button_type,
attached); attached);
if (ret < 0) if (ret < 0)
goto out; return ret;
break; break;
case MAX77693_MUIC_ADC_SEND_END_BUTTON: case MAX77693_MUIC_ADC_SEND_END_BUTTON:
case MAX77693_MUIC_ADC_REMOTE_S1_BUTTON: case MAX77693_MUIC_ADC_REMOTE_S1_BUTTON:
...@@ -738,17 +742,15 @@ static int max77693_muic_adc_handler(struct max77693_muic_info *info) ...@@ -738,17 +742,15 @@ static int max77693_muic_adc_handler(struct max77693_muic_info *info)
dev_info(info->dev, dev_info(info->dev,
"accessory is %s but it isn't used (adc:0x%x)\n", "accessory is %s but it isn't used (adc:0x%x)\n",
attached ? "attached" : "detached", cable_type); attached ? "attached" : "detached", cable_type);
goto out; return -EAGAIN;
default: default:
dev_err(info->dev, dev_err(info->dev,
"failed to detect %s accessory (adc:0x%x)\n", "failed to detect %s accessory (adc:0x%x)\n",
attached ? "attached" : "detached", cable_type); attached ? "attached" : "detached", cable_type);
ret = -EINVAL; return -EINVAL;
goto out;
} }
out: return 0;
return ret;
} }
static int max77693_muic_chg_handler(struct max77693_muic_info *info) 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,7 +961,8 @@ static void max77693_muic_irq_work(struct work_struct *work)
default: default:
dev_err(info->dev, "muic interrupt: irq %d occurred\n", dev_err(info->dev, "muic interrupt: irq %d occurred\n",
irq_type); irq_type);
break; mutex_unlock(&info->mutex);
return;
} }
if (ret < 0) if (ret < 0)
...@@ -1007,21 +1010,27 @@ static int max77693_muic_detect_accessory(struct max77693_muic_info *info) ...@@ -1007,21 +1010,27 @@ static int max77693_muic_detect_accessory(struct max77693_muic_info *info)
&attached); &attached);
if (attached && adc != MAX77693_MUIC_ADC_OPEN) { if (attached && adc != MAX77693_MUIC_ADC_OPEN) {
ret = max77693_muic_adc_handler(info); ret = max77693_muic_adc_handler(info);
if (ret < 0) if (ret < 0) {
dev_err(info->dev, "Cannot detect accessory\n"); dev_err(info->dev, "Cannot detect accessory\n");
mutex_unlock(&info->mutex);
return ret;
}
} }
chg_type = max77693_muic_get_cable_type(info, MAX77693_CABLE_GROUP_CHG, chg_type = max77693_muic_get_cable_type(info, MAX77693_CABLE_GROUP_CHG,
&attached); &attached);
if (attached && chg_type != MAX77693_CHARGER_TYPE_NONE) { if (attached && chg_type != MAX77693_CHARGER_TYPE_NONE) {
ret = max77693_muic_chg_handler(info); ret = max77693_muic_chg_handler(info);
if (ret < 0) if (ret < 0) {
dev_err(info->dev, "Cannot detect charger accessory\n"); dev_err(info->dev, "Cannot detect charger accessory\n");
mutex_unlock(&info->mutex);
return ret;
}
} }
mutex_unlock(&info->mutex); mutex_unlock(&info->mutex);
return ret; return 0;
} }
static void max77693_muic_detect_cable_wq(struct work_struct *work) static void max77693_muic_detect_cable_wq(struct work_struct *work)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment