public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: peter.chen@freescale.com (Peter Chen)
To: linux-arm-kernel@lists.infradead.org
Subject: [RESEND PATCH v5 4/7] usb: chipidea: consolidate ci_role_driver's API for both roles
Date: Fri, 25 Jan 2013 11:30:15 +0800	[thread overview]
Message-ID: <20130125033013.GB29795@nchen-desktop> (raw)
In-Reply-To: <8738xqodhp.fsf@ashishki-desk.ger.corp.intel.com>

On Thu, Jan 24, 2013 at 04:35:30PM +0200, Alexander Shishkin wrote:
> Peter Chen <peter.chen@freescale.com> writes:
> 
> > - Create init/destroy API for probe and remove
> > - start/stop API are only used otg id switch process
> > - Create the gadget at ci_hdrc_probe if the gadget is supported
> > at that port, the main purpose for this is to avoid gadget module
> > load fail at init.rc
> 
> I don't think it's necessary to mention android-specific init scripts
> here in our patches.

Ok, will just mention init script.
> 
> >  
> > +static inline void ci_role_destroy(struct ci13xxx *ci)
> > +{
> > +	enum ci_role role = ci->role;
> > +
> > +	if (role == CI_ROLE_END)
> > +		return;
> > +
> > +	ci->role = CI_ROLE_END;
> > +
> > +	ci->roles[role]->destroy(ci);
> > +}
> 
> What does this do? It should take role an a parameter, at least. Or it
> can be called ci_roles_destroy() and, well, destroy all the roles. Now
> we're in a situation where we destroy one.
Yes, this function has some problems, I suggest just call two lines at
ci_role_destory, do you think so?

	ci->roles[role]->destroy(ci);
	ci->role = CI_ROLE_END;
> 
> The idea is that, with this api, we can (and should) have both roles
> allocated all the time, but only one role start()'ed.
> 
> What we can do here is move the udc's .init() code to
> ci_hdrc_gadget_init() and add a complementary ci_hdrc_gadget_destroy(),
> which we call in ci_hdrc_remove() and probe's error path. And we can
> probably do something similar for the host, or just leave it as it is
> now. Seems simpler to me.
Yes, current code has bug that it should call ci_role_destroy at probe's
error path.
For your comments, it still needs to add destory function for udc which will
be called at core.c. I still prefer current way due to below reasons:

- It can keep ci_hdrc_gadget_init() clean
- .init and .remove are different logical function with .start and .stop.
The .init and .remove are used for create and destroy, .start and .stop
are used at id role switch.

> >  }
> > diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
> > index caecad9..6024a4f 100644
> > --- a/drivers/usb/chipidea/host.c
> > +++ b/drivers/usb/chipidea/host.c
> > @@ -92,8 +92,10 @@ int ci_hdrc_host_init(struct ci13xxx *ci)
> >  	if (!rdrv)
> >  		return -ENOMEM;
> >  
> > +	rdrv->init	= host_start;
> >  	rdrv->start	= host_start;
> >  	rdrv->stop	= host_stop;
> > +	rdrv->destroy	= host_stop;
> 
> Will this allocate the hcd twice if we start in host role? Looks like that.
No, if we start host role, the host will be allocated once at probe.
host_start is only called when the id value from 1 to 0.
> 

-- 

Best Regards,
Peter Chen

  reply	other threads:[~2013-01-25  3:30 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-21  1:56 [RESEND PATCH v5 0/7] Add fully tested id switch and vbus connect detect support for Chipidea Peter Chen
2013-01-21  1:56 ` [RESEND PATCH v5 1/7] Revert "USB: chipidea: add vbus detect for udc" Peter Chen
2013-01-21  1:56 ` [RESEND PATCH v5 2/7] usb: chipidea: add otg file Peter Chen
2013-01-21  1:56 ` [RESEND PATCH v5 3/7] usb: chipidea: add otg id switch and vbus connect/disconnect detect Peter Chen
2013-01-24 14:06   ` Alexander Shishkin
2013-01-25  6:13     ` Peter Chen
2013-01-24 15:25   ` Alexander Shishkin
2013-01-25  6:28     ` Peter Chen
2013-01-25  9:40       ` Alexander Shishkin
2013-01-28  3:32         ` Peter Chen
2013-01-30  6:06   ` kishon
2013-01-30  6:57     ` Peter Chen
2013-01-30 10:31       ` Alexander Shishkin
2013-01-31  2:02         ` Peter Chen
2013-01-21  1:56 ` [RESEND PATCH v5 4/7] usb: chipidea: consolidate ci_role_driver's API for both roles Peter Chen
2013-01-24 14:35   ` Alexander Shishkin
2013-01-25  3:30     ` Peter Chen [this message]
2013-01-25 12:12       ` Alexander Shishkin
2013-01-28  5:21         ` Peter Chen
2013-01-29  9:37           ` Alexander Shishkin
2013-01-30  6:52             ` Peter Chen
2013-01-21  1:56 ` [RESEND PATCH v5 5/7] usb: chipidea: udc: add pullup/pulldown dp at hw_device_state Peter Chen
2013-01-21  1:56 ` [RESEND PATCH v5 6/7] usb: chipidea: udc: retire the flag CI13_PULLUP_ON_VBUS Peter Chen
2013-01-21  1:56 ` [RESEND PATCH v5 7/7] usb: chipidea: imx: add internal vbus regulator control Peter Chen

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=20130125033013.GB29795@nchen-desktop \
    --to=peter.chen@freescale.com \
    --cc=linux-arm-kernel@lists.infradead.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