From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752073AbcF2Iis (ORCPT ); Wed, 29 Jun 2016 04:38:48 -0400 Received: from mail-qk0-f182.google.com ([209.85.220.182]:33654 "EHLO mail-qk0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751622AbcF2Iio (ORCPT ); Wed, 29 Jun 2016 04:38:44 -0400 MIME-Version: 1.0 In-Reply-To: <87bn2kieb6.fsf@linux.intel.com> References: <87bn2uomzd.fsf@linux.intel.com> <87eg7giexn.fsf@linux.intel.com> <87bn2kieb6.fsf@linux.intel.com> From: Baolin Wang Date: Wed, 29 Jun 2016 16:38:42 +0800 Message-ID: Subject: Re: [PATCH v12 2/4] gadget: Support for the usb charger framework To: Felipe Balbi Cc: Greg KH , Sebastian Reichel , Dmitry Eremin-Solenikov , David Woodhouse , robh@kernel.org, Jun Li , Marek Szyprowski , Ruslan Bilovol , Peter Chen , Alan Stern , r.baldyga@samsung.com, grygorii.strashko@ti.com, Yoshihiro Shimoda , Lee Jones , Mark Brown , Charles Keepax , patches@opensource.wolfsonmicro.com, Linux PM list , USB , device-mainlining@lists.linuxfoundation.org, LKML 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 29 June 2016 at 16:34, Felipe Balbi wrote: > > Hi, > > Baolin Wang writes: >>>>>> For supporting the usb charger, it adds the usb_charger_init() and >>>>>> usb_charger_exit() functions for usb charger initialization and exit. >>>>>> >>>>>> It will report to the usb charger when the gadget state is changed, >>>>>> then the usb charger can do the power things. >>>>>> >>>>>> Signed-off-by: Baolin Wang >>>>>> Reviewed-by: Li Jun >>>>>> Tested-by: Li Jun >>>>> >>>>> Before anything, I must say that I really liked this patch. It's >>>>> minimaly invasive to udc core and does all the necessary changes. If it >>>>> wasn't for the extra charger class, this would've been perfect. >>>>> >>>>> Can't you just tie a charger to a UDC and avoid the charger class >>>>> completely? >>>>> >>>>>> static inline int usb_gadget_vbus_draw(struct usb_gadget *gadget, unsigned mA) >>>>>> { >>>>>> + if (gadget->charger) >>>>> >>>>> I guess you could do this check inside >>>>> usb_gadget_set_cur_limit_by_type() itself. >>>> >>>> We will access the 'gadget->charger->type' member when issuing >>>> usb_gadget_set_cur_limit_by_type(), so I think I should leave the >>>> check here in next new version. >>> >>> Here's what I mean: >>> >>> int usb_charger_set_cur_limit(struct usb_gadget *gadget, unsigned int mA) >>> { >>> struct usb_charger *charger; >>> enum usb_charger_type type; >>> >>> if (!gadget->charger) >>> return 0; >>> >>> charger = gadget->charger; >>> type = charger->type; >>> >>> return __usb_charger_set_cur_limit(charger, type, mA); >>> } >> >> But that means we need to export both 'usb_charger_set_cur_limit()' >> function and '__usb_charger_set_cur_limit()' function in charger.c >> file. Cause some user may want to set the current limitation by one >> charger type parameter (may be not from charger->type), like by >> issuing '__usb_charger_set_cur_limit(charger, SDP_TYPE, mA)'. How do >> you think about this situation? Thanks. > > if we have that requirement, that's totally fine. Just rename > __usb_charger_set_cur_limit() back to > _usb_charger_set_cur_limit_by_type() and expose both. But > set_cur_limit_by_type can assume its arguments are valid at all times. Make sense. I'll fix this issue in v14 version. Thanks. -- Baolin.wang Best Regards