All of lore.kernel.org
 help / color / mirror / Atom feed
From: Felipe Balbi <balbi@kernel.org>
To: Jun Li <jun.li@nxp.com>, Baolin Wang <baolin.wang@linaro.org>,
	Peter Chen <hzpeterchen@gmail.com>
Cc: Greg KH <gregkh@linuxfoundation.org>,
	Sebastian Reichel <sre@kernel.org>,
	Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>,
	David Woodhouse <dwmw2@infradead.org>,
	Peter Chen <peter.chen@freescale.com>,
	Alan Stern <stern@rowland.harvard.edu>,
	Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>,
	Lee Jones <lee.jones@linaro.org>, Mark Brown <broonie@kernel.org>,
	Charles Keepax <ckeepax@opensource.wolfsonmicro.com>,
	"patches@opensource.wolfsonmicro.com"
	<patches@opensource.wolfsonmicro.com>,
	Linux PM list <linux-pm@vger.kernel.org>,
	USB <linux-usb@vger.kernel.org>,
	"device-mainlining@lists.linuxfoundation.org"
	<device-mainlining@lists.linuxfoundation.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH v9 2/4] gadget: Support for the usb charger framework
Date: Wed, 06 Apr 2016 16:58:03 +0300	[thread overview]
Message-ID: <87egai261g.fsf@intel.com> (raw)
In-Reply-To: <AM4PR04MB2130E03385128C1CD22553E7899F0@AM4PR04MB2130.eurprd04.prod.outlook.com>

[-- Attachment #1: Type: text/plain, Size: 2978 bytes --]


Hi,

Jun Li <jun.li@nxp.com> writes:
>> >> >> > 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().

because of semantics. usb_gadget_vbus_draw() is *only* supposed to
connect a load across vbus and gnd so some battery can be charged. Also,
we need to abstract away this ->get_charger_type() operation because it
might be different for each UDC.

$subject has a fragility, however: It's assuming that we should always
call ->get_charger_type() before ->vbus_draw(), but that's a good
default, I'd say.

>> >> > 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.

that sure is a fair point.

-- 
balbi

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Felipe Balbi <balbi@kernel.org>
To: Jun Li <jun.li@nxp.com>, Baolin Wang <baolin.wang@linaro.org>,
	Peter Chen <hzpeterchen@gmail.com>
Cc: Greg KH <gregkh@linuxfoundation.org>,
	Sebastian Reichel <sre@kernel.org>,
	Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>,
	David Woodhouse <dwmw2@infradead.org>,
	Peter Chen <peter.chen@freescale.com>,
	Alan Stern <stern@rowland.harvard.edu>,
	Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>,
	Lee Jones <lee.jones@linaro.org>, Mark Brown <broonie@kernel.org>,
	Charles Keepax <ckeepax@opensource.wolfsonmicro.com>,
	"patches\@opensource.wolfsonmicro.com" 
	<patches@opensource.wolfsonmicro.com>,
	Linux PM list <linux-pm@vger.kernel.org>,
	USB <linux-usb@vger.kernel.org>,
	"device-mainlining\@lists.linuxfoundation.org" 
	<device-mainlining@lists.linuxfoundation.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH v9 2/4] gadget: Support for the usb charger framework
Date: Wed, 06 Apr 2016 16:58:03 +0300	[thread overview]
Message-ID: <87egai261g.fsf@intel.com> (raw)
In-Reply-To: <AM4PR04MB2130E03385128C1CD22553E7899F0@AM4PR04MB2130.eurprd04.prod.outlook.com>

