From: Markus Elfring <Markus.Elfring@web.de>
To: linux-can@vger.kernel.org, Marc Kleine-Budde <mkl@pengutronix.de>,
Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Cc: LKML <linux-kernel@vger.kernel.org>,
kernel-janitors@vger.kernel.org, Chen Ni <nichen@iscas.ac.cn>
Subject: [PATCH v3] can: ucan: Use two USB endpoint API functions rather than duplicating their implementations
Date: Sat, 28 Jun 2025 09:19:40 +0200 [thread overview]
Message-ID: <0a675827-33af-4ec4-97dc-2e4523e41194@web.de> (raw)
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 28 Jun 2025 08:56:51 +0200
* Reuse existing functionality from usb_endpoint_is_bulk_in()
and usb_endpoint_is_bulk_out() instead of keeping duplicate source code.
* Omit two comment lines which became redundant with this refactoring.
The source code was transformed by using the Coccinelle software.
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Signed-off-by: Markus Elfring <Markus.Elfring@web.de>
---
V3:
https://lore.kernel.org/linux-can/20250626-opalescent-tireless-locust-564d48-mkl@pengutronix.de/
* Use an other email address for the tag “Signed-off-by”.
* Provide the patch version not as a direct reply to a development discussion.
V2:
Further change possibilities were taken better into account for
the USB endpoint API with the help of Vincent Mailhol.
drivers/net/can/usb/ucan.c | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)
diff --git a/drivers/net/can/usb/ucan.c b/drivers/net/can/usb/ucan.c
index 07406daf7c88..0935a9b540d6 100644
--- a/drivers/net/can/usb/ucan.c
+++ b/drivers/net/can/usb/ucan.c
@@ -1351,19 +1351,11 @@ static int ucan_probe(struct usb_interface *intf,
out_ep_size = 0;
for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) {
ep = &iface_desc->endpoint[i].desc;
-
- if (((ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK) != 0) &&
- ((ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
- USB_ENDPOINT_XFER_BULK)) {
- /* In Endpoint */
+ if (usb_endpoint_is_bulk_in(ep)) {
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)) {
- /* Out Endpoint */
+ } else if (usb_endpoint_is_bulk_out(ep)) {
out_ep_addr = ep->bEndpointAddress;
out_ep_addr &= USB_ENDPOINT_NUMBER_MASK;
out_ep_size = le16_to_cpu(ep->wMaxPacketSize);
--
2.50.0
next reply other threads:[~2025-06-28 7:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-28 7:19 Markus Elfring [this message]
2025-06-29 7:19 ` Vincent Mailhol
2025-06-29 7:51 ` [v3] " Markus Elfring
2025-06-29 8:33 ` Vincent Mailhol
2025-06-29 10:34 ` Markus Elfring
2025-06-29 11:38 ` Markus Elfring
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=0a675827-33af-4ec4-97dc-2e4523e41194@web.de \
--to=markus.elfring@web.de \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-can@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mailhol.vincent@wanadoo.fr \
--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
all inboxes | Powered by JetHome®