From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752127AbdC2O1f (ORCPT ); Wed, 29 Mar 2017 10:27:35 -0400 Received: from mail.kernel.org ([198.145.29.136]:36612 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751194AbdC2O1d (ORCPT ); Wed, 29 Mar 2017 10:27:33 -0400 MIME-Version: 1.0 In-Reply-To: <20170329115453.4268-3-andi.shyti@samsung.com> References: <20170329115453.4268-1-andi.shyti@samsung.com> <20170329115453.4268-3-andi.shyti@samsung.com> From: Krzysztof Kozlowski Date: Wed, 29 Mar 2017 17:27:10 +0300 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 2/2] extcon: max77843: support USB accessories as external USB hosts To: Andi Shyti Cc: MyungJoo Ham , Chanwoo Choi , Jaewon Kim , Seung-Woo Kim , linux-kernel@vger.kernel.org, Andi Shyti Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 29, 2017 at 2:54 PM, Andi Shyti wrote: > The ADC state defines the resistance that a USB device has in > order to distinguish between devices. > > The external accessories (like the Gear VR) are defined as: > > MAX77843_MUIC_ADC_RESERVED_ACC_1 > MAX77843_MUIC_ADC_RESERVED_ACC_2 > MAX77843_MUIC_ADC_RESERVED_ACC_3 > MAX77843_MUIC_ADC_RESERVED_ACC_4 > MAX77843_MUIC_ADC_RESERVED_ACC_5 > > and they should be set as such in the extcon driver. > > Do not ignore interrupts generated by external accessories by > handling cables of the type from any of the above. > > Do not handle any charging related action. This can be > misleading as also external devices might have some power and in > such cases the MUIC might consider them as power providers. In > this case check the value of the adc and if it corresponds to > one or the MAX77843_MUIC_ADC_RESERVED_ACC_*, return a no-action > value (MAX77843_MUIC_CHG_NONE). > > Signed-off-by: Andi Shyti > --- > drivers/extcon/extcon-max77843.c | 17 ++++++++++++----- > 1 file changed, 12 insertions(+), 5 deletions(-) > > diff --git a/drivers/extcon/extcon-max77843.c b/drivers/extcon/extcon-max77843.c > index fcdabc4b4025..00795fe9ab60 100644 > --- a/drivers/extcon/extcon-max77843.c > +++ b/drivers/extcon/extcon-max77843.c > @@ -271,6 +271,13 @@ static int max77843_muic_get_cable_type(struct max77843_muic_info *info, > } else { > *attached = true; > switch (adc) { > + case MAX77843_MUIC_ADC_RESERVED_ACC_1: > + case MAX77843_MUIC_ADC_RESERVED_ACC_2: > + case MAX77843_MUIC_ADC_RESERVED_ACC_3: > + case MAX77843_MUIC_ADC_RESERVED_ACC_4: > + case MAX77843_MUIC_ADC_RESERVED_ACC_5: In commit msg you mentioned it but in code not. It looks weird to handle a vague "reserved" type in a specific way. How about adding some meaningful names instead of "reserved"? Or at least documenting, that they match Gear VR. Really, imagine later one would be looking at the code and trying to figure out why "reserved" means something Best regards, Krzysztof > + info->prev_chg_type = MAX77843_MUIC_CHG_NONE; > + break; > case MAX77843_MUIC_ADC_GROUND: > info->prev_chg_type = MAX77843_MUIC_CHG_GND; > break; > @@ -403,6 +410,11 @@ static int max77843_muic_adc_handler(struct max77843_muic_info *info) > > switch (cable_type) { > case MAX77843_MUIC_ADC_GROUND: > + case MAX77843_MUIC_ADC_RESERVED_ACC_1: > + case MAX77843_MUIC_ADC_RESERVED_ACC_2: > + case MAX77843_MUIC_ADC_RESERVED_ACC_3: > + case MAX77843_MUIC_ADC_RESERVED_ACC_4: > + case MAX77843_MUIC_ADC_RESERVED_ACC_5: > ret = max77843_muic_adc_gnd_handler(info); > if (ret < 0) > return ret; > @@ -427,11 +439,6 @@ static int max77843_muic_adc_handler(struct max77843_muic_info *info) > case MAX77843_MUIC_ADC_REMOTE_S10_BUTTON: > case MAX77843_MUIC_ADC_REMOTE_S11_BUTTON: > case MAX77843_MUIC_ADC_REMOTE_S12_BUTTON: > - case MAX77843_MUIC_ADC_RESERVED_ACC_1: > - case MAX77843_MUIC_ADC_RESERVED_ACC_2: > - case MAX77843_MUIC_ADC_RESERVED_ACC_3: > - case MAX77843_MUIC_ADC_RESERVED_ACC_4: > - case MAX77843_MUIC_ADC_RESERVED_ACC_5: > case MAX77843_MUIC_ADC_AUDIO_DEVICE_TYPE2: > case MAX77843_MUIC_ADC_PHONE_POWERED_DEV: > case MAX77843_MUIC_ADC_TTY_CONVERTER: > -- > 2.11.0 >