[-- Attachment #1: Type: text/plain, Size: 2978 bytes --]


Hi,

Jun Li <jun.li@nxp.com> writes:
>> >> >> > 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().

because of semantics. usb_gadget_vbus_draw() is *only* supposed to
connect a load across vbus and gnd so some battery can be charged. Also,
we need to abstract away this ->get_charger_type() operation because it
might be different for each UDC.

$subject has a fragility, however: It's assuming that we should always
call ->get_charger_type() before ->vbus_draw(), but that's a good
default, I'd say.

>> >> > 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.

that sure is a fair point.

-- 
balbi

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]

  reply	other threads:[~2016-04-06 13:58 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-01  7:21 [PATCH v9 0/4] Introduce usb charger framework to deal with the usb gadget power negotation Baolin Wang
     [not found] ` <cover.1459494743.git.baolin.wang-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2016-04-01  7:21   ` [PATCH v9 1/4] gadget: Introduce the usb charger framework Baolin Wang
2016-04-01  7:21     ` Baolin Wang
2016-04-05  7:56     ` Peter Chen
     [not found]       ` <20160405075612.GB31351-Fb7DQEYuewWctlrPMvKcciBecyulp+rMXqFh9Ls21Oc@public.gmane.org>
2016-04-05  9:41         ` Baolin Wang
2016-04-05  9:41           ` Baolin Wang
2016-04-06  7:25     ` Peter Chen
2016-04-06  7:38       ` Felipe Balbi
2016-04-06  7:43         ` Peter Chen
2016-04-06  8:05           ` Felipe Balbi
2016-04-06  8:10             ` Peter Chen
2016-04-06 10:25               ` Felipe Balbi
2016-04-07  2:39                 ` Peter Chen
2016-04-07  4:56                   ` Felipe Balbi
2016-04-07  6:11                     ` Baolin Wang
2016-04-06  8:11             ` Peter Chen
2016-04-06 10:25               ` Felipe Balbi
2016-04-06  8:26     ` Jun Li
2016-04-06 11:31       ` Baolin Wang
2016-04-06 11:31         ` Baolin Wang
2016-04-06 11:55         ` Jun Li
2016-04-06 11:55           ` Jun Li
2016-04-01  7:21   ` [PATCH v9 3/4] gadget: Integrate with the usb gadget supporting for usb charger Baolin Wang
2016-04-01  7:21     ` Baolin Wang
2016-04-01  7:21 ` [PATCH v9 2/4] gadget: Support for the usb charger framework Baolin Wang
2016-04-06  7:19   ` Peter Chen
2016-04-06 10:46     ` Baolin Wang
2016-04-06 12:03       ` Jun Li
     [not found]         ` <AM4PR04MB2130F58AA1018FFD367C89E0899F0-WOempg8NbQQzjTQnahXoOs9NdZoXdze2vxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2016-04-06 12:21           ` Felipe Balbi
2016-04-06 12:21             ` Felipe Balbi
2016-04-06 12:51             ` Jun Li
     [not found]               ` <AM4PR04MB213054CF3F597CE2E6FE976F899F0-WOempg8NbQQzjTQnahXoOs9NdZoXdze2vxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2016-04-06 12:55                 ` Felipe Balbi
2016-04-06 12:55                   ` Felipe Balbi
     [not found]                   ` <87oa9m28x0.fsf-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2016-04-06 13:49                     ` Jun Li
2016-04-06 13:49                       ` Jun Li
2016-04-06 13:58                       ` Felipe Balbi [this message]
2016-04-06 13:58                         ` Felipe Balbi
2016-04-07  3:03                         ` Peter Chen
2016-04-07  4:58                           ` Felipe Balbi
2016-04-07  4:58                             ` Felipe Balbi
2016-04-01  7:21 ` [PATCH v9 4/4] power: wm831x_power: Support USB charger current limit management Baolin Wang
2016-04-05  6:46 ` [PATCH v9 0/4] Introduce usb charger framework to deal with the usb gadget power negotation Peter Chen
2016-04-05  7:54   ` Baolin Wang
2016-04-05  8:12     ` Peter Chen
2016-04-05  9:34       ` Baolin Wang
2016-04-05  9:43         ` Peter Chen
2016-04-05 11:06           ` Baolin Wang
2016-04-05 17:01           ` Mark Brown
2016-04-05 16:53       ` Mark Brown
2016-04-06  1:15         ` Peter Chen
2016-04-06 17:01           ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87egai261g.fsf@intel.com \
    --to=balbi@kernel.org \
    --cc=baolin.wang@linaro.org \
    --cc=broonie@kernel.org \
    --cc=ckeepax@opensource.wolfsonmicro.com \
    --cc=dbaryshkov@gmail.com \
    --cc=device-mainlining@lists.linuxfoundation.org \
    --cc=dwmw2@infradead.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hzpeterchen@gmail.com \
    --cc=jun.li@nxp.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=patches@opensource.wolfsonmicro.com \
    --cc=peter.chen@freescale.com \
    --cc=sre@kernel.org \
    --cc=stern@rowland.harvard.edu \
    --cc=yoshihiro.shimoda.uh@renesas.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.