public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Stephen Warren <swarren@wwwdotorg.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/1] tegra: seaboard: Initialize multiple USB controllers at once
Date: Thu, 14 Jun 2012 12:01:00 -0600	[thread overview]
Message-ID: <4FDA26DC.2090503@wwwdotorg.org> (raw)
In-Reply-To: <4B9C9637D5087840A465BDCB251780E9E2D629AF6F@HKMAIL02.nvidia.com>

On 06/13/2012 10:17 PM, Jim Lin wrote:
> Add support for command line "usb reset" or "usb start" to initialize
> , "usb stop" to stop multiple USB controllers at once.
> Other commands like "usb tree" also support multiple controllers.

These patches also need to be sent to the USB maintainer since they
touch core USB code. (Now CC'd)

Rather than one mega-patch that touch the USB core, and the Tegra
driver, can't the patch be split up a bit so that one patch adds the
ability to support multiple controllers, and then another patch modifies
the Tegra USB driver to support this, etc. Many smaller patches are much
easier to review.

This patch adds a huge number of ifdefs. I'm sure many of them can be
removed completely. For example, in the following code, why not /always/
get the rootdev from dev->controller->rootdev, and remove the global
variable. I would guess that the code size increase would be extremely
minimal, but it would make the code a lot more maintainable by removing
all the ifdefs.

>  submit_control_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
>                    int length, struct devrequest *setup)
>  {
> +#ifdef CONFIG_USB_INIT_MULTI
> +       struct ehci_ctrl *ctrl = dev->controller;
> +#endif
> 
>         if (usb_pipetype(pipe) != PIPE_CONTROL) {
>                 debug("non-control pipe (type=%lu)", usb_pipetype(pipe));
>                 return -1;
>         }
> 
> +#ifdef CONFIG_USB_INIT_MULTI
> +       if (usb_pipedevice(pipe) == ctrl->rootdev) {
> +               if (ctrl->rootdev == 0)
> +#else
>         if (usb_pipedevice(pipe) == rootdev) {
>                 if (rootdev == 0)
> +#endif
>                         dev->speed = USB_SPEED_HIGH;
>                 return ehci_submit_root(dev, pipe, buffer, length, setup);
>         }

The patch above removes the use of the global variable "rootdev", but I
don't see anywhere that ifdef's that variable out of existence. Not
doing so would allow code to accidentally use the global when it should
be using the per-device value; how can you be sure you've patched all
the places in the code that you need to? What about future changes to
the code by people who aren't aware of the USB_INIT_MULTI feature?

Similarly, why not just outright change the prototype of
tegrausb_stop_port() so that it always takes a port number; the existing
calls can hard-code a port ID of 0 for compatibility:

> +#ifdef CONFIG_USB_INIT_MULTI
> +int ehci_hcd_stop(int index)
> +{
> +       tegrausb_stop_port(index);
> +       return 0;
> +}
> +#else
>  int ehci_hcd_stop(void)
>  {
>         tegrausb_stop_port();
>         return 0;
>  }
>> +#endif

In the end, I think if you rework the patch to remove all/most of the
ifdefs, the only thing that's left will be that the loop to initialize
USB would loop over either just device 0 or devices 0..n-1, and even
that wouldn't need to be ifdef'd...

  reply	other threads:[~2012-06-14 18:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-14  4:17 [U-Boot] [PATCH 1/1] tegra: seaboard: Initialize multiple USB controllers at once Jim Lin
2012-06-14 18:01 ` Stephen Warren [this message]
2012-06-14 18:47   ` Marek Vasut

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=4FDA26DC.2090503@wwwdotorg.org \
    --to=swarren@wwwdotorg.org \
    --cc=u-boot@lists.denx.de \
    /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