drivers/net/can/usb/ucan.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-)
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 26 Jun 2025 16:34:26 +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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
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
On 26.06.2025 16:46:32, Markus Elfring wrote: > From: Markus Elfring <elfring@users.sourceforge.net> > Date: Thu, 26 Jun 2025 16:34:26 +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. > > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Sorry, this patch is not Signed-off-by its sender. Please don't use existing threads for vN+1. Marc -- Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung Nürnberg | Phone: +49-5121-206917-129 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
>> From: Markus Elfring <elfring@users.sourceforge.net> … >> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> > > Sorry, this patch is not Signed-off-by its sender. I find my Developer's Certificate of Origin appropriate here. Regards, Markus
Hi Markus, Thanks for the v2. On 26/06/2025 at 23:46, Markus Elfring wrote: > From: Markus Elfring <elfring@users.sourceforge.net> > Date: Thu, 26 Jun 2025 16:34:26 +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. > > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr> Yours sincerely, Vincent Mailhol
© 2016 - 2025 Red Hat, Inc.