[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-id: <20170329115453.4268-2-andi.shyti@samsung.com>
Date: Wed, 29 Mar 2017 20:54:52 +0900
From: Andi Shyti <andi.shyti@...sung.com>
To: MyungJoo Ham <myungjoo.ham@...sung.com>,
Chanwoo Choi <cw00.choi@...sung.com>,
Jaewon Kim <jaewon02.kim@...sung.com>
Cc: Seung-Woo Kim <sw0312.kim@...sung.com>,
Krzysztof Kozlowski <krzk@...nel.org>,
linux-kernel@...r.kernel.org, Andi Shyti <andi.shyti@...sung.com>,
Andi Shyti <andi@...zian.org>
Subject: [PATCH 1/2] extcon: max77843: improve the code and minimize duplicated
lines
Signed-off-by: Andi Shyti <andi.shyti@...sung.com>
---
drivers/extcon/extcon-max77843.c | 33 ++++++++-------------------------
1 file changed, 8 insertions(+), 25 deletions(-)
diff --git a/drivers/extcon/extcon-max77843.c b/drivers/extcon/extcon-max77843.c
index 6e722d552cf1..fcdabc4b4025 100644
--- a/drivers/extcon/extcon-max77843.c
+++ b/drivers/extcon/extcon-max77843.c
@@ -264,37 +264,20 @@ static int max77843_muic_get_cable_type(struct max77843_muic_info *info,
chg_type = info->status[MAX77843_MUIC_STATUS2] &
MAX77843_MUIC_STATUS2_CHGTYP_MASK;
- /* Check GROUND accessory with charger cable */
- if (adc == MAX77843_MUIC_ADC_GROUND) {
- if (chg_type == MAX77843_MUIC_CHG_NONE) {
- /*
- * The following state when charger cable is
- * disconnected but the GROUND accessory still
- * connected.
- */
- *attached = false;
- cable_type = info->prev_chg_type;
- info->prev_chg_type = MAX77843_MUIC_CHG_NONE;
- } else {
-
- /*
- * The following state when charger cable is
- * connected on the GROUND accessory.
- */
- *attached = true;
- cable_type = MAX77843_MUIC_CHG_GND;
- info->prev_chg_type = MAX77843_MUIC_CHG_GND;
- }
- break;
- }
-
if (chg_type == MAX77843_MUIC_CHG_NONE) {
*attached = false;
cable_type = info->prev_chg_type;
info->prev_chg_type = MAX77843_MUIC_CHG_NONE;
} else {
*attached = true;
- cable_type = info->prev_chg_type = chg_type;
+ switch (adc) {
+ case MAX77843_MUIC_ADC_GROUND:
+ info->prev_chg_type = MAX77843_MUIC_CHG_GND;
+ break;
+ default:
+ info->prev_chg_type = chg_type;
+ }
+ cable_type = info->prev_chg_type;
}
break;
case MAX77843_CABLE_GROUP_ADC_GND:
--
2.11.0
Powered by blists - more mailing lists