linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Olivier Sobrie <olivier@sobrie.be>
Cc: Wolfgang Grandegger <wg@grandegger.com>, linux-can@vger.kernel.org
Subject: Re: [PATCH] can: kvaser_usb: fix usb endpoints detection
Date: Mon, 28 Oct 2013 00:29:31 +0100	[thread overview]
Message-ID: <526DA1DB.9000600@pengutronix.de> (raw)
In-Reply-To: <1382908073-6865-1-git-send-email-olivier@sobrie.be>

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

On 10/27/2013 10:07 PM, Olivier Sobrie wrote:
> Some devices, like the Kvaser Memorator Professional, have several
> bulk in endpoints. Only the first one found should be used by the
> driver. The same holds for the bulk out endpoint.

Can you give reference where this information comes from? e.g.
documentation or another driver?

> Signed-off-by: Olivier Sobrie <olivier@sobrie.be>
> ---
>  drivers/net/can/usb/kvaser_usb.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/can/usb/kvaser_usb.c b/drivers/net/can/usb/kvaser_usb.c
> index 3b95465..bdbf5bf 100644
> --- a/drivers/net/can/usb/kvaser_usb.c
> +++ b/drivers/net/can/usb/kvaser_usb.c
> @@ -1554,13 +1554,14 @@ static void kvaser_usb_get_endpoints(const struct usb_interface *intf,
>  
>  	iface_desc = &intf->altsetting[0];
>  
> -	for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
> +	for (i = 0; (i < iface_desc->desc.bNumEndpoints) && (!*in || !*out);
> +	     ++i) {
>  		endpoint = &iface_desc->endpoint[i].desc;
>  
> -		if (usb_endpoint_is_bulk_in(endpoint))
> +		if (!*in && usb_endpoint_is_bulk_in(endpoint))
>  			*in = endpoint;
>  
> -		if (usb_endpoint_is_bulk_out(endpoint))
> +		if (!*out && usb_endpoint_is_bulk_out(endpoint))
>  			*out = endpoint;

I personally would add a break or return here, together with a short
comment:

	/* only use first endpoint for in and out */
	if (*in && *out)
		return;

>  	}
>  }
> 

Thanks for taking care of the driver,
Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 259 bytes --]

  reply	other threads:[~2013-10-27 23:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-27 21:07 [PATCH] can: kvaser_usb: fix usb endpoints detection Olivier Sobrie
2013-10-27 23:29 ` Marc Kleine-Budde [this message]
2013-10-28  8:29   ` Marc Kleine-Budde
2013-10-28 12:06   ` Olivier Sobrie
2013-10-28 12:26     ` Marc Kleine-Budde
2013-10-28  9:25 ` Marc Kleine-Budde
2013-10-28 12:08   ` Olivier Sobrie

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=526DA1DB.9000600@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=linux-can@vger.kernel.org \
    --cc=olivier@sobrie.be \
    --cc=wg@grandegger.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 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).