linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Felipe Balbi <balbi-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: Baolin Wang <baolin.wang-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Cc: Greg KH
	<gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>,
	Sebastian Reichel <sre-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Dmitry Eremin-Solenikov
	<dbaryshkov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	David Woodhouse <dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>,
	robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	Jun Li <jun.li-3arQi8VN3Tc@public.gmane.org>,
	Marek Szyprowski
	<m.szyprowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>,
	Ruslan Bilovol
	<ruslan.bilovol-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Peter Chen <peter.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org>,
	Alan Stern
	<stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.org>,
	r.baldyga-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org,
	grygorii.strashko-l0cyMroinI0@public.gmane.org,
	Yoshihiro Shimoda
	<yoshihiro.shimoda.uh-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>,
	Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Charles Keepax
	<ckeepax-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>,
	patches-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org,
	Linux PM list <linux-pm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	USB <linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	device-mainlining-cunTk1MwBs98uUxBSJOaYoYkZiVZrdSR2LY78lusg7I@public.gmane.org,
	LKML <linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH v12 2/4] gadget: Support for the usb charger framework
Date: Wed, 29 Jun 2016 15:06:46 +0300	[thread overview]
Message-ID: <87twgcgpwp.fsf@linux.intel.com> (raw)
In-Reply-To: <CAMz4kuL9pJzNsn7xXXCp4s9Rczm5vWhuWfF7VjkuxsMUzNZXZQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

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


Hi,

Baolin Wang <baolin.wang-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> 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 <baolin.wang-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
>>>>>>> Reviewed-by: Li Jun <jun.li-3arQi8VN3Tc@public.gmane.org>
>>>>>>> Tested-by: Li Jun <jun.li-3arQi8VN3Tc@public.gmane.org>
>>>>>>
>>>>>> 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.

there's one thing bothering me though:

gadget->charger is supposed to be "current detected charger" right? If
we have a single port tied to a single charger, in which case would we
*ever* need to change current limit of any charger type other than
"current charger" ?

IOW, why do we need _set_cur_limit_by_type() exported at all?

-- 
balbi

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

  parent reply	other threads:[~2016-06-29 12:06 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-21  8:39 [PATCH v12 0/4] Introduce usb charger framework to deal with the usb gadget power negotation Baolin Wang
     [not found] ` <cover.1466497505.git.baolin.wang-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2016-06-21  8:39   ` [PATCH v12 1/4] gadget: Introduce the usb charger framework Baolin Wang
2016-06-21 10:25     ` Felipe Balbi
2016-06-21 11:23       ` Baolin Wang
2016-06-21 14:50         ` Felipe Balbi
2016-06-22  1:49           ` Baolin Wang
2016-06-21  8:39   ` [PATCH v12 2/4] gadget: Support for " Baolin Wang
2016-06-21 10:27     ` Felipe Balbi
2016-06-21 11:29       ` Baolin Wang
2016-06-21 11:49         ` Felipe Balbi
     [not found]           ` <87twgmn4m7.fsf-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2016-06-21 12:05             ` Baolin Wang
2016-06-21 12:27               ` Felipe Balbi
     [not found]                 ` <87inx2n2vs.fsf-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2016-06-21 12:34                   ` Baolin Wang
     [not found]                     ` <CAMz4kuKnzjPOqEr9kJY6SCnq2rszsc55X5=7mWb+ZcbL6G_8DQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-06-21 12:36                       ` Felipe Balbi
2016-06-21 12:43                         ` Baolin Wang
2016-06-21 12:53                           ` Felipe Balbi
2016-06-21 12:54                             ` Felipe Balbi
     [not found]                             ` <87a8ien1o0.fsf-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2016-06-22  1:45                               ` Baolin Wang
     [not found]       ` <87bn2uomzd.fsf-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2016-06-23  8:56         ` Baolin Wang
2016-06-29  8:20           ` Felipe Balbi
2016-06-29  8:31             ` Baolin Wang
2016-06-29  8:34               ` Felipe Balbi
2016-06-29  8:38                 ` Baolin Wang
     [not found]                   ` <CAMz4kuL9pJzNsn7xXXCp4s9Rczm5vWhuWfF7VjkuxsMUzNZXZQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-06-29 12:06                     ` Felipe Balbi [this message]
2016-06-29 12:16                       ` Baolin Wang
2016-06-29 12:30                         ` Felipe Balbi
2016-06-21  8:39   ` [PATCH v12 3/4] gadget: Integrate with the usb gadget supporting for usb charger Baolin Wang
2016-06-21  8:39 ` [PATCH v12 4/4] power: wm831x_power: Support USB charger current limit management Baolin Wang
2016-06-21 10:30   ` Felipe Balbi
2016-06-21 11:03     ` Mark Brown
2016-06-21 11:45       ` Baolin Wang
2016-06-21 11:53         ` Felipe Balbi
2016-06-21 11:57           ` Baolin Wang
2016-06-21 11:50       ` Felipe Balbi
2016-06-21 14:53         ` 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=87twgcgpwp.fsf@linux.intel.com \
    --to=balbi-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
    --cc=baolin.wang-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=ckeepax-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org \
    --cc=dbaryshkov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=device-mainlining-cunTk1MwBs98uUxBSJOaYoYkZiVZrdSR2LY78lusg7I@public.gmane.org \
    --cc=dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org \
    --cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
    --cc=grygorii.strashko-l0cyMroinI0@public.gmane.org \
    --cc=jun.li-3arQi8VN3Tc@public.gmane.org \
    --cc=lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-pm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=m.szyprowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
    --cc=patches-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org \
    --cc=peter.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org \
    --cc=r.baldyga-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
    --cc=robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=ruslan.bilovol-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=sre-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.org \
    --cc=yoshihiro.shimoda.uh-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).