Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755241AbcDFM6A (ORCPT ); Wed, 6 Apr 2016 08:58:00 -0400 Received: from mga02.intel.com ([134.134.136.20]:56071 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754904AbcDFM56 (ORCPT ); Wed, 6 Apr 2016 08:57:58 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,447,1455004800"; d="asc'?scan'208";a="939485924" From: Felipe Balbi 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 Subject: RE: [PATCH v9 2/4] gadget: Support for the usb charger framework In-Reply-To: References: <13c2f4fb71958bf9a5527acbed8b8b60dc569656.1459494744.git.baolin.wang@linaro.org> <20160406071956.GA21101@shlinux2.ap.freescale.net> <871t6j2ai2.fsf@intel.com> User-Agent: Notmuch/0.21+96~g9bbc54b (http://notmuchmail.org) Emacs/25.0.90.3 (x86_64-pc-linux-gnu) Date: Wed, 06 Apr 2016 15:55:55 +0300 Message-ID: <87oa9m28x0.fsf@intel.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3569 Lines: 100 --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable 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 >>=20 >> 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, unsigne= d mA) > { > + enum usb_charger_type type; > + > + if (gadget->charger) { > + type =3D 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 us= ed? isn't it right there in the code ? Isn't usb_gadget_vbus_draw() calling it ? What did I miss here ? >> > This api, as my understanding, gadget only need report gadget state >> changes. >> > All information required for usb charger is charger type and gadget >> state. >>=20 >> you're making an assumption about how the HW is laid out which might not >> be true. >>=20 > > 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. cheers =2D-=20 balbi --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJXBQdcAAoJEIaOsuA1yqREtH4QAKyfZz6UdEH6HbGbeVqYjhUc qJJZiMk7lp9FpZIkFdTTSILEkHfYy26PRc5di6rsuwmsOIZOKx1r9iLFPYYJQy8P IhOuk7SvP5oGe5Tsadt+qb+IQoqKezhndMjTr41bdWy6NhkPpuzYxTqrD4JpWWfZ vcZxWeTFIM9fjJaNHFiLFsVKvYIBhfsPIty9gJ3LPThhSdyuVXg96DpdTeJbkHNT WDx/W6iCcSNiNMIeg+Wn3sHzDgvgJp9vZN8eHbsbiIKGtGuv0mJ0bfxIbsG1bgM0 CIDylERz7umOzqNo/MPBu+B2KlJwBqtT2b9mue0OCW2SxRFXXlhNTTuWx0UzYwAq JDWbC1xzVpCY8z0KNtk/nkcK6tiwTvis46xZjIUhND67TMbKKGoOF1JzztIw+qab m/4d2iupYdKXtAlNgBMivnvHgyYCXAdsOG0ic5TgOhM4IjtKyDDdJ5y5Up/kANy8 f4Ycc9/0+iDjXtncBbapgzSOqfy5xS57sXOb2HLUDgx3quHGgu8f2NDGSg+fMH50 DnrEfy1HmYJ49zoJ8oN7duzSuyifCuo3evB7xCgRC7CDSY6yR2PzvpLAOGmdD0D/ nfnIwpsF0EseuNnyMvloxWPgkzIYN7Etwuvki2qdULp32+8FaSUWCXeLJwlEgOXf M0hbzXuI+JzBqLA5uP7n =/7Tr -----END PGP SIGNATURE----- --=-=-=--