Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1614644 > unrolled thread

[PATCH v2 0/2] Add support for USB accessories in the max77843 extcon

Started byAndi Shyti <andi.shyti@gmail.com>
First post2017-04-02 07:40 +0200
Last post2017-04-03 10:00 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH v2 0/2] Add support for USB accessories in the max77843 extcon Andi Shyti <andi.shyti@gmail.com> - 2017-04-02 07:40 +0200
    [PATCH v2 1/2] extcon: max77843: improve the code and minimize duplicated lines Andi Shyti <andi.shyti@gmail.com> - 2017-04-02 07:40 +0200
      Re: [PATCH v2 1/2] extcon: max77843: improve the code and minimize  duplicated lines Chanwoo Choi <cw00.choi@samsung.com> - 2017-04-03 10:00 +0200

#1614644 — [PATCH v2 0/2] Add support for USB accessories in the max77843 extcon

FromAndi Shyti <andi.shyti@gmail.com>
Date2017-04-02 07:40 +0200
Subject[PATCH v2 0/2] Add support for USB accessories in the max77843 extcon
Message-ID<trGp3-4Fr-5@gated-at.bofh.it>
From: Andi Shyti <andi@smida.it>

Hi,

this patchset add handling of external USB accessories that are
connected to the extcon max77843 device.

The first patch is preparatory, that mainly aims to improve the
readability of the second patch. It makes some code refactoring
reducing the duplicated code, the result is exactly the same.

It has been tested on TM2 with mainline kernel 4.11-rc4.

Andi

Changelog v1 -> v2
------------------
Added a comment to explain better the meaning of the
MAX77843_MUIC_ADC_RESERVED_ACC_* devices as recommended by
Krzysztof.

Andi Shyti (2):
  extcon: max77843: improve the code and minimize duplicated lines
  extcon: max77843: support USB accessories as external USB hosts

 drivers/extcon/extcon-max77843.c | 57 +++++++++++++++++++---------------------
 1 file changed, 27 insertions(+), 30 deletions(-)

-- 
2.11.0

[toc] | [next] | [standalone]


#1614645 — [PATCH v2 1/2] extcon: max77843: improve the code and minimize duplicated lines

FromAndi Shyti <andi.shyti@gmail.com>
Date2017-04-02 07:40 +0200
Subject[PATCH v2 1/2] extcon: max77843: improve the code and minimize duplicated lines
Message-ID<trGp3-4Fr-7@gated-at.bofh.it>
In reply to#1614644
From: Andi Shyti <andi.shyti@samsung.com>

Signed-off-by: Andi Shyti <andi.shyti@samsung.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

[toc] | [prev] | [next] | [standalone]


#1614953 — Re: [PATCH v2 1/2] extcon: max77843: improve the code and minimize duplicated lines

FromChanwoo Choi <cw00.choi@samsung.com>
Date2017-04-03 10:00 +0200
SubjectRe: [PATCH v2 1/2] extcon: max77843: improve the code and minimize duplicated lines
Message-ID<ts546-3XB-15@gated-at.bofh.it>
In reply to#1614645
Hi,

Actually, I checked this patch on following four case.
It is same operation between before and after.
-------------------------------------------------------------
       | adc                       | chg_type               |
-------------------------------------------------------------
case 1 | MAX77843_MUIC_ADC_GROUND  | MAX77843_MUIC_CHG_NONE |
case 2 | MAX77843_MUIC_ADC_GROUND  |                        |
case 3 |                           | MAX77843_MUIC_CHG_NONE |
case 4 |                           |                        |
-------------------------------------------------------------


But, I don't want to apply this patch.

By applying this patch, I think there is no huge benefits
and certainly I prefer to remain the all descriptions for specific use-case.
(- This patch deletes the 13 lines and add new 8 lines except for the comment.)

On 2017년 04월 02일 14:35, Andi Shyti wrote:
> From: Andi Shyti <andi.shyti@samsung.com>
> 
> Signed-off-by: Andi Shyti <andi.shyti@samsung.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:
> 


-- 
Best Regards,
Chanwoo Choi
Samsung Electronics

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web