Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752819AbcDFNtM (ORCPT ); Wed, 6 Apr 2016 09:49:12 -0400 Received: from mail-db3on0064.outbound.protection.outlook.com ([157.55.234.64]:21920 "EHLO emea01-db3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752739AbcDFNtJ convert rfc822-to-8bit (ORCPT ); Wed, 6 Apr 2016 09:49:09 -0400 From: Jun Li To: Felipe Balbi , Baolin Wang , Peter Chen CC: Greg KH , Sebastian Reichel , Dmitry Eremin-Solenikov , David Woodhouse , Peter Chen , Alan Stern , Yoshihiro Shimoda , Lee Jones , "Mark Brown" , Charles Keepax , "patches@opensource.wolfsonmicro.com" , Linux PM list , USB , "device-mainlining@lists.linuxfoundation.org" , LKML Subject: RE: [PATCH v9 2/4] gadget: Support for the usb charger framework Thread-Topic: [PATCH v9 2/4] gadget: Support for the usb charger framework Thread-Index: AQHRi+evqEo8RiU/f0GkOiqzWpmAkZ98kaEAgAA5vgCAABNbsIAABzaAgAABvFCAAAfUgIAAAUlw Date: Wed, 6 Apr 2016 13:49:04 +0000 Message-ID: References: <13c2f4fb71958bf9a5527acbed8b8b60dc569656.1459494744.git.baolin.wang@linaro.org> <20160406071956.GA21101@shlinux2.ap.freescale.net> <871t6j2ai2.fsf@intel.com> <87oa9m28x0.fsf@intel.com> In-Reply-To: <87oa9m28x0.fsf@intel.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=nxp.com; x-originating-ip: [58.209.166.9] x-ms-office365-filtering-correlation-id: e82de29c-9e45-4eb8-ea6a-08d35e223791 x-microsoft-exchange-diagnostics: 1;AM4PR04MB2130;5:7asTmYG1c97TB4YKG7oan8GDxsfrUuH2Z7O3Tphj9NBBbkoB0BMxbsSSC+5F7P2ysJtOahiNAKBsVLTytoswDjB7A9PcGvxVVaefq882MrtgRsBxRBCRKYzRqeFDJ8ozxVrzRmnWDz59xpdesD/F3Q==;24:4PuvJxtZpuI69/8xoCYzszBXIElMPCHnL3EmhP/GhM9MtIAxeqdqC5M3Of5c4XdUWzRIjK+IQT8VBXA1U6Ow4lBbRHVTUFiw4KdAFdfTLWY= x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:AM4PR04MB2130; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6055026);SRVR:AM4PR04MB2130;BCL:0;PCL:0;RULEID:;SRVR:AM4PR04MB2130; x-forefront-prvs: 0904004ECB x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6009001)(377454003)(24454002)(57704003)(13464003)(2906002)(5008740100001)(77096005)(4326007)(76576001)(5004730100002)(3846002)(19580395003)(3660700001)(122556002)(81166005)(74316001)(3280700002)(189998001)(5001770100001)(19580405001)(2950100001)(2900100001)(106116001)(33656002)(10400500002)(50986999)(93886004)(5003600100002)(54356999)(76176999)(586003)(1096002)(102836003)(6116002)(1220700001)(86362001)(87936001)(92566002)(5002640100001)(66066001)(11100500001)(7059030);DIR:OUT;SFP:1101;SCL:1;SRVR:AM4PR04MB2130;H:AM4PR04MB2130.eurprd04.prod.outlook.com;FPR:;SPF:None;MLV:sfv;LANG:en; spamdiagnosticoutput: 1:23 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Apr 2016 13:49:04.1861 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR04MB2130 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3979 Lines: 101 Hi > -----Original Message----- > From: Felipe Balbi [mailto:balbi@kernel.org] > Sent: Wednesday, April 06, 2016 8:56 PM > To: Jun Li ; Baolin Wang ; Peter > Chen > Cc: Greg KH ; Sebastian Reichel > ; Dmitry Eremin-Solenikov ; David > Woodhouse ; Peter Chen ; > Alan Stern ; r.baldyga@samsung.com; Yoshihiro > Shimoda ; Lee Jones > ; Mark Brown ; Charles Keepax > ; patches@opensource.wolfsonmicro.com; > Linux PM list ; USB ; > device-mainlining@lists.linuxfoundation.org; LKML kernel@vger.kernel.org> > Subject: RE: [PATCH v9 2/4] gadget: Support for the usb charger framework > > > Hi, > > Jun Li writes: > >> >> On 6 April 2016 at 15:19, Peter Chen wrote: > >> >> > On Fri, Apr 01, 2016 at 03:21:50PM +0800, Baolin Wang wrote: > >> >> >> > >> >> >> @@ -563,6 +564,8 @@ struct usb_gadget_ops { > >> >> >> struct usb_ep *(*match_ep)(struct usb_gadget *, > >> >> >> struct usb_endpoint_descriptor *, > >> >> >> struct usb_ss_ep_comp_descriptor *); > >> >> >> + /* get the charger type */ > >> >> >> + enum usb_charger_type (*get_charger_type)(struct > >> >> >> + usb_gadget *); > >> >> >> }; > >> >> > > >> >> > Since we already have get_charger_type callback at usb_charger > >> >> > structure, why we still need this API at usb_gadget_ops? > >> >> > >> >> In case some users want to get charger type at gadget level. > >> >> > >> > Why gadget needs to know charger type? I also don't catch the > >> > intent of > >> > >> because some gadgets need to call usb_gadget_vbus_draw(), although > >> for that they need power in mA rather. > > > > In below change of usb_gadget_vbus_draw(), already can get charger > > type via usb_charger_get_type(). > > > > static inline int usb_gadget_vbus_draw(struct usb_gadget *gadget, > > unsigned mA) { > > + enum usb_charger_type type; > > + > > + if (gadget->charger) { > > + type = usb_charger_get_type(gadget->charger); > > + usb_charger_set_cur_limit_by_type(gadget->charger, type, > mA); > > + } > > + > > if (!gadget->ops->vbus_draw) > > return -EOPNOTSUPP; > > return gadget->ops->vbus_draw(gadget, mA); > > > > Could you detail in what situation gadget->ops-> get_charger_type() is > used? > > isn't it right there in the code ? Isn't usb_gadget_vbus_draw() calling > it ? What did I miss here ? Well, that's true, so my real meaning is why gadget need get charger type via another new api gadget->ops->get_charger_type(). > > >> > This api, as my understanding, gadget only need report gadget state > >> changes. > >> > All information required for usb charger is charger type and gadget > >> state. > >> > >> you're making an assumption about how the HW is laid out which might > >> not be true. > >> > > > > What other information you refer to here? Or what I am not aware of? > > what I'm trying to say is that you're assuming gadgets don't need to know > anything other than charger type and gadget state (suspended, resume, > enumerated, default state, addressed, etc), but that might not be true for > all UDCs. You can't make that assumption that charger type and gadget > state is enough. The real question is what do we need *now*, but still > keep in mind that what we need *now* might be valid 2 years from now, so > API needs to be a little flexible. Get your point, flexible, I just thought create an api without any user for existing case/spec, wouldn't it be better to let the real user add it later when it's needed. > > cheers > > -- > balbi