Linux CAN drivers development
 help / color / mirror / Atom feed
From: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
To: Markus Elfring <Markus.Elfring@web.de>
Cc: LKML <linux-kernel@vger.kernel.org>,
	kernel-janitors@vger.kernel.org, Chen Ni <nichen@iscas.ac.cn>,
	linux-can@vger.kernel.org, Marc Kleine-Budde <mkl@pengutronix.de>
Subject: Re: [PATCH] can: ucan: Use usb_endpoint_type() rather than duplicating its implementation
Date: Wed, 25 Jun 2025 02:29:56 +0900	[thread overview]
Message-ID: <bf5442d1-34e0-495f-8a56-4e47f53ca4ad@wanadoo.fr> (raw)
In-Reply-To: <48e217a7-b90e-4af3-b535-812c449dd3ba@web.de>

Hi Markus,

On 25/06/2025 at 02:12, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 24 Jun 2025 19:05:04 +0200
> 
> Reuse existing functionality from usb_endpoint_type() instead of keeping
> duplicate source code.
> 
> The source code was transformed by using the Coccinelle software.

Looking at the helpers in linux/usb/ch9.h, it seems that Coccinelle missed many
simplifications.

> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Can you use the same e-mail address for signing and for sending the patch?

> ---
>  drivers/net/can/usb/ucan.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/can/usb/ucan.c b/drivers/net/can/usb/ucan.c
> index 07406daf7c88..3c8dad8bcca4 100644
> --- a/drivers/net/can/usb/ucan.c
> +++ b/drivers/net/can/usb/ucan.c
> @@ -1353,16 +1353,14 @@ static int ucan_probe(struct usb_interface *intf,
>  		ep = &iface_desc->endpoint[i].desc;
>  
>  		if (((ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK) != 0) &&
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This is:

	usb_endpoint_dir_in(ep)

> -		    ((ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
> -		     USB_ENDPOINT_XFER_BULK)) {
> +		    usb_endpoint_type(ep) == USB_ENDPOINT_XFER_BULK) {
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This is:

	usb_endpoint_xfer_bulk(ep)

>  			/* In Endpoint */
After changing to usb_endpoint_dir_in(ep), this comment can be removed.

>  			in_ep_addr = ep->bEndpointAddress;
>  			in_ep_addr &= USB_ENDPOINT_NUMBER_MASK;
>  			in_ep_size = le16_to_cpu(ep->wMaxPacketSize);
>  		} else if (((ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK) ==
>  			    0) &&
> -			   ((ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
> -			    USB_ENDPOINT_XFER_BULK)) {
> +			   usb_endpoint_type(ep) == USB_ENDPOINT_XFER_BULK) {

Similarly as above use:

	usb_endpoint_dir_out(ep)

and:

	usb_endpoint_xfer_bulk(ep)

>  			/* Out Endpoint */
>  			out_ep_addr = ep->bEndpointAddress;
>  			out_ep_addr &= USB_ENDPOINT_NUMBER_MASK;


Yours sincerely,
Vincent Mailhol


  reply	other threads:[~2025-06-24 17:38 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-24 17:12 [PATCH] can: ucan: Use usb_endpoint_type() rather than duplicating its implementation Markus Elfring
2025-06-24 17:29 ` Vincent Mailhol [this message]
2025-06-24 18:28   ` Markus Elfring
2025-06-24 22:59     ` Vincent Mailhol
2025-06-25  5:47       ` [PATCH] " Markus Elfring
2025-06-25 15:51         ` Vincent Mailhol
2025-06-25 16:23           ` Markus Elfring
2025-06-26  2:47             ` Vincent Mailhol
2025-06-26  7:22               ` Markus Elfring
2025-06-26  9:23                 ` Vincent Mailhol
2025-06-26 14:46                   ` [PATCH v2] can: ucan: Use two USB endpoint API functions rather than duplicating their implementations Markus Elfring
2025-06-26 14:50                     ` Vincent Mailhol
2025-06-26 15:06                     ` Marc Kleine-Budde
2025-06-26 15:17                       ` [v2] " Markus Elfring
2025-06-24 19:21   ` [PATCH] can: ucan: Use usb_endpoint_type() rather than duplicating its implementation Markus Elfring
2025-06-24 23:03     ` Vincent Mailhol

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=bf5442d1-34e0-495f-8a56-4e47f53ca4ad@wanadoo.fr \
    --to=mailhol.vincent@wanadoo.fr \
    --cc=Markus.Elfring@web.de \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-can@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=nichen@iscas.ac.cn \
    /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