[PATCH v3 2/5] can: gs_usb.c: store pipe instead of endpoint address

From: Alexander Kozhinov
Date: Tue Oct 08 2024 - 15:25:51 EST


This change implements nitpick: instead of storing the ep_in and ep_out in your priv, you can
instead directly store the result of usb_rcvbulkpipe(parent->udev,
parent->ep_in) and usb_sndbulkpipe(dev->udev, dev->parent->ep_out).

Signed-off-by: Alexander Kozhinov <ak.alexander.kozhinov@xxxxxxxxx>
---
drivers/net/can/usb/gs_usb.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/net/can/usb/gs_usb.c b/drivers/net/can/usb/gs_usb.c
index f3eb447267f9..e6511af5f692 100644
--- a/drivers/net/can/usb/gs_usb.c
+++ b/drivers/net/can/usb/gs_usb.c
@@ -334,8 +334,8 @@ struct gs_usb {
unsigned int hf_size_rx;
u8 active_channels;

- u8 ep_in;
- u8 ep_out;
+ unsigned int pipe_in;
+ unsigned int pipe_out;
};

/* 'allocate' a tx context.
@@ -687,7 +687,7 @@ static void gs_usb_receive_bulk_callback(struct urb *urb)

resubmit_urb:
usb_fill_bulk_urb(urb, parent->udev,
- usb_rcvbulkpipe(parent->udev, parent->ep_in),
+ parent->pipe_in,
hf, dev->parent->hf_size_rx,
gs_usb_receive_bulk_callback, parent);

@@ -819,7 +819,7 @@ static netdev_tx_t gs_can_start_xmit(struct sk_buff *skb,
}

usb_fill_bulk_urb(urb, dev->udev,
- usb_sndbulkpipe(dev->udev, dev->parent->ep_out),
+ dev->parent->pipe_out,
hf, dev->hf_size_tx,
gs_usb_xmit_callback, txc);

@@ -925,8 +925,7 @@ static int gs_can_open(struct net_device *netdev)
/* fill, anchor, and submit rx urb */
usb_fill_bulk_urb(urb,
dev->udev,
- usb_rcvbulkpipe(dev->udev,
- dev->parent->ep_in),
+ dev->parent->pipe_in,
buf,
dev->parent->hf_size_rx,
gs_usb_receive_bulk_callback, parent);
@@ -1479,8 +1478,8 @@ static int gs_usb_probe(struct usb_interface *intf,
parent->udev = udev;

/* store the detected endpoints */
- parent->ep_in = ep_in->bEndpointAddress;
- parent->ep_out = ep_out->bEndpointAddress;
+ parent->pipe_in = usb_rcvbulkpipe(parent->udev, ep_in->bEndpointAddress);
+ parent->pipe_out = usb_sndbulkpipe(parent->udev, ep_out->bEndpointAddress);

for (i = 0; i < icount; i++) {
unsigned int hf_size_rx = 0;
--
2.43.